1 #!/usr/bin/env nix-shell
2 #!nix-shell --pure -i bash -p wget -p gnupg -p cacert -p nix
4 # Update patch set for GNU Bash or Readline.
8 echo "Usage: $(basename "$0") PROJECT VERSION"
10 echo "Update the patch set for PROJECT (one of \`bash' or \`readline') for"
11 echo "the given version (e.g., \`4.0'). Produce \`PROJECT-patches.nix'."
18 VERSION_CONDENSED
="$(echo "$VERSION" | sed -es/\\.//g)"
19 PATCH_LIST
="$DIR/$PROJECT-$VERSION-patches.nix"
25 wget
"https://tiswww.case.edu/php/chet/gpgkey.asc"
26 echo "4ef5051ce7200241e65d29c11eb57df8 gpgkey.asc" > gpgkey.asc.md5
27 md5sum -c gpgkey.asc.md5
28 gpg
--import .
/gpgkey.asc
31 ( echo "# Automatically generated by \`$(basename "$0")'; do not edit." ; \
38 wget
-P "$DIR" "ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i" ||
break
39 wget
-P "$DIR" "ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i.sig"
40 gpg
--verify "$DIR/$PROJECT$VERSION_CONDENSED-$i.sig"
41 hash=$
(nix-hash
--flat --type sha256
--base32 "$DIR/$PROJECT$VERSION_CONDENSED-$i")
42 echo "(patch \"$i\" \"$hash\")" \
45 rm -f "$DIR/$PROJECT$VERSION_CONDENSED-$i"{,.sig
}
48 echo "]" >> "$PATCH_LIST"
50 # bash interprets numbers starting with 0 as octals
51 echo "Got $((10#$i - 1)) patches."
52 echo "Patch list has been written to \`$PATCH_LIST'."