diff options
author | happysalada <raphael@megzari.com> | 2021-08-24 11:26:52 +0900 |
---|---|---|
committer | Raphael Megzari <raphael@megzari.com> | 2021-08-26 07:36:01 +0900 |
commit | 1a5b80085f86992bc2af984570a8fd75ada7b2d1 (patch) | |
tree | c05cce84824101b5f6f9405e45858051f93987ee /pkgs/shells/bash | |
parent | 041022af7cee3dce5d685e86ccdfd6d2c9c6f9a5 (diff) |
bash: update-patch-set script fixes
- make the script runnable from any directory - add missing nix dependency to run nix-hash - make padding non implicit - small shellcheck fixes (variable quoting...)
Diffstat (limited to 'pkgs/shells/bash')
-rwxr-xr-x | pkgs/shells/bash/update-patch-set.sh | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/pkgs/shells/bash/update-patch-set.sh b/pkgs/shells/bash/update-patch-set.sh index cb4f372f5433b..03b00228822d0 100755 --- a/pkgs/shells/bash/update-patch-set.sh +++ b/pkgs/shells/bash/update-patch-set.sh @@ -1,11 +1,11 @@ #!/usr/bin/env nix-shell -#!nix-shell --pure -i bash -p wget -p gnupg -p cacert +#!nix-shell --pure -i bash -p wget -p gnupg -p cacert -p nix # Update patch set for GNU Bash or Readline. if [ $# -ne 2 ] then - echo "Usage: $(basename $0) PROJECT VERSION" + echo "Usage: $(basename "$0") PROJECT VERSION" echo "" echo "Update the patch set for PROJECT (one of \`bash' or \`readline') for" echo "the given version (e.g., \`4.0'). Produce \`PROJECT-patches.nix'." @@ -14,14 +14,12 @@ fi PROJECT="$1" VERSION="$2" -VERSION_CONDENSED="$(echo $VERSION | sed -es/\\.//g)" -PATCH_LIST="$PROJECT-$VERSION-patches.nix" +DIR=$(dirname "$0") +VERSION_CONDENSED="$(echo "$VERSION" | sed -es/\\.//g)" +PATCH_LIST="$DIR/$PROJECT-$VERSION-patches.nix" set -e -start=1 -end=100 # must be > 99 for correct padding - rm -vf "$PATCH_LIST" wget "https://tiswww.case.edu/php/chet/gpgkey.asc" @@ -35,18 +33,20 @@ rm gpgkey.asc{,.md5} echo "patch: [" ) \ >> "$PATCH_LIST" -for i in `seq -w $start $end` +for i in {001..100} do - wget ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i || break - wget ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i.sig - gpg --verify $PROJECT$VERSION_CONDENSED-$i.sig - echo "(patch \"$i\" \"$(nix-hash --flat --type sha256 --base32 $PROJECT$VERSION_CONDENSED-$i)\")" \ + wget -P "$DIR" "ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i" || break + wget -P "$DIR" "ftp.gnu.org/gnu/$PROJECT/$PROJECT-$VERSION-patches/$PROJECT$VERSION_CONDENSED-$i.sig" + gpg --verify "$DIR/$PROJECT$VERSION_CONDENSED-$i.sig" + hash=$(nix-hash --flat --type sha256 --base32 "$DIR/$PROJECT$VERSION_CONDENSED-$i") + echo "(patch \"$i\" \"$hash\")" \ >> "$PATCH_LIST" - rm -f $PROJECT$VERSION_CONDENSED-$i{,.sig} + rm -f "$DIR/$PROJECT$VERSION_CONDENSED-$i"{,.sig} done echo "]" >> "$PATCH_LIST" -echo "Got $(expr $i - 1) patches." +# bash interprets numbers starting with 0 as octals +echo "Got $((10#$i - 1)) patches." echo "Patch list has been written to \`$PATCH_LIST'." |