xbps-src: abstract away non-portable stat(1)

This implements semi-portable abstractions for both GNU and BSD
flavors of stat.
This commit is contained in:
q66 2023-09-11 04:30:55 +02:00 committed by Đoàn Trần Công Danh
parent 4349108b68
commit 937272e967
6 changed files with 43 additions and 7 deletions

View file

@ -57,7 +57,7 @@ purge_distfiles() {
cur=0
percent=-1
for distfile in ${distfiles[@]}; do
inode=$(stat "$distfile" --printf "%i")
inode=$(stat_inode "$distfile")
if [ -z "${inodes[$inode]}" ]; then
inodes[$inode]="$distfile"
else
@ -77,7 +77,7 @@ purge_distfiles() {
hash_distfile=${file##*/}
hash=${hash_distfile:0:$HASHLEN}
[ -n "${my_hashes[$hash]}" ] && continue
inode=$(stat "$file" --printf "%i")
inode=$(stat_inode "$file")
echo "Obsolete $hash (inode: $inode)"
( IFS="|"; for f in ${inodes[$inode]}; do rm -vf "$f"; rmdir "${f%/*}" 2>/dev/null; done )
done