[pacman-contrib] [PATCH 1/2] updpkgsums: rely on makepkg's exported schema declaration for algo types
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
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> --- This can of course be pulled at any time, unlike the previous patch. src/vim/syntax/PKGBUILD.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/vim/syntax/PKGBUILD.vim b/src/vim/syntax/PKGBUILD.vim index 8e3e1b9..e02772e 100644 --- a/src/vim/syntax/PKGBUILD.vim +++ b/src/vim/syntax/PKGBUILD.vim @@ -216,6 +216,17 @@ hi def link pbSha512Quotes Keyword hi def link pbSha512Hash Error hi def link pbValidSha512sums Number +" b2sums +syn keyword pb_k_b2sums b2sums contained +syn match pbIllegalB2sums /[^='"()\/ ]/ contained contains=pbValidB2sums +syn match pbValidB2sums /\x\{128\}/ contained +syn region pbB2sumsGroup start=/^b2sums/ end=/)/ contains=pb_k_b2sums,pbB2Quotes,pbB2Hash,pbIllegalB2sums keepend +syn match pbB2Quotes /'.*'\|".*"/ contained contains=pbB2Hash,pbIllegalB2sums +syn match pbB2Hash /\x\+/ contained contains=pbValidB2sums +hi def link pbB2Quotes Keyword +hi def link pbB2Hash Error +hi def link pbValidB2sums Number + " options syn keyword pb_k_options options contained syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained -- 2.21.0
LGTM, thanks. Excerpts from Eli Schwartz's message of April 17, 2019 4:49:
Signed-off-by: Eli Schwartz <eschwartz@archlinux.org> ---
This can of course be pulled at any time, unlike the previous patch.
src/vim/syntax/PKGBUILD.vim | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/src/vim/syntax/PKGBUILD.vim b/src/vim/syntax/PKGBUILD.vim index 8e3e1b9..e02772e 100644 --- a/src/vim/syntax/PKGBUILD.vim +++ b/src/vim/syntax/PKGBUILD.vim @@ -216,6 +216,17 @@ hi def link pbSha512Quotes Keyword hi def link pbSha512Hash Error hi def link pbValidSha512sums Number
+" b2sums +syn keyword pb_k_b2sums b2sums contained +syn match pbIllegalB2sums /[^='"()\/ ]/ contained contains=pbValidB2sums +syn match pbValidB2sums /\x\{128\}/ contained +syn region pbB2sumsGroup start=/^b2sums/ end=/)/ contains=pb_k_b2sums,pbB2Quotes,pbB2Hash,pbIllegalB2sums keepend +syn match pbB2Quotes /'.*'\|".*"/ contained contains=pbB2Hash,pbIllegalB2sums +syn match pbB2Hash /\x\+/ contained contains=pbValidB2sums +hi def link pbB2Quotes Keyword +hi def link pbB2Hash Error +hi def link pbValidB2sums Number + " options syn keyword pb_k_options options contained syn match pbOptions /\(no\)\?\(strip\|docs\|libtool\|emptydirs\|zipman\|purge\|distcc\|color\|ccache\|check\|sign\|makeflags\|buildflags\)/ contained -- 2.21.0
-- Sincerely, Johannes Löthberg :: SA0DEM
Sorry for the delay, I've been rather busy as of late.. Excerpts from Eli Schwartz's message of April 17, 2019 4:49:
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> ---
I really like the idea, but...
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'}
... I don't really like using @datarootdir@ for this, since we don't necessarily know that pacman was installed to the same datarootdir that we will be installed to. Would be nicer if there was a libmakepkg.pc that pointed to the libmakepkg install dir, or at least its prefix, so we could query the system for the proper path..
+ +# 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
-- Sincerely, Johannes Löthberg :: SA0DEM
On 4/23/19 2:47 PM, Johannes Löthberg wrote:
Sorry for the delay, I've been rather busy as of late..
Excerpts from Eli Schwartz's message of April 17, 2019 4:49:
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> ---
I really like the idea, but...
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'}
... I don't really like using @datarootdir@ for this, since we don't necessarily know that pacman was installed to the same datarootdir that we will be installed to.
Would be nicer if there was a libmakepkg.pc that pointed to the libmakepkg install dir, or at least its prefix, so we could query the system for the proper path..
Pending https://lists.archlinux.org/pipermail/pacman-dev/2019-April/023345.html This patch is therefore delayed until then.
+ +# 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
-- Eli Schwartz Bug Wrangler and Trusted User
participants (2)
-
Eli Schwartz
-
Johannes Löthberg