Skip to content

Commit 45b0ff2

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix-install-stanza
2 parents 004e3ae + 006af3e commit 45b0ff2

File tree

27 files changed

+244
-103
lines changed

27 files changed

+244
-103
lines changed

.bazelci/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ default_tests_with_rpm: &default_tests_with_rpm
3333
- "//toolchains/..."
3434

3535
win_tests: &win_tests
36+
test_flags:
37+
- "--test_tag_filters=-nowindows"
38+
build_flags:
39+
- "--build_tag_filters=-nowindows"
3640
test_targets:
3741
- "//pkg/..."
3842
- "//tests/..."

distro/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ py_test(
8484
"packaging_test.py",
8585
":release_version.py",
8686
],
87+
imports = [".."],
8788
data = [
8889
"testdata/BUILD.tpl",
8990
":distro",

docs/latest.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ Rules for making .tar files.
259259
## pkg_tar
260260

261261
<pre>
262-
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>,
263-
<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>,
262+
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>,
263+
<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>,
264264
<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>,
265265
<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>)
266266
</pre>
@@ -273,31 +273,30 @@ pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar
273273
| Name | Description | Type | Mandatory | Default |
274274
| :------------- | :------------- | :------------- | :------------- | :------------- |
275275
| <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 | |
276-
| <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 |
277-
| <a id="pkg_tar-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
278-
| <a id="pkg_tar-compressor_args"></a>compressor_args | - | String | optional | "" |
279-
| <a id="pkg_tar-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
276+
| <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 |
277+
| <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for <code>compressor</code>. | String | optional | "" |
278+
| <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 | [] |
280279
| <a id="pkg_tar-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
281280
| <a id="pkg_tar-empty_files"></a>empty_files | - | List of strings | optional | [] |
282281
| <a id="pkg_tar-extension"></a>extension | - | String | optional | "tar" |
283-
| <a id="pkg_tar-files"></a>files | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
282+
| <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 | {} |
284283
| <a id="pkg_tar-include_runfiles"></a>include_runfiles | - | Boolean | optional | False |
285284
| <a id="pkg_tar-mode"></a>mode | - | String | optional | "0555" |
286285
| <a id="pkg_tar-modes"></a>modes | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
287286
| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | -1 |
288287
| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
289-
| <a id="pkg_tar-owner"></a>owner | - | String | optional | "0.0" |
288+
| <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" |
290289
| <a id="pkg_tar-ownername"></a>ownername | - | String | optional | "." |
291290
| <a id="pkg_tar-ownernames"></a>ownernames | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
292291
| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
293-
| <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 | "" |
292+
| <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 | "" |
294293
| <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 |
295294
| <a id="pkg_tar-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name) | String | optional | "" |
296295
| <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 |
297296
| <a id="pkg_tar-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
298297
| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
299298
| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
300-
| <a id="pkg_tar-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
299+
| <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 | [] |
301300
| <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 |
302301
| <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 | "" |
303302
| <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">
583582

584583
Create a symlink.
585584

585+
Wraps [pkg_mklink_impl](#pkg_mklink_impl)
586+
587+
586588
**PARAMETERS**
587589

588590

pkg/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ starlark_library(
6868
py_binary(
6969
name = "make_rpm",
7070
srcs = ["make_rpm.py"],
71+
imports = [".."],
7172
python_version = "PY3",
7273
srcs_version = "PY3",
7374
target_compatible_with = select({
@@ -84,6 +85,7 @@ py_binary(
8485
py_library(
8586
name = "make_rpm_lib",
8687
srcs = ["make_rpm.py"],
88+
imports = [".."],
8789
srcs_version = "PY3",
8890
visibility = [
8991
"//experimental:__subpackages__",

pkg/private/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ py_library(
6565
srcs = [
6666
"build_info.py",
6767
],
68+
imports = ["../.."],
6869
srcs_version = "PY3",
6970
visibility = [
7071
"//:__subpackages__",
@@ -78,6 +79,7 @@ py_library(
7879
"__init__.py",
7980
"archive.py",
8081
],
82+
imports = ["../.."],
8183
srcs_version = "PY3",
8284
visibility = [
8385
"//:__subpackages__",
@@ -91,6 +93,7 @@ py_library(
9193
"__init__.py",
9294
"helpers.py",
9395
],
96+
imports = ["../.."],
9497
srcs_version = "PY3",
9598
visibility = [
9699
"//:__subpackages__",
@@ -101,6 +104,7 @@ py_library(
101104
py_library(
102105
name = "manifest",
103106
srcs = ["manifest.py"],
107+
imports = ["../.."],
104108
srcs_version = "PY3",
105109
visibility = ["//visibility:public"],
106110
)

pkg/private/deb/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ exports_files(
4848
py_binary(
4949
name = "make_deb",
5050
srcs = ["make_deb.py"],
51+
imports = ["../../.."],
5152
python_version = "PY3",
5253
visibility = ["//visibility:public"],
5354
deps = [
@@ -58,6 +59,7 @@ py_binary(
5859
py_library(
5960
name = "make_deb_lib",
6061
srcs = ["make_deb.py"],
62+
imports = ["../../.."],
6163
srcs_version = "PY3",
6264
visibility = ["//tests/deb:__pkg__"],
6365
deps = [

pkg/private/deb/deb.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
load("//pkg:providers.bzl", "PackageVariablesInfo")
1717
load("//pkg/private:util.bzl", "setup_output_files")
1818

19-
_tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz"]
19+
_tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz", "tar.zst"]
2020

2121
def _pkg_deb_impl(ctx):
2222
"""The implementation for the pkg_deb rule."""

pkg/private/deb/make_deb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ def CreateDeb(output,
237237
ext = 'tar.bz2'
238238
else:
239239
ext = '.'.join(ext)
240-
if ext not in ['tar.bz2', 'tar.gz', 'tar.xz', 'tar.lzma']:
240+
if ext not in ['tar.bz2', 'tar.gz', 'tar.xz', 'tar.lzma', 'tar.zst']:
241241
ext = 'tar'
242242
data_size = os.stat(data).st_size
243243
with open(data, 'rb') as datafile:

pkg/private/tar/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ exports_files(
4545
py_binary(
4646
name = "build_tar",
4747
srcs = ["build_tar.py"],
48+
imports = ["../../.."],
4849
python_version = "PY3",
4950
srcs_version = "PY3",
5051
visibility = ["//visibility:public"],
@@ -62,6 +63,7 @@ py_library(
6263
srcs = [
6364
"tar_writer.py",
6465
],
66+
imports = ["../../.."],
6567
srcs_version = "PY3",
6668
visibility = [
6769
"//tests:__subpackages__",

pkg/private/tar/build_tar.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ def normalize_path(self, path: str) -> str:
7070
# No path should ever come in with slashs on either end, but protect
7171
# against that anyway.
7272
dest = dest.strip('/')
73-
if self.directory:
73+
# This prevents a potential problem for users with both a prefix_dir and
74+
# symlinks that also repeat the prefix_dir. The old behavior was that we
75+
# would get just the symlink path. Now we are prefixing with the prefix,
76+
# so you get the file in the wrong place.
77+
# We silently de-dup that. If people come up with a real use case for
78+
# the /a/b/a/b/rest... output we can start an issue and come up with a
79+
# solution at that time.
80+
if self.directory and not dest.startswith(self.directory):
7481
dest = self.directory + dest
7582
return dest
7683

0 commit comments

Comments
 (0)