shutils/purge_distfiles.sh: fix purging of multiple distfiles

Previously, xbps-src would try to find checksums in template files
and not purge those found but it actually ignored everything that
had the checksums specified on multiple lines.

The reason for this is that the bash 'read' builtin reads until it
finds a newline, and if you specify multiple checksums on multiple
lines rather than on one line it would ignore all but the first.

Fix this by replacing newlines with spaces, so that it can properly
read all checksums into an array.
This commit is contained in:
q66 2019-12-23 00:50:50 +01:00
parent aa604e79f7
commit 7febf540a9

View File

@ -25,7 +25,7 @@ purge_distfiles() {
pkg=${template#*/}
pkg=${pkg%/*}
if [ ! -L "srcpkgs/$pkg" ]; then
checksum="$(grep -Ehrow [0-9a-f]{$HASHLEN} ${template}|sort|uniq)"
checksum="$(grep -Ehrow [0-9a-f]{$HASHLEN} ${template}|sort|uniq|tr '\n' ' ')"
read -a _my_hashes <<< ${checksum}
i=0
while [ -n "${_my_hashes[$i]}" ]; do