From bda06c296c648213977ddc5b0a7cd3849491fc1c Mon Sep 17 00:00:00 2001 From: Sahin Yort Date: Thu, 5 Dec 2024 15:05:25 -0800 Subject: [PATCH] fix root duplicates --- distroless/private/flatten.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/distroless/private/flatten.sh b/distroless/private/flatten.sh index b35342e..71f0fa6 100755 --- a/distroless/private/flatten.sh +++ b/distroless/private/flatten.sh @@ -31,17 +31,20 @@ if [[ "$output" != "-" ]]; then fi done - awk '{ if (substr($0,0,1) == "#") { next; } line_count[$1]++; if (line_count[$1] > 1) { - print substr($1, 3, length($1)); + if ($1 == "/.") { + next + } + print $1 } }' "$mtree" | sort | uniq | sort -r > "$duplicates" - $bsdtar $@ | run_gtar --delete --file - --occurrence=1 --files-from="$duplicates" > "$output" + + $bsdtar --exclude "^./$" $@ | run_gtar --delete --file - --occurrence=1 --files-from="$duplicates" > "$output" rm "$mtree" else # No deduplication, business as usual