purge-distfiles: grep instead of sourcing template
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 <pullmoll@t-online.de>
This commit is contained in:
parent
899da38831
commit
87779af6c8
1 changed files with 2 additions and 7 deletions
|
@ -4,10 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
purge_distfiles() {
|
purge_distfiles() {
|
||||||
# Ignore msg_error calls when sourcing templates
|
readonly HASHLEN=64
|
||||||
msg_error() {
|
|
||||||
:
|
|
||||||
}
|
|
||||||
if [ -z "$XBPS_SRCDISTDIR" ]; then
|
if [ -z "$XBPS_SRCDISTDIR" ]; then
|
||||||
msg_error "The variable \$XBPS_SRCDISTDIR is not set."
|
msg_error "The variable \$XBPS_SRCDISTDIR is not set."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -28,8 +25,7 @@ purge_distfiles() {
|
||||||
pkg=${template#*/}
|
pkg=${template#*/}
|
||||||
pkg=${pkg%/*}
|
pkg=${pkg%/*}
|
||||||
if [ ! -L "srcpkgs/$pkg" ]; then
|
if [ ! -L "srcpkgs/$pkg" ]; then
|
||||||
unset checksum
|
checksum="$(grep -Ehrow [0-9a-f]{$HASHLEN} ${template}|sort|uniq)"
|
||||||
source $template 2>/dev/null
|
|
||||||
read -a _my_hashes <<< ${checksum}
|
read -a _my_hashes <<< ${checksum}
|
||||||
i=0
|
i=0
|
||||||
while [ -n "${_my_hashes[$i]}" ]; do
|
while [ -n "${_my_hashes[$i]}" ]; do
|
||||||
|
@ -77,7 +73,6 @@ purge_distfiles() {
|
||||||
echo
|
echo
|
||||||
|
|
||||||
hashes=($XBPS_SRCDISTDIR/by_sha256/*)
|
hashes=($XBPS_SRCDISTDIR/by_sha256/*)
|
||||||
readonly HASHLEN=64
|
|
||||||
for file in ${hashes[@]}; do
|
for file in ${hashes[@]}; do
|
||||||
hash_distfile=${file##*/}
|
hash_distfile=${file##*/}
|
||||||
hash=${hash_distfile:0:$HASHLEN}
|
hash=${hash_distfile:0:$HASHLEN}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue