makepkg: break out checksum generation to its own function
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.
This commit is contained in:
parent
a3d7230e4d
commit
51353edc61
1 changed files with 41 additions and 32 deletions
|
@ -1119,32 +1119,16 @@ get_integlist() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
generate_checksums() {
|
generate_one_checksum() {
|
||||||
msg "$(gettext "Generating checksums for source files...")"
|
local integ=$1 numsrc=${#source[*]} indentsz idx
|
||||||
|
|
||||||
if ! type -p openssl >/dev/null; then
|
if (( numsrc == 0 )); then
|
||||||
error "$(gettext "Cannot find the %s binary required for generating sourcefile checksums.")" "openssl"
|
return
|
||||||
exit 1 # $E_MISSING_PROGRAM
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local integlist
|
printf "%ssums=(%n" "$integ" indentsz
|
||||||
if (( $# == 0 )); then
|
|
||||||
IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
|
|
||||||
else
|
|
||||||
integlist=("$@")
|
|
||||||
fi
|
|
||||||
|
|
||||||
local integ
|
for (( idx = 0; idx < numsrc; ++idx )); do
|
||||||
for integ in "${integlist[@]}"; do
|
|
||||||
if ! in_array "$integ" "${known_hash_algos[@]}"; then
|
|
||||||
error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
|
|
||||||
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 netfile=${source[idx]}
|
||||||
local proto sum
|
local proto sum
|
||||||
proto="$(get_protocol "$netfile")"
|
proto="$(get_protocol "$netfile")"
|
||||||
|
@ -1169,10 +1153,35 @@ generate_checksums() {
|
||||||
printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'"
|
printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'"
|
||||||
|
|
||||||
# print a newline on lines before the last
|
# print a newline on lines before the last
|
||||||
(( ++idx < numsrc )) && echo
|
(( idx < (numsrc - 1) )) && echo
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ")"
|
echo ")"
|
||||||
|
}
|
||||||
|
|
||||||
|
generate_checksums() {
|
||||||
|
msg "$(gettext "Generating checksums for source files...")"
|
||||||
|
|
||||||
|
if ! type -p openssl >/dev/null; then
|
||||||
|
error "$(gettext "Cannot find the %s binary required for generating sourcefile checksums.")" "openssl"
|
||||||
|
exit 1 # $E_MISSING_PROGRAM
|
||||||
|
fi
|
||||||
|
|
||||||
|
local integlist
|
||||||
|
if (( $# == 0 )); then
|
||||||
|
IFS=$'\n' read -rd '' -a integlist < <(get_integlist)
|
||||||
|
else
|
||||||
|
integlist=("$@")
|
||||||
|
fi
|
||||||
|
|
||||||
|
local integ
|
||||||
|
for integ in "${integlist[@]}"; do
|
||||||
|
if ! in_array "$integ" "${known_hash_algos[@]}"; then
|
||||||
|
error "$(gettext "Invalid integrity algorithm '%s' specified.")" "$integ"
|
||||||
|
exit 1 # $E_CONFIG_ERROR
|
||||||
|
fi
|
||||||
|
|
||||||
|
generate_one_checksum "$integ"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue