00-distfiles.sh: avoid unnecessary second loop
We're already done after the first loop, if all distfiles were found and their checksums verified ok.
This commit is contained in:
parent
ce87fc612a
commit
d7b1a31cf0
|
@ -30,7 +30,7 @@ verify_cksum() {
|
||||||
if [ "$cksum" != "$filesum" ]; then
|
if [ "$cksum" != "$filesum" ]; then
|
||||||
echo
|
echo
|
||||||
msg_red "SHA256 mismatch for '$curfile:'\n$filesum\n"
|
msg_red "SHA256 mismatch for '$curfile:'\n$filesum\n"
|
||||||
errors=$(($errors + 1))
|
errors=$((errors + 1))
|
||||||
else
|
else
|
||||||
if [ ! -f "$XBPS_SRCDISTDIR/by_sha256/${cksum}_${curfile}" ]; then
|
if [ ! -f "$XBPS_SRCDISTDIR/by_sha256/${cksum}_${curfile}" ]; then
|
||||||
mkdir -p "$XBPS_SRCDISTDIR/by_sha256"
|
mkdir -p "$XBPS_SRCDISTDIR/by_sha256"
|
||||||
|
@ -94,7 +94,7 @@ try_mirrors() {
|
||||||
|
|
||||||
hook() {
|
hook() {
|
||||||
local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
|
local srcdir="$XBPS_SRCDISTDIR/$pkgname-$version"
|
||||||
local dfcount=0 errors=0
|
local dfcount=0 dfgood=0 errors=0
|
||||||
|
|
||||||
if [ ! -d "$srcdir" ]; then
|
if [ ! -d "$srcdir" ]; then
|
||||||
mkdir -p -m775 "$srcdir"
|
mkdir -p -m775 "$srcdir"
|
||||||
|
@ -113,15 +113,20 @@ hook() {
|
||||||
if [ -f "$distfile" ]; then
|
if [ -f "$distfile" ]; then
|
||||||
filesum=$(${XBPS_DIGEST_CMD} "$distfile")
|
filesum=$(${XBPS_DIGEST_CMD} "$distfile")
|
||||||
cksum=$(get_cksum $curfile $dfcount)
|
cksum=$(get_cksum $curfile $dfcount)
|
||||||
if [ "$cksum" != "$filesum" ]; then
|
if [ "$cksum" = "$filesum" ]; then
|
||||||
|
dfgood=$((dfgood + 1))
|
||||||
|
else
|
||||||
inode=$(stat "$distfile" --printf "%i")
|
inode=$(stat "$distfile" --printf "%i")
|
||||||
msg_warn "$pkgver: wrong checksum found for ${curfile} - purging (inode: ${inode})\n"
|
msg_warn "$pkgver: wrong checksum found for ${curfile} - purging (inode: ${inode})\n"
|
||||||
find ${XBPS_SRCDISTDIR} -inum ${inode} -delete -print
|
find ${XBPS_SRCDISTDIR} -inum ${inode} -delete -print
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
dfcount=$(($dfcount + 1))
|
dfcount=$((dfcount + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# We're done, if all distfiles were found and had good checksums
|
||||||
|
[ $dfcount -eq $dfgood ] && return
|
||||||
|
|
||||||
# Download missing distfiles and verify their checksums
|
# Download missing distfiles and verify their checksums
|
||||||
dfcount=0
|
dfcount=0
|
||||||
for f in ${distfiles}; do
|
for f in ${distfiles}; do
|
||||||
|
@ -153,7 +158,7 @@ hook() {
|
||||||
# distfile downloaded, verify sha256 hash.
|
# distfile downloaded, verify sha256 hash.
|
||||||
flock -n ${distfile}.part rm -f ${distfile}.part
|
flock -n ${distfile}.part rm -f ${distfile}.part
|
||||||
verify_cksum $curfile $distfile $dfcount
|
verify_cksum $curfile $distfile $dfcount
|
||||||
dfcount=$(($dfcount + 1))
|
dfcount=$((dfcount + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $errors -gt 0 ]; then
|
if [ $errors -gt 0 ]; then
|
||||||
|
|
Loading…
Reference in New Issue