summaryrefslogtreecommitdiff
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2013-09-03 20:03:04 -0400
committerAllan McRae <allan@archlinux.org>2013-09-18 14:28:03 +1000
commit93888089643b017390538d1f6f3a2d2aa9918851 (patch)
tree1d170e3fb707b4f29fe09d25ae2abce82f8ca410 /scripts/makepkg.sh.in
parentde570d1a65a24dfc53797d4a53e2ff82ec814ab3 (diff)
downloadpacman-93888089643b017390538d1f6f3a2d2aa9918851.tar.xz
makepkg: use c-style for loops for integrity checks
These loops already maintain an independent loop counter, so cut out the middle man. While this change doesn't necessarily require that we drop support for sparse arrays, we do via this patch. A new lint check is added in check_sanity to abort when a sparse array is encountered. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in51
1 files changed, 24 insertions, 27 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 44d5335b..c5f76714 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1145,12 +1145,11 @@ generate_checksums() {
exit 1 # $E_CONFIG_ERROR
fi
- local ct=0
- local indentsz numsrc=${#source[@]}
+ local indentsz idx numsrc=${#source[@]}
printf "%s%n" "${integ}sums=(" indentsz
- local netfile
- for netfile in "${source[@]}"; do
+ for (( idx = 0; idx < numsrc; i++ )); do
+ local netfile=${source[idx]}
local proto sum
proto="$(get_protocol "$netfile")"
@@ -1171,10 +1170,10 @@ generate_checksums() {
esac
# indent checksum on lines after the first
- printf "%*s%s" $(( ct ? indentsz : 0 )) '' "'$sum'"
+ printf "%*s%s" $(( idx ? indentsz : 0 )) '' "'$sum'"
# print a newline on lines before the last
- (( ++ct < numsrc )) && echo
+ (( ++idx < numsrc )) && echo
done
echo ")"
@@ -1193,39 +1192,31 @@ check_checksums() {
if (( ${#integrity_sums[@]} == ${#source[@]} )); then
msg "$(gettext "Validating source files with %s...")" "${integ}sums"
correlation=1
- local errors=0
- local idx=0
- local file
- for file in "${source[@]}"; do
- local found=1
- file="$(get_filename "$file")"
+ 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
+ if [[ ${integrity_sums[idx]} = 'SKIP' ]]; then
printf '%s\n' "$(gettext "Skipped")" >&2
- idx=$((idx + 1))
continue
fi
if ! file="$(get_filepath "$file")"; then
printf '%s\n' "$(gettext "NOT FOUND")" >&2
errors=1
- found=0
+ continue
fi
- if (( $found )) ; then
- 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
+ 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
-
- idx=$((idx + 1))
done
if (( errors )); then
@@ -2261,6 +2252,12 @@ check_sanity() {
fi
done
+ local idx=("${!source[@]}")
+ if (( (idx[-1] + 1) != ${#source[*]} )); then
+ error "$(gettext "Sparse arrays are not allowed for source")"
+ ret=1
+ fi
+
return $ret
}