From f136051c8791ba16978195182d7f27bfcfbf5d08 Mon Sep 17 00:00:00 2001 From: Ronan Pigott Date: Sat, 26 Oct 2019 13:30:10 -0700 Subject: [PATCH] makepkg: do not count hard links multiple times Signed-off-by: Ronan Pigott --- scripts/makepkg.sh.in | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 997c8668..6631da63 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -584,7 +584,20 @@ write_kv_pair() { } write_pkginfo() { - local size="$(find . -type f -exec cat {} + 2>/dev/null | wc -c)" + local i size=0 + declare -A files + while read -rd $'\0' file; do + if [[ -f "$file" && ! -L "$file" ]]; then + i=$(stat -c '%i' "$file") + if [[ -z "${files[$i]}" ]]; then + files[$i]=$(wc -c < "$file") + fi + fi + done < <(shopt -s globstar; printf "%s\0" **/*) + + for i in "${!files[@]}"; do + size=$((size + ${files[$i]})) + done merge_arch_attrs -- 2.23.0