Skip to content

Commit

Permalink
fix oops
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZbarsky-at committed Jun 17, 2024
1 parent 4be3b96 commit a82b6c1
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 5 deletions.
9 changes: 9 additions & 0 deletions npm/private/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ bzl_library(
],
deps = [
":starlark_codegen_utils",
":tar",
":utils",
"@aspect_bazel_lib//lib:repo_utils",
"@aspect_bazel_lib//lib:repositories",
Expand All @@ -139,6 +140,7 @@ bzl_library(
visibility = ["//npm:__subpackages__"],
deps = [
":starlark_codegen_utils",
":tar",
":utils",
"@aspect_bazel_lib//lib:base64",
"@bazel_skylib//lib:dicts",
Expand Down Expand Up @@ -305,6 +307,13 @@ bzl_library(
visibility = ["//npm:__subpackages__"],
)

bzl_library(
name = "tar",
srcs = ["tar.bzl"],
visibility = ["//npm:__subpackages__"],
deps = ["@aspect_bazel_lib//lib:repo_utils"],
)

bzl_library(
name = "versions",
srcs = ["versions.bzl"],
Expand Down
3 changes: 2 additions & 1 deletion npm/private/npm_import.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,8 @@ def _download_and_extract_archive(rctx, package_json_only):
# so we use tar here which takes a --strip-components N argument instead of rctx.download_and_extract
tar_args = ["tar", "-xf", _TARBALL_FILENAME, "--strip-components", "1", "-C", _EXTRACT_TO_DIRNAME, "--no-same-owner", "--no-same-permissions"]

if rctx.attr.is_gnu_tar == "True" or (rctx.attr.is_gnu_tar == "" and check_is_gnu_tar(rctx)):
is_gnu_tar = rctx.attr.is_gnu_tar == "True" or (rctx.attr.is_gnu_tar == "" and check_is_gnu_tar(rctx))
if is_gnu_tar:
# Some packages have directory permissions missing the executable bit, which prevents GNU tar from
# extracting files into the directory. Delay permission restoration for directories until all files
# have been extracted.
Expand Down
6 changes: 3 additions & 3 deletions npm/private/npm_translate_lock_generate.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ _NPM_IMPORT_TMPL = \
package = "{package}",
version = "{version}",
url = "{url}",
is_gnu_tar = {gnu_tar},
is_gnu_tar = "{is_gnu_tar}",
package_visibility = {package_visibility},{maybe_dev}{maybe_commit}{maybe_generate_bzl_library_targets}{maybe_integrity}{maybe_deps}{maybe_transitive_closure}{maybe_patches}{maybe_patch_args}{maybe_lifecycle_hooks}{maybe_custom_postinstall}{maybe_lifecycle_hooks_env}{maybe_lifecycle_hooks_execution_requirements}{maybe_bins}{maybe_npm_auth}{maybe_npm_auth_basic}{maybe_npm_auth_username}{maybe_npm_auth_password}{maybe_replace_package}{maybe_lifecycle_hooks_use_default_shell_env}
)
"""
Expand Down Expand Up @@ -477,10 +477,10 @@ def _generate_repositories(rctx, npm_imports, pnpm_lock_label, link_workspace):
repositories_bzl.append(" pass")
repositories_bzl.append("")

is_gnu_tar = check_is_gnu_tar(rctx)
is_gnu_tar = str(check_is_gnu_tar(rctx))

for _, _import in enumerate(npm_imports):
repositories_bzl.append(_gen_npm_import(rctx, is_gnu_tar, is_gnu_tar, link_workspace))
repositories_bzl.append(_gen_npm_import(rctx, is_gnu_tar, _import, link_workspace))

return repositories_bzl

Expand Down
5 changes: 4 additions & 1 deletion npm/private/tar.bzl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
"""Tar helpers."""

load("@aspect_bazel_lib//lib:repo_utils.bzl", "repo_utils")

# TODO: use a hermetic tar from aspect_bazel_lib and remove this.
def check_is_gnu_tar(rctx):
"""# TODO: use a hermetic tar from aspect_bazel_lib and we can drop the "if _is_gnu_tar" branch
"""Check if the host tar command is GNU tar.
Args:
rctx: the repository context
Expand Down

0 comments on commit a82b6c1

Please sign in to comment.