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

fix(write_source_files): fix nested directories #65

Merged
merged 14 commits into from
Apr 6, 2022
Prev Previous commit
Next Next commit
add copy symlink fix back
  • Loading branch information
jbedard committed Apr 6, 2022
commit 057a7ca8e8b887d37bc25c268348be3214a775ca
2 changes: 1 addition & 1 deletion e2e/write_source_files_symlinks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ bazel run //lib/tests/write_source_files:write_symlinks

# Exit if any symlinks
[ -L lib/tests/write_source_files/symlink_test/a/test.txt ] && exit 1
[ -L lib/tests/write_source_files/symlink_test/b/test.txt ] && exit 1
[ -L lib/tests/write_source_files/symlink_test/b/test.txt ] && exit 1
2 changes: 1 addition & 1 deletion lib/private/write_source_file.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ if [[ -f "$in" ]]; then
else
rm -Rf "$out"/*
mkdir -p "$out"
cp -fR "$in"/* "$out"
cp -fRL "$in"/* "$out"
Copy link
Collaborator

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.

Copy link
Collaborator

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?

Copy link
Collaborator Author

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...

Copy link
Collaborator Author

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...

Copy link
Collaborator

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.

chmod -R +w "$out"/*
fi
""".format(in_path = in_path, out_path = out_path))
Expand Down