Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 59 lines 1.5 kB view raw
1{ 2 writeScript, 3 lib, 4 xidel, 5 common-updater-scripts, 6 coreutils, 7 gnused, 8 gnugrep, 9 curl, 10 gnupg, 11 attrPath, 12 runtimeShell, 13 baseUrl ? "https://archive.mozilla.org/pub/firefox/releases/", 14 versionPrefix ? "", 15 versionSuffix ? "", 16 versionKey ? "version", 17}: 18 19writeScript "update-${attrPath}" '' 20 #!${runtimeShell} 21 PATH=${ 22 lib.makeBinPath [ 23 common-updater-scripts 24 coreutils 25 curl 26 gnugrep 27 gnupg 28 gnused 29 xidel 30 ] 31 } 32 33 set -eux 34 HOME=`mktemp -d` 35 export GNUPGHOME=`mktemp -d` 36 curl https://keys.openpgp.org/vks/v1/by-fingerprint/09BEED63F3462A2DFFAB3B875ECB6497C1A20256 | gpg --import - 37 38 url=${baseUrl} 39 40 # retriving latest released version 41 # - extracts all links from the $url 42 # - extracts lines only with number and dots followed by a slash 43 # - removes trailing slash 44 # - sorts everything with semver in mind 45 # - picks up latest release 46 version=`xidel -s $url --extract "//a" | \ 47 grep "^${versionPrefix}[0-9.]*${versionSuffix}/$" | \ 48 sed s/[/]$// | \ 49 sort --version-sort | \ 50 tail -n 1` 51 52 curl --silent --show-error -o "$HOME"/shasums "$url$version/SHA512SUMS" 53 curl --silent --show-error -o "$HOME"/shasums.asc "$url$version/SHA512SUMS.asc" 54 gpgv --keyring="$GNUPGHOME"/pubring.kbx "$HOME"/shasums.asc "$HOME"/shasums 55 56 hash=$(grep '\.source\.tar\.xz$' "$HOME"/shasums | grep '^[^ ]*' -o) 57 58 update-source-version ${attrPath} "$version" "$hash" "" --version-key=${versionKey} 59''