Skip to content

Commit

Permalink
fix: remove problematic chmod extract command in npm_package_store in…
Browse files Browse the repository at this point in the history
… favor of using a custom postinstall (#1904)
  • Loading branch information
gregmagolan committed Aug 21, 2024
1 parent 99d0900 commit 4f5ef8c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
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/c@2.0.2": "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/meaning-of-life@1.0.0-pnpm.patch",
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 (pngjs@5.0.0 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 (pngjs@5.0.0 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

0 comments on commit 4f5ef8c

Please sign in to comment.