-
-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix(write_source_files): fix nested directories #65
Conversation
genrule( | ||
name = "subdir", | ||
outs = ["subdir_test"], | ||
cmd = "mkdir -p $@/a/b/c; echo 'test' > $@/a/b/c/test.txt", | ||
) | ||
|
||
write_source_files( | ||
name = "write_subdir", | ||
diff_test = False, | ||
files = {"subdir_test": ":subdir_test"}, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Want to add a comment to connect this to the integration test?
mkdir -p "$out" | ||
cp -fR "$in"/* "$out" | ||
chmod 664 "$out"/* | ||
cp -fRL "$in"/* "$out" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think capital -R
is or will be deprecated on mac? I recall @gregmagolan had a PR out about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the L
for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L
makes it follow symlinks instead of copy them.
If bazel creates a directory with symlinks to other locations we don't want to just copy the links but copy the content they point to. Otherwise we end up with symlinks into the sandbox copied into the source dir...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rules_nodejs pkg_web
seems to create these symlinks which is where we saw the problem. I think pkg_web
creates a directory structure for the package but then the files within those directories are symlinks to the original source of files being "packaged". Basically avoid copying files all over the place and use symlinks as much as possible.
When writing that package into the source dir we want to copy the real files and not the symlinks...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-R is the correct one with consistent meaning on both platforms. It is the lowercase -r
that has a different meaning on macos vs linux.
lib/private/write_source_file.bzl
Outdated
@@ -164,11 +164,12 @@ echo "Copying $in to $out in $PWD" | |||
|
|||
if [[ -f "$in" ]]; then | |||
cp -f "$in" "$out" | |||
chmod 664 "$out" | |||
chmod +w "$out" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So these only add write permission for the current user. Should it be for all? Seems like bazel normally does -r-xr-xr-x
(makes all 3 the same). Should we do similar and add w
for all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
User and group is probably safe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
mkdir -p "$out" | ||
cp -fR "$in"/* "$out" | ||
chmod 664 "$out"/* | ||
cp -fRL "$in"/* "$out" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-R is the correct one with consistent meaning on both platforms. It is the lowercase -r
that has a different meaning on macos vs linux.
No description provided.