From 87779af6c89d19750817d67ffe56718e82d52b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Buchm=C3=BCller?= Date: Sat, 23 Jun 2018 16:28:04 +0200 Subject: [PATCH] purge-distfiles: grep instead of sourcing template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To catch all SHA256 hashes from a template, even the ones which are used only under certain preconditions, use grep [0-9a-f]{64} to find all hashes in a template. The may be some false positives which does not hurt the intended purpose to purge obsolete distfiles. Signed-off-by: Jürgen Buchmüller --- common/xbps-src/shutils/purge_distfiles.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/common/xbps-src/shutils/purge_distfiles.sh b/common/xbps-src/shutils/purge_distfiles.sh index 73df13932bc..1cfaf5bdc0b 100644 --- a/common/xbps-src/shutils/purge_distfiles.sh +++ b/common/xbps-src/shutils/purge_distfiles.sh @@ -4,10 +4,7 @@ purge_distfiles() { - # Ignore msg_error calls when sourcing templates - msg_error() { - : - } + readonly HASHLEN=64 if [ -z "$XBPS_SRCDISTDIR" ]; then msg_error "The variable \$XBPS_SRCDISTDIR is not set." exit 1 @@ -28,8 +25,7 @@ purge_distfiles() { pkg=${template#*/} pkg=${pkg%/*} if [ ! -L "srcpkgs/$pkg" ]; then - unset checksum - source $template 2>/dev/null + checksum="$(grep -Ehrow [0-9a-f]{$HASHLEN} ${template}|sort|uniq)" read -a _my_hashes <<< ${checksum} i=0 while [ -n "${_my_hashes[$i]}" ]; do @@ -77,7 +73,6 @@ purge_distfiles() { echo hashes=($XBPS_SRCDISTDIR/by_sha256/*) - readonly HASHLEN=64 for file in ${hashes[@]}; do hash_distfile=${file##*/} hash=${hash_distfile:0:$HASHLEN}