Rather than heuristically match (md|sha)[[:digit:]]+sums or even .*sums, read makepkg's internal description of known hash algorithms, and use it to generate a search pattern. This ensures that we will always be in sync with the makepkg installed on the user's system. Fixes support for the newly added b2sums algorithm. Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- This depends on pacman from git master, because schema.sh does not exist in pacman 5.1.x src/updpkgsums.sh.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/updpkgsums.sh.in b/src/updpkgsums.sh.in index 9c545ea..618f471 100644 --- a/src/updpkgsums.sh.in +++ b/src/updpkgsums.sh.in @@ -22,6 +22,11 @@ shopt -s extglob declare -r myname='updpkgsums' declare -r myver='@PACKAGE_VERSION@' +LIBRARY=${LIBRARY:-'@datarootdir@/makepkg'} + +# Import libmakepkg +source "$LIBRARY"/util/schema.sh + usage() { printf "%s v%s\n" "${myname}" "${myver}" echo @@ -92,9 +97,10 @@ export BUILDDIR=$(mktemp -d "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") newbuildfile=$(mktemp "${TMPDIR:-/tmp}/updpkgsums.XXXXXX") trap "rm -rf '$BUILDDIR' '$newbuildfile'" EXIT +sumtypes=$(IFS='|'; echo "${known_hash_algos[*]}") newsums=$(makepkg -g -p "$buildfile" "${MAKEPKG_OPTS[@]}") || die 'Failed to generate new checksums' -awk -v newsums="$newsums" ' - /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ { +awk -v sumtypes="$sumtypes" -v newsums="$newsums" ' + $0 ~"^[[:blank:]]*(" sumtypes ")sums(_[^=]+)?=", $0 ~ "\)[[:blank:]]*(#.*)?$" { if (!w) { print newsums w++ -- 2.21.0