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: remove problematic chmod extract command in npm_package_store in favor of using a custom postinstall #1904

Merged
merged 1 commit into from
Aug 21, 2024
Merged
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
1 change: 1 addition & 0 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ npm.npm_translate_lock(
custom_postinstalls = {
"@aspect-test/c": "echo moo > cow.txt",
"@aspect-test/[email protected]": "echo mooo >> cow.txt",
"pngjs": "chmod -R a+X *", # fixes malformed tarball content file permissions in this package after extraction (see https://github.com/aspect-build/rules_js/issues/1637 for more details)
},
data = [
"//:examples/npm_deps/patches/[email protected]",
Expand Down
6 changes: 2 additions & 4 deletions npm/private/npm_package_store.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,7 @@ def _npm_package_store_impl(ctx):
# npm packages are always published with one top-level directory inside the tarball,
# tho the name is not predictable we can use the --strip-components 1 argument with
# tar to strip one directory level. Some packages have directory permissions missing
# executable which make the directories not listable ([email protected] for example). Run
# `chmod -R a+X` to fix up these packages (https://stackoverflow.com/a/14634721).
# See https://github.com/aspect-build/rules_js/issues/1637 for more info.
# executable which make the directories not listable ([email protected] for example).
bsdtar = ctx.toolchains["@aspect_bazel_lib//lib:tar_toolchain_type"]
args = ctx.actions.args()
args.add(bsdtar.tarinfo.binary)
Expand All @@ -233,7 +231,7 @@ def _npm_package_store_impl(ctx):
tools = [bsdtar.tarinfo.binary],
inputs = depset(direct = [src], transitive = [bsdtar.default.files]),
outputs = [package_store_directory],
command = "$1 --extract --no-same-owner --no-same-permissions --strip-components 1 --file $2 --directory $3 && chmod -R a+X $3/*",
command = "$1 --extract --no-same-owner --no-same-permissions --strip-components 1 --file $2 --directory $3",
arguments = [args],
mnemonic = "NpmPackageExtract",
progress_message = "Extracting npm package {}@{}".format(package, version),
Expand Down
Loading