[pacman-dev] [PATCH 0/5] Resend of arch-specific source/checksum support
Hi, this addresses previous feedback from agregory and also fixes a bug I found in my own testing. I've had success creating packages such as: https://aur-dev.archlinux.org/packages/ch/chromium-plugins/PKGBUILD https://aur-dev.archlinux.org/packages/go/google-chrome/PKGBUILD https://aur-dev.archlinux.org/packages/wi/wine/PKGBUILD Which are, imo, far more beautiful than the boundless "if $CARCH" checks. Feedback welcome -- I'm very interested in getting these in good enough shape to be merged for 4.2. Branch: http://code.falconindy.com/cgit/pacman.git/log/?h=arch-specific Dave Reisner (5): makepkg: break out check_checksums to reasonably sized functions makepkg: break out checksum generation to its own function PKGBUILD: add support for arch-specific sources updpkgsums: update to recognize arch-specific sources makepkg: move negation in inequality comparisons contrib/updpkgsums.sh.in | 2 +- doc/PKGBUILD.5.txt | 4 + scripts/makepkg.sh.in | 298 ++++++++++++++++++++++++++++++++--------------- 3 files changed, 208 insertions(+), 96 deletions(-) -- 2.0.4
--- scripts/makepkg.sh.in | 94 +++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 41 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8e8a64c..116b46e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1177,53 +1177,65 @@ generate_checksums() { done } -check_checksums() { - (( SKIPCHECKSUMS )) && return 0 - (( ! ${#source[@]} )) && return 0 +verify_integrity_one() { + local source_name=$1 integ=$2 expectedsum=$3 - local correlation=0 - local integ required - for integ in "${known_hash_algos[@]}"; do - local sumname="${integ}sums[@]" - local integrity_sums=("${!sumname}") - if (( ${#integrity_sums[@]} == ${#source[@]} )); then - msg "$(gettext "Validating source files with %s...")" "${integ}sums" - correlation=1 - local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - local file="$(get_filename "${source[idx]}")" - printf ' %s ... ' "$file" >&2 - - if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then - printf '%s\n' "$(gettext "Skipped")" >&2 - continue - fi + local file="$(get_filename "$source_name")" + printf ' %s ... ' "$file" >&2 - if ! file="$(get_filepath "$file")"; then - printf '%s\n' "$(gettext "NOT FOUND")" >&2 - errors=1 - continue - fi + if [[ $expectedsum = 'SKIP' ]]; then + printf '%s\n' "$(gettext "Skipped")" >&2 + return + fi - local expectedsum="${integrity_sums[idx],,}" - local realsum="$(openssl dgst -${integ} "$file")" - realsum="${realsum##* }" - if [[ $expectedsum = "$realsum" ]]; then - printf '%s\n' "$(gettext "Passed")" >&2 - else - printf '%s\n' "$(gettext "FAILED")" >&2 - errors=1 - fi - done + if ! file="$(get_filepath "$file")"; then + printf '%s\n' "$(gettext "NOT FOUND")" >&2 + return 1 + fi - if (( errors )); then - error "$(gettext "One or more files did not pass the validity check!")" - exit 1 # TODO: error code - fi - elif (( ${#integrity_sums[@]} )); then - error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + local realsum="$(openssl dgst -${integ} "$file")" + realsum="${realsum##* }" + if [[ ${expectedsum,,} = "$realsum" ]]; then + printf '%s\n' "$(gettext "Passed")" >&2 + else + printf '%s\n' "$(gettext "FAILED")" >&2 + return 1 + fi + + return 0 +} + +verify_integrity_sums() { + local integ=$1 integrity_sums + + array_build integrity_sums "${integ}sums" + + if (( ${#integrity_sums[@]} == ${#source[@]} )); then + msg "$(gettext "Validating source files with %s...")" "${integ}sums" + local idx errors=0 + for (( idx = 0; idx < ${#source[*]}; idx++ )); do + verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + done + + if (( errors )); then + error "$(gettext "One or more files did not pass the validity check!")" exit 1 # TODO: error code fi + elif (( ${#integrity_sums[@]} )); then + error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + exit 1 # TODO: error code + else + return 1 + fi +} + +check_checksums() { + (( SKIPCHECKSUMS )) && return 0 + + local correlation=0 + local integ + for integ in "${known_hash_algos[@]}"; do + verify_integrity_sums "$integ" && correlation=1 done if (( ! correlation )); then -- 2.0.4
On 16/08/14 01:41, Dave Reisner wrote:
--- scripts/makepkg.sh.in | 94 +++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 41 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8e8a64c..116b46e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1177,53 +1177,65 @@ generate_checksums() { done }
-check_checksums() { - (( SKIPCHECKSUMS )) && return 0 - (( ! ${#source[@]} )) && return 0
Because you deleted this, a PKGBUILD with no sources gives: ==> Validating source files with md5sums... ==> Validating source files with sha1sums... ==> Validating source files with sha224sums... ==> Validating source files with sha256sums... ==> Validating source files with sha384sums... ==> Validating source files with sha512sums...
+verify_integrity_one() { + local source_name=$1 integ=$2 expectedsum=$3
- local correlation=0 - local integ required - for integ in "${known_hash_algos[@]}"; do - local sumname="${integ}sums[@]" - local integrity_sums=("${!sumname}") - if (( ${#integrity_sums[@]} == ${#source[@]} )); then - msg "$(gettext "Validating source files with %s...")" "${integ}sums" - correlation=1 - local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - local file="$(get_filename "${source[idx]}")" - printf ' %s ... ' "$file" >&2 - - if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then - printf '%s\n' "$(gettext "Skipped")" >&2 - continue - fi + local file="$(get_filename "$source_name")" + printf ' %s ... ' "$file" >&2
- if ! file="$(get_filepath "$file")"; then - printf '%s\n' "$(gettext "NOT FOUND")" >&2 - errors=1 - continue - fi + if [[ $expectedsum = 'SKIP' ]]; then + printf '%s\n' "$(gettext "Skipped")" >&2 + return + fi
- local expectedsum="${integrity_sums[idx],,}" - local realsum="$(openssl dgst -${integ} "$file")" - realsum="${realsum##* }" - if [[ $expectedsum = "$realsum" ]]; then - printf '%s\n' "$(gettext "Passed")" >&2 - else - printf '%s\n' "$(gettext "FAILED")" >&2 - errors=1 - fi - done + if ! file="$(get_filepath "$file")"; then + printf '%s\n' "$(gettext "NOT FOUND")" >&2 + return 1 + fi
- if (( errors )); then - error "$(gettext "One or more files did not pass the validity check!")" - exit 1 # TODO: error code - fi - elif (( ${#integrity_sums[@]} )); then - error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + local realsum="$(openssl dgst -${integ} "$file")" + realsum="${realsum##* }" + if [[ ${expectedsum,,} = "$realsum" ]]; then + printf '%s\n' "$(gettext "Passed")" >&2 + else + printf '%s\n' "$(gettext "FAILED")" >&2 + return 1 + fi + + return 0 +} + +verify_integrity_sums() { + local integ=$1 integrity_sums + + array_build integrity_sums "${integ}sums" +
So we used to do this: local sumname="${integ}sums[@]" local integrity_sums=("${!sumname}") My question is why change to array_build? Is there an advantage that I am missing?
+ if (( ${#integrity_sums[@]} == ${#source[@]} )); then + msg "$(gettext "Validating source files with %s...")" "${integ}sums" + local idx errors=0 + for (( idx = 0; idx < ${#source[*]}; idx++ )); do + verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + done + + if (( errors )); then + error "$(gettext "One or more files did not pass the validity check!")" exit 1 # TODO: error code fi + elif (( ${#integrity_sums[@]} )); then + error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + exit 1 # TODO: error code + else + return 1 + fi +} + +check_checksums() { + (( SKIPCHECKSUMS )) && return 0 + + local correlation=0 + local integ + for integ in "${known_hash_algos[@]}"; do + verify_integrity_sums "$integ" && correlation=1 done
if (( ! correlation )); then
On Mon, Sep 29, 2014 at 01:50:08PM +1000, Allan McRae wrote:
On 16/08/14 01:41, Dave Reisner wrote:
--- scripts/makepkg.sh.in | 94 +++++++++++++++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 41 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 8e8a64c..116b46e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1177,53 +1177,65 @@ generate_checksums() { done }
-check_checksums() { - (( SKIPCHECKSUMS )) && return 0 - (( ! ${#source[@]} )) && return 0
Because you deleted this, a PKGBUILD with no sources gives:
==> Validating source files with md5sums... ==> Validating source files with sha1sums... ==> Validating source files with sha224sums... ==> Validating source files with sha256sums... ==> Validating source files with sha384sums... ==> Validating source files with sha512sums...
Hrmm, I see this problem manifest differently... perhaps because you tested it at this patch rather than at the head of my branch? Regardless, will fix, and I'll be on the lookout for this as well.
+verify_integrity_one() { + local source_name=$1 integ=$2 expectedsum=$3
- local correlation=0 - local integ required - for integ in "${known_hash_algos[@]}"; do - local sumname="${integ}sums[@]" - local integrity_sums=("${!sumname}") - if (( ${#integrity_sums[@]} == ${#source[@]} )); then - msg "$(gettext "Validating source files with %s...")" "${integ}sums" - correlation=1 - local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - local file="$(get_filename "${source[idx]}")" - printf ' %s ... ' "$file" >&2 - - if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then - printf '%s\n' "$(gettext "Skipped")" >&2 - continue - fi + local file="$(get_filename "$source_name")" + printf ' %s ... ' "$file" >&2
- if ! file="$(get_filepath "$file")"; then - printf '%s\n' "$(gettext "NOT FOUND")" >&2 - errors=1 - continue - fi + if [[ $expectedsum = 'SKIP' ]]; then + printf '%s\n' "$(gettext "Skipped")" >&2 + return + fi
- local expectedsum="${integrity_sums[idx],,}" - local realsum="$(openssl dgst -${integ} "$file")" - realsum="${realsum##* }" - if [[ $expectedsum = "$realsum" ]]; then - printf '%s\n' "$(gettext "Passed")" >&2 - else - printf '%s\n' "$(gettext "FAILED")" >&2 - errors=1 - fi - done + if ! file="$(get_filepath "$file")"; then + printf '%s\n' "$(gettext "NOT FOUND")" >&2 + return 1 + fi
- if (( errors )); then - error "$(gettext "One or more files did not pass the validity check!")" - exit 1 # TODO: error code - fi - elif (( ${#integrity_sums[@]} )); then - error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + local realsum="$(openssl dgst -${integ} "$file")" + realsum="${realsum##* }" + if [[ ${expectedsum,,} = "$realsum" ]]; then + printf '%s\n' "$(gettext "Passed")" >&2 + else + printf '%s\n' "$(gettext "FAILED")" >&2 + return 1 + fi + + return 0 +} + +verify_integrity_sums() { + local integ=$1 integrity_sums + + array_build integrity_sums "${integ}sums" +
So we used to do this:
local sumname="${integ}sums[@]" local integrity_sums=("${!sumname}")
My question is why change to array_build? Is there an advantage that I am missing?
The old method relies on undocumented behavior. array_build does not.
+ if (( ${#integrity_sums[@]} == ${#source[@]} )); then + msg "$(gettext "Validating source files with %s...")" "${integ}sums" + local idx errors=0 + for (( idx = 0; idx < ${#source[*]}; idx++ )); do + verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + done + + if (( errors )); then + error "$(gettext "One or more files did not pass the validity check!")" exit 1 # TODO: error code fi + elif (( ${#integrity_sums[@]} )); then + error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + exit 1 # TODO: error code + else + return 1 + fi +} + +check_checksums() { + (( SKIPCHECKSUMS )) && return 0 + + local correlation=0 + local integ + for integ in "${known_hash_algos[@]}"; do + verify_integrity_sums "$integ" && correlation=1 done
if (( ! correlation )); then
--- v2: restore (( ! ${#source[@]} )) check This is pretty nitpicky, since it's changed a few patches later, but we might as well keep the history clean... scripts/makepkg.sh.in | 95 +++++++++++++++++++++++++++++---------------------- 1 file changed, 54 insertions(+), 41 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 49f5e59..2b5171e 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1176,53 +1176,66 @@ generate_checksums() { done } -check_checksums() { - (( SKIPCHECKSUMS )) && return 0 - (( ! ${#source[@]} )) && return 0 +verify_integrity_one() { + local source_name=$1 integ=$2 expectedsum=$3 - local correlation=0 - local integ required - for integ in "${known_hash_algos[@]}"; do - local sumname="${integ}sums[@]" - local integrity_sums=("${!sumname}") - if (( ${#integrity_sums[@]} == ${#source[@]} )); then - msg "$(gettext "Validating source files with %s...")" "${integ}sums" - correlation=1 - local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - local file="$(get_filename "${source[idx]}")" - printf ' %s ... ' "$file" >&2 - - if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then - printf '%s\n' "$(gettext "Skipped")" >&2 - continue - fi + local file="$(get_filename "$source_name")" + printf ' %s ... ' "$file" >&2 - if ! file="$(get_filepath "$file")"; then - printf '%s\n' "$(gettext "NOT FOUND")" >&2 - errors=1 - continue - fi + if [[ $expectedsum = 'SKIP' ]]; then + printf '%s\n' "$(gettext "Skipped")" >&2 + return + fi - local expectedsum="${integrity_sums[idx],,}" - local realsum="$(openssl dgst -${integ} "$file")" - realsum="${realsum##* }" - if [[ $expectedsum = "$realsum" ]]; then - printf '%s\n' "$(gettext "Passed")" >&2 - else - printf '%s\n' "$(gettext "FAILED")" >&2 - errors=1 - fi - done + if ! file="$(get_filepath "$file")"; then + printf '%s\n' "$(gettext "NOT FOUND")" >&2 + return 1 + fi - if (( errors )); then - error "$(gettext "One or more files did not pass the validity check!")" - exit 1 # TODO: error code - fi - elif (( ${#integrity_sums[@]} )); then - error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + local realsum="$(openssl dgst -${integ} "$file")" + realsum="${realsum##* }" + if [[ ${expectedsum,,} = "$realsum" ]]; then + printf '%s\n' "$(gettext "Passed")" >&2 + else + printf '%s\n' "$(gettext "FAILED")" >&2 + return 1 + fi + + return 0 +} + +verify_integrity_sums() { + local integ=$1 integrity_sums + + array_build integrity_sums "${integ}sums" + + if (( ${#integrity_sums[@]} == ${#source[@]} )); then + msg "$(gettext "Validating source files with %s...")" "${integ}sums" + local idx errors=0 + for (( idx = 0; idx < ${#source[*]}; idx++ )); do + verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + done + + if (( errors )); then + error "$(gettext "One or more files did not pass the validity check!")" exit 1 # TODO: error code fi + elif (( ${#integrity_sums[@]} )); then + error "$(gettext "Integrity checks (%s) differ in size from the source array.")" "$integ" + exit 1 # TODO: error code + else + return 1 + fi +} + +check_checksums() { + (( SKIPCHECKSUMS )) && return 0 + (( ! ${#source[@]} )) && return 0 + + local correlation=0 + local integ + for integ in "${known_hash_algos[@]}"; do + verify_integrity_sums "$integ" && correlation=1 done if (( ! correlation )); then -- 2.1.1
This also fixes a "bug" in which a PKGBUILD without any source array would generate "md5sums=()". While not technically wrong, we can easily do better and emit nothing at all. --- scripts/makepkg.sh.in | 73 +++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 116b46e..a8ae1de 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1120,6 +1120,46 @@ get_integlist() { fi } +generate_one_checksum() { + local integ=$1 numsrc=${#source[*]} indentsz idx + + if (( numsrc == 0 )); then + return + fi + + printf "%ssums=(%n" "$integ" indentsz + + for (( idx = 0; idx < numsrc; ++idx )); do + local netfile=${source[idx]} + local proto sum + proto="$(get_protocol "$netfile")" + + case $proto in + bzr*|git*|hg*|svn*) + sum="SKIP" + ;; + *) + if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then + local file + file="$(get_filepath "$netfile")" || missing_source_file "$netfile" + sum="$(openssl dgst -${integ} "$file")" + sum=${sum##* } + else + sum="SKIP" + fi + ;; + esac + + # indent checksum on lines after the first + printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" + + # print a newline on lines before the last + (( idx < (numsrc - 1) )) && echo + done + + echo ")" +} + generate_checksums() { msg "$(gettext "Generating checksums for source files...")" @@ -1142,38 +1182,7 @@ generate_checksums() { exit 1 # $E_CONFIG_ERROR fi - local indentsz idx numsrc=${#source[@]} - printf "%s%n" "${integ}sums=(" indentsz - - for (( idx = 0; idx < numsrc; i++ )); do - local netfile=${source[idx]} - local proto sum - proto="$(get_protocol "$netfile")" - - case $proto in - bzr*|git*|hg*|svn*) - sum="SKIP" - ;; - *) - if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then - local file - file="$(get_filepath "$netfile")" || missing_source_file "$netfile" - sum="$(openssl dgst -${integ} "$file")" - sum=${sum##* } - else - sum="SKIP" - fi - ;; - esac - - # indent checksum on lines after the first - printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" - - # print a newline on lines before the last - (( ++idx < numsrc )) && echo - done - - echo ")" + generate_one_checksum "$integ" done } -- 2.0.4
On 16/08/14 01:41, Dave Reisner wrote:
This also fixes a "bug" in which a PKGBUILD without any source array would generate "md5sums=()". While not technically wrong, we can easily do better and emit nothing at all. --- scripts/makepkg.sh.in | 73 +++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 32 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 116b46e..a8ae1de 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1120,6 +1120,46 @@ get_integlist() { fi }
+generate_one_checksum() { + local integ=$1 numsrc=${#source[*]} indentsz idx
Is there a reason to change to [*] instead of [@] here?
+ + if (( numsrc == 0 )); then + return + fi + + printf "%ssums=(%n" "$integ" indentsz + + for (( idx = 0; idx < numsrc; ++idx )); do + local netfile=${source[idx]} + local proto sum + proto="$(get_protocol "$netfile")" + + case $proto in + bzr*|git*|hg*|svn*) + sum="SKIP" + ;; + *) + if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then + local file + file="$(get_filepath "$netfile")" || missing_source_file "$netfile" + sum="$(openssl dgst -${integ} "$file")" + sum=${sum##* } + else + sum="SKIP" + fi + ;; + esac + + # indent checksum on lines after the first + printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" + + # print a newline on lines before the last + (( idx < (numsrc - 1) )) && echo + done + + echo ")" +} + generate_checksums() { msg "$(gettext "Generating checksums for source files...")"
@@ -1142,38 +1182,7 @@ generate_checksums() { exit 1 # $E_CONFIG_ERROR fi
- local indentsz idx numsrc=${#source[@]} - printf "%s%n" "${integ}sums=(" indentsz - - for (( idx = 0; idx < numsrc; i++ )); do - local netfile=${source[idx]} - local proto sum - proto="$(get_protocol "$netfile")" - - case $proto in - bzr*|git*|hg*|svn*) - sum="SKIP" - ;; - *) - if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then - local file - file="$(get_filepath "$netfile")" || missing_source_file "$netfile" - sum="$(openssl dgst -${integ} "$file")" - sum=${sum##* } - else - sum="SKIP" - fi - ;; - esac - - # indent checksum on lines after the first - printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" - - # print a newline on lines before the last - (( ++idx < numsrc )) && echo - done - - echo ")" + generate_one_checksum "$integ" done }
On Mon, Sep 29, 2014 at 01:57:39PM +1000, Allan McRae wrote:
On 16/08/14 01:41, Dave Reisner wrote:
This also fixes a "bug" in which a PKGBUILD without any source array would generate "md5sums=()". While not technically wrong, we can easily do better and emit nothing at all. --- scripts/makepkg.sh.in | 73 +++++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 32 deletions(-)
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 116b46e..a8ae1de 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1120,6 +1120,46 @@ get_integlist() { fi }
+generate_one_checksum() { + local integ=$1 numsrc=${#source[*]} indentsz idx
Is there a reason to change to [*] instead of [@] here?
Nope. ${#a[*]} and ${#a[@]} are functionally equivalent.
+ + if (( numsrc == 0 )); then + return + fi + + printf "%ssums=(%n" "$integ" indentsz + + for (( idx = 0; idx < numsrc; ++idx )); do + local netfile=${source[idx]} + local proto sum + proto="$(get_protocol "$netfile")" + + case $proto in + bzr*|git*|hg*|svn*) + sum="SKIP" + ;; + *) + if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then + local file + file="$(get_filepath "$netfile")" || missing_source_file "$netfile" + sum="$(openssl dgst -${integ} "$file")" + sum=${sum##* } + else + sum="SKIP" + fi + ;; + esac + + # indent checksum on lines after the first + printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" + + # print a newline on lines before the last + (( idx < (numsrc - 1) )) && echo + done + + echo ")" +} + generate_checksums() { msg "$(gettext "Generating checksums for source files...")"
@@ -1142,38 +1182,7 @@ generate_checksums() { exit 1 # $E_CONFIG_ERROR fi
- local indentsz idx numsrc=${#source[@]} - printf "%s%n" "${integ}sums=(" indentsz - - for (( idx = 0; idx < numsrc; i++ )); do - local netfile=${source[idx]} - local proto sum - proto="$(get_protocol "$netfile")" - - case $proto in - bzr*|git*|hg*|svn*) - sum="SKIP" - ;; - *) - if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then - local file - file="$(get_filepath "$netfile")" || missing_source_file "$netfile" - sum="$(openssl dgst -${integ} "$file")" - sum=${sum##* } - else - sum="SKIP" - fi - ;; - esac - - # indent checksum on lines after the first - printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'" - - # print a newline on lines before the last - (( ++idx < numsrc )) && echo - done - - echo ")" + generate_one_checksum "$integ" done }
This implements support for declarations such as: arch=('i686' 'x86_64') ... source=("somescript.sh") source_i686=("http://evilmonster.com/i686/ponies-9001-1.i686.bin") source_x86_64=("http://evilmonster.com/i686/ponies-9001-1.x86_64.bin") md5sums=('d41d8cd98f00b204e9800998ecf8427e') md5sums_i686=('e4ca381035a34b7a852184cc0dd89baa') md5sums_x86_64=('4019740e6998f30a3c534bac6a83f582') Just the same as the "untagged" sources, multiple integrity algorithms are supported. The manpage is updated to reflect support for these suffices. This commit also refactors download_sources slightly -- to use the otherwise preferred convention of lowercase local variable names, and to make the handling of $1 more clear. --- doc/PKGBUILD.5.txt | 4 ++ scripts/makepkg.sh.in | 151 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 123 insertions(+), 32 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index e2389cb..7a8531b 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -116,6 +116,10 @@ below). Compressed files will be extracted automatically unless found in the noextract array described below. + +Additional architecture-specific sources can be added by appending an +underscore and the architecture name e.g., 'source_x86_64=()'. There must be a +corresponding integrity array with checksums, e.g. 'md5sums_x86_64=()'. ++ It is also possible to change the name of the downloaded file, which is helpful with weird URLs and for handling multiple source files with the same name. The syntax is: `source=('filename::url')`. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index a8ae1de..c7061c0 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -768,16 +768,53 @@ extract_svn() { popd &>/dev/null } +get_all_sources() { + local aggregate l a + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + for a in "${arch[@]}"; do + if array_build l "source_$a"; then + aggregate+=("${l[@]}") + fi + done + + array_build "$1" "aggregate" +} + +get_all_sources_for_arch() { + local aggregate l + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + if array_build l "source_$CARCH"; then + aggregate+=("${l[@]}") + fi + + array_build "$1" "aggregate" +} + download_sources() { + local netfile all_sources + local get_source_fn=get_all_sources_for_arch get_vcs=1 + msg "$(gettext "Retrieving sources...")" - local GET_VCS=1 - if [[ $1 == "fast" ]]; then - GET_VCS=0 - fi + case $1 in + all) + get_source_fn=get_all_sources + ;; + fast) + get_vcs=0 + ;; + esac - local netfile - for netfile in "${source[@]}"; do + "$get_source_fn" 'all_sources' + for netfile in "${all_sources[@]}"; do pushd "$SRCDEST" &>/dev/null local proto=$(get_protocol "$netfile") @@ -786,16 +823,16 @@ download_sources() { download_local "$netfile" ;; bzr*) - (( GET_VCS )) && download_bzr "$netfile" + (( get_vcs )) && download_bzr "$netfile" ;; git*) - (( GET_VCS )) && download_git "$netfile" + (( get_vcs )) && download_git "$netfile" ;; hg*) - (( GET_VCS )) && download_hg "$netfile" + (( get_vcs )) && download_hg "$netfile" ;; svn*) - (( GET_VCS )) && download_svn "$netfile" + (( get_vcs )) && download_svn "$netfile" ;; *) download_file "$netfile" @@ -977,8 +1014,10 @@ in_array() { } source_has_signatures() { - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources_for_arch 'all_sources' + for file in "${all_sources[@]}"; do if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then return 0 fi @@ -1121,16 +1160,27 @@ get_integlist() { } generate_one_checksum() { - local integ=$1 numsrc=${#source[*]} indentsz idx + local integ=$1 arch=$2 sources numsrc indentsz idx + + if [[ $arch ]]; then + array_build sources "source_$arch" + else + array_build sources 'source' + fi + numsrc=${#sources[*]} if (( numsrc == 0 )); then return fi - printf "%ssums=(%n" "$integ" indentsz + if [[ $arch ]]; then + printf "%ssums_%s=(%n" "$integ" "$arch" indentsz + else + printf "%ssums=(%n" "$integ" indentsz + fi for (( idx = 0; idx < numsrc; ++idx )); do - local netfile=${source[idx]} + local netfile=${sources[idx]} local proto sum proto="$(get_protocol "$netfile")" @@ -1183,6 +1233,9 @@ generate_checksums() { fi generate_one_checksum "$integ" + for a in "${arch[@]}"; do + generate_one_checksum "$integ" "$a" + done done } @@ -1215,15 +1268,25 @@ verify_integrity_one() { } verify_integrity_sums() { - local integ=$1 integrity_sums + local integ=$1 arch=$2 integrity_sums=() sources=() - array_build integrity_sums "${integ}sums" + if [[ $arch ]]; then + array_build integrity_sums "${integ}sums_$arch" + array_build sources "source_$arch" + else + array_build integrity_sums "${integ}sums" + array_build sources source + fi - if (( ${#integrity_sums[@]} == ${#source[@]} )); then + if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then + return 1 + fi + + if (( ${#integrity_sums[@]} == ${#sources[@]} )); then msg "$(gettext "Validating source files with %s...")" "${integ}sums" local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + for (( idx = 0; idx < ${#sources[*]}; idx++ )); do + verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 done if (( errors )); then @@ -1242,9 +1305,20 @@ check_checksums() { (( SKIPCHECKSUMS )) && return 0 local correlation=0 - local integ + local integ a for integ in "${known_hash_algos[@]}"; do verify_integrity_sums "$integ" && correlation=1 + + case $1 in + all) + for a in "${arch[@]}"; do + verify_integrity_sums "$integ" "$a" && correlation=1 + done + ;; + *) + verify_integrity_sums "$integ" "$CARCH" && correlation=1 + ;; + esac done if (( ! correlation )); then @@ -1321,8 +1395,17 @@ check_pgpsigs() { local warning=0 local errors=0 local statusfile=$(mktemp) + local all_sources - for file in "${source[@]}"; do + case $1 in + all) + get_all_sources 'all_sources' + ;; + *) + get_all_sources_for_arch 'all_sources' + ;; + esac + for file in "${all_sources[@]}"; do file="$(get_filename "$file")" if [[ ! $file = *.@(sig?(n)|asc) ]]; then continue @@ -1426,20 +1509,22 @@ check_source_integrity() { warning "$(gettext "Skipping all source file integrity checks.")" elif (( SKIPCHECKSUMS )); then warning "$(gettext "Skipping verification of source file checksums.")" - check_pgpsigs + check_pgpsigs "$@" elif (( SKIPPGPCHECK )); then warning "$(gettext "Skipping verification of source file PGP signatures.")" - check_checksums + check_checksums "$@" else - check_checksums - check_pgpsigs + check_checksums "$@" + check_pgpsigs "$@" fi } extract_sources() { msg "$(gettext "Extracting sources...")" - local netfile - for netfile in "${source[@]}"; do + local netfile all_sources + + get_all_sources_for_arch 'all_sources' + for netfile in "${all_sources[@]}"; do local file=$(get_filename "$netfile") if in_array "$file" "${noextract[@]}"; then # skip source files in the noextract=() array @@ -2130,8 +2215,10 @@ create_srcpackage() { msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}" - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources 'all_sources' + for file in "${all_sources[@]}"; do if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then local absfile absfile=$(get_filepath "$file") || missing_source_file "$file" @@ -3358,12 +3445,12 @@ if (( SOURCEONLY )); then chmod a-s "$srcdir" cd_safe "$srcdir" if (( SOURCEONLY == 2 )); then - download_sources + download_sources all elif ( (( ! SKIPCHECKSUMS )) || \ ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then download_sources fast fi - check_source_integrity + check_source_integrity all cd_safe "$startdir" enter_fakeroot -- 2.0.4
This implements support for declarations such as: arch=('i686' 'x86_64') ... source=("somescript.sh") source_i686=("http://evilmonster.com/i686/ponies-9001-1.i686.bin") source_x86_64=("http://evilmonster.com/i686/ponies-9001-1.x86_64.bin") md5sums=('d41d8cd98f00b204e9800998ecf8427e') md5sums_i686=('e4ca381035a34b7a852184cc0dd89baa') md5sums_x86_64=('4019740e6998f30a3c534bac6a83f582') Just the same as the "untagged" sources, multiple integrity algorithms are supported. The manpage is updated to reflect support for these suffices. This commit also refactors download_sources slightly: 1) to use the otherwise preferred convention of lowercase local variable names, and to make the handling of $1 more clear. 2) rename the "fast" parameter to "novcs", to make it more clear what this token does. 3) add a new possible token "allarch" to ensure that download_sources will fetch all sources, for all architectures. --- foutrelis pointed out that 'makepkg -g' wouldn't attempt to download sources for all architectures. So, I've added some additional polish to download_sources to make it take several tokens, instead of just one. And, give the token "fast" a better name... We really need some of these codepaths to converge sooner... doc/PKGBUILD.5.txt | 4 ++ scripts/makepkg.sh.in | 161 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 131 insertions(+), 34 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index e2389cb..7a8531b 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -116,6 +116,10 @@ below). Compressed files will be extracted automatically unless found in the noextract array described below. + +Additional architecture-specific sources can be added by appending an +underscore and the architecture name e.g., 'source_x86_64=()'. There must be a +corresponding integrity array with checksums, e.g. 'md5sums_x86_64=()'. ++ It is also possible to change the name of the downloaded file, which is helpful with weird URLs and for handling multiple source files with the same name. The syntax is: `source=('filename::url')`. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index a8ae1de..0678105 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -768,16 +768,59 @@ extract_svn() { popd &>/dev/null } +get_all_sources() { + local aggregate l a + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + for a in "${arch[@]}"; do + if array_build l "source_$a"; then + aggregate+=("${l[@]}") + fi + done + + array_build "$1" "aggregate" +} + +get_all_sources_for_arch() { + local aggregate l + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + if array_build l "source_$CARCH"; then + aggregate+=("${l[@]}") + fi + + array_build "$1" "aggregate" +} + download_sources() { + local netfile all_sources + local get_source_fn=get_all_sources_for_arch get_vcs=1 + msg "$(gettext "Retrieving sources...")" - local GET_VCS=1 - if [[ $1 == "fast" ]]; then - GET_VCS=0 - fi + while true; do + case $1 in + allarch) + get_source_fn=get_all_sources + ;; + novcs) + get_vcs=0 + ;; + *) + break 2 + ;; + esac + shift + done - local netfile - for netfile in "${source[@]}"; do + "$get_source_fn" 'all_sources' + for netfile in "${all_sources[@]}"; do pushd "$SRCDEST" &>/dev/null local proto=$(get_protocol "$netfile") @@ -786,16 +829,16 @@ download_sources() { download_local "$netfile" ;; bzr*) - (( GET_VCS )) && download_bzr "$netfile" + (( get_vcs )) && download_bzr "$netfile" ;; git*) - (( GET_VCS )) && download_git "$netfile" + (( get_vcs )) && download_git "$netfile" ;; hg*) - (( GET_VCS )) && download_hg "$netfile" + (( get_vcs )) && download_hg "$netfile" ;; svn*) - (( GET_VCS )) && download_svn "$netfile" + (( get_vcs )) && download_svn "$netfile" ;; *) download_file "$netfile" @@ -977,8 +1020,10 @@ in_array() { } source_has_signatures() { - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources_for_arch 'all_sources' + for file in "${all_sources[@]}"; do if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then return 0 fi @@ -1121,16 +1166,27 @@ get_integlist() { } generate_one_checksum() { - local integ=$1 numsrc=${#source[*]} indentsz idx + local integ=$1 arch=$2 sources numsrc indentsz idx + if [[ $arch ]]; then + array_build sources "source_$arch" + else + array_build sources 'source' + fi + + numsrc=${#sources[*]} if (( numsrc == 0 )); then return fi - printf "%ssums=(%n" "$integ" indentsz + if [[ $arch ]]; then + printf "%ssums_%s=(%n" "$integ" "$arch" indentsz + else + printf "%ssums=(%n" "$integ" indentsz + fi for (( idx = 0; idx < numsrc; ++idx )); do - local netfile=${source[idx]} + local netfile=${sources[idx]} local proto sum proto="$(get_protocol "$netfile")" @@ -1183,6 +1239,9 @@ generate_checksums() { fi generate_one_checksum "$integ" + for a in "${arch[@]}"; do + generate_one_checksum "$integ" "$a" + done done } @@ -1215,15 +1274,25 @@ verify_integrity_one() { } verify_integrity_sums() { - local integ=$1 integrity_sums + local integ=$1 arch=$2 integrity_sums=() sources=() - array_build integrity_sums "${integ}sums" + if [[ $arch ]]; then + array_build integrity_sums "${integ}sums_$arch" + array_build sources "source_$arch" + else + array_build integrity_sums "${integ}sums" + array_build sources source + fi + + if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then + return 1 + fi - if (( ${#integrity_sums[@]} == ${#source[@]} )); then + if (( ${#integrity_sums[@]} == ${#sources[@]} )); then msg "$(gettext "Validating source files with %s...")" "${integ}sums" local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + for (( idx = 0; idx < ${#sources[*]}; idx++ )); do + verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 done if (( errors )); then @@ -1242,9 +1311,20 @@ check_checksums() { (( SKIPCHECKSUMS )) && return 0 local correlation=0 - local integ + local integ a for integ in "${known_hash_algos[@]}"; do verify_integrity_sums "$integ" && correlation=1 + + case $1 in + all) + for a in "${arch[@]}"; do + verify_integrity_sums "$integ" "$a" && correlation=1 + done + ;; + *) + verify_integrity_sums "$integ" "$CARCH" && correlation=1 + ;; + esac done if (( ! correlation )); then @@ -1321,8 +1401,17 @@ check_pgpsigs() { local warning=0 local errors=0 local statusfile=$(mktemp) + local all_sources - for file in "${source[@]}"; do + case $1 in + all) + get_all_sources 'all_sources' + ;; + *) + get_all_sources_for_arch 'all_sources' + ;; + esac + for file in "${all_sources[@]}"; do file="$(get_filename "$file")" if [[ ! $file = *.@(sig?(n)|asc) ]]; then continue @@ -1426,20 +1515,22 @@ check_source_integrity() { warning "$(gettext "Skipping all source file integrity checks.")" elif (( SKIPCHECKSUMS )); then warning "$(gettext "Skipping verification of source file checksums.")" - check_pgpsigs + check_pgpsigs "$@" elif (( SKIPPGPCHECK )); then warning "$(gettext "Skipping verification of source file PGP signatures.")" - check_checksums + check_checksums "$@" else - check_checksums - check_pgpsigs + check_checksums "$@" + check_pgpsigs "$@" fi } extract_sources() { msg "$(gettext "Extracting sources...")" - local netfile - for netfile in "${source[@]}"; do + local netfile all_sources + + get_all_sources_for_arch 'all_sources' + for netfile in "${all_sources[@]}"; do local file=$(get_filename "$netfile") if in_array "$file" "${noextract[@]}"; then # skip source files in the noextract=() array @@ -2130,8 +2221,10 @@ create_srcpackage() { msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}" - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources 'all_sources' + for file in "${all_sources[@]}"; do if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then local absfile absfile=$(get_filepath "$file") || missing_source_file "$file" @@ -3254,7 +3347,7 @@ if (( GENINTEG )); then mkdir -p "$srcdir" chmod a-s "$srcdir" cd_safe "$srcdir" - download_sources fast + download_sources novcs allarch generate_checksums exit 0 # $E_OK fi @@ -3358,12 +3451,12 @@ if (( SOURCEONLY )); then chmod a-s "$srcdir" cd_safe "$srcdir" if (( SOURCEONLY == 2 )); then - download_sources + download_sources allarch elif ( (( ! SKIPCHECKSUMS )) || \ ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then - download_sources fast + download_sources novcs fi - check_source_integrity + check_source_integrity all cd_safe "$startdir" enter_fakeroot -- 2.0.4
On 16/08/14 11:47, Dave Reisner wrote:
This implements support for declarations such as:
arch=('i686' 'x86_64') ...
source=("somescript.sh") source_i686=("http://evilmonster.com/i686/ponies-9001-1.i686.bin") source_x86_64=("http://evilmonster.com/i686/ponies-9001-1.x86_64.bin")
md5sums=('d41d8cd98f00b204e9800998ecf8427e') md5sums_i686=('e4ca381035a34b7a852184cc0dd89baa') md5sums_x86_64=('4019740e6998f30a3c534bac6a83f582')
Just the same as the "untagged" sources, multiple integrity algorithms are supported. The manpage is updated to reflect support for these suffices.
This commit also refactors download_sources slightly:
1) to use the otherwise preferred convention of lowercase local variable names, and to make the handling of $1 more clear. 2) rename the "fast" parameter to "novcs", to make it more clear what this token does. 3) add a new possible token "allarch" to ensure that download_sources will fetch all sources, for all architectures. --- foutrelis pointed out that 'makepkg -g' wouldn't attempt to download sources for all architectures. So, I've added some additional polish to download_sources to make it take several tokens, instead of just one. And, give the token "fast" a better name...
We really need some of these codepaths to converge sooner...
Ack.
This implements support for declarations such as: arch=('i686' 'x86_64') ... source=("somescript.sh") source_i686=("http://evilmonster.com/i686/ponies-9001-1.i686.bin") source_x86_64=("http://evilmonster.com/i686/ponies-9001-1.x86_64.bin") md5sums=('d41d8cd98f00b204e9800998ecf8427e') md5sums_i686=('e4ca381035a34b7a852184cc0dd89baa') md5sums_x86_64=('4019740e6998f30a3c534bac6a83f582') Just the same as the "untagged" sources, multiple integrity algorithms are supported. The manpage is updated to reflect support for these suffices. This commit also refactors download_sources slightly: 1) to use the otherwise preferred convention of lowercase local variable names, and to make the handling of $1 more clear. 2) rename the "fast" parameter to "novcs", to make it more clear what this token does. 3) add a new possible token "allarch" to ensure that download_sources will fetch all sources, for all architectures. --- v3: implement architecture-aware "have_sources" to replace null source check. doc/PKGBUILD.5.txt | 4 ++ scripts/makepkg.sh.in | 182 ++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 151 insertions(+), 35 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index c653aac..74aea32 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -116,6 +116,10 @@ below). Compressed files will be extracted automatically unless found in the noextract array described below. + +Additional architecture-specific sources can be added by appending an +underscore and the architecture name e.g., 'source_x86_64=()'. There must be a +corresponding integrity array with checksums, e.g. 'md5sums_x86_64=()'. ++ It is also possible to change the name of the downloaded file, which is helpful with weird URLs and for handling multiple source files with the same name. The syntax is: `source=('filename::url')`. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0402475..af90660 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -767,16 +767,59 @@ extract_svn() { popd &>/dev/null } +get_all_sources() { + local aggregate l a + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + for a in "${arch[@]}"; do + if array_build l "source_$a"; then + aggregate+=("${l[@]}") + fi + done + + array_build "$1" "aggregate" +} + +get_all_sources_for_arch() { + local aggregate l + + if array_build l 'source'; then + aggregate+=("${l[@]}") + fi + + if array_build l "source_$CARCH"; then + aggregate+=("${l[@]}") + fi + + array_build "$1" "aggregate" +} + download_sources() { + local netfile all_sources + local get_source_fn=get_all_sources_for_arch get_vcs=1 + msg "$(gettext "Retrieving sources...")" - local GET_VCS=1 - if [[ $1 == "fast" ]]; then - GET_VCS=0 - fi + while true; do + case $1 in + allarch) + get_source_fn=get_all_sources + ;; + novcs) + get_vcs=0 + ;; + *) + break 2 + ;; + esac + shift + done - local netfile - for netfile in "${source[@]}"; do + "$get_source_fn" 'all_sources' + for netfile in "${all_sources[@]}"; do pushd "$SRCDEST" &>/dev/null local proto=$(get_protocol "$netfile") @@ -785,16 +828,16 @@ download_sources() { download_local "$netfile" ;; bzr*) - (( GET_VCS )) && download_bzr "$netfile" + (( get_vcs )) && download_bzr "$netfile" ;; git*) - (( GET_VCS )) && download_git "$netfile" + (( get_vcs )) && download_git "$netfile" ;; hg*) - (( GET_VCS )) && download_hg "$netfile" + (( get_vcs )) && download_hg "$netfile" ;; svn*) - (( GET_VCS )) && download_svn "$netfile" + (( get_vcs )) && download_svn "$netfile" ;; *) download_file "$netfile" @@ -976,8 +1019,10 @@ in_array() { } source_has_signatures() { - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources_for_arch 'all_sources' + for file in "${all_sources[@]}"; do if [[ ${file%%::*} = *.@(sig?(n)|asc) ]]; then return 0 fi @@ -1120,16 +1165,27 @@ get_integlist() { } generate_one_checksum() { - local integ=$1 numsrc=${#source[*]} indentsz idx + local integ=$1 arch=$2 sources numsrc indentsz idx + + if [[ $arch ]]; then + array_build sources "source_$arch" + else + array_build sources 'source' + fi + numsrc=${#sources[*]} if (( numsrc == 0 )); then return fi - printf "%ssums=(%n" "$integ" indentsz + if [[ $arch ]]; then + printf "%ssums_%s=(%n" "$integ" "$arch" indentsz + else + printf "%ssums=(%n" "$integ" indentsz + fi for (( idx = 0; idx < numsrc; ++idx )); do - local netfile=${source[idx]} + local netfile=${sources[idx]} local proto sum proto="$(get_protocol "$netfile")" @@ -1182,6 +1238,9 @@ generate_checksums() { fi generate_one_checksum "$integ" + for a in "${arch[@]}"; do + generate_one_checksum "$integ" "$a" + done done } @@ -1214,15 +1273,25 @@ verify_integrity_one() { } verify_integrity_sums() { - local integ=$1 integrity_sums + local integ=$1 arch=$2 integrity_sums=() sources=() - array_build integrity_sums "${integ}sums" + if [[ $arch ]]; then + array_build integrity_sums "${integ}sums_$arch" + array_build sources "source_$arch" + else + array_build integrity_sums "${integ}sums" + array_build sources source + fi + + if (( ${#integrity_sums[@]} == 0 && ${#sources[@]} == 0 )); then + return 1 + fi - if (( ${#integrity_sums[@]} == ${#source[@]} )); then + if (( ${#integrity_sums[@]} == ${#sources[@]} )); then msg "$(gettext "Validating source files with %s...")" "${integ}sums" local idx errors=0 - for (( idx = 0; idx < ${#source[*]}; idx++ )); do - verify_integrity_one "${source[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 + for (( idx = 0; idx < ${#sources[*]}; idx++ )); do + verify_integrity_one "${sources[idx]}" "$integ" "${integrity_sums[idx]}" || errors=1 done if (( errors )); then @@ -1237,14 +1306,44 @@ verify_integrity_sums() { fi } +have_sources() { + local a + + case $1 in + all) + for a in "${arch[@]}"; do + array_build _ source_"$a" && return 0 + done + ;; + *) + if (( ${#source[*]} )) || array_build _ source_"$CARCH"; then + return 0 + fi + ;; + esac + + return 1 +} + check_checksums() { (( SKIPCHECKSUMS )) && return 0 - (( ! ${#source[@]} )) && return 0 + have_sources "$1" || return 0 local correlation=0 - local integ + local integ a for integ in "${known_hash_algos[@]}"; do verify_integrity_sums "$integ" && correlation=1 + + case $1 in + all) + for a in "${arch[@]}"; do + verify_integrity_sums "$integ" "$a" && correlation=1 + done + ;; + *) + verify_integrity_sums "$integ" "$CARCH" && correlation=1 + ;; + esac done if (( ! correlation )); then @@ -1321,8 +1420,17 @@ check_pgpsigs() { local warning=0 local errors=0 local statusfile=$(mktemp) + local all_sources - for file in "${source[@]}"; do + case $1 in + all) + get_all_sources 'all_sources' + ;; + *) + get_all_sources_for_arch 'all_sources' + ;; + esac + for file in "${all_sources[@]}"; do file="$(get_filename "$file")" if [[ ! $file = *.@(sig?(n)|asc) ]]; then continue @@ -1426,20 +1534,22 @@ check_source_integrity() { warning "$(gettext "Skipping all source file integrity checks.")" elif (( SKIPCHECKSUMS )); then warning "$(gettext "Skipping verification of source file checksums.")" - check_pgpsigs + check_pgpsigs "$@" elif (( SKIPPGPCHECK )); then warning "$(gettext "Skipping verification of source file PGP signatures.")" - check_checksums + check_checksums "$@" else - check_checksums - check_pgpsigs + check_checksums "$@" + check_pgpsigs "$@" fi } extract_sources() { msg "$(gettext "Extracting sources...")" - local netfile - for netfile in "${source[@]}"; do + local netfile all_sources + + get_all_sources_for_arch 'all_sources' + for netfile in "${all_sources[@]}"; do local file=$(get_filename "$netfile") if in_array "$file" "${noextract[@]}"; then # skip source files in the noextract=() array @@ -2130,8 +2240,10 @@ create_srcpackage() { msg2 "$(gettext "Adding %s...")" "$BUILDSCRIPT" ln -s "${BUILDFILE}" "${srclinks}/${pkgbase}/${BUILDSCRIPT}" - local file - for file in "${source[@]}"; do + local file all_sources + + get_all_sources 'all_sources' + for file in "${all_sources[@]}"; do if [[ "$file" = "$(get_filename "$file")" ]] || (( SOURCEONLY == 2 )); then local absfile absfile=$(get_filepath "$file") || missing_source_file "$file" @@ -3268,7 +3380,7 @@ if (( GENINTEG )); then mkdir -p "$srcdir" chmod a-s "$srcdir" cd_safe "$srcdir" - download_sources fast + download_sources novcs allarch generate_checksums exit 0 # $E_OK fi @@ -3372,12 +3484,12 @@ if (( SOURCEONLY )); then chmod a-s "$srcdir" cd_safe "$srcdir" if (( SOURCEONLY == 2 )); then - download_sources + download_sources allarch elif ( (( ! SKIPCHECKSUMS )) || \ ( (( ! SKIPPGPCHECK )) && source_has_signatures ) ); then - download_sources fast + download_sources novcs fi - check_source_integrity + check_source_integrity all cd_safe "$startdir" enter_fakeroot -- 2.1.1
This change reveals a bootstrapping bug -- since we call the bare "makepkg" and rely on PATH lookup, we might not have a makepkg which can generate architecture-specific checksums. --- The careful observer will note that this bootstrap issue applies to more than just this one script. contrib/updpkgsums.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in index 7e680b8..43c8337 100644 --- a/contrib/updpkgsums.sh.in +++ b/contrib/updpkgsums.sh.in @@ -81,7 +81,7 @@ fi # but it's better to be extra careful before unlinking files. newsums=$(makepkg -g -p "$buildfile") && rm -f "$buildfile" && exec awk -v newsums="$newsums" ' - /^[[:blank:]]*(md|sha)[[:digit:]]+sums=/,/\)[[:blank:]]*(#.*)?$/ { + /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ { if (!w) { print newsums w++ -- 2.0.4
On 16/08/14 01:42, Dave Reisner wrote:
This change reveals a bootstrapping bug -- since we call the bare "makepkg" and rely on PATH lookup, we might not have a makepkg which can generate architecture-specific checksums. --- The careful observer will note that this bootstrap issue applies to more than just this one script.
Ack. "Patches accepted" for the bootstrap issue, although I think we have better things to fix.
contrib/updpkgsums.sh.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/updpkgsums.sh.in b/contrib/updpkgsums.sh.in index 7e680b8..43c8337 100644 --- a/contrib/updpkgsums.sh.in +++ b/contrib/updpkgsums.sh.in @@ -81,7 +81,7 @@ fi # but it's better to be extra careful before unlinking files. newsums=$(makepkg -g -p "$buildfile") && rm -f "$buildfile" && exec awk -v newsums="$newsums" ' - /^[[:blank:]]*(md|sha)[[:digit:]]+sums=/,/\)[[:blank:]]*(#.*)?$/ { + /^[[:blank:]]*(md|sha)[[:digit:]]+sums(_[^=]+)?=/,/\)[[:blank:]]*(#.*)?$/ { if (!w) { print newsums w++
This commit changes the few remaining instances of: [[ ! $foo = "$bar" ]] to the more common: [[ $foo != "$bar" ]] --- scripts/makepkg.sh.in | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c7061c0..f74b1b1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1027,12 +1027,12 @@ source_has_signatures() { run_pacman() { local cmd - if [[ ! $1 = -@(T|Qq) ]]; then + if [[ $1 != -@(T|Qq) ]]; then cmd=("$PACMAN_PATH" $PACMAN_OPTS "$@") else cmd=("$PACMAN_PATH" "$@") fi - if [[ ! $1 = -@(T|Qq) ]]; then + if [[ $1 != -@(T|Qq) ]]; then if type -p sudo >/dev/null; then cmd=(sudo "${cmd[@]}") else @@ -1189,7 +1189,7 @@ generate_one_checksum() { sum="SKIP" ;; *) - if [[ ! $netfile = *.@(sig?(n)|asc) ]]; then + if [[ $netfile != *.@(sig?(n)|asc) ]]; then local file file="$(get_filepath "$netfile")" || missing_source_file "$netfile" sum="$(openssl dgst -${integ} "$file")" @@ -1407,7 +1407,7 @@ check_pgpsigs() { esac for file in "${all_sources[@]}"; do file="$(get_filename "$file")" - if [[ ! $file = *.@(sig?(n)|asc) ]]; then + if [[ $file != *.@(sig?(n)|asc) ]]; then continue fi @@ -3202,7 +3202,7 @@ PACMAN_PATH=$(type -P $PACMAN) # check if messages are to be printed using color unset ALL_OFF BOLD BLUE GREEN RED YELLOW -if [[ -t 2 && ! $USE_COLOR = "n" ]] && check_buildenv "color" "y"; then +if [[ -t 2 && $USE_COLOR != "n" ]] && check_buildenv "color" "y"; then # prefer terminal safe colored and bold text when tput is supported if tput setaf 0 &>/dev/null; then ALL_OFF="$(tput sgr0)" -- 2.0.4
participants (3)
-
Allan McRae
-
Dave Reisner
-
Dave Reisner