aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraiuto <aiuto@google.com>2023-10-16 16:10:06 -0400
committerGitHub <noreply@github.com>2023-10-16 16:10:06 -0400
commit006af3e3932c5edc240b3ba762a5d6901cd7de9e (patch)
tree7b10c02d1030e5a2400dbf3212ed3d88c256dd53
parent320107ad11779cf24dbc4c9d247e1e20eed832fa (diff)
downloadrules_pkg-006af3e3932c5edc240b3ba762a5d6901cd7de9e.tar.gz
When pkg_tar.prefix_dir == base of symlink path, don't double-dip. (#749)
* Correct for case where tar has prefix_dir and files/symlinks, but the user has already mapped the prefix_dir into those paths. Under the old behavior, prefix_dir was (incorrectly) not added to symlinks, so some users made the desired prefix part of the link. Protecting them against the double inclusion of the prefix is probably the least surprising behavior. Add tests for this, which required improving verify_archive_test. * make buildifier happy * do not run the symlink test on windows * huh? why are symlinks in a tree failing on CI?
-rw-r--r--.bazelci/tests.yml4
-rwxr-xr-xdocs/latest.md22
-rw-r--r--pkg/private/tar/build_tar.py9
-rw-r--r--pkg/private/tar/tar.bzl41
-rw-r--r--pkg/verify_archive.bzl33
-rw-r--r--pkg/verify_archive_test_main.py.tpl16
-rw-r--r--tests/tar/BUILD152
7 files changed, 197 insertions, 80 deletions
diff --git a/.bazelci/tests.yml b/.bazelci/tests.yml
index 19297a1..953283d 100644
--- a/.bazelci/tests.yml
+++ b/.bazelci/tests.yml
@@ -33,6 +33,10 @@ default_tests_with_rpm: &default_tests_with_rpm
- "//toolchains/..."
win_tests: &win_tests
+ test_flags:
+ - "--test_tag_filters=-nowindows"
+ build_flags:
+ - "--build_tag_filters=-nowindows"
test_targets:
- "//pkg/..."
- "//tests/..."
diff --git a/docs/latest.md b/docs/latest.md
index 6d6e4a5..acd0959 100755
--- a/docs/latest.md
+++ b/docs/latest.md
@@ -259,8 +259,8 @@ Rules for making .tar files.
## pkg_tar
<pre>
-pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>,
- <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>,
+pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>,
+ <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>,
<a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>, <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>,
<a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
</pre>
@@ -273,31 +273,30 @@ pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="pkg_tar-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="pkg_tar-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private/tar:build_tar |
-| <a id="pkg_tar-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-compressor_args"></a>compressor_args | - | String | optional | "" |
-| <a id="pkg_tar-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-compressor"></a>compressor | External tool which can compress the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for <code>compressor</code>. | String | optional | "" |
+| <a id="pkg_tar-deps"></a>deps | tar files which will be unpacked and repacked into the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="pkg_tar-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
| <a id="pkg_tar-empty_files"></a>empty_files | - | List of strings | optional | [] |
| <a id="pkg_tar-extension"></a>extension | - | String | optional | "tar" |
-| <a id="pkg_tar-files"></a>files | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_tar-files"></a>files | Obsolete. Do not use. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
| <a id="pkg_tar-include_runfiles"></a>include_runfiles | - | Boolean | optional | False |
| <a id="pkg_tar-mode"></a>mode | - | String | optional | "0555" |
| <a id="pkg_tar-modes"></a>modes | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | -1 |
| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_tar-owner"></a>owner | - | String | optional | "0.0" |
+| <a id="pkg_tar-owner"></a>owner | Default numeric owner.group to apply to files when not set via pkg_attribures. | String | optional | "0.0" |
| <a id="pkg_tar-ownername"></a>ownername | - | String | optional | "." |
| <a id="pkg_tar-ownernames"></a>ownernames | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written. The name may contain variables, same as [package_file_name](#package_file_name) | String | optional | "" |
+| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written.<br><br> This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See [package_file_name](#package_file_name) for examples. | String | optional | "" |
| <a id="pkg_tar-package_dir_file"></a>package_dir_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_tar-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name) | String | optional | "" |
| <a id="pkg_tar-package_variables"></a>package_variables | See [Common Attributes](#package_variables) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_tar-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-srcs"></a>srcs | Inputs which will become part of the tar archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="pkg_tar-stamp"></a>stamp | Enable file time stamping. Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div> | Integer | optional | 0 |
| <a id="pkg_tar-strip_prefix"></a>strip_prefix | (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.) | String | optional | "" |
| <a id="pkg_tar-symlinks"></a>symlinks | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
@@ -583,6 +582,9 @@ pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">
Create a symlink.
+Wraps [pkg_mklink_impl](#pkg_mklink_impl)
+
+
**PARAMETERS**
diff --git a/pkg/private/tar/build_tar.py b/pkg/private/tar/build_tar.py
index 4ff9852..08a3a06 100644
--- a/pkg/private/tar/build_tar.py
+++ b/pkg/private/tar/build_tar.py
@@ -70,7 +70,14 @@ class TarFile(object):
# No path should ever come in with slashs on either end, but protect
# against that anyway.
dest = dest.strip('/')
- if self.directory:
+ # This prevents a potential problem for users with both a prefix_dir and
+ # symlinks that also repeat the prefix_dir. The old behavior was that we
+ # would get just the symlink path. Now we are prefixing with the prefix,
+ # so you get the file in the wrong place.
+ # We silently de-dup that. If people come up with a real use case for
+ # the /a/b/a/b/rest... output we can start an issue and come up with a
+ # solution at that time.
+ if self.directory and not dest.startswith(self.directory):
dest = self.directory + dest
return dest
diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl
index b361988..3a4d1a6 100644
--- a/pkg/private/tar/tar.bzl
+++ b/pkg/private/tar/tar.bzl
@@ -244,7 +244,7 @@ def _pkg_tar_impl(ctx):
# or this OutputGroup might be totally removed.
# Depend on it at your own risk!
OutputGroupInfo(
- manifest = [manifest_file],
+ manifest = [manifest_file],
),
]
@@ -253,21 +253,37 @@ pkg_tar_impl = rule(
implementation = _pkg_tar_impl,
attrs = {
"strip_prefix": attr.string(
- doc = """(note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)"""
+ doc = """(note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)""",
),
"package_dir": attr.string(
doc = """Prefix to be prepend to all paths written.
-The name may contain variables, same as [package_file_name](#package_file_name)""",
+
+ This is applied as a final step, while writing to the archive.
+ Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir.
+ The value may contain variables. See [package_file_name](#package_file_name) for examples.
+ """,
),
"package_dir_file": attr.label(allow_single_file = True),
- "deps": attr.label_list(allow_files = tar_filetype),
- "srcs": attr.label_list(allow_files = True),
- "files": attr.label_keyed_string_dict(allow_files = True),
+ "deps": attr.label_list(
+ doc = """tar files which will be unpacked and repacked into the archive.""",
+ allow_files = tar_filetype,
+ ),
+ "srcs": attr.label_list(
+ doc = """Inputs which will become part of the tar archive.""",
+ allow_files = True,
+ ),
+ "files": attr.label_keyed_string_dict(
+ doc = """Obsolete. Do not use.""",
+ allow_files = True,
+ ),
"mode": attr.string(default = "0555"),
"modes": attr.string_dict(),
"mtime": attr.int(default = _DEFAULT_MTIME),
"portable_mtime": attr.bool(default = True),
- "owner": attr.string(default = "0.0"),
+ "owner": attr.string(
+ doc = """Default numeric owner.group to apply to files when not set via pkg_attribures.""",
+ default = "0.0",
+ ),
"ownername": attr.string(default = "."),
"owners": attr.string_dict(),
"ownernames": attr.string_dict(),
@@ -277,8 +293,14 @@ The name may contain variables, same as [package_file_name](#package_file_name)"
"include_runfiles": attr.bool(),
"empty_dirs": attr.string_list(),
"remap_paths": attr.string_dict(),
- "compressor": attr.label(executable = True, cfg = "exec"),
- "compressor_args": attr.string(),
+ "compressor": attr.label(
+ doc = """External tool which can compress the archive.""",
+ executable = True,
+ cfg = "exec",
+ ),
+ "compressor_args": attr.string(
+ doc = """Arg list for `compressor`.""",
+ ),
# Common attributes
"out": attr.output(mandatory = True),
@@ -323,6 +345,7 @@ def pkg_tar(name, **kwargs):
@wraps(pkg_tar_impl)
"""
+
# Compatibility with older versions of pkg_tar that define files as
# a flat list of labels.
if "srcs" not in kwargs:
diff --git a/pkg/verify_archive.bzl b/pkg/verify_archive.bzl
index 39ac059..07a9f0e 100644
--- a/pkg/verify_archive.bzl
+++ b/pkg/verify_archive.bzl
@@ -23,7 +23,6 @@ The execution time is O(# expected patterns * size of archive).
load("@rules_python//python:defs.bzl", "py_test")
-
def _gen_verify_archive_test_main_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
@@ -38,6 +37,7 @@ def _gen_verify_archive_test_main_impl(ctx):
"${MUST_NOT_CONTAIN_REGEX}": str(ctx.attr.must_not_contain_regex),
"${MIN_SIZE}": str(ctx.attr.min_size),
"${MAX_SIZE}": str(ctx.attr.max_size),
+ "${VERIFY_LINKS}": str(ctx.attr.verify_links),
},
)
return [
@@ -55,7 +55,6 @@ _gen_verify_archive_test_main = rule(
allow_single_file = True,
mandatory = True,
),
-
"must_contain": attr.string_list(
doc = "List of paths which all must appear in the archive.",
),
@@ -69,10 +68,13 @@ _gen_verify_archive_test_main = rule(
doc = """List of regexes that must not be in the archive.""",
),
"min_size": attr.int(
- doc = """Minimum number of entries in the archive."""
+ doc = """Minimum number of entries in the archive.""",
),
"max_size": attr.int(
- doc = """Maximum number of entries in the archive."""
+ doc = """Maximum number of entries in the archive.""",
+ ),
+ "verify_links": attr.string_dict(
+ doc = """Dict keyed by paths which must appear, and be symlinks to their values.""",
),
# Implicit dependencies.
@@ -83,10 +85,17 @@ _gen_verify_archive_test_main = rule(
},
)
-def verify_archive_test(name, target,
- must_contain=None, must_contain_regex=None,
- must_not_contain=None, must_not_contain_regex=None,
- min_size=1, max_size=-1):
+def verify_archive_test(
+ name,
+ target,
+ must_contain = None,
+ must_contain_regex = None,
+ must_not_contain = None,
+ must_not_contain_regex = None,
+ min_size = 1,
+ max_size = -1,
+ tags = None,
+ verify_links = None):
"""Tests that an archive contains specific file patterns.
This test is used to verify that an archive contains the expected content.
@@ -99,12 +108,14 @@ def verify_archive_test(name, target,
must_not_contain_regex: A list of path regexes which must not appear in the archive.
min_size: The minimum number of entries which must be in the archive.
max_size: The maximum number of entries which must be in the archive.
+ tags: standard meaning
+ verify_links: Dict keyed by paths which must appear, and be symlinks to their values.
"""
- test_src = name + "__internal_main.py"
+ test_src = name + "__internal_main.py"
_gen_verify_archive_test_main(
name = name + "_internal_main",
target = target,
- test_name = name.replace('-', '_') + "Test",
+ test_name = name.replace("-", "_") + "Test",
out = test_src,
must_contain = must_contain,
must_contain_regex = must_contain_regex,
@@ -112,6 +123,8 @@ def verify_archive_test(name, target,
must_not_contain_regex = must_not_contain_regex,
min_size = min_size,
max_size = max_size,
+ tags = tags,
+ verify_links = verify_links,
)
py_test(
name = name,
diff --git a/pkg/verify_archive_test_main.py.tpl b/pkg/verify_archive_test_main.py.tpl
index 2d6a192..681bb0a 100644
--- a/pkg/verify_archive_test_main.py.tpl
+++ b/pkg/verify_archive_test_main.py.tpl
@@ -36,10 +36,13 @@ class VerifyArchiveTest(unittest.TestCase):
def load_tar(self, path):
self.paths = []
+ self.links = {}
with tarfile.open(path, 'r:*') as f:
i = 0
for info in f:
self.paths.append(info.name)
+ if info.linkname:
+ self.links[info.name] = info.linkname
def assertMinSize(self, min_size):
"""Check that the archive contains at least min_size entries.
@@ -60,6 +63,8 @@ class VerifyArchiveTest(unittest.TestCase):
Args:
max_size: The maximum number of targets we expect.
"""
+ if max_size < 0:
+ return
actual_size = len(self.paths)
self.assertLessEqual(
len(self.paths),
@@ -100,6 +105,14 @@ class VerifyArchiveTest(unittest.TestCase):
if r_comp.match(path):
self.fail('Found disallowed pattern (%s) in the archive' % pattern)
+ def verify_links(self, verify_links):
+ for link, target in verify_links.items():
+ if link not in self.paths:
+ self.fail('Required link (%s) is not in the archive' % link)
+ if self.links[link] != target:
+ self.fail('link (%s) points to the wrong place. Expected (%s) got (%s)' %
+ (link, target, self.links[link]))
+
class ${TEST_NAME}(VerifyArchiveTest):
@@ -125,6 +138,9 @@ class ${TEST_NAME}(VerifyArchiveTest):
def test_must_not_contain(self):
self.check_must_not_contain_regex(${MUST_NOT_CONTAIN_REGEX})
+ def test_verify_links(self):
+ self.verify_links(${VERIFY_LINKS})
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/tar/BUILD b/tests/tar/BUILD
index dd138a2..93f2e47 100644
--- a/tests/tar/BUILD
+++ b/tests/tar/BUILD
@@ -277,21 +277,21 @@ pkg_tar(
verify_archive_test(
name = "repackaging_long_filename_test",
- target = ":test-tar-repackaging-long-filename",
+ max_size = 2,
must_contain = [
"can_i_repackage_a_file_with_a_long_name/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt",
],
+ must_contain_regex = [
+ ".*can_i_repackage_a_file_with_a_long_name/$",
+ ],
# there is really no need for these cases. I just want to use all the test capabilities.
must_not_contain = [
"i_am_not here",
],
- must_contain_regex = [
- ".*can_i_repackage_a_file_with_a_long_name/$",
- ],
must_not_contain_regex = [
"^five.is.right.out",
],
- max_size = 2,
+ target = ":test-tar-repackaging-long-filename",
)
pkg_tar(
@@ -350,6 +350,9 @@ py_test(
],
imports = ["../.."],
data = [
+ ":test-pkg-tar-from-pkg-files-with-attributes",
+ ":test-pkg-tar-with-attributes",
+ ":test-remap-paths-tree-artifact",
":test-tar-empty_dirs.tar",
":test-tar-empty_files.tar",
":test-tar-files_dict.tar",
@@ -361,15 +364,12 @@ py_test(
":test-tar-strip_prefix-etc.tar",
":test-tar-strip_prefix-none.tar",
":test-tar-strip_prefix-substring.tar",
- ":test_tar_leading_dotslash",
- ":test_tar_package_dir_substitution.tar",
":test-tar-tree-artifact",
":test-tar-tree-artifact-noroot",
":test-tar-with-runfiles",
- ":test-pkg-tar-with-attributes",
- ":test-pkg-tar-from-pkg-files-with-attributes",
":test-tree-input-with-strip-prefix",
- ":test-remap-paths-tree-artifact",
+ ":test_tar_leading_dotslash",
+ ":test_tar_package_dir_substitution.tar",
"//tests:testdata/tar_test.tar",
"//tests:testdata/tar_test.tar.bz2",
"//tests:testdata/tar_test.tar.gz",
@@ -472,6 +472,48 @@ py_test(
],
)
+directory(
+ name = "generate_tree_with_prefix",
+ contents = "hello there",
+ filenames = [
+ "a/a",
+ "a/b",
+ ],
+ outdir = "tree_prefix_to_strip",
+)
+
+pkg_tar(
+ name = "test-tree-input-with-strip-prefix",
+ srcs = [
+ ":generate_tree_with_prefix",
+ ],
+ strip_prefix = "tree_prefix_to_strip",
+)
+
+directory(
+ name = "tree_artifact_to_rename",
+ contents = "hello there",
+ filenames = [
+ "a",
+ "rename_me/should_not_rename",
+ ],
+ outdir = "rename_me",
+)
+
+pkg_tar(
+ name = "test-remap-paths-tree-artifact",
+ srcs = [
+ ":tree_artifact_to_rename",
+ ],
+ remap_paths = {
+ "/rename_me": "a_new_name",
+ },
+)
+
+#
+# Test with symlinks
+#
+
link_tree(
name = "node_modules",
links = {
@@ -490,11 +532,12 @@ directory(
"foo/hello.txt",
"foo/bar/baz",
],
- links = {
- "foo/bar/hello": "../hello.txt",
- "foo/bar/alt_baz": "baz",
- "foo/alt_baz": "bar/baz",
- },
+ # TODO(https://github.com/bazelbuild/rules_pkg/issues/750)
+ #links = {
+ # "foo/bar/hello": "../hello.txt",
+ # "foo/bar/alt_baz": "baz",
+ # "foo/alt_baz": "bar/baz",
+ #},
)
# This target has symlinks 3 ways.
@@ -508,50 +551,59 @@ pkg_tar(
":tree_artifact_with_links",
"//tests:file_and_link",
],
+ symlinks = {
+ "tree_artifact/toss_in_another": "/foo",
+ },
+)
+
+verify_archive_test(
+ name = "relative_links_test",
+ min_size = 10,
+ must_contain = [
+ "BUILD",
+ "outer_BUILD",
+ "node_modules/.pnpm/bar@1.0.0/node_modules/bar",
+ ],
+ tags = ["nowindows"],
+ target = ":relative_links_tar",
+ verify_links = {
+ "node_modules/.pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
+ "tree_artifact/toss_in_another": "/foo",
+ },
)
pkg_tar(
name = "relative_links_re_tar",
+ package_dir = "new/base",
+ symlinks = {
+ # We expect package_dir to apply to this
+ "tree_artifact/toss_in_another": "some_target",
+ # But we protect the user from duplicationg package_dir in their
+ # link. That was the old behavior of symlink.
+ "new/base/something/this": "that",
+ },
deps = [
":relative_links_tar",
],
)
-directory(
- name = "generate_tree_with_prefix",
- contents = "hello there",
- filenames = [
- "a/a",
- "a/b",
- ],
- outdir = "tree_prefix_to_strip",
-)
-
-pkg_tar(
- name = "test-tree-input-with-strip-prefix",
- srcs = [
- ":generate_tree_with_prefix",
- ],
- strip_prefix = "tree_prefix_to_strip",
-)
-
-
-directory(
- name = "tree_artifact_to_rename",
- contents = "hello there",
- filenames = [
- "a",
- "rename_me/should_not_rename"
+verify_archive_test(
+ name = "relative_links_re_test",
+ min_size = 10,
+ must_contain = [
+ "new/base/BUILD",
+ "new/base/outer_BUILD",
+ "new/base/node_modules/.pnpm/bar@1.0.0/node_modules/bar",
],
- outdir = "rename_me",
-)
-
-pkg_tar(
- name = "test-remap-paths-tree-artifact",
- remap_paths = {
- "/rename_me": "a_new_name",
+ must_not_contain = [
+ "BUILD",
+ "new/base/new/base/something/this",
+ ],
+ tags = ["nowindows"],
+ target = ":relative_links_re_tar",
+ verify_links = {
+ "new/base/node_modules/.pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
+ "new/base/tree_artifact/toss_in_another": "some_target",
+ "new/base/something/this": "that",
},
- srcs = [
- ":tree_artifact_to_rename",
- ],
)