#!/usr/bin/env bash repo="ogham/dog" current=$(reprepro -b /var/www/repos/apt/debian list stable dog | head -n1 | awk '{print $3}') api=$(curl --silent "https://api.github.com/repos/$repo/releases/latest") new=$(echo $api | grep -Po '"tag_name": "v\K.*?(?=")') if [ "$current" == "$new" ]; then exit fi echo "New DIG version $current -> $new" END="unknown-linux-gnu.zip" bin_url=$(echo $api | python3 -c "import sys; from json import loads as l; x = l(sys.stdin.read()); print(' '.join(s['browser_download_url'] for s in x['assets'] if s['name'].endswith('$END')))") STARTDIR="/tmp/dog" DESTDIR="$STARTDIR/pkg" OUTDIR="$STARTDIR/deb" rm -rf "$STARTDIR" mkdir "$STARTDIR" wget -q $bin_url -O "$STARTDIR/dog.zip" unzip "$STARTDIR/dog.zip" -d "$STARTDIR" # install -Dm 755 "$STARTDIR/dog" "$DESTDIR/usr/bin/dog" install -Dm 755 "/root/dog" "$DESTDIR/usr/bin/dog" install -D -g 0 -o 0 -m 0644 "$STARTDIR/man/dog.1" "$DESTDIR/usr/local/man/man1/dog.1" install -Dm 755 "$STARTDIR/completions/dog.bash" "$DESTDIR/etc/bash_completion.d/dog.bash" mkdir -p "$DESTDIR/DEBIAN" cat >"$DESTDIR/DEBIAN/control"< Description: Colourful and easy-to-read Command-line DNS client Homepage: https://github.com/ogham/dog Bugs: https://github.com/ogham/dog/issues EOL cat >"$STARTDIR/changelog"< $(date -R) EOL install -Dm 644 "$STARTDIR/changelog" "$DESTDIR/usr/share/doc/dog/changelog.Debian" gzip "$DESTDIR/usr/share/doc/dog/changelog.Debian" rm -rf "$OUTDIR" mkdir "$OUTDIR" dpkg-deb --build "$DESTDIR" "$OUTDIR" reprepro -b /var/www/repos/apt/debian includedeb stable "$OUTDIR"/*.deb reprepro -b /var/www/repos/apt/debian includedeb oldstable "$OUTDIR"/*.deb rm -rf "$STARTDIR"