Skip to content

feat(mtree_mutate): support file_mode argument #1059

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

skeggse
Copy link
Contributor

@skeggse skeggse commented Mar 20, 2025

fixes #921

@skeggse skeggse changed the title feat(mutate_mtree): support file_mode argument feat(mtree_mutate): support file_mode argument Mar 20, 2025
@skeggse
Copy link
Contributor Author

skeggse commented Mar 20, 2025

Tested locally using

    http_archive(
        name = "aspect_bazel_lib",
        integrity = "sha256-xi9efFcuNYR8c50Ji0+yj1cxy5kW6c+sQBDrDFMKuKM=",
        strip_prefix = "bazel-lib-3e312b35178fae5de0cad2a1fadcd03d9819b3b1",
        url = "https://github.com/skeggse/bazel-lib/archive/3e312b35178fae5de0cad2a1fadcd03d9819b3b1.tar.gz",
    )

seems to work

@@ -153,6 +153,9 @@ _mutate_mtree_attrs = {
"mtime": attr.string(
doc = "Specifies the modification time (mtime) to be applied to all files in the tar file. Used for deterministic builds.",
),
"file_mode": attr.string(
Copy link
Collaborator

Choose a reason for hiding this comment

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

name "file_mode" is confusing since this applies to everything, of any type. Should this be just mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doesn't it apply solely to type=file?

if (file_mode != "" && $0 ~ /type=file/) {
sub(/mode=[0-9]+/, "mode=" file_mode)
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

No, mtree contains everything, intermediary directories, files, symlinks, fifo etc. in this case, this variable will apply to all directories and files.

Copy link
Contributor Author

@skeggse skeggse Mar 29, 2025

Choose a reason for hiding this comment

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

i'm still not sure i understand. the line of code i linked to specifically checks for type=file. how is the mode getting changed for non-files, and why am i not seeing the behavior you're claiming in my local testing?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh my bad, that’s true. Do we something more generic than this though? I feel like we can do better in terms of Public API.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me thinker over the weekend and see if I could come up with a better api

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

Successfully merging this pull request may close these issues.

[FR]: mtree_mutate should support changing mode
2 participants