Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] mtree_mutate incorrectly strips root directory prefixes #978

Open
j-eid opened this issue Oct 30, 2024 · 0 comments
Open

[Bug] mtree_mutate incorrectly strips root directory prefixes #978

j-eid opened this issue Oct 30, 2024 · 0 comments

Comments

@j-eid
Copy link

j-eid commented Oct 30, 2024

It looks like #852 causes issues with strip_prefix in mtree_mutate when stripping the root directory.

components = split($1, _, "/");
if ($0 ~ /type=dir/ && components == 1) {
$1 = $1 "/";
}

This causes a / to be added to the first keyword in the mtree specification.

Steps to reproduce

# BUILD

genrule(
    name = "test.mf",
    outs = ["test.mf.spec"],
    cmd = "printf 'root_dir/ uid=0 gid=0 time=0 mode=0755 type=dir\nroot_dir/child_dir/ uid=0 gid=0 time=0 mode=0755 type=dir' >$@",
)

mtree_mutate(
    name = "test_mutate.mf",
    mtree = ":test.mf",
    strip_prefix = "root_dir",
)

Result:

# test_mutate.mf.spec

uid=0/ gid=0 time=0 mode=0755 type=dir
child_dir/ uid=0 gid=0 time=0 mode=0755 type=dir

The entry should probably be deleted unless package_dir is provided. I'm not very familiar with awk syntax, but another check for whether package_dir is provided and a more complex check on L18 would probably fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant