Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions distroless/private/flatten.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ if [[ "$deduplicate" == "True" ]]; then

$bsdtar --confirmation "$@" 2< <("${awk}" '
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if bsdtar itself doesn't modify the result, then it has no effect on normalization.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh right, this will preserve the original path, so i was completely wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hang on, I have a pr that was just sitting on my computer

function normalize(p) {
# Strip leading "./" and trailing "/" so that "./etc/" and "etc/" are treated as the same path.
sub(/^\.\//, "", p)
# Strip trailing "/" and add leading "./" so that "./etc/" and "etc/" are treated as the same path.
sub(/\/$/, "", p)
if (p !~ /^\.\// && p !~ /^\//) {
p = "./" p
}
return p
}
{
Expand Down
6 changes: 3 additions & 3 deletions examples/flatten/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -146,16 +146,16 @@ flatten(
name = "flatten_dedup_normalize",
deduplicate = True,
tars = [
":dotslash_tar",
":nodotslash_tar",
":dotslash_tar",
],
)

assert_tar_listing(
name = "test_flatten_dedup_normalize",
actual = "flatten_dedup_normalize",
expected = """\
etc/
etc/sub/
./etc/
./etc/sub/
""",
)
Loading