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,6 +1119,46 @@ get_integlist() {
|
||||||
fi
|
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() {
|
generate_checksums() {
|
||||||
msg "$(gettext "Generating checksums for source files...")"
|
msg "$(gettext "Generating checksums for source files...")"
|
||||||
|
|
||||||
|
@ -1141,38 +1181,7 @@ generate_checksums() {
|
||||||
exit 1 # $E_CONFIG_ERROR
|
exit 1 # $E_CONFIG_ERROR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local indentsz idx numsrc=${#source[@]}
|
generate_one_checksum "$integ"
|
||||||
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 ")"
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue