Upgrade rules_pkg to 1.1.0 am: b3594bde25 Original change: https://googleplex-android-review.googlesource.com/c/platform/external/bazelbuild-rules_pkg/+/34854019 Change-Id: If4d8337780ea7bbedc7b8b0ba3adf806032a9a73 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/.bazelci/examples_naming.yml b/.bazelci/examples_naming.yml index 0f55f60..07295ef 100644 --- a/.bazelci/examples_naming.yml +++ b/.bazelci/examples_naming.yml
@@ -7,8 +7,8 @@ centos7: platform: centos7_java11_devtoolset10 <<: *common - ubuntu1804: - platform: ubuntu1804 + ubuntu2204: + platform: ubuntu2204 <<: *common macos: platform: macos @@ -18,7 +18,7 @@ <<: *common bzlmod: name: bzlmod - platform: ubuntu1804 + platform: ubuntu2204 build_flags: - "--enable_bzlmod" <<: *common
diff --git a/.bazelci/examples_rich_structure.yml b/.bazelci/examples_rich_structure.yml index e6f2d17..08e1ae0 100644 --- a/.bazelci/examples_rich_structure.yml +++ b/.bazelci/examples_rich_structure.yml
@@ -7,8 +7,8 @@ centos7: platform: centos7_java11_devtoolset10 <<: *common - ubuntu1804: - platform: ubuntu1804 + ubuntu2204: + platform: ubuntu2204 <<: *common macos: <<: *common
diff --git a/.bazelci/examples_stamping.yml b/.bazelci/examples_stamping.yml index 0eebfaa..82926d9 100644 --- a/.bazelci/examples_stamping.yml +++ b/.bazelci/examples_stamping.yml
@@ -7,8 +7,8 @@ centos7: platform: centos7_java11_devtoolset10 <<: *common - ubuntu1804: - platform: ubuntu1804 + ubuntu2204: + platform: ubuntu2204 <<: *common macos: <<: *common
diff --git a/.bazelci/integration.yml b/.bazelci/integration.yml index 94ca75a..5eaf6fc 100644 --- a/.bazelci/integration.yml +++ b/.bazelci/integration.yml
@@ -10,5 +10,5 @@ tasks: integration: name: rolling_distro - platform: ubuntu1804 + platform: ubuntu2204 <<: *common
diff --git a/.bazelci/tests.yml b/.bazelci/tests.yml index bd5ae61..76d1f27 100644 --- a/.bazelci/tests.yml +++ b/.bazelci/tests.yml
@@ -61,10 +61,10 @@ - "-//pkg/legacy/tests/rpm/..." # -# Commmon features and tests by platform -# -ubuntu1804: &ubuntu - platform: ubuntu1804 +# Common features and tests by platform +# +ubuntu2204: &ubuntu + platform: ubuntu2204 <<: *common <<: *default_tests
diff --git a/.bazelrc b/.bazelrc new file mode 100644 index 0000000..9cbe44f --- /dev/null +++ b/.bazelrc
@@ -0,0 +1 @@ +build --enable_workspace
diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml index 962b770..5897036 100644 --- a/.bcr/presubmit.yml +++ b/.bcr/presubmit.yml
@@ -11,7 +11,7 @@ build_targets: *build_targets macos: build_targets: *build_targets - ubuntu2004: + ubuntu2204: build_targets: *build_targets windows: build_targets: *build_targets
diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 0000000..bcdef8a --- /dev/null +++ b/.github/workflows/pre-commit.yml
@@ -0,0 +1,14 @@ +name: Pre-Commit + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pre-commit/action@v3.0.1
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 52c7cd0..227bcf1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml
@@ -6,7 +6,29 @@ repos: # Check formatting and lint for starlark code - repo: https://github.com/keith/pre-commit-buildifier - rev: 6.3.3 + rev: 8.0.0 hooks: - id: buildifier - id: buildifier-lint + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-toml + - id: destroyed-symlinks + - id: detect-private-key + - id: end-of-file-fixer + exclude: | + (?x)^( + tests/testdata/| + docs/ + ) + - id: trailing-whitespace + - repo: https://github.com/crate-ci/typos + rev: v1.29.4 + hooks: + - id: typos + exclude: | + (?x)^( + CHANGELOG.md| + tests/testdata/ + )
diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..d56b623 --- /dev/null +++ b/.typos.toml
@@ -0,0 +1,3 @@ +[default.extend-words] +FO = "FO" +fo = "fo"
diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c91aa..9c1f94d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md
@@ -43,7 +43,7 @@ - Align pkg_rpm returned files with other rules (#692) - fix(pkg_tar): properly normalize paths for empty files (#760) - Document that package_dir also uses package_variables (#747) -- Fix handling paths with whitepsaces (#733) +- Fix handling paths with whitespaces (#733) - Fix python 3.6, doesn't support compresslevel - Use Gzip compress level 6 (#720) - write debian Date field in UTC rather than local time (#712) @@ -51,7 +51,7 @@ **Breaking Changes - Remove PackageArtifactsInfo. (#752) - + Thanks to: Adam Azarchs, Alex Eagle, August Karlstedt, Austin Schuh, Adrian Vogelsgesang, flode, Florian Scheibner, Ignas Kaziukėnas, Jean-Hadrien Chabran, Matt, Mike Kelly, Paul Draper, Sam Schwebach, Tomasz Wojno, and Vertexwahn @@ -117,7 +117,7 @@ - Get rid of the long deprecated archive_name and extension from pkg_zip. (#552) - Make 'out' work in a reasonable way. Fixes #414 - Partial fix for #284 - + ## Bug fixes: - Only allow .deb Description to be multiline. (#573) @@ -414,7 +414,7 @@ - Author: aiuto <aiuto@google.com> Date: Fri May 22 14:50:42 2020 -0400 - Add a minimal WORKSPACE file to the distributon. (#182) + Add a minimal WORKSPACE file to the distribution. (#182) We extract this from the top level workspace so it is easier to keep in sync. - commit 808c192a0c48f292e6dfaaeb3bfa3d4378f6996d @@ -533,11 +533,11 @@ Date: Thu Mar 12 15:14:32 2020 -0400 Depend on rules_python (#140) - + * load rules python - + * add workspace deps - + * add missing loads commit 2b375a08bfe36d2c35885a6f4e5b12d7898c9426 @@ -545,11 +545,11 @@ Date: Wed Mar 11 14:49:21 2020 -0400 Update test data in response to #121 (#137) - + PR #121 changed pkg_deb's behavior but didn't update test data to match. - + Reported in PR #132. - + Testing Done: - `bazelisk test ...` @@ -558,29 +558,29 @@ Date: Fri Feb 28 01:22:37 2020 -0500 Add pkgfilegroup for package-independent destination mappings (#128) - + * Add pkgfilegroup for package-independent destination mappings - + This adds an experimental rule, `pkgfilegroup`, along with associated Providers, that gives rule developers and users a consistent mechanism for using the output of bazel targets in packaging rules. - + Inspired by #36. - + Other capabilities that are provided by this that were not mentioned in #36 are: - + - Creation of empty directories (`pkg_mkdirs`) - Exclusion of files from a `pkgfilegroup` (`excludes`) - Renames of files in a `pkgfilegroup` (`renames`) - + * Add analysis tests for pkgfilegroup and friends - + This provides some analysis tests for various features of `pkgfilegroup` and `pkg_mkdirs`. See #128. - + You can run them by invoking `bazel test experimental/...` from the `pkg` directory - + This implementation of pkgfilegroup was inspired by #36. commit 7a991dea418ab17c7e86f0a7b5e7d4a87ef4304b @@ -588,15 +588,15 @@ Date: Fri Feb 28 01:02:24 2020 -0500 Improve handling of sources from external repositories (#132) - + Avoid use of [`File.short_path`][1] when mapping filenames, because when creating archives from files imported from external repositories we'll create archive members with leading `./../` prefixes. Instead, we'll stick to stripping to leading `File.root.path` (if present) from `File.path`, resulting in archive members like `external/repo/package/file.txt`. - + [1]: https://docs.bazel.build/versions/master/skylark/lib/File.html#short_path - + Resolves #131. commit 532f2857e712c5fcb71c662d680108685b242251 @@ -610,7 +610,7 @@ Date: Fri Feb 28 05:49:40 2020 +0000 Rpm source date epoch (#113) - + * Added --source_date_epoch * Support source_date_epoch_file since stamp variables are not accessible * Fixed _make_rpm label @@ -628,9 +628,9 @@ Date: Wed Dec 4 22:32:01 2019 +0100 Add "./" prefix to files in control.tar (#121) - + This improves compatibility to Debian packages created using dpkg. - + https://github.com/bazelbuild/rules_pkg/issues/116 commit 2f09779667f0d6644c2ca5914d6113a82666ec63 @@ -638,7 +638,7 @@ Date: Fri Nov 15 10:09:45 2019 -0800 pkg_deb: Support Breaks and Replaces. (#117) - + https://www.debian.org/doc/debian-policy/ch-relationships.html#overwriting-files-and-replacing-packages-replaces commit 9192d3b3a0f6ccfdecdc66f08f0b2664fa0afc0f @@ -646,7 +646,7 @@ Date: Fri Oct 4 16:33:47 2019 -0400 Fix repo names with '-' in them. - + We can not use the form "@repo-name" in Bazel, so the common solution is to transform that to "@repo_name". We auto-correct the repo names to the required form when printing the WORKSPACE stanza.
diff --git a/METADATA b/METADATA index 20ed9cc..e572ac5 100644 --- a/METADATA +++ b/METADATA
@@ -8,12 +8,12 @@ license_type: NOTICE last_upgrade_date { year: 2025 - month: 2 - day: 19 + month: 7 + day: 30 } identifier { type: "Git" value: "https://github.com/bazelbuild/rules_pkg" - version: "5c6aec64627c91f8ae71820173766237311d4ac6" + version: "1.1.0" } }
diff --git a/MODULE.bazel b/MODULE.bazel index 50f7590..55d4c87 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -1,19 +1,19 @@ module( name = "rules_pkg", - version = "1.0.1", # Must sync with version.bzl. + version = "1.1.0", # Must sync with version.bzl. compatibility_level = 1, repo_name = "rules_pkg", ) # Do not update to newer versions until you need a specific new feature. -bazel_dep(name = "rules_license", version = "0.0.7") -bazel_dep(name = "rules_python", version = "0.31.0") -bazel_dep(name = "bazel_skylib", version = "1.4.2") +bazel_dep(name = "rules_license", version = "1.0.0") +bazel_dep(name = "rules_python", version = "1.0.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") # Only for development -bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True) -bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True) -bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True) +bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True) +bazel_dep(name = "rules_cc", version = "0.0.17", dev_dependency = True) +bazel_dep(name = "stardoc", version = "0.7.2", dev_dependency = True) # Find the system rpmbuild if one is available. find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True) @@ -23,3 +23,10 @@ "@rules_pkg_rpmbuild//:all", dev_dependency = True, ) + +local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository") + +local_repository( + name = "mappings_test_external_repo", + path = "tests/mappings/external_repo", +)
diff --git a/README.md b/README.md index aa621e8..45f5e31 100644 --- a/README.md +++ b/README.md
@@ -28,7 +28,7 @@ Sample, but see [releases](https://github.com/bazelbuild/rules_pkg/releases) for the current release. -``` +```starlark load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_pkg", @@ -44,7 +44,7 @@ To use `pkg_rpm()`, you must provide a copy of `rpmbuild`. You can use the system installed `rpmbuild` with this stanza. -``` +```starlark load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild") find_system_rpmbuild( @@ -55,12 +55,12 @@ ## MODULE.bazel setup -``` +```starlark bazel_dep(name = "rules_pkg", version = "0.0.10") ``` To use `pkg_rpm()`, you must provide a copy of `rpmbuild`. You can use the system installed `rpmbuild` with this stanza. -``` +```starlark find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod") use_repo(find_rpm, "rules_pkg_rpmbuild") register_toolchains("@rules_pkg_rpmbuild//:all")
diff --git a/WORKSPACE b/WORKSPACE index fee32ef..aeea9eb 100644 --- a/WORKSPACE +++ b/WORKSPACE
@@ -36,9 +36,9 @@ http_archive( name = "platforms", - sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", urls = [ - "https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], ) @@ -60,10 +60,10 @@ http_archive( name = "bazel_stardoc", - sha256 = "c9794dcc8026a30ff67cf7cf91ebe245ca294b20b071845d12c192afe243ad72", + sha256 = "0e1ed4a98f26e718776bd64d053d02bb34d98572ccd03d6ba355112a1205706b", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz", - "https://github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.7.2/stardoc-0.7.2.tar.gz", + "https://github.com/bazelbuild/stardoc/releases/download/0.7.2/stardoc-0.7.2.tar.gz", ], ) @@ -73,9 +73,9 @@ http_archive( name = "rules_cc", - sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", - strip_prefix = "rules_cc-0.0.9", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], + sha256 = "abc605dd850f813bb37004b77db20106a19311a96b2da1c92b789da529d28fe1", + strip_prefix = "rules_cc-0.0.17", + urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.17/rules_cc-0.0.17.tar.gz"], ) load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies")
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index 3a25ac4..6680fd5 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod
@@ -21,6 +21,7 @@ name = "rules_pkg_git", verbose = False, ) + register_toolchains( "@rules_pkg_git//:git_auto_toolchain", "//toolchains/git:git_missing_toolchain",
diff --git a/deb_packages/README.md b/deb_packages/README.md deleted file mode 100644 index d60633d..0000000 --- a/deb_packages/README.md +++ /dev/null
@@ -1,5 +0,0 @@ -# This module is deprecated - -The work here has forked to two other places. Please look at both to see which is better maintained and meets your needs best. -- https://github.com/mariusgrigoriu/rules_dpkg -- https://github.com/aisbaa/deb_packages
diff --git a/distro/packaging_test.py b/distro/packaging_test.py index 38c34c8..f4b0645 100644 --- a/distro/packaging_test.py +++ b/distro/packaging_test.py
@@ -44,7 +44,6 @@ content = inp.read() if _VERBOSE: print('=== Expect', want) - module_block_re = re.compile m = re.search( r"""module\([^)]+\)""", content, @@ -92,7 +91,7 @@ CopyTestFile('BUILD.tpl', 'BUILD') os.chdir(tempdir) - build_result = subprocess.check_output(['bazel', 'build', ':dummy_tar']) + build_result = subprocess.check_output(['bazel', 'build', '--enable_workspace', ':dummy_tar']) if _VERBOSE: print('=== Build Result ===') print(build_result)
diff --git a/doc_build/BUILD b/doc_build/BUILD index d45155b..14db111 100644 --- a/doc_build/BUILD +++ b/doc_build/BUILD
@@ -31,22 +31,11 @@ srcs = [ "BUILD", ] + glob([ - "*.bzl", "*.py", ]), visibility = ["//distro:__pkg__"], ) -exports_files( - glob([ - "*.bzl", - ]), - visibility = [ - "//distro:__pkg__", - "//doc_build:__pkg__", - ], -) - # pairs of rule name and the source file to get it from # buildifier: leave-alone, do not sort ORDER = [ @@ -80,7 +69,10 @@ symbol_names = [ rule, ], - deps = [":rules_pkg_lib"], + deps = [ + ":rules_pkg_lib", + "//toolchains/rpm:standard_package", + ], ) for rule, src in ORDER if src
diff --git a/doc_build/merge.py b/doc_build/merge.py index ae67d10..9ff7842 100755 --- a/doc_build/merge.py +++ b/doc_build/merge.py
@@ -75,7 +75,7 @@ def main(argv: typing.Sequence[str]) -> None: wrapper_map = {} - for file in argv[1:]: + for file in argv[1:]: merge_file(file, sys.stdout, wrapper_map) if wrapper_map: print("We didn't use all the @wraps()", wrapper_map, file=sys.stderr)
diff --git a/docs/0.10.0/reference.md b/docs/0.10.0/reference.md index 5939363..c52c1e0 100755 --- a/docs/0.10.0/reference.md +++ b/docs/0.10.0/reference.md
@@ -109,7 +109,7 @@ - `out` the Debian package or a symlink to the actual package. - `deb` the package with any precise file name created with `package_file_name`. - `changes` the .changes file. - + **ATTRIBUTES** @@ -225,7 +225,7 @@ - `out` the RPM or a symlink to the actual package. - `rpm` the package with any precise file name created with `package_file_name`. - `changes` the .changes file. - + **ATTRIBUTES** @@ -396,14 +396,14 @@ Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -411,15 +411,15 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. - + **ATTRIBUTES** @@ -448,7 +448,7 @@ This rule represents a collection of packaging specifications (e.g. those created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, such as a prefix or a human-readable category. - + **ATTRIBUTES** @@ -480,7 +480,7 @@ Consumers of `pkg_files`s will, where possible, create the necessary directory structure for your files so you do not have to unless you have special requirements. Consult `pkg_mkdirs` for more details. - + **ATTRIBUTES** @@ -520,7 +520,7 @@ For some package management systems (e.g. RPM), directory ownership (2) may imply additional semantics. Consult your package manager's and target distribution's documentation for more details. - + **ATTRIBUTES** @@ -547,7 +547,7 @@ Symbolic links specified by this rule may point at files/directories outside of the package, or otherwise left dangling. - + **ATTRIBUTES** @@ -721,6 +721,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | "" | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | - - -
diff --git a/docs/0.6.0/reference.md b/docs/0.6.0/reference.md index 8a8b5f9..5495423 100755 --- a/docs/0.6.0/reference.md +++ b/docs/0.6.0/reference.md
@@ -221,7 +221,7 @@ Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -426,14 +426,14 @@ Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -441,15 +441,15 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. - + **ATTRIBUTES** @@ -478,7 +478,7 @@ This rule represents a collection of packaging specifications (e.g. those created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, such as a prefix or a human-readable category. - + **ATTRIBUTES** @@ -512,7 +512,7 @@ Consumers of `pkg_files`s will, where possible, create the necessary directory structure for your files so you do not have to unless you have special requirements. Consult `pkg_mkdirs` for more details. - + **ATTRIBUTES** @@ -551,7 +551,7 @@ For some package management systems (e.g. RPM), directory ownership (2) may imply additional semantics. Consult your package manager's and target distribution's documentation for more details. - + **ATTRIBUTES** @@ -578,7 +578,7 @@ Symbolic links specified by this rule may point at files/directories outside of the package, or otherwise left dangling. - + **ATTRIBUTES** @@ -746,5 +746,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | "" | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | - -
diff --git a/docs/0.7.0/reference.md b/docs/0.7.0/reference.md index bc67345..48393c6 100755 --- a/docs/0.7.0/reference.md +++ b/docs/0.7.0/reference.md
@@ -199,7 +199,7 @@ Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -360,14 +360,14 @@ Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -375,15 +375,15 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. - + **ATTRIBUTES** @@ -412,7 +412,7 @@ This rule represents a collection of packaging specifications (e.g. those created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, such as a prefix or a human-readable category. - + **ATTRIBUTES** @@ -446,7 +446,7 @@ Consumers of `pkg_files`s will, where possible, create the necessary directory structure for your files so you do not have to unless you have special requirements. Consult `pkg_mkdirs` for more details. - + **ATTRIBUTES** @@ -485,7 +485,7 @@ For some package management systems (e.g. RPM), directory ownership (2) may imply additional semantics. Consult your package manager's and target distribution's documentation for more details. - + **ATTRIBUTES** @@ -512,7 +512,7 @@ Symbolic links specified by this rule may point at files/directories outside of the package, or otherwise left dangling. - + **ATTRIBUTES** @@ -681,6 +681,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | "" | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | - - -
diff --git a/docs/0.8.0/reference.md b/docs/0.8.0/reference.md index 4ba55cc..187dba7 100755 --- a/docs/0.8.0/reference.md +++ b/docs/0.8.0/reference.md
@@ -203,7 +203,7 @@ Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -364,14 +364,14 @@ Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -379,15 +379,15 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. - + **ATTRIBUTES** @@ -416,7 +416,7 @@ This rule represents a collection of packaging specifications (e.g. those created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, such as a prefix or a human-readable category. - + **ATTRIBUTES** @@ -450,7 +450,7 @@ Consumers of `pkg_files`s will, where possible, create the necessary directory structure for your files so you do not have to unless you have special requirements. Consult `pkg_mkdirs` for more details. - + **ATTRIBUTES** @@ -489,7 +489,7 @@ For some package management systems (e.g. RPM), directory ownership (2) may imply additional semantics. Consult your package manager's and target distribution's documentation for more details. - + **ATTRIBUTES** @@ -516,7 +516,7 @@ Symbolic links specified by this rule may point at files/directories outside of the package, or otherwise left dangling. - + **ATTRIBUTES** @@ -685,6 +685,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | "" | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | - - -
diff --git a/docs/0.9.1/reference.md b/docs/0.9.1/reference.md index 52293be..0914931 100755 --- a/docs/0.9.1/reference.md +++ b/docs/0.9.1/reference.md
@@ -204,7 +204,7 @@ Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. - + **ATTRIBUTES** @@ -365,14 +365,14 @@ Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -380,15 +380,15 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. - + **ATTRIBUTES** @@ -417,7 +417,7 @@ This rule represents a collection of packaging specifications (e.g. those created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, such as a prefix or a human-readable category. - + **ATTRIBUTES** @@ -449,7 +449,7 @@ Consumers of `pkg_files`s will, where possible, create the necessary directory structure for your files so you do not have to unless you have special requirements. Consult `pkg_mkdirs` for more details. - + **ATTRIBUTES** @@ -488,7 +488,7 @@ For some package management systems (e.g. RPM), directory ownership (2) may imply additional semantics. Consult your package manager's and target distribution's documentation for more details. - + **ATTRIBUTES** @@ -515,7 +515,7 @@ Symbolic links specified by this rule may point at files/directories outside of the package, or otherwise left dangling. - + **ATTRIBUTES** @@ -684,6 +684,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | "" | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | - - -
diff --git a/docs/1.0.1/reference.md b/docs/1.0.1/reference.md index e6eb916..ea293dd 100755 --- a/docs/1.0.1/reference.md +++ b/docs/1.0.1/reference.md
@@ -765,6 +765,3 @@ | <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | required | | | <a id="pkg_rpm-version"></a>version | - | String | optional | `""` | | <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | - - -
diff --git a/docs/1.1.0/reference.md b/docs/1.1.0/reference.md new file mode 100755 index 0000000..c11eb7c --- /dev/null +++ b/docs/1.1.0/reference.md
@@ -0,0 +1,801 @@ +# rules_pkg - 1.1.0 + +<div class="toc"> + <h2>Common Attributes</h2> + <ul> + <li><a href="#common">Package attributes</a></li> + <li><a href="#mapping-attrs">File attributes</a></li> + </ul> + + <h2>Packaging Rules</h2> + <ul> + <li><a href="#pkg_deb">//pkg:deb.bzl%pkg_deb</a></li> + <li><a href="#pkg_rpm">//pkg:rpm.bzl%pkg_rpm</a></li> + <li><a href="#pkg_tar">//pkg:tar.bzl%pkg_tar</a></li> + <li><a href="#pkg_zip">//pkg:zip.bzl%pkg_zip</a></li> + </ul> + + <h2>File Tree Creation Rules</h2> + <ul> + <li><a href="#filter_directory">//pkg:mappings.bzl%filter_directory</a></li> + <li><a href="#pkg_filegroup">//pkg:mappings.bzl%pkg_filegroup</a></li> + <li><a href="#pkg_files">//pkg:mappings.bzl%pkg_files</a></li> + <li><a href="#pkg_mkdirs">//pkg:mappings.bzl%pkg_mkdirs</a></li> + <li><a href="#pkg_mklink">//pkg:mappings.bzl%pkg_mklink</a></li> + <li><a href="#pkg_attributes">//pkg:mappings.bzl%pkg_attributes</a></li> + <li><a href="#strip_prefix.files_only">//pkg:mappings.bzl%strip_prefix</a></li> + </ul> +</div> + +<a name="common"></a> + +### Common Attributes + +These attributes are used in several rules within this module. + +**ATTRIBUTES** + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :-------------: | :-------------: | :------------- | +| <a name="out">out</a> | Name of the output file. This file will always be created and used to access the package content. If `package_file_name` is also specified, `out` will be a symlink. | String | required | | +| <a name="package_file_name">package_file_name</a> | The name of the file which will contain the package. The name may contain variables in the forms `{var}` and $(var)`. The values for substitution are specified through `package_variables` or taken from [ctx.var](https://bazel.build/rules/lib/ctx#var). | String | optional | package type specific | +| <a name="package_variables">package_variables</a> | A target that provides `PackageVariablesInfo` to substitute into `package_file_name`. `pkg_zip` and `pkg_tar` also support this in `package_dir` | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None | +| attributes | Attributes to set on entities created within packages. Not to be confused with bazel rule attributes. See 'Mapping "Attributes"' below | Undefined. | optional | Varies. Consult individual rule documentation for details. | + +See +[examples/naming_package_files](https://github.com/bazelbuild/rules_pkg/tree/main/examples/naming_package_files) +for examples of how `out`, `package_file_name`, and `package_variables` +interact. + +<div class="since"><i>Since 0.8.0</i></div>: File name substitution now supports the $(var) syntax. +<div class="since"><i>Since 0.8.0</i></div>: File name substitution now supports direct use of [ctx.var](https://bazel.build/rules/lib/ctx#var). + + +<a name="mapping-attrs"></a> +### Mapping "Attributes" + +The "attributes" attribute specifies properties of package contents as used in +rules such as `pkg_files`, and `pkg_mkdirs`. These allow fine-grained control +of the contents of your package. For example: + +```python +attributes = pkg_attributes( + mode = "0644", + user = "root", + group = "wheel", + my_custom_attribute = "some custom value", +) +``` + +`mode`, `user`, and `group` correspond to common UNIX-style filesystem +permissions. Attributes should always be specified using the `pkg_attributes` +helper macro. + +Each mapping rule has some default mapping attributes. At this time, the only +default is "mode", which will be set if it is not otherwise overridden by the user. + +If `user` and `group` are not specified, then defaults for them will be chosen +by the underlying package builder. Any specific behavior from package builders +should not be relied upon. + +Any other attributes should be specified as additional arguments to +`pkg_attributes`. + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Rule for creating Debian packages. + +<a id="pkg_deb"></a> + +## pkg_deb + +<pre> +load("@rules_pkg//pkg/private/deb:deb.bzl", "pkg_deb") + +pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>, + <a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>, + <a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>, <a href="#pkg_deb-license">license</a>, + <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-package">package</a>, <a href="#pkg_deb-package_file_name">package_file_name</a>, <a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>, + <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>, <a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-section">section</a>, <a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>, + <a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>) +</pre> + +Create a Debian package. + +This rule produces 2 artifacts: a .deb and a .changes file. The DefaultInfo will +include both. If you need downstream rule to specifically depend on only the .deb or +.changes file then you can use `filegroup` to select distinct output groups. + +**OutputGroupInfo** +- `out` the Debian package or a symlink to the actual package. +- `deb` the package with any precise file name created with `package_file_name`. +- `changes` the .changes file. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_deb-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_deb-data"></a>data | A tar file that contains the data for the debian package. | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="pkg_deb-out"></a>out | See [Common Attributes](#out) | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="pkg_deb-architecture"></a>architecture | Package architecture. Must not be used with architecture_file. | String | optional | `"all"` | +| <a id="pkg_deb-architecture_file"></a>architecture_file | File that contains the package architecture. Must not be used with architecture. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-breaks"></a>breaks | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-built_using"></a>built_using | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | String | optional | `""` | +| <a id="pkg_deb-built_using_file"></a>built_using_file | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-changelog"></a>changelog | The package changelog. See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-conffiles"></a>conffiles | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | List of strings | optional | `[]` | +| <a id="pkg_deb-conffiles_file"></a>conffiles_file | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-config"></a>config | config file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-conflicts"></a>conflicts | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-depends"></a>depends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-depends_file"></a>depends_file | File that contains a list of package dependencies. Must not be used with `depends`. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-description"></a>description | The package description. Must not be used with `description_file`. | String | optional | `""` | +| <a id="pkg_deb-description_file"></a>description_file | The package description. Must not be used with `description`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-distribution"></a>distribution | "distribution: See http://www.debian.org/doc/debian-policy. | String | optional | `"unstable"` | +| <a id="pkg_deb-enhances"></a>enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-homepage"></a>homepage | The homepage of the project. | String | optional | `""` | +| <a id="pkg_deb-license"></a>license | The license of the project. | String | optional | `""` | +| <a id="pkg_deb-maintainer"></a>maintainer | The maintainer of the package. | String | required | | +| <a id="pkg_deb-package"></a>package | The name of the package | String | required | | +| <a id="pkg_deb-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name). Default: "{package}-{version}-{architecture}.deb | String | optional | `""` | +| <a id="pkg_deb-package_variables"></a>package_variables | See [Common Attributes](#package_variables) | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-postinst"></a>postinst | The post-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-postrm"></a>postrm | The post-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-predepends"></a>predepends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-preinst"></a>preinst | "The pre-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-prerm"></a>prerm | The pre-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-priority"></a>priority | The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities. | String | optional | `""` | +| <a id="pkg_deb-provides"></a>provides | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-recommends"></a>recommends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-replaces"></a>replaces | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-section"></a>section | The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections. | String | optional | `""` | +| <a id="pkg_deb-suggests"></a>suggests | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | `[]` | +| <a id="pkg_deb-templates"></a>templates | templates file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-triggers"></a>triggers | triggers file for configuring installation events exchanged by packages. See https://wiki.debian.org/DpkgTriggers. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_deb-urgency"></a>urgency | "urgency: See http://www.debian.org/doc/debian-policy. | String | optional | `"medium"` | +| <a id="pkg_deb-version"></a>version | Package version. Must not be used with `version_file`. | String | optional | `""` | +| <a id="pkg_deb-version_file"></a>version_file | File that contains the package version. Must not be used with `version`. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Provides rules for creating RPM packages via pkg_filegroup and friends. + +pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will +find to convenient to use the one provided with their system. To enable that +toolchain add the following stanza to WORKSPACE: + +``` +# Find rpmbuild if it exists. +load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild") +find_system_rpmbuild(name="rules_pkg_rpmbuild") +``` + +<a id="pkg_sub_rpm"></a> + +## pkg_sub_rpm + +<pre> +load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_sub_rpm") + +pkg_sub_rpm(<a href="#pkg_sub_rpm-name">name</a>, <a href="#pkg_sub_rpm-srcs">srcs</a>, <a href="#pkg_sub_rpm-architecture">architecture</a>, <a href="#pkg_sub_rpm-conflicts">conflicts</a>, <a href="#pkg_sub_rpm-description">description</a>, <a href="#pkg_sub_rpm-epoch">epoch</a>, <a href="#pkg_sub_rpm-group">group</a>, <a href="#pkg_sub_rpm-obsoletes">obsoletes</a>, <a href="#pkg_sub_rpm-package_name">package_name</a>, + <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>) +</pre> + +Define a sub RPM to be built as part of a parent RPM + +This rule uses the outputs of the rules in `mappings.bzl` to define an sub +RPM that will be built as part of a larger RPM defined by a `pkg_rpm` instance. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_sub_rpm-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_sub_rpm-srcs"></a>srcs | Mapping groups to include in this RPM | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | +| <a id="pkg_sub_rpm-architecture"></a>architecture | Sub RPM architecture | String | optional | `""` | +| <a id="pkg_sub_rpm-conflicts"></a>conflicts | List of RPM capability expressions that conflict with this package | List of strings | optional | `[]` | +| <a id="pkg_sub_rpm-description"></a>description | Multi-line description of this subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-epoch"></a>epoch | RPM `Epoch` tag for this subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-group"></a>group | Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag. Other distributions may require it, but it is harmless in any case. | String | optional | `""` | +| <a id="pkg_sub_rpm-obsoletes"></a>obsoletes | List of RPM capability expressions that this package obsoletes | List of strings | optional | `[]` | +| <a id="pkg_sub_rpm-package_name"></a>package_name | name of the subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-post_scriptlet"></a>post_scriptlet | RPM `%post` scriplet for this subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-postun_scriptlet"></a>postun_scriptlet | RPM `%postun` scriplet for this subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-provides"></a>provides | List of RPM capability expressions that this package provides | List of strings | optional | `[]` | +| <a id="pkg_sub_rpm-requires"></a>requires | List of RPM capability expressions that this package requires | List of strings | optional | `[]` | +| <a id="pkg_sub_rpm-summary"></a>summary | Sub RPM `Summary` tag | String | optional | `""` | +| <a id="pkg_sub_rpm-version"></a>version | RPM `Version` tag for this subrpm | String | optional | `""` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Provides rules for creating RPM packages via pkg_filegroup and friends. + +pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will +find to convenient to use the one provided with their system. To enable that +toolchain add the following stanza to WORKSPACE: + +``` +# Find rpmbuild if it exists. +load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild") +find_system_rpmbuild(name="rules_pkg_rpmbuild") +``` + +<a id="pkg_rpm"></a> + +## pkg_rpm + +<pre> +load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_rpm") + +pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>, + <a href="#pkg_rpm-debuginfo">debuginfo</a>, <a href="#pkg_rpm-defines">defines</a>, <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-epoch">epoch</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>, + <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>, <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>, + <a href="#pkg_rpm-posttrans_scriptlet">posttrans_scriptlet</a>, <a href="#pkg_rpm-posttrans_scriptlet_file">posttrans_scriptlet_file</a>, <a href="#pkg_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_rpm-postun_scriptlet_file">postun_scriptlet_file</a>, + <a href="#pkg_rpm-pre_scriptlet">pre_scriptlet</a>, <a href="#pkg_rpm-pre_scriptlet_file">pre_scriptlet_file</a>, <a href="#pkg_rpm-preun_scriptlet">preun_scriptlet</a>, <a href="#pkg_rpm-preun_scriptlet_file">preun_scriptlet_file</a>, <a href="#pkg_rpm-provides">provides</a>, <a href="#pkg_rpm-release">release</a>, + <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-requires">requires</a>, <a href="#pkg_rpm-requires_contextual">requires_contextual</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, + <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_template">spec_template</a>, <a href="#pkg_rpm-subrpms">subrpms</a>, <a href="#pkg_rpm-summary">summary</a>, <a href="#pkg_rpm-url">url</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>) +</pre> + +Creates an RPM format package via `pkg_filegroup` and friends. + +The uses the outputs of the rules in `mappings.bzl` to construct arbitrary +RPM packages. Attributes of this rule provide preamble information and +scriptlets, which are then used to compose a valid RPM spec file. + +This rule will fail at analysis time if: + +- Any `srcs` input creates the same destination, regardless of other + attributes. + +This rule only functions on UNIXy platforms. The following tools must be +available on your system for this to function properly: + +- `rpmbuild` (as specified in `rpmbuild_path`, or available in `$PATH`) + +- GNU coreutils. BSD coreutils may work, but are not tested. + +To set RPM file attributes (like `%config` and friends), set the +`rpm_filetag` in corresponding packaging rule (`pkg_files`, etc). The value +is prepended with "%" and added to the `%files` list, for example: + +``` +attrs = {"rpm_filetag": ("config(missingok, noreplace)",)}, +``` + +Is the equivalent to `%config(missingok, noreplace)` in the `%files` list. + +This rule produces 2 artifacts: an .rpm and a .changes file. The DefaultInfo will +include both. If you need downstream rule to specifically depend on only the .rpm or +.changes file then you can use `filegroup` to select distinct output groups. + +**OutputGroupInfo** +- `out` the RPM or a symlink to the actual package. +- `rpm` the package with any precise file name created with `package_file_name`. +- `changes` the .changes file. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_rpm-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_rpm-srcs"></a>srcs | Mapping groups to include in this RPM.<br><br>These are typically brought into life as `pkg_filegroup`s. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | +| <a id="pkg_rpm-architecture"></a>architecture | Package architecture.<br><br>This currently sets the `BuildArch` tag, which influences the output architecture of the package.<br><br>Typically, `BuildArch` only needs to be set when the package is known to be cross-platform (e.g. written in an interpreted language), or, less common, when it is known that the application is only valid for specific architectures.<br><br>When no attribute is provided, this will default to your host's architecture. This is usually what you want. | String | optional | `""` | +| <a id="pkg_rpm-binary_payload_compression"></a>binary_payload_compression | Compression mode used for this RPM<br><br>Must be a form that `rpmbuild(8)` knows how to process, which will depend on the version of `rpmbuild` in use. The value corresponds to the `%_binary_payload` macro and is set on the `rpmbuild(8)` command line if provided.<br><br>Some examples of valid values (which may not be supported on your system) can be found [here](https://git.io/JU9Wg). On CentOS systems (also likely Red Hat and Fedora), you can find some supported values by looking for `%_binary_payload` in `/usr/lib/rpm/macros`. Other systems have similar files and configurations.<br><br>If not provided, the compression mode will be computed by `rpmbuild` itself. Defaults may vary per distribution or build of `rpm`; consult the relevant documentation for more details.<br><br>WARNING: Bazel is currently not aware of action threading requirements for non-test actions. Using threaded compression may result in overcommitting your system. | String | optional | `""` | +| <a id="pkg_rpm-changelog"></a>changelog | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-conflicts"></a>conflicts | List of capabilities that conflict with this package when it is installed.<br><br>Corresponds to the "Conflicts" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | `[]` | +| <a id="pkg_rpm-debug"></a>debug | Debug the RPM helper script and RPM generation | Boolean | optional | `False` | +| <a id="pkg_rpm-debuginfo"></a>debuginfo | Enable generation of debuginfo RPMs<br><br>For supported platforms this will enable the generation of debuginfo RPMs adjacent to the regular RPMs. Currently this is supported by Fedora 40, CentOS7 and CentOS Stream 9. | Boolean | optional | `False` | +| <a id="pkg_rpm-defines"></a>defines | Additional definitions to pass to rpmbuild | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | +| <a id="pkg_rpm-description"></a>description | Multi-line description of this package, corresponds to RPM %description.<br><br>Exactly one of `description` or `description_file` must be provided. | String | optional | `""` | +| <a id="pkg_rpm-description_file"></a>description_file | File containing a multi-line description of this package, corresponds to RPM %description. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-epoch"></a>epoch | Optional; RPM "Epoch" tag. | String | optional | `""` | +| <a id="pkg_rpm-group"></a>group | Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag. Other distributions may require it, but it is harmless in any case. | String | optional | `""` | +| <a id="pkg_rpm-license"></a>license | RPM "License" tag.<br><br>The software license for the code distributed in this package.<br><br>The underlying RPM builder requires you to put something here; if your package is not going to be distributed, feel free to set this to something like "Internal". | String | required | | +| <a id="pkg_rpm-obsoletes"></a>obsoletes | List of rpm capability expressions that this package obsoletes.<br><br>Corresponds to the "Obsoletes" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | `[]` | +| <a id="pkg_rpm-package_file_name"></a>package_file_name | See 'Common Attributes' in the rules_pkg reference.<br><br>If this is not provided, the package file given a NVRA-style (name-version-release.arch) output, which is preferred by most RPM repositories. | String | optional | `""` | +| <a id="pkg_rpm-package_name"></a>package_name | Optional; RPM name override.<br><br>If not provided, the `name` attribute of this rule will be used instead.<br><br>This influences values like the spec file name. | String | optional | `""` | +| <a id="pkg_rpm-package_variables"></a>package_variables | See 'Common Attributes' in the rules_pkg reference | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet | RPM `%post` scriptlet. Currently only allowed to be a shell script.<br><br>`post_scriptlet` and `post_scriptlet_file` are mutually exclusive. | String | optional | `""` | +| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file | File containing the RPM `%post` scriptlet | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet | RPM `%posttrans` scriptlet. Currently only allowed to be a shell script.<br><br>`posttrans_scriptlet` and `posttrans_scriptlet_file` are mutually exclusive. | String | optional | `""` | +| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file | File containing the RPM `%posttrans` scriptlet | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet | RPM `%postun` scriptlet. Currently only allowed to be a shell script.<br><br>`postun_scriptlet` and `postun_scriptlet_file` are mutually exclusive. | String | optional | `""` | +| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file | File containing the RPM `%postun` scriptlet | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet | RPM `%pre` scriptlet. Currently only allowed to be a shell script.<br><br>`pre_scriptlet` and `pre_scriptlet_file` are mutually exclusive. | String | optional | `""` | +| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file | File containing the RPM `%pre` scriptlet | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet | RPM `%preun` scriptlet. Currently only allowed to be a shell script.<br><br>`preun_scriptlet` and `preun_scriptlet_file` are mutually exclusive. | String | optional | `""` | +| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file | File containing the RPM `%preun` scriptlet | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-provides"></a>provides | List of rpm capabilities that this package provides.<br><br>Corresponds to the "Provides" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | `[]` | +| <a id="pkg_rpm-release"></a>release | RPM "Release" tag<br><br>Exactly one of `release` or `release_file` must be provided. | String | optional | `""` | +| <a id="pkg_rpm-release_file"></a>release_file | File containing RPM "Release" tag. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-requires"></a>requires | List of rpm capability expressions that this package requires.<br><br>Corresponds to the "Requires" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | `[]` | +| <a id="pkg_rpm-requires_contextual"></a>requires_contextual | Contextualized requirement specifications<br><br>This is a map of various properties (often scriptlet types) to capability name specifications, e.g.:<br><br><pre><code class="language-python">{"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}</code></pre><br><br>Which causes the below to be added to the spec file's preamble:<br><br><pre><code>Requires(pre): GConf2 Requires(post): GConf2 Requires(postun): GConf2</code></pre><br><br>This is most useful for ensuring that required tools exist when scriptlets are run, although there may be other valid use cases. Valid keys for this attribute may include, but are not limited to:<br><br>- `pre` - `post` - `preun` - `postun` - `pretrans` - `posttrans`<br><br>For capabilities that are always required by packages at runtime, use the `requires` attribute instead.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br>NOTE: `pkg_rpm` does not check if the keys of this dictionary are acceptable to `rpm(8)`. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional | `{}` | +| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path | Path to a `rpmbuild` binary. Deprecated in favor of the rpmbuild toolchain | String | optional | `""` | +| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch | Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps.<br><br>Negative values (like the default) disable this feature. | Integer | optional | `-1` | +| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file | File containing the SOURCE_DATE_EPOCH value.<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-spec_template"></a>spec_template | Spec file template.<br><br>Use this if you need to add additional logic to your spec files that is not available by default.<br><br>In most cases, you should not need to override this attribute. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `"@rules_pkg//pkg/rpm:template.spec.tpl"` | +| <a id="pkg_rpm-subrpms"></a>subrpms | Sub RPMs to build with this RPM<br><br>A list of `pkg_sub_rpm` instances that can be used to create sub RPMs as part of the overall package build.<br><br>NOTE: use of `subrpms` is incompatible with the legacy `spec_file` mode | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | +| <a id="pkg_rpm-summary"></a>summary | RPM "Summary" tag.<br><br>One-line summary of this package. Must not contain newlines. | String | required | | +| <a id="pkg_rpm-url"></a>url | RPM "URL" tag; this project/vendor's home on the Internet. | String | optional | `""` | +| <a id="pkg_rpm-version"></a>version | RPM "Version" tag.<br><br>Exactly one of `version` or `version_file` must be provided. | String | optional | `""` | +| <a id="pkg_rpm-version_file"></a>version_file | File containing RPM "Version" tag. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Rules for making .tar files. + +<a id="pkg_tar"></a> + +## pkg_tar + +<pre> +load("@rules_pkg//pkg/private/tar:tar.bzl", "pkg_tar") + +pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-allow_duplicates_from_deps">allow_duplicates_from_deps</a>, + <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compression_level">compression_level</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, + <a href="#pkg_tar-create_parents">create_parents</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-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-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>) +</pre> + + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_tar-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_tar-deps"></a>deps | tar files which will be unpacked and repacked into the archive. | <a href="https://bazel.build/concepts/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/concepts/labels">List of labels</a> | optional | `[]` | +| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="pkg_tar-allow_duplicates_from_deps"></a>allow_duplicates_from_deps | - | Boolean | optional | `False` | +| <a id="pkg_tar-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content | If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code. | Boolean | optional | `True` | +| <a id="pkg_tar-compression_level"></a>compression_level | Specify the numeric compression level in gzip mode; may be 0-9 or -1 (default to 6). | Integer | optional | `-1` | +| <a id="pkg_tar-compressor"></a>compressor | External tool which can compress the archive. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for `compressor`. | String | optional | `""` | +| <a id="pkg_tar-create_parents"></a>create_parents | - | Boolean | optional | `True` | +| <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 | Obsolete. Do not use. | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional | `{}` | +| <a id="pkg_tar-include_runfiles"></a>include_runfiles | Include runfiles for executables. These appear as they would in bazel-bin.For example: 'path/to/myprog.runfiles/path/to/my_data.txt'. | 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/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | +| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | `-1` | +| <a id="pkg_tar-owner"></a>owner | Default numeric owner.group to apply to files when not set via pkg_attributes. | 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/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | +| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | 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/concepts/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/concepts/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/rules/lib/dict">Dictionary: String -> String</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/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Zip archive creation rule and associated logic. + +<a id="pkg_zip"></a> + +## pkg_zip + +<pre> +load("@rules_pkg//pkg/private/zip:zip.bzl", "pkg_zip") + +pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>, + <a href="#pkg_zip-compression_type">compression_type</a>, <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>, + <a href="#pkg_zip-package_variables">package_variables</a>, <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>) +</pre> + + + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_zip-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_zip-srcs"></a>srcs | List of files that should be included in the archive. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | +| <a id="pkg_zip-out"></a>out | output file name. Default: name + ".zip". | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="pkg_zip-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content | If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code. | Boolean | optional | `True` | +| <a id="pkg_zip-compression_level"></a>compression_level | The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used | Integer | optional | `6` | +| <a id="pkg_zip-compression_type"></a>compression_type | The compression to use. Note that lzma and bzip2 might not be supported by all readers. The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED | String | optional | `"deflated"` | +| <a id="pkg_zip-include_runfiles"></a>include_runfiles | See standard attributes. | Boolean | optional | `False` | +| <a id="pkg_zip-mode"></a>mode | The default mode for all files in the archive. | String | optional | `"0555"` | +| <a id="pkg_zip-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_zip-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name) | String | optional | `""` | +| <a id="pkg_zip-package_variables"></a>package_variables | See [Common Attributes](#package_variables) | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | `False` | +| <a id="pkg_zip-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. | Integer | optional | `0` | +| <a id="pkg_zip-strip_prefix"></a>strip_prefix | - | String | optional | `""` | +| <a id="pkg_zip-timestamp"></a>timestamp | Time stamp to place on all files in the archive, expressed as seconds since the Unix Epoch, as per RFC 3339. The default is January 01, 1980, 00:00 UTC.<br><br>Due to limitations in the format of zip files, values before Jan 1, 1980 will be rounded up and the precision in the zip file is limited to a granularity of 2 seconds. | Integer | optional | `315532800` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Package creation helper mapping rules. + +This module declares Provider interfaces and rules for specifying the contents +of packages in a package-type-agnostic way. The main rules supported here are +the following: + +- `pkg_files` describes destinations for rule outputs +- `pkg_mkdirs` describes directory structures +- `pkg_mklink` describes symbolic links +- `pkg_filegroup` creates groupings of above to add to packages + +Rules that actually make use of the outputs of the above rules are not specified +here. + +<a id="filter_directory"></a> + +## filter_directory + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "filter_directory") + +filter_directory(<a href="#filter_directory-name">name</a>, <a href="#filter_directory-src">src</a>, <a href="#filter_directory-excludes">excludes</a>, <a href="#filter_directory-outdir_name">outdir_name</a>, <a href="#filter_directory-prefix">prefix</a>, <a href="#filter_directory-renames">renames</a>, <a href="#filter_directory-strip_prefix">strip_prefix</a>) +</pre> + +Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. + +Effective order of operations: + +1) Files are `exclude`d +2) `renames` _or_ `strip_prefix` is applied. +3) `prefix` is applied + +In particular, if a `rename` applies to an individual file, `strip_prefix` +will not be applied to that particular file. + +Each non-`rename``d path will look like this: + +``` +$OUTPUT_DIR/$PREFIX/$FILE_WITHOUT_STRIP_PREFIX +``` + +Each `rename`d path will look like this: + +``` +$OUTPUT_DIR/$PREFIX/$FILE_RENAMED +``` + +If an operation cannot be applied (`strip_prefix`) to any component in the +directory, or if one is unused (`exclude`, `rename`), the underlying command +will fail. See the individual attributes for details. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="filter_directory-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="filter_directory-src"></a>src | Directory (TreeArtifact) to process. | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="filter_directory-excludes"></a>excludes | Files to exclude from the output directory.<br><br>Each element must refer to an individual file in `src`.<br><br>All exclusions must be used. | List of strings | optional | `[]` | +| <a id="filter_directory-outdir_name"></a>outdir_name | Name of output directory (otherwise defaults to the rule's name) | String | optional | `""` | +| <a id="filter_directory-prefix"></a>prefix | Prefix to add to all paths in the output directory.<br><br>This does not include the output directory name, which will be added regardless. | String | optional | `""` | +| <a id="filter_directory-renames"></a>renames | Files to rename in the output directory.<br><br>Keys are destinations, values are sources prior to any path modifications (e.g. via `prefix` or `strip_prefix`). Files that are `exclude`d must not be renamed.<br><br>This currently only operates on individual files. `strip_prefix` does not apply to them.<br><br>All renames must be used. | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | `{}` | +| <a id="filter_directory-strip_prefix"></a>strip_prefix | Prefix to remove from all paths in the output directory.<br><br>Must apply to all paths in the directory, even those rename'd. | String | optional | `""` | + + +<a id="pkg_filegroup"></a> + +## pkg_filegroup + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup") + +pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-srcs">srcs</a>, <a href="#pkg_filegroup-prefix">prefix</a>) +</pre> + +Package contents grouping rule. + +This rule represents a collection of packaging specifications (e.g. those +created by `pkg_files`, `pkg_mklink`, etc.) that have something in common, +such as a prefix or a human-readable category. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_filegroup-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_filegroup-srcs"></a>srcs | A list of packaging specifications to be grouped together. | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | +| <a id="pkg_filegroup-prefix"></a>prefix | A prefix to prepend to provided paths, applied like so:<br><br>- For files and directories, this is simply prepended to the destination - For symbolic links, this is prepended to the "destination" part. | String | optional | `""` | + + +<a id="pkg_files"></a> + +## pkg_files + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_files") + +pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-include_runfiles">include_runfiles</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>) +</pre> + +General-purpose package target-to-destination mapping rule. + +This rule provides a specification for the locations and attributes of +targets when they are packaged. No outputs are created other than Providers +that are intended to be consumed by other packaging rules, such as +`pkg_rpm`. `pkg_files` targets may be consumed by other `pkg_files` or +`pkg_filegroup` to build up complex layouts, or directly by top level +packaging rules such as `pkg_files`. + +Consumers of `pkg_files`s will, where possible, create the necessary +directory structure for your files so you do not have to unless you have +special requirements. Consult `pkg_mkdirs` for more details. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_files-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_files-srcs"></a>srcs | Files/Labels to include in the outputs of these rules | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | +| <a id="pkg_files-attributes"></a>attributes | Attributes to set on packaged files.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the file's mode will be set to UNIX "0644", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details. | String | optional | `"{}"` | +| <a id="pkg_files-excludes"></a>excludes | List of files or labels to exclude from the inputs to this rule.<br><br>Mostly useful for removing files from generated outputs or preexisting `filegroup`s. | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional | `[]` | +| <a id="pkg_files-include_runfiles"></a>include_runfiles | Add runfiles for all srcs.<br><br>The runfiles are in the paths that Bazel uses. For example, for the target `//my_prog:foo`, we would see files under paths like `foo.runfiles/<repo name>/my_prog/<file>` | Boolean | optional | `False` | +| <a id="pkg_files-prefix"></a>prefix | Installation prefix.<br><br>This may be an arbitrary string, but it should be understandable by the packaging system you are using to have the desired outcome. For example, RPM macros like `%{_libdir}` may work correctly in paths for RPM packages, not, say, Debian packages.<br><br>If any part of the directory structure of the computed destination of a file provided to `pkg_filegroup` or any similar rule does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`).<br><br>It is possible to establish directory structures with arbitrary permissions using `pkg_mkdirs`. | String | optional | `""` | +| <a id="pkg_files-renames"></a>renames | Destination override map.<br><br>This attribute allows the user to override destinations of files in `pkg_file`s relative to the `prefix` attribute. Keys to the dict are source files/labels, values are destinations relative to the `prefix`, ignoring whatever value was provided for `strip_prefix`.<br><br>If the key refers to a TreeArtifact (directory output), you may specify the constant `REMOVE_BASE_DIRECTORY` as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the `prefix` and `strip_prefix` attributes), not the directory name.<br><br>The following keys are rejected:<br><br>- Any label that expands to more than one file (mappings must be one-to-one).<br><br>- Any label or file that was either not provided or explicitly `exclude`d.<br><br>The following values result in undefined behavior:<br><br>- "" (the empty string)<br><br>- "."<br><br>- Anything containing ".." | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional | `{}` | +| <a id="pkg_files-strip_prefix"></a>strip_prefix | What prefix of a file's path to discard prior to installation.<br><br>This specifies what prefix of an incoming file's path should not be included in the output package at after being appended to the install prefix (the `prefix` attribute). Note that this is only applied to full directory names, see `strip_prefix` for more details.<br><br>Use the `strip_prefix` struct to define this attribute. If this attribute is not specified, all directories will be stripped from all files prior to being included in packages (`strip_prefix.files_only()`).<br><br>If prefix stripping fails on any file provided in `srcs`, the build will fail.<br><br>Note that this only functions on paths that are known at analysis time. Specifically, this will not consider directories within TreeArtifacts (directory outputs), or the directories themselves. See also #269. | String | optional | `"."` | + + +<a id="pkg_mkdirs"></a> + +## pkg_mkdirs + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_mkdirs") + +pkg_mkdirs(<a href="#pkg_mkdirs-name">name</a>, <a href="#pkg_mkdirs-attributes">attributes</a>, <a href="#pkg_mkdirs-dirs">dirs</a>) +</pre> + +Defines creation and ownership of directories in packages + +Use this if: + +1) You need to create an empty directory in your package. + +2) Your package needs to explicitly own a directory, even if it already owns + files in those directories. + +3) You need nonstandard permissions (typically, not "0755") on a directory + in your package. + +For some package management systems (e.g. RPM), directory ownership (2) may +imply additional semantics. Consult your package manager's and target +distribution's documentation for more details. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_mkdirs-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_mkdirs-attributes"></a>attributes | Attributes to set on packaged directories.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the directory's mode will be set to UNIX "0755", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details. | String | optional | `"{}"` | +| <a id="pkg_mkdirs-dirs"></a>dirs | Directory names to make within the package<br><br>If any part of the requested directory structure does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`). | List of strings | required | | + + +<a id="pkg_mklink_impl"></a> + +## pkg_mklink_impl + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink_impl") + +pkg_mklink_impl(<a href="#pkg_mklink_impl-name">name</a>, <a href="#pkg_mklink_impl-attributes">attributes</a>, <a href="#pkg_mklink_impl-link_name">link_name</a>, <a href="#pkg_mklink_impl-target">target</a>) +</pre> + +Define a symlink within packages + +This rule results in the creation of a single link within a package. + +Symbolic links specified by this rule may point at files/directories outside of the +package, or otherwise left dangling. + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_mklink_impl-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_mklink_impl-attributes"></a>attributes | Attributes to set on packaged symbolic links.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>Symlink permissions may have different meanings depending on your host operating system; consult its documentation for more details.<br><br>If not otherwise overridden, the link's mode will be set to UNIX "0777", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details. | String | optional | `"{}"` | +| <a id="pkg_mklink_impl-link_name"></a>link_name | Link "destination", a path within the package.<br><br>This is the actual created symbolic link.<br><br>If the directory structure provided by this attribute is not otherwise created when exist within the package when it is built, it will be created implicitly, much like with `pkg_files`.<br><br>This path may be prefixed or rooted by grouping or packaging rules. | String | required | | +| <a id="pkg_mklink_impl-target"></a>target | Link "target", a path on the filesystem.<br><br>This is what the link "points" to, and may point to an arbitrary filesystem path, even relative paths. | String | required | | + + +<a id="pkg_attributes"></a> + +## pkg_attributes + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes") + +pkg_attributes(<a href="#pkg_attributes-mode">mode</a>, <a href="#pkg_attributes-user">user</a>, <a href="#pkg_attributes-group">group</a>, <a href="#pkg_attributes-uid">uid</a>, <a href="#pkg_attributes-gid">gid</a>, <a href="#pkg_attributes-kwargs">**kwargs</a>) +</pre> + +Format attributes for use in package mapping rules. + +If "mode" is not provided, it will default to the mapping rule's default +mode. These vary per mapping rule; consult the respective documentation for +more details. + +Not providing any of "user", "group", "uid", or "gid" will result in the package +builder choosing one for you. The chosen value should not be relied upon. + +Well-known attributes outside of the above are documented in the rules_pkg +reference. + +This is the only supported means of passing in attributes to package mapping +rules (e.g. `pkg_files`). + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| <a id="pkg_attributes-mode"></a>mode | string: UNIXy octal permissions, as a string. | `None` | +| <a id="pkg_attributes-user"></a>user | string: Filesystem owning user name. | `None` | +| <a id="pkg_attributes-group"></a>group | string: Filesystem owning group name. | `None` | +| <a id="pkg_attributes-uid"></a>uid | int: Filesystem owning user id. | `None` | +| <a id="pkg_attributes-gid"></a>gid | int: Filesystem owning group id. | `None` | +| <a id="pkg_attributes-kwargs"></a>kwargs | any other desired attributes. | none | + +**RETURNS** + +A value usable in the "attributes" attribute in package mapping rules. + + +<a id="pkg_mklink"></a> + +## pkg_mklink + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink") + +pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">link_name</a>, <a href="#pkg_mklink-target">target</a>, <a href="#pkg_mklink-attributes">attributes</a>, <a href="#pkg_mklink-src">src</a>, <a href="#pkg_mklink-kwargs">**kwargs</a>) +</pre> + +Create a symlink. + +Wraps [pkg_mklink_impl](#pkg_mklink_impl) + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| <a id="pkg_mklink-name"></a>name | target name | none | +| <a id="pkg_mklink-link_name"></a>link_name | the path in the package that should point to the target. | none | +| <a id="pkg_mklink-target"></a>target | target path that the link should point to. | none | +| <a id="pkg_mklink-attributes"></a>attributes | file attributes. | `None` | +| <a id="pkg_mklink-src"></a>src | - | `None` | +| <a id="pkg_mklink-kwargs"></a>kwargs | - | none | + + +<a id="strip_prefix.files_only"></a> + +## strip_prefix.files_only + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + +strip_prefix.files_only() +</pre> + + + + + +<a id="strip_prefix.from_pkg"></a> + +## strip_prefix.from_pkg + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + +strip_prefix.from_pkg(<a href="#strip_prefix.from_pkg-path">path</a>) +</pre> + + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| <a id="strip_prefix.from_pkg-path"></a>path | - | `""` | + + +<a id="strip_prefix.from_root"></a> + +## strip_prefix.from_root + +<pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + +strip_prefix.from_root(<a href="#strip_prefix.from_root-path">path</a>) +</pre> + + + +**PARAMETERS** + + +| Name | Description | Default Value | +| :------------- | :------------- | :------------- | +| <a id="strip_prefix.from_root-path"></a>path | - | `""` | + + + +<!-- Generated with Stardoc: http://skydoc.bazel.build --> + +Rules to create RPM archives. + +NOTE: this module is deprecated in favor of pkg/rpm_pfg.bzl. For more +information on the `pkg_filegroup` framework it uses, see pkg/mappings.bzl. + +pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will +find to convenient to use the one provided with their system. To enable that +toolchain add the following stanza to WORKSPACE: + + # Find rpmbuild if it exists. + load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild") + find_system_rpmbuild(name="rules_pkg_rpmbuild") + +<a id="pkg_rpm"></a> + +## pkg_rpm + +<pre> +load("@rules_pkg//pkg/legacy:rpm.bzl", "pkg_rpm") + +pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-data">data</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, + <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_file">spec_file</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>) +</pre> + +Legacy version + +**ATTRIBUTES** + + +| Name | Description | Type | Mandatory | Default | +| :------------- | :------------- | :------------- | :------------- | :------------- | +| <a id="pkg_rpm-name"></a>name | A unique name for this target. | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required | | +| <a id="pkg_rpm-data"></a>data | - | <a href="https://bazel.build/concepts/labels">List of labels</a> | required | | +| <a id="pkg_rpm-architecture"></a>architecture | - | String | optional | `"all"` | +| <a id="pkg_rpm-changelog"></a>changelog | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-debug"></a>debug | - | Boolean | optional | `False` | +| <a id="pkg_rpm-release"></a>release | - | String | optional | `""` | +| <a id="pkg_rpm-release_file"></a>release_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path | - | String | optional | `""` | +| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch | - | Integer | optional | `0` | +| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | +| <a id="pkg_rpm-spec_file"></a>spec_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | required | | +| <a id="pkg_rpm-version"></a>version | - | String | optional | `""` | +| <a id="pkg_rpm-version_file"></a>version_file | - | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` |
diff --git a/docs/_config.yml b/docs/_config.yml index c419263..277f1f2 100644 --- a/docs/_config.yml +++ b/docs/_config.yml
@@ -1 +1 @@ -theme: jekyll-theme-cayman \ No newline at end of file +theme: jekyll-theme-cayman
diff --git a/docs/_includes/head.html b/docs/_includes/head.html index 1b2b8fe..8ed7b52 100644 --- a/docs/_includes/head.html +++ b/docs/_includes/head.html
@@ -1,3 +1,3 @@ -<!-- _inclues/head.html --> +<!-- _includes/head.html --> <meta charset="utf-8"> <meta name="robots" content="noindex,nofollow">
diff --git a/docs/index.md b/docs/index.md index 89e83f6..b05174e 100644 --- a/docs/index.md +++ b/docs/index.md
@@ -16,7 +16,8 @@ consult more than one place to get a complete picture. * [Latest Snapshot at head](latest.md) -* [Version 1.0.0](1.0.0/reference.md) +* [Version 1.1.0](1.1.0/reference.md) +* [Version 1.0.1](1.0.1/reference.md) * [Version 0.10.0](0.10.0/reference.md) * [Version 0.9.1](0.9.1/reference.md) * [Version 0.8.0](0.8.0/reference.md)
diff --git a/docs/latest.md b/docs/latest.md index d2fb47f..edced5d 100755 --- a/docs/latest.md +++ b/docs/latest.md
@@ -1,4 +1,4 @@ -# rules_pkg - 1.0.1 +# rules_pkg - 1.1.0 <div class="toc"> <h2>Common Attributes</h2> @@ -90,6 +90,8 @@ ## pkg_deb <pre> +load("@rules_pkg//pkg/private/deb:deb.bzl", "pkg_deb") + pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>, <a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>, <a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>, <a href="#pkg_deb-license">license</a>, @@ -177,8 +179,10 @@ ## pkg_sub_rpm <pre> +load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_sub_rpm") + pkg_sub_rpm(<a href="#pkg_sub_rpm-name">name</a>, <a href="#pkg_sub_rpm-srcs">srcs</a>, <a href="#pkg_sub_rpm-architecture">architecture</a>, <a href="#pkg_sub_rpm-conflicts">conflicts</a>, <a href="#pkg_sub_rpm-description">description</a>, <a href="#pkg_sub_rpm-epoch">epoch</a>, <a href="#pkg_sub_rpm-group">group</a>, <a href="#pkg_sub_rpm-obsoletes">obsoletes</a>, <a href="#pkg_sub_rpm-package_name">package_name</a>, - <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>) + <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>) </pre> Define a sub RPM to be built as part of a parent RPM @@ -201,6 +205,7 @@ | <a id="pkg_sub_rpm-obsoletes"></a>obsoletes | List of RPM capability expressions that this package obsoletes | List of strings | optional | `[]` | | <a id="pkg_sub_rpm-package_name"></a>package_name | name of the subrpm | String | optional | `""` | | <a id="pkg_sub_rpm-post_scriptlet"></a>post_scriptlet | RPM `%post` scriplet for this subrpm | String | optional | `""` | +| <a id="pkg_sub_rpm-postun_scriptlet"></a>postun_scriptlet | RPM `%postun` scriplet for this subrpm | String | optional | `""` | | <a id="pkg_sub_rpm-provides"></a>provides | List of RPM capability expressions that this package provides | List of strings | optional | `[]` | | <a id="pkg_sub_rpm-requires"></a>requires | List of RPM capability expressions that this package requires | List of strings | optional | `[]` | | <a id="pkg_sub_rpm-summary"></a>summary | Sub RPM `Summary` tag | String | optional | `""` | @@ -227,6 +232,8 @@ ## pkg_rpm <pre> +load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_rpm") + pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-debuginfo">debuginfo</a>, <a href="#pkg_rpm-defines">defines</a>, <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-epoch">epoch</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>, <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>, <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>, @@ -332,12 +339,14 @@ ## pkg_tar <pre> +load("@rules_pkg//pkg/private/tar:tar.bzl", "pkg_tar") + pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-allow_duplicates_from_deps">allow_duplicates_from_deps</a>, - <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-create_parents">create_parents</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-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-stamp">stamp</a>, - <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>) + <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compression_level">compression_level</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, + <a href="#pkg_tar-create_parents">create_parents</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-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-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>) </pre> @@ -353,6 +362,7 @@ | <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/concepts/labels">Label</a> | required | | | <a id="pkg_tar-allow_duplicates_from_deps"></a>allow_duplicates_from_deps | - | Boolean | optional | `False` | | <a id="pkg_tar-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content | If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code. | Boolean | optional | `True` | +| <a id="pkg_tar-compression_level"></a>compression_level | Specify the numeric compression level in gzip mode; may be 0-9 or -1 (default to 6). | Integer | optional | `-1` | | <a id="pkg_tar-compressor"></a>compressor | External tool which can compress the archive. | <a href="https://bazel.build/concepts/labels">Label</a> | optional | `None` | | <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for `compressor`. | String | optional | `""` | | <a id="pkg_tar-create_parents"></a>create_parents | - | Boolean | optional | `True` | @@ -390,6 +400,8 @@ ## pkg_zip <pre> +load("@rules_pkg//pkg/private/zip:zip.bzl", "pkg_zip") + pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>, <a href="#pkg_zip-compression_type">compression_type</a>, <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>, <a href="#pkg_zip-package_variables">package_variables</a>, <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>) @@ -441,6 +453,8 @@ ## filter_directory <pre> +load("@rules_pkg//pkg:mappings.bzl", "filter_directory") + filter_directory(<a href="#filter_directory-name">name</a>, <a href="#filter_directory-src">src</a>, <a href="#filter_directory-excludes">excludes</a>, <a href="#filter_directory-outdir_name">outdir_name</a>, <a href="#filter_directory-prefix">prefix</a>, <a href="#filter_directory-renames">renames</a>, <a href="#filter_directory-strip_prefix">strip_prefix</a>) </pre> @@ -490,6 +504,8 @@ ## pkg_filegroup <pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup") + pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-srcs">srcs</a>, <a href="#pkg_filegroup-prefix">prefix</a>) </pre> @@ -514,6 +530,8 @@ ## pkg_files <pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_files") + pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-include_runfiles">include_runfiles</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>) </pre> @@ -550,6 +568,8 @@ ## pkg_mkdirs <pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_mkdirs") + pkg_mkdirs(<a href="#pkg_mkdirs-name">name</a>, <a href="#pkg_mkdirs-attributes">attributes</a>, <a href="#pkg_mkdirs-dirs">dirs</a>) </pre> @@ -584,6 +604,8 @@ ## pkg_mklink_impl <pre> +load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink_impl") + pkg_mklink_impl(<a href="#pkg_mklink_impl-name">name</a>, <a href="#pkg_mklink_impl-attributes">attributes</a>, <a href="#pkg_mklink_impl-link_name">link_name</a>, <a href="#pkg_mklink_impl-target">target</a>) </pre> @@ -610,7 +632,9 @@ ## pkg_attributes <pre> -pkg_attributes(<a href="#pkg_attributes-mode">mode</a>, <a href="#pkg_attributes-user">user</a>, <a href="#pkg_attributes-group">group</a>, <a href="#pkg_attributes-uid">uid</a>, <a href="#pkg_attributes-gid">gid</a>, <a href="#pkg_attributes-kwargs">kwargs</a>) +load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes") + +pkg_attributes(<a href="#pkg_attributes-mode">mode</a>, <a href="#pkg_attributes-user">user</a>, <a href="#pkg_attributes-group">group</a>, <a href="#pkg_attributes-uid">uid</a>, <a href="#pkg_attributes-gid">gid</a>, <a href="#pkg_attributes-kwargs">**kwargs</a>) </pre> Format attributes for use in package mapping rules. @@ -651,7 +675,9 @@ ## pkg_mklink <pre> -pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">link_name</a>, <a href="#pkg_mklink-target">target</a>, <a href="#pkg_mklink-attributes">attributes</a>, <a href="#pkg_mklink-src">src</a>, <a href="#pkg_mklink-kwargs">kwargs</a>) +load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink") + +pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">link_name</a>, <a href="#pkg_mklink-target">target</a>, <a href="#pkg_mklink-attributes">attributes</a>, <a href="#pkg_mklink-src">src</a>, <a href="#pkg_mklink-kwargs">**kwargs</a>) </pre> Create a symlink. @@ -677,6 +703,8 @@ ## strip_prefix.files_only <pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + strip_prefix.files_only() </pre> @@ -689,6 +717,8 @@ ## strip_prefix.from_pkg <pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + strip_prefix.from_pkg(<a href="#strip_prefix.from_pkg-path">path</a>) </pre> @@ -707,6 +737,8 @@ ## strip_prefix.from_root <pre> +load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") + strip_prefix.from_root(<a href="#strip_prefix.from_root-path">path</a>) </pre> @@ -741,6 +773,8 @@ ## pkg_rpm <pre> +load("@rules_pkg//pkg/legacy:rpm.bzl", "pkg_rpm") + pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-data">data</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_file">spec_file</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>) </pre>
diff --git a/docs/pkg_deb.md b/docs/pkg_deb.md index 6e7faa1..4fe1566 100755 --- a/docs/pkg_deb.md +++ b/docs/pkg_deb.md
@@ -79,5 +79,3 @@ | name | <p align="center"> - </p> | none | | archive_name | <p align="center"> - </p> | <code>None</code> | | kwargs | <p align="center"> - </p> | none | - -
diff --git a/examples/naming_package_files/MODULE.bazel b/examples/naming_package_files/MODULE.bazel index 3bc4f13..8186587 100644 --- a/examples/naming_package_files/MODULE.bazel +++ b/examples/naming_package_files/MODULE.bazel
@@ -3,10 +3,11 @@ version = "0.0.1", ) -# Temporarilly using WORKSPACE.bzlmod until CI switches to bazel past 7.0.0 -#local_path_override( -# module_name = "rules_pkg", -# path = "../..", -#) +bazel_dep(name = "rules_pkg") +local_path_override( + module_name = "rules_pkg", + path = "../..", +) -bazel_dep(name = "rules_cc", version = "0.0.2") +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.17")
diff --git a/examples/naming_package_files/WORKSPACE b/examples/naming_package_files/WORKSPACE deleted file mode 100644 index 0e5b0d9..0000000 --- a/examples/naming_package_files/WORKSPACE +++ /dev/null
@@ -1,33 +0,0 @@ -# Copyright 2020 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -workspace(name = "rules_pkg_examples") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -local_repository( - name = "rules_pkg", - path = "../..", -) - -load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies() - -http_archive( - name = "rules_cc", - sha256 = "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd", - strip_prefix = "rules_cc-b1c40e1de81913a3c40e5948f78719c28152486d", - url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip", -)
diff --git a/examples/naming_package_files/WORKSPACE.bzlmod b/examples/naming_package_files/WORKSPACE.bzlmod deleted file mode 100644 index ac785ff..0000000 --- a/examples/naming_package_files/WORKSPACE.bzlmod +++ /dev/null
@@ -1,8 +0,0 @@ -local_repository( - name = "rules_pkg", - path = "../..", -) - -load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies()
diff --git a/examples/naming_package_files/package_upload.bzl b/examples/naming_package_files/package_upload.bzl index a28dafa..ce29ecf 100644 --- a/examples/naming_package_files/package_upload.bzl +++ b/examples/naming_package_files/package_upload.bzl
@@ -31,7 +31,7 @@ debian_upload = rule( implementation = _debian_upload_impl, - doc = """A demonstraion of consuming OutputGroupInfo to get a file name.""", + doc = """A demonstration of consuming OutputGroupInfo to get a file name.""", attrs = { "package": attr.label( doc = "Package to upload",
diff --git a/examples/naming_package_files/readme.md b/examples/naming_package_files/readme.md index 14b3234..7d6da58 100644 --- a/examples/naming_package_files/readme.md +++ b/examples/naming_package_files/readme.md
@@ -87,7 +87,7 @@ name = "a_deb_package", package = "foo-tools", ... - # Note: target_cpu comes from the --cpu on the command line, and dows not + # Note: target_cpu comes from the --cpu on the command line, and does not # have to be stated in the BUILD file. package_file_name = "foo-tools_{version}-{revision}_{target_cpu}.deb", package_variables = ":my_naming_vars", @@ -104,4 +104,3 @@ lrwxrwxrwx 1 user primarygroup 163 Jul 26 12:56 bazel-bin/a_deb_package.deb -> /home/user/.cache/bazel/_bazel_user/.../execroot/rules_pkg_examples/bazel-out/k8-fastbuild/bin/foo-tools_1-2_k8.deb -r-xr-xr-x 1 user primarygroup 10662 Jul 26 12:56 bazel-bin/foo-tools_1-2_k8.deb ``` -
diff --git a/examples/rich_structure/BUILD b/examples/rich_structure/BUILD index dce188e..0ae868a 100644 --- a/examples/rich_structure/BUILD +++ b/examples/rich_structure/BUILD
@@ -22,7 +22,7 @@ # # This example shows various techniques for specifying how your source tree # transforms into the installation tree. As such, it favors using a lot of -# distict features, at the expense of uniformity. +# distinct features, at the expense of uniformity. pkg_files( name = "share_doc",
diff --git a/examples/rich_structure/MODULE.bazel b/examples/rich_structure/MODULE.bazel index e69de29..8186587 100644 --- a/examples/rich_structure/MODULE.bazel +++ b/examples/rich_structure/MODULE.bazel
@@ -0,0 +1,13 @@ +module( + name = "rules_pkg_examples", + version = "0.0.1", +) + +bazel_dep(name = "rules_pkg") +local_path_override( + module_name = "rules_pkg", + path = "../..", +) + +bazel_dep(name = "platforms", version = "0.0.10") +bazel_dep(name = "rules_cc", version = "0.0.17")
diff --git a/examples/rich_structure/README.md b/examples/rich_structure/README.md index ed800a0..c2e3de8 100644 --- a/examples/rich_structure/README.md +++ b/examples/rich_structure/README.md
@@ -46,5 +46,5 @@ move to `Library/Foo`. To emulate reality better, the source tree is organized in a way that is -convenient for the developers. This example illustrates techniques create +convenient for the developers. This example illustrates techniques to create the desired final structure.
diff --git a/examples/rich_structure/WORKSPACE b/examples/rich_structure/WORKSPACE deleted file mode 100644 index 4986594..0000000 --- a/examples/rich_structure/WORKSPACE +++ /dev/null
@@ -1,37 +0,0 @@ -# Copyright 2021 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -workspace(name = "rich_structure") - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -local_repository( - name = "rules_pkg", - path = "../..", -) - -load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies() - -http_archive( - name = "rules_cc", - sha256 = "2037875b9a4456dce4a79d112a8ae885bbc4aad968e6587dca6e64f3a0900cdf", - strip_prefix = "rules_cc-0.0.9", - urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.9/rules_cc-0.0.9.tar.gz"], -) - -load("@rules_cc//cc:repositories.bzl", "rules_cc_dependencies") - -rules_cc_dependencies()
diff --git a/examples/rich_structure/docs/index.md b/examples/rich_structure/docs/index.md index 29e7b82..dbfbf91 100644 --- a/examples/rich_structure/docs/index.md +++ b/examples/rich_structure/docs/index.md
@@ -1,4 +1,3 @@ # The foo system Some text -
diff --git a/examples/rich_structure/src/client/BUILD b/examples/rich_structure/src/client/BUILD index 9d9f545..e8b184b 100644 --- a/examples/rich_structure/src/client/BUILD +++ b/examples/rich_structure/src/client/BUILD
@@ -56,10 +56,9 @@ ":foo", ":fooctl", ], + include_runfiles = True, # Where it should be in the final package prefix = select(shared_object_path_selector) + "/bin", - # Should this work? - # runfiles_prefix = select(shared_object_path_selector) + "/bin/runfiles", ) pkg_files(
diff --git a/examples/rpm/debuginfo/BUILD b/examples/rpm/debuginfo/BUILD index 72dc80f..f760044 100644 --- a/examples/rpm/debuginfo/BUILD +++ b/examples/rpm/debuginfo/BUILD
@@ -13,16 +13,15 @@ # limitations under the License. # -*- coding: utf-8 -*- - load("@rules_pkg//pkg:mappings.bzl", "pkg_files") load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm") cc_binary( name = "test", - copts = ["-g"], srcs = [ "test.c", ], + copts = ["-g"], ) pkg_files( @@ -37,12 +36,12 @@ srcs = [ ":rpm_files", ], - release = "0", - version = "1", - license = "Some license", - summary = "Summary", - description = "Description", debuginfo = True, + description = "Description", + license = "Some license", + release = "0", + summary = "Summary", + version = "1", ) # If you have rpmbuild, you probably have rpm2cpio too.
diff --git a/examples/rpm/debuginfo/MODULE.bazel b/examples/rpm/debuginfo/MODULE.bazel index b2d8a8f..7e72ad2 100644 --- a/examples/rpm/debuginfo/MODULE.bazel +++ b/examples/rpm/debuginfo/MODULE.bazel
@@ -15,7 +15,6 @@ module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod") bazel_dep(name = "rules_pkg") - local_path_override( module_name = "rules_pkg", path = "../../..",
diff --git a/examples/rpm/nospecfile/BUILD b/examples/rpm/nospecfile/BUILD index 3cf1b3b..dd5e4ef 100644 --- a/examples/rpm/nospecfile/BUILD +++ b/examples/rpm/nospecfile/BUILD
@@ -30,18 +30,18 @@ srcs = [ ":rpm_files", ], - release = "0", - version = "1", - summary = "rules_pkg example RPM", + architecture = "x86_64", description = "This is a package description.", license = "Apache License, v2.0", - architecture = "x86_64", - requires = [ - "somerpm", - ], provides = [ "somefile", ], + release = "0", + requires = [ + "somerpm", + ], + summary = "rules_pkg example RPM", + version = "1", ) # If you have rpmbuild, you probably have rpm2cpio too.
diff --git a/examples/rpm/nospecfile/MODULE.bazel b/examples/rpm/nospecfile/MODULE.bazel index b2d8a8f..7e72ad2 100644 --- a/examples/rpm/nospecfile/MODULE.bazel +++ b/examples/rpm/nospecfile/MODULE.bazel
@@ -15,7 +15,6 @@ module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod") bazel_dep(name = "rules_pkg") - local_path_override( module_name = "rules_pkg", path = "../../..",
diff --git a/examples/rpm/prebuilt_rpmbuild/BUILD b/examples/rpm/prebuilt_rpmbuild/BUILD index 3f57592..8ba7ea8 100644 --- a/examples/rpm/prebuilt_rpmbuild/BUILD +++ b/examples/rpm/prebuilt_rpmbuild/BUILD
@@ -19,8 +19,8 @@ name = "test-rpm", data = [ "BUILD", - "WORKSPACE", "README.md", + "WORKSPACE", "test_rpm.spec", ], release = "0",
diff --git a/examples/rpm/subrpm/BUILD b/examples/rpm/subrpm/BUILD index 0da73ca..6737e6e 100644 --- a/examples/rpm/subrpm/BUILD +++ b/examples/rpm/subrpm/BUILD
@@ -14,7 +14,7 @@ # -*- coding: utf-8 -*- load("@rules_pkg//pkg:mappings.bzl", "pkg_files") -load("@rules_pkg//pkg:rpm.bzl", "pkg_sub_rpm", "pkg_rpm") +load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm", "pkg_sub_rpm") pkg_files( name = "subrpm_files", @@ -26,17 +26,17 @@ pkg_sub_rpm( name = "subrpm", package_name = "subrpm", - summary = "Test subrpm", - description = "Test subrpm description", - requires = [ - "somerpm", - ], - provides = [ - "someprovision", - ], srcs = [ ":subrpm_files", ], + description = "Test subrpm description", + provides = [ + "someprovision", + ], + requires = [ + "somerpm", + ], + summary = "Test subrpm", ) pkg_files( @@ -52,21 +52,21 @@ srcs = [ ":rpm_files", ], - release = "0", - version = "1", - summary = "rules_pkg example RPM", + architecture = "x86_64", description = "This is a package description.", license = "Apache License, v2.0", - architecture = "x86_64", - requires = [ - "somerpm", - ], provides = [ "somefile", ], + release = "0", + requires = [ + "somerpm", + ], subrpms = [ ":subrpm", ], + summary = "rules_pkg example RPM", + version = "1", ) # If you have rpmbuild, you probably have rpm2cpio too.
diff --git a/examples/rpm/subrpm/MODULE.bazel b/examples/rpm/subrpm/MODULE.bazel index b2d8a8f..7e72ad2 100644 --- a/examples/rpm/subrpm/MODULE.bazel +++ b/examples/rpm/subrpm/MODULE.bazel
@@ -15,7 +15,6 @@ module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod") bazel_dep(name = "rules_pkg") - local_path_override( module_name = "rules_pkg", path = "../../..",
diff --git a/examples/rpm/system_rpmbuild/BUILD b/examples/rpm/system_rpmbuild/BUILD index 3f57592..8ba7ea8 100644 --- a/examples/rpm/system_rpmbuild/BUILD +++ b/examples/rpm/system_rpmbuild/BUILD
@@ -19,8 +19,8 @@ name = "test-rpm", data = [ "BUILD", - "WORKSPACE", "README.md", + "WORKSPACE", "test_rpm.spec", ], release = "0",
diff --git a/examples/rpm/system_rpmbuild/WORKSPACE b/examples/rpm/system_rpmbuild/WORKSPACE index 9dac982..569f8b7 100644 --- a/examples/rpm/system_rpmbuild/WORKSPACE +++ b/examples/rpm/system_rpmbuild/WORKSPACE
@@ -28,4 +28,4 @@ "find_system_rpmbuild", ) -find_system_rpmbuild(name="my_rpmbuild") +find_system_rpmbuild(name = "my_rpmbuild")
diff --git a/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel b/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel index b2d8a8f..7e72ad2 100644 --- a/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel +++ b/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel
@@ -15,7 +15,6 @@ module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod") bazel_dep(name = "rules_pkg") - local_path_override( module_name = "rules_pkg", path = "../../..",
diff --git a/examples/time_stamping/MODULE.bazel b/examples/time_stamping/MODULE.bazel index e69de29..9145ba5 100644 --- a/examples/time_stamping/MODULE.bazel +++ b/examples/time_stamping/MODULE.bazel
@@ -0,0 +1,10 @@ +module( + name = "rules_pkg_examples", + version = "0.0.1", +) + +bazel_dep(name = "rules_pkg") +local_path_override( + module_name = "rules_pkg", + path = "../..", +)
diff --git a/examples/time_stamping/WORKSPACE b/examples/time_stamping/WORKSPACE deleted file mode 100644 index d170970..0000000 --- a/examples/time_stamping/WORKSPACE +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2021 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -workspace(name = "rules_pkg_examples") - -local_repository( - name = "rules_pkg", - path = "../..", -) - -load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies()
diff --git a/examples/time_stamping/readme.md b/examples/time_stamping/readme.md index 39d2edf..2903395 100644 --- a/examples/time_stamping/readme.md +++ b/examples/time_stamping/readme.md
@@ -13,7 +13,7 @@ ## Try this ``` -bazel build :* +bazel build :* for tarball in bazel-bin/*.tar ; do echo ==== $tarball tar tvf $tarball
diff --git a/examples/where_is_my_output/MODULE.bazel b/examples/where_is_my_output/MODULE.bazel index e69de29..9145ba5 100644 --- a/examples/where_is_my_output/MODULE.bazel +++ b/examples/where_is_my_output/MODULE.bazel
@@ -0,0 +1,10 @@ +module( + name = "rules_pkg_examples", + version = "0.0.1", +) + +bazel_dep(name = "rules_pkg") +local_path_override( + module_name = "rules_pkg", + path = "../..", +)
diff --git a/examples/where_is_my_output/WORKSPACE b/examples/where_is_my_output/WORKSPACE deleted file mode 100644 index e2cdda3..0000000 --- a/examples/where_is_my_output/WORKSPACE +++ /dev/null
@@ -1,24 +0,0 @@ -# Copyright 2021 The Bazel Authors. All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -workspace(name = "rich_structure") - -local_repository( - name = "rules_pkg", - path = "../..", -) - -load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies") - -rules_pkg_dependencies()
diff --git a/mappings.bzl b/mappings.bzl index 194529c..e2faf7a 100644 --- a/mappings.bzl +++ b/mappings.bzl
@@ -12,8 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""File mappings for packaging rules.""" + load( "//pkg:mappings.bzl", + _REMOVE_BASE_DIRECTORY = "REMOVE_BASE_DIRECTORY", _filter_directory = "filter_directory", _pkg_attributes = "pkg_attributes", _pkg_filegroup = "pkg_filegroup", @@ -21,7 +24,6 @@ _pkg_mkdirs = "pkg_mkdirs", _pkg_mklink = "pkg_mklink", _strip_prefix = "strip_prefix", - _REMOVE_BASE_DIRECTORY = "REMOVE_BASE_DIRECTORY", ) REMOVE_BASE_DIRECTORY = _REMOVE_BASE_DIRECTORY
diff --git a/pkg.bzl b/pkg.bzl index 8468062..ee4548e 100644 --- a/pkg.bzl +++ b/pkg.bzl
@@ -12,6 +12,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +"""Rules for manipulation of various packaging.""" + load("//pkg:deb.bzl", _pkg_deb = "pkg_deb") load("//pkg:tar.bzl", _pkg_tar = "pkg_tar") load("//pkg:zip.bzl", _pkg_zip = "pkg_zip")
diff --git a/pkg/.bazelignore b/pkg/.bazelignore index b856cd9..b05fe20 100644 --- a/pkg/.bazelignore +++ b/pkg/.bazelignore
@@ -1 +1 @@ -tests/external_project \ No newline at end of file +tests/external_project
diff --git a/pkg/BUILD b/pkg/BUILD index b3115f5..01d9994 100644 --- a/pkg/BUILD +++ b/pkg/BUILD
@@ -56,6 +56,7 @@ srcs = [ ":standard_package", "//pkg:pkg.bzl", + "//pkg:rpm_pfg.bzl", "//pkg/private:standard_package", "//pkg/private/deb:standard_package", "//pkg/private/tar:standard_package",
diff --git a/pkg/deps.bzl b/pkg/deps.bzl index 1fecfbf..e89ae6e 100644 --- a/pkg/deps.bzl +++ b/pkg/deps.bzl
@@ -23,36 +23,36 @@ def rules_pkg_dependencies(): http_archive( name = "bazel_skylib", - sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", + sha256 = "bc283cdfcd526a52c3201279cda4bc298652efa898b10b4db0837dc51652756f", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", + "https://github.com/bazelbuild/bazel-skylib/releases/download/1.7.1/bazel-skylib-1.7.1.tar.gz", ], ) http_archive( name = "platforms", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", - "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", + "https://github.com/bazelbuild/platforms/releases/download/0.0.10/platforms-0.0.10.tar.gz", ], - sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51", + sha256 = "218efe8ee736d26a3572663b374a253c012b716d8af0c07e842e82f238a0a7ee", ) http_archive( name = "rules_python", - sha256 = "0a8003b044294d7840ac7d9d73eef05d6ceb682d7516781a4ec62eeb34702578", - strip_prefix = "rules_python-0.24.0", - url = "https://github.com/bazelbuild/rules_python/releases/download/0.24.0/rules_python-0.24.0.tar.gz", + sha256 = "4f7e2aa1eb9aa722d96498f5ef514f426c1f55161c3c9ae628c857a7128ceb07", + strip_prefix = "rules_python-1.0.0", + url = "https://github.com/bazelbuild/rules_python/releases/download/1.0.0/rules_python-1.0.0.tar.gz", ) http_archive( name = "rules_license", urls = [ - "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz", - "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz", + "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz", + "https://github.com/bazelbuild/rules_license/releases/download/1.0.0/rules_license-1.0.0.tar.gz", ], - sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360", + sha256 = "26d4021f6898e23b82ef953078389dd49ac2b5618ac564ade4ef87cced147b38", ) def rules_pkg_register_toolchains():
diff --git a/pkg/make_rpm.py b/pkg/make_rpm.py index 3e1a3f7..7b44ed5 100644 --- a/pkg/make_rpm.py +++ b/pkg/make_rpm.py
@@ -178,6 +178,15 @@ RPMS_DIR = 'RPMS' DIRS = [SOURCE_DIR, BUILD_DIR, RPMS_DIR, TEMP_DIR] + # `debuginfo` RPM types as defined in `toolchains/rpm/rpmbuild_configure.bzl` + DEBUGINFO_TYPE_NONE = "none" + DEBUGINFO_TYPE_CENTOS = "centos" + DEBUGINFO_TYPE_FEDORA = "fedora" + SUPPORTED_DEBUGINFO_TYPES = { + DEBUGINFO_TYPE_CENTOS, + DEBUGINFO_TYPE_FEDORA, + } + def __init__(self, name, version, release, arch, rpmbuild_path, source_date_epoch=None, debug=False): @@ -362,7 +371,7 @@ if self.debug: args.append('-vv') - if debuginfo_type == "fedora40": + if debuginfo_type == RpmBuilder.DEBUGINFO_TYPE_FEDORA: os.makedirs(f'{dirname}/{RpmBuilder.BUILD_DIR}/{RpmBuilder.BUILD_SUBDIR}') # Common options @@ -375,13 +384,13 @@ '--define', '_builddir %s/BUILD' % dirname, ] - if debuginfo_type in ["fedora40", "centos7", "centos9", "almalinux9.3"]: + if debuginfo_type in RpmBuilder.SUPPORTED_DEBUGINFO_TYPES: args += ['--undefine', '_debugsource_packages'] - if debuginfo_type in ["centos7", "centos9", "almalinux9.3"]: + if debuginfo_type == RpmBuilder.DEBUGINFO_TYPE_CENTOS: args += ['--define', 'buildsubdir .'] - if debuginfo_type == "fedora40": + if debuginfo_type == RpmBuilder.DEBUGINFO_TYPE_FEDORA: args += ['--define', f'buildsubdir {RpmBuilder.BUILD_SUBDIR}'] args += [ @@ -399,7 +408,7 @@ if self.file_list_path: # %files -f is taken relative to the package root base_path = os.path.basename(self.file_list_path) - if debuginfo_type == "fedora40": + if debuginfo_type == RpmBuilder.DEBUGINFO_TYPE_FEDORA: base_path = os.path.join("..", base_path) args += ['--define', 'build_rpm_files %s' % base_path] @@ -556,30 +565,31 @@ parser.add_argument('--install_script', help='Installer script') parser.add_argument('--file_list', - help='File containing a list of files to include with rpm spec %files -f') + help='File containing a list of files to include with rpm spec %%files -f') parser.add_argument('--preamble', help='File containing the RPM Preamble') parser.add_argument('--description', - help='File containing the RPM %description text') + help='File containing the RPM %%description text') parser.add_argument('--subrpms', help='File containing the RPM subrpm details') parser.add_argument('--pre_scriptlet', - help='File containing the RPM %pre scriptlet, if to be substituted') + help='File containing the RPM %%pre scriptlet, if to be substituted') parser.add_argument('--post_scriptlet', - help='File containing the RPM %post scriptlet, if to be substituted') + help='File containing the RPM %%post scriptlet, if to be substituted') parser.add_argument('--preun_scriptlet', - help='File containing the RPM %preun scriptlet, if to be substituted') + help='File containing the RPM %%preun scriptlet, if to be substituted') parser.add_argument('--postun_scriptlet', - help='File containing the RPM %postun scriptlet, if to be substituted') + help='File containing the RPM %%postun scriptlet, if to be substituted') parser.add_argument('--posttrans_scriptlet', - help='File containing the RPM %posttrans scriptlet, if to be substituted') + help='File containing the RPM %%posttrans scriptlet, if to be substituted') parser.add_argument('--changelog', help='File containing the RPM changelog text') parser.add_argument('--rpmbuild_arg', dest='rpmbuild_args', action='append', help='Any additional arguments to pass to rpmbuild') - parser.add_argument('--debuginfo_type', dest='debuginfo_type', default='none', - help='debuginfo type to use (centos7, fedora40, or none)') + parser.add_argument('--debuginfo_type', default=RpmBuilder.DEBUGINFO_TYPE_NONE, + choices=sorted(RpmBuilder.SUPPORTED_DEBUGINFO_TYPES) + [RpmBuilder.DEBUGINFO_TYPE_NONE], + help='debuginfo type to use') parser.add_argument('files', nargs='*') options = parser.parse_args(argv or ())
diff --git a/pkg/mappings.bzl b/pkg/mappings.bzl index be863ec..9e7653a 100644 --- a/pkg/mappings.bzl +++ b/pkg/mappings.bzl
@@ -31,7 +31,7 @@ load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo") load("//pkg/private:util.bzl", "get_repo_mapping_manifest") -# TODO(#333): strip_prefix module functions should produce unique outputs. In +# TODO(#333): strip_prefix module functions should produce unique outputs. In # particular, this one and `_sp_from_pkg` can overlap. _PKGFILEGROUP_STRIP_ALL = "." @@ -43,14 +43,12 @@ def _sp_from_pkg(path = ""): if path.startswith("/"): return path[1:] - else: - return path + return path def _sp_from_root(path = ""): if path.startswith("/"): return path - else: - return "/" + path + return "/" + path strip_prefix = struct( _doc = """pkg_files `strip_prefix` helper. Instructs `pkg_files` what to do with directory prefixes of files. @@ -148,21 +146,20 @@ if path_norm.startswith(to_strip_norm): return path_norm[len(to_strip_norm):] - elif src_file.is_directory and (path_norm + "/") == to_strip_norm: + if src_file.is_directory and (path_norm + "/") == to_strip_norm: return "" - else: - # Avoid user surprise by failing if prefix stripping doesn't work as - # expected. - # - # We already leave enough breadcrumbs, so if File.owner() returns None, - # this won't be a problem. - failmsg = "Could not strip prefix '{}' from file {} ({})".format(to_strip, str(src_file), str(src_file.owner)) - if src_file.is_directory: - failmsg += """\n\nNOTE: prefix stripping does not operate within TreeArtifacts (directory outputs) + + # Avoid user surprise by failing if prefix stripping doesn't work as expected. + # + # We already leave enough breadcrumbs, so if File.owner() returns None, + # this won't be a problem. + failmsg = "Could not strip prefix '{}' from file {} ({})".format(to_strip, str(src_file), str(src_file.owner)) + if src_file.is_directory: + failmsg += """\n\nNOTE: prefix stripping does not operate within TreeArtifacts (directory outputs) To strip the directory named by the TreeArtifact itself, see documentation for the `renames` attribute. """ - fail(failmsg) + fail(failmsg) # The below routines make use of some path checking magic that may difficult to # understand out of the box. This following table may be helpful to demonstrate @@ -189,8 +186,7 @@ # File.owner returns a Label structure if file.owner == None: fail("File {} ({}) has no owner attribute; cannot continue".format(file, file.path)) - else: - return file.owner + return file.owner def _relative_workspace_root(label): # Helper function that returns the workspace root relative to the bazel File @@ -219,7 +215,7 @@ ) def _pkg_files_impl(ctx): - # The input sources are already known. Let's calculate the destinations... + # The input sources are already known. Let's calculate the destinations... # Exclude excludes srcs = [] # srcs is source File objects, not Targets @@ -263,7 +259,7 @@ # rename_src.files is a depset rename_src_files = rename_src.files.to_list() - # Need to do a length check before proceeding. We cannot rename + # Need to do a length check before proceeding. We cannot rename # multiple files simultaneously. if len(rename_src_files) != 1: fail( @@ -441,7 +437,7 @@ will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the `prefix` and `strip_prefix` attributes), not the directory name. - + The following keys are rejected: - Any label that expands to more than one file (mappings must be @@ -449,13 +445,13 @@ - Any label or file that was either not provided or explicitly `exclude`d. - + The following values result in undefined behavior: - "" (the empty string) - "." - + - Anything containing ".." """, @@ -808,14 +804,14 @@ doc = """Transform directories (TreeArtifacts) using pkg_filegroup-like semantics. Effective order of operations: - + 1) Files are `exclude`d 2) `renames` _or_ `strip_prefix` is applied. - 3) `prefix` is applied - + 3) `prefix` is applied + In particular, if a `rename` applies to an individual file, `strip_prefix` will not be applied to that particular file. - + Each non-`rename``d path will look like this: ``` @@ -823,11 +819,11 @@ ``` Each `rename`d path will look like this: - + ``` $OUTPUT_DIR/$PREFIX/$FILE_RENAMED ``` - + If an operation cannot be applied (`strip_prefix`) to any component in the directory, or if one is unused (`exclude`, `rename`), the underlying command will fail. See the individual attributes for details. @@ -858,11 +854,11 @@ ), "renames": attr.string_dict( doc = """Files to rename in the output directory. - + Keys are destinations, values are sources prior to any path modifications (e.g. via `prefix` or `strip_prefix`). Files that are `exclude`d must not be renamed. - + This currently only operates on individual files. `strip_prefix` does not apply to them. @@ -871,7 +867,7 @@ ), "excludes": attr.string_list( doc = """Files to exclude from the output directory. - + Each element must refer to an individual file in `src`. All exclusions must be used.
diff --git a/pkg/pkg.bzl b/pkg/pkg.bzl index 1f4ba20..e703cb7 100644 --- a/pkg/pkg.bzl +++ b/pkg/pkg.bzl
@@ -11,6 +11,7 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. + """Rules for manipulation of various packaging.""" load("//pkg/private/deb:deb.bzl", _pkg_deb = "pkg_deb")
diff --git a/pkg/private/build_info.py b/pkg/private/build_info.py index 6780623..8b8f3a0 100644 --- a/pkg/private/build_info.py +++ b/pkg/private/build_info.py
@@ -20,7 +20,7 @@ Reads a file of "name<space>value" pairs and returns the value of the BUILD_TIMESTAMP. The file should be in the workspace status format: https://docs.bazel.build/versions/master/user-manual.html#workspace_status - + Args: volatile_status_file: path to input file. Typically ctx.version_file.path. Returns:
diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py index 9d10c4b..84748c5 100644 --- a/pkg/private/deb/make_deb.py +++ b/pkg/private/deb/make_deb.py
@@ -59,6 +59,7 @@ ('Built-Using', False, False, None), ('Distribution', False, False, 'unstable'), ('Urgency', False, False, 'medium'), + ('Multi-Arch', False, False), ] # size of chunks for copying package content to final .deb file @@ -407,7 +408,9 @@ priority=options.priority, conflicts=options.conflicts, breaks=options.breaks, - installedSize=helpers.GetFlagValue(options.installed_size)) + installedSize=helpers.GetFlagValue(options.installed_size), + multiArch=helpers.GetFlagValue(options.multi_arch) + ) CreateChanges( output=options.changes, deb_file=options.output,
diff --git a/pkg/private/install.py.tpl b/pkg/private/install.py.tpl index 93c3967..ddd6dfe 100644 --- a/pkg/private/install.py.tpl +++ b/pkg/private/install.py.tpl
@@ -23,6 +23,7 @@ import pathlib import shutil import sys +import tempfile from pkg.private import manifest @@ -79,7 +80,19 @@ def _do_file_copy(self, src, dest): logging.debug("COPY %s <- %s", dest, src) - shutil.copyfile(src, dest) + # Copy to a temporary file and then move it to the destination. + # This ensures code-signed executables on certain platforms + # behave correctly. + # See: https://developer.apple.com/documentation/security/updating-mac-software + # Use `dir` to ensure the temporary file is created on the same file system as the destination, + # to avoid cross-filesystem replace which is an error on some platforms. + with tempfile.NamedTemporaryFile(delete=False, dir=os.path.dirname(dest)) as tmp_file: + try: + shutil.copyfile(src, tmp_file.name) + os.replace(tmp_file.name, dest) + except: + pathlib.Path(tmp_file.name).unlink(missing_ok=True) + raise def _do_mkdir(self, dirname, mode): logging.debug("MKDIR %s %s", mode, dirname)
diff --git a/pkg/private/pkg_files.bzl b/pkg/private/pkg_files.bzl index d8e4477..55fa497 100644 --- a/pkg/private/pkg_files.bzl +++ b/pkg/private/pkg_files.bzl
@@ -394,6 +394,7 @@ data_path: path to package data_path_without_prefix: path to the package after prefix stripping include_runfiles: Include runfiles + workspace_name: name of the main workspace """ if not DefaultInfo in src: return @@ -544,7 +545,7 @@ def add_symlink(mapping_context, dest_path, src, origin): """Add a symlink to the content map. - TODO(aiuto): This is a vestage left from the pkg_tar use. We could + TODO(aiuto): This is a vestige left from the pkg_tar use. We could converge code by having pkg_tar be a macro that expands symlinks to pkg_symlink targets and srcs them in.
diff --git a/pkg/private/tar/build_tar.py b/pkg/private/tar/build_tar.py index adaa781..4b858e5 100644 --- a/pkg/private/tar/build_tar.py +++ b/pkg/private/tar/build_tar.py
@@ -74,7 +74,7 @@ # paths should not have a leading ./ if dest.startswith('./'): dest = dest[2:] - # No path should ever come in with slashs on either end, but protect + # No path should ever come in with slashes on either end, but protect # against that anyway. dest = dest.strip('/') # This prevents a potential problem for users with both a prefix_dir and
diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl index a6d6844..29539a6 100644 --- a/pkg/private/tar/tar.bzl +++ b/pkg/private/tar/tar.bzl
@@ -259,8 +259,8 @@ "symlinks": attr.string_dict(), "empty_files": attr.string_list(), "include_runfiles": attr.bool( - doc = ("""Include runfiles for executables. These appear as they would in bazel-bin.""" - + """For example: 'path/to/myprog.runfiles/path/to/my_data.txt'."""), + doc = ("""Include runfiles for executables. These appear as they would in bazel-bin.""" + + """For example: 'path/to/myprog.runfiles/path/to/my_data.txt'."""), ), "empty_dirs": attr.string_list(), "remap_paths": attr.string_dict(),
diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py index 06d0cad..6c0d926 100644 --- a/pkg/private/tar/tar_writer.py +++ b/pkg/private/tar/tar_writer.py
@@ -102,12 +102,12 @@ self.name = name self.tar = tarfile.open(name=name, mode=mode, fileobj=self.fileobj, - format=tarfile.GNU_FORMAT) + format=tarfile.GNU_FORMAT) self.members = set() self.directories = set() # Preseed the added directory list with things we should not add. If we # some day need to allow '.' or '/' as an explicit member of the archive, - # we can adjust that here based on the setting of root_dirctory. + # we can adjust that here based on the setting of root_directory. self.directories.add('/') self.directories.add('./') self.create_parents = create_parents @@ -130,9 +130,12 @@ if not info.name.endswith('/'): info.name += '/' if not self.allow_dups_from_deps and self._have_added(info.name): + # Directories with different contents should get merged without warnings. + # If they have overlapping content, the warning will be on their duplicate *files* instead + if info.type != tarfile.DIRTYPE: print('Duplicate file in archive: %s, ' 'picking first occurrence' % info.name) - return + return self.tar.addfile(info, fileobj) self.members.add(info.name) @@ -344,4 +347,3 @@ if self.compressor_proc and self.compressor_proc.wait() != 0: raise self.Error('Custom compression command ' '"{}" failed'.format(self.compressor_cmd)) -
diff --git a/pkg/rpm.bzl b/pkg/rpm.bzl index c9d9e3b..6f42976 100644 --- a/pkg/rpm.bzl +++ b/pkg/rpm.bzl
@@ -49,6 +49,7 @@ name: rule name srcs: pkg_rpm_pfg `srcs` attribute spec_file: pkg_rpm_legacy `spec_file` attribute + subrpms: pkg_rpm_pfg `subrpms` attribute **kwargs: arguments to either `pkg_rpm_pfg` or `pkg_rpm_legacy`, depending on mode @@ -66,7 +67,7 @@ pkg_rpm_pfg( name = name, srcs = srcs, - subrpms = subrpms, + subrpms = subrpms, **kwargs ) elif spec_file:
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl index cf6cb6b..9f4adcc 100644 --- a/pkg/rpm_pfg.bzl +++ b/pkg/rpm_pfg.bzl
@@ -26,6 +26,11 @@ """ load( + "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", + "DEBUGINFO_TYPE_FEDORA", + "DEBUGINFO_TYPE_NONE", +) +load( "//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", @@ -47,6 +52,7 @@ "group": "RPM subpackage `Group` tag", "description": "Multi-line description of this subpackage", "post_scriptlet": "RPM `$post` scriplet for this subpackage", + "postun_scriptlet": "RPM `$postun` scriplet for this subpackage", "architecture": "Subpackage architecture", "epoch": "RPM `Epoch` tag for this subpackage", "version": "RPM `Version` tag for this subpackage", @@ -175,7 +181,7 @@ # this can be inlined easily. return path if path.startswith(("/", "%")) else "/" + path -def _make_rpm_filename(rpm_name, version, architecture, package_name=None, release=None): +def _make_rpm_filename(rpm_name, version, architecture, package_name = None, release = None): prefix = "%s-%s" items = [rpm_name, version] @@ -185,7 +191,7 @@ if release: prefix += "-%s" - items += [release] + items.append(release) fmt = prefix + ".%s.rpm" @@ -222,7 +228,7 @@ rpm_ctx.rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dest)) install_stanza_fmt = _INSTALL_FILE_STANZA_FMT - if debuginfo_type == "fedora40": + if debuginfo_type == DEBUGINFO_TYPE_FEDORA: install_stanza_fmt = _INSTALL_FILE_STANZA_FMT_FEDORA40_DEBUGINFO rpm_ctx.install_script_pieces.append(install_stanza_fmt.format( @@ -315,7 +321,7 @@ dep.label, file_base, rpm_ctx, - debuginfo_type + debuginfo_type, ) for entry, origin in pfg_info.pkg_dirs: file_base = _make_filetags(entry.attributes, "%dir") @@ -350,26 +356,29 @@ "Summary: %s" % rpm_info.summary, ] + if rpm_info.group: + rpm_lines.append("Group: %s" % rpm_info.group) + if rpm_info.architecture: - rpm_lines += ["BuildArch: %s" % rpm_info.architecture] + rpm_lines.append("BuildArch: %s" % rpm_info.architecture) if rpm_info.epoch: - rpm_lines += ["Epoch: %s" % rpm_info.epoch] + rpm_lines.append("Epoch: %s" % rpm_info.epoch) if rpm_info.version: - rpm_lines += ["Version: %s" % rpm_info.version] + rpm_lines.append("Version: %s" % rpm_info.version) for r in rpm_info.requires: - rpm_lines += ["Requires: %s" % r] + rpm_lines.append("Requires: %s" % r) for p in rpm_info.provides: - rpm_lines += ["Provides: %s" % p] + rpm_lines.append("Provides: %s" % p) for c in rpm_info.conflicts: - rpm_lines += ["Conflicts: %s" % c] + rpm_lines.append("Conflicts: %s" % c) for o in rpm_info.obsoletes: - rpm_lines += ["Obsoletes: %s" % o] + rpm_lines.append("Obsoletes: %s" % o) rpm_lines += [ "", @@ -381,6 +390,14 @@ rpm_lines += [ "", "%%post %s" % rpm_info.package_name, + rpm_info.post_scriptlet, + ] + + if rpm_info.postun_scriptlet: + rpm_lines += [ + "", + "%%postun %s" % rpm_info.package_name, + rpm_info.postun_scriptlet, ] if rpm_info.srcs: @@ -394,10 +411,10 @@ # rpmbuild will be unhappy if we have no files so we stick # default file mode in for that scenario - rpm_lines += [DEFAULT_FILE_MODE] + rpm_lines.append(DEFAULT_FILE_MODE) rpm_lines += sub_rpm_ctx.rpm_files_list - rpm_lines += [""] + rpm_lines.append("") rpm_ctx.install_script_pieces.extend(sub_rpm_ctx.install_script_pieces) rpm_ctx.packaged_directories.extend(sub_rpm_ctx.packaged_directories) @@ -458,7 +475,7 @@ files = [] tools = [] - debuginfo_type = "none" + debuginfo_type = DEBUGINFO_TYPE_NONE name = ctx.attr.package_name if ctx.attr.package_name else ctx.label.name rpm_ctx.make_rpm_args.append("--name=" + name) @@ -726,7 +743,12 @@ subrpm_lines = [] for s in ctx.attr.subrpms: subrpm_lines.extend(_process_subrpm( - ctx, rpm_name, s[PackageSubRPMInfo], rpm_ctx, debuginfo_type)) + ctx, + rpm_name, + s[PackageSubRPMInfo], + rpm_ctx, + debuginfo_type, + )) subrpm_file = ctx.actions.declare_file( "{}.spec.subrpms".format(rpm_name), @@ -738,9 +760,10 @@ files.append(subrpm_file) rpm_ctx.make_rpm_args.append("--subrpms=" + subrpm_file.path) - if debuginfo_type != "none": + if debuginfo_type != DEBUGINFO_TYPE_NONE: debuginfo_default_file = ctx.actions.declare_file( - "{}-debuginfo.rpm".format(rpm_name)) + "{}-debuginfo.rpm".format(rpm_name), + ) debuginfo_package_file_name = _make_rpm_filename( rpm_name, ctx.attr.version, @@ -757,7 +780,8 @@ rpm_ctx.output_rpm_files.append(debuginfo_output_file) rpm_ctx.make_rpm_args.append( - "--subrpm_out_file=debuginfo:%s" % debuginfo_output_file.path ) + "--subrpm_out_file=debuginfo:%s" % debuginfo_output_file.path, + ) #### Procedurally-generated scripts/lists (%install, %files) @@ -1292,6 +1316,7 @@ group = ctx.attr.group, description = ctx.attr.description, post_scriptlet = ctx.attr.post_scriptlet, + postun_scriptlet = ctx.attr.postun_scriptlet, architecture = ctx.attr.architecture, epoch = ctx.attr.epoch, version = ctx.attr.version, @@ -1329,6 +1354,7 @@ ), "description": attr.string(doc = "Multi-line description of this subrpm"), "post_scriptlet": attr.string(doc = "RPM `%post` scriplet for this subrpm"), + "postun_scriptlet": attr.string(doc = "RPM `%postun` scriplet for this subrpm"), "architecture": attr.string(doc = "Sub RPM architecture"), "epoch": attr.string(doc = "RPM `Epoch` tag for this subrpm"), "version": attr.string(doc = "RPM `Version` tag for this subrpm"),
diff --git a/pkg/verify_archive.bzl b/pkg/verify_archive.bzl index d132d49..89d054b 100644 --- a/pkg/verify_archive.bzl +++ b/pkg/verify_archive.bzl
@@ -23,6 +23,21 @@ load("@rules_python//python:defs.bzl", "py_test") +# Attribute names common to all build rules. See https://bazel.build/reference/be/common-definitions +COMMON_BUILD_ATTR_NAMES = [ + "tags", + "target_compatible_with", + "testonly", + "visibility", +] + +# Attribute names common to all test rules. See https://bazel.build/reference/be/common-definitions#common-attributes-tests +COMMON_TEST_ATTR_NAMES = COMMON_BUILD_ATTR_NAMES + [ + "size", + "timeout", + "flaky", +] + def _gen_verify_archive_test_main_impl(ctx): ctx.actions.expand_template( template = ctx.file._template, @@ -95,8 +110,8 @@ must_not_contain_regex = None, min_size = 1, max_size = -1, - tags = None, - verify_links = None): + verify_links = None, + **kwargs): """Tests that an archive contains specific file patterns. This test is used to verify that an archive contains the expected content. @@ -109,8 +124,9 @@ 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. + **kwargs: The args to be passed to the underlying rules, if supported. + See https://github.com/bazelbuild/rules_pkg/blob/main/pkg/verify_archive.bzl for the full list. """ test_src = name + "__internal_main.py" _gen_verify_archive_test_main( @@ -124,8 +140,8 @@ must_not_contain_regex = must_not_contain_regex, min_size = min_size, max_size = max_size, - tags = tags, verify_links = verify_links, + **{key: kwargs[key] for key in COMMON_BUILD_ATTR_NAMES if key in kwargs} ) py_test( name = name, @@ -133,4 +149,5 @@ main = test_src, data = [target], python_version = "PY3", + **{key: kwargs[key] for key in COMMON_TEST_ATTR_NAMES if key in kwargs} )
diff --git a/pkg/verify_archive_test_main.py.tpl b/pkg/verify_archive_test_main.py.tpl index f831ecb..f0b9719 100644 --- a/pkg/verify_archive_test_main.py.tpl +++ b/pkg/verify_archive_test_main.py.tpl
@@ -96,13 +96,12 @@ if r_comp.match(path): matched = True break - if not match: + if not matched: self.fail('Did not find pattern (%s) in the archive' % pattern) def check_must_not_contain_regex(self, must_not_contain_regex): for pattern in must_not_contain_regex: r_comp = re.compile(pattern) - matched = False for path in self.paths: if r_comp.match(path): self.fail('Found disallowed pattern (%s) in the archive' % pattern) @@ -134,10 +133,10 @@ def test_must_not_contain(self): self.check_must_not_contain(${MUST_NOT_CONTAIN}) - def test_must_not_contain(self): + def test_must_contain_regex(self): self.check_must_contain_regex(${MUST_CONTAIN_REGEX}) - def test_must_not_contain(self): + def test_must_not_contain_regex(self): self.check_must_not_contain_regex(${MUST_NOT_CONTAIN_REGEX}) def test_verify_links(self):
diff --git a/tests/mappings/BUILD b/tests/mappings/BUILD index e913c0b..8d6b7b6 100644 --- a/tests/mappings/BUILD +++ b/tests/mappings/BUILD
@@ -12,6 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +load("@rules_python//python:defs.bzl", "py_library") load( "//pkg:mappings.bzl", "pkg_attributes", @@ -27,8 +28,6 @@ "mappings_analysis_tests", "mappings_unit_tests", ) -load("@rules_python//python:defs.bzl", "py_library") - package(default_applicable_licenses = ["//:license"])
diff --git a/tests/mappings/external_repo/MODULE.bazel b/tests/mappings/external_repo/MODULE.bazel new file mode 100644 index 0000000..0137c38 --- /dev/null +++ b/tests/mappings/external_repo/MODULE.bazel
@@ -0,0 +1,45 @@ +# Copyright 2025 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +module( + name = "test_external_project", + version = "0", + compatibility_level = 0, +) + +local_path_override( + module_name = "rules_pkg", + path = "../../../", +) + +bazel_dep(name = "rules_license", version = "1.0.0") +bazel_dep(name = "rules_python", version = "1.0.0") +bazel_dep(name = "bazel_skylib", version = "1.7.1") + +######################################### +# Do not update to newer versions until you need a specific new feature. + +# Only for development +#bazel_dep(name = "platforms", version = "0.0.10", dev_dependency = True) +#bazel_dep(name = "rules_cc", version = "0.0.17", dev_dependency = True) +#bazel_dep(name = "stardoc", version = "0.7.2", dev_dependency = True) +# +## Find the system rpmbuild if one is available. +#find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True) +#use_repo(find_rpm, "rules_pkg_rpmbuild") +# +#register_toolchains( +# "@rules_pkg_rpmbuild//:all", +# dev_dependency = True, +#)
diff --git a/tests/mappings/mappings_external_repo_test.bzl b/tests/mappings/mappings_external_repo_test.bzl index 7b9b0ac..acf28ee 100644 --- a/tests/mappings/mappings_external_repo_test.bzl +++ b/tests/mappings/mappings_external_repo_test.bzl
@@ -132,7 +132,7 @@ # file, but then have it consumed by some remote package. "@mappings_test_external_repo//pkg:pf_local_file_in_extrepo", # This test is more focused around the verify_archive_test repo but is still - # based on using someting from another repo. In particular, ensuring the + # based on using something from another repo. In particular, ensuring the # verify_archive_test macro can be called properly from a workspace outside # of the main one. "@mappings_test_external_repo//pkg:external_archive_test",
diff --git a/tests/mappings/mappings_test.bzl b/tests/mappings/mappings_test.bzl index 235a71c..27a61cb 100644 --- a/tests/mappings/mappings_test.bzl +++ b/tests/mappings/mappings_test.bzl
@@ -60,7 +60,6 @@ expected_dests = {e: None for e in ctx.attr.expected_dests} actual_dests = target_under_test[PackageFilesInfo].dest_src_map.keys() - n_found = 0 for actual in actual_dests: asserts.true(
diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD index 1ed11d3..1146158 100644 --- a/tests/rpm/BUILD +++ b/tests/rpm/BUILD
@@ -128,9 +128,13 @@ ############################################################################ _POST_SCRIPTLET = "echo post" + _POSTUN_SCRIPTLET = "echo postun" + _PRE_SCRIPTLET = "echo pre" + _PREUN_SCRIPTLET = "echo preun" + _POSTTRANS_SCRIPTLET = "echo posttrans" [ @@ -153,6 +157,7 @@ ############################################################################ _VERSION = "1.1.1" + _RELEASE = "2222" genrule( @@ -181,10 +186,10 @@ description = """pkg_rpm test rpm description""", license = "Apache 2.0", post_scriptlet = _POST_SCRIPTLET, + posttrans_scriptlet = _POSTTRANS_SCRIPTLET, postun_scriptlet = _POSTUN_SCRIPTLET, pre_scriptlet = _PRE_SCRIPTLET, preun_scriptlet = _PREUN_SCRIPTLET, - posttrans_scriptlet = _POSTTRANS_SCRIPTLET, provides = ["test"], release = _RELEASE, requires = ["test-lib > 1.0"], @@ -206,10 +211,10 @@ description = """pkg_rpm test rpm description""", license = "Apache 2.0", post_scriptlet = _POST_SCRIPTLET, + posttrans_scriptlet = _POSTTRANS_SCRIPTLET, postun_scriptlet = _POSTUN_SCRIPTLET, pre_scriptlet = _PRE_SCRIPTLET, preun_scriptlet = _PREUN_SCRIPTLET, - posttrans_scriptlet = _POSTTRANS_SCRIPTLET, provides = ["test"], release = _RELEASE, requires = ["test-lib > 1.0"], @@ -234,10 +239,10 @@ description = """pkg_rpm test rpm description""", license = "Apache 2.0", post_scriptlet = _POST_SCRIPTLET, + posttrans_scriptlet = _POSTTRANS_SCRIPTLET, postun_scriptlet = _POSTUN_SCRIPTLET, pre_scriptlet = _PRE_SCRIPTLET, preun_scriptlet = _PREUN_SCRIPTLET, - posttrans_scriptlet = _POSTTRANS_SCRIPTLET, provides = ["test"], release = _RELEASE, requires = ["test-lib > 1.0"], @@ -258,10 +263,10 @@ description = """pkg_rpm test rpm description""", license = "Apache 2.0", post_scriptlet_file = ":post", + posttrans_scriptlet_file = ":posttrans", postun_scriptlet_file = ":postun", pre_scriptlet_file = ":pre", preun_scriptlet_file = ":preun", - posttrans_scriptlet_file = ":posttrans", provides = ["test"], release = "2222", requires = ["test-lib > 1.0"], @@ -283,10 +288,10 @@ epoch = "1", license = "Apache 2.0", post_scriptlet_file = ":post", + posttrans_scriptlet_file = ":posttrans", postun_scriptlet_file = ":postun", pre_scriptlet_file = ":pre", preun_scriptlet_file = ":preun", - posttrans_scriptlet_file = ":posttrans", provides = ["test"], release_file = ":release_file", requires = ["test-lib > 1.0"], @@ -308,10 +313,10 @@ epoch = "1", license = "Apache 2.0", post_scriptlet = _POST_SCRIPTLET, + posttrans_scriptlet = _POSTTRANS_SCRIPTLET, postun_scriptlet = _POSTUN_SCRIPTLET, pre_scriptlet = _PRE_SCRIPTLET, preun_scriptlet = _PREUN_SCRIPTLET, - posttrans_scriptlet = _POSTTRANS_SCRIPTLET, provides = ["test"], release = _RELEASE, requires = ["test-lib > 1.0"], @@ -429,11 +434,11 @@ ":test_rpm", ":test_rpm_bzip2", ":test_rpm_direct", + ":test_rpm_epoch", ":test_rpm_manifest", ":test_rpm_metadata", - ":test_rpm_scriptlets_files", ":test_rpm_release_version_files", - ":test_rpm_epoch", + ":test_rpm_scriptlets_files", ], ) @@ -510,21 +515,23 @@ pkg_sub_rpm( name = "sub_rpm", package_name = "test_sub_rpm", - description = "Test subrpm description", - summary = "Test subrpm", srcs = [ ":test_sub_rpm_files", ], + description = "Test subrpm description", + summary = "Test subrpm", ) pkg_sub_rpm( name = "sub_rpm2", package_name = "test_sub_rpm2", - description = "Test subrpm2 description", - summary = "Test subrpm2", srcs = [ ":test_sub_rpm_files", ], + description = "Test subrpm2 description", + post_scriptlet = "echo post", + postun_scriptlet = "echo postun", + summary = "Test subrpm2", ) genrule( @@ -542,19 +549,19 @@ pkg_rpm( name = "test_sub_rpm_main", - description = "This is a package description.", - summary = "rules_pkg example RPM", - architecture = "noarch", - version = "1", - license = "Apache License, v2.0", - release = "0", srcs = [ ":test_sub_rpm_main_files", ], + architecture = "noarch", + description = "This is a package description.", + license = "Apache License, v2.0", + release = "0", subrpms = [ ":sub_rpm", ":sub_rpm2", ], + summary = "rules_pkg example RPM", + version = "1", ) genrule( @@ -565,13 +572,13 @@ # pkg_rpm emits two outputs RPMS=($(SRCS)) echo "===== main RPM =====" > $@ - rpm -qpi --list $${RPMS[0]} | \ + rpm -qpi --scripts --list $${RPMS[0]} | \ grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' >> $@ echo "===== sub RPM ======" >> $@ - rpm -qpi --list $${RPMS[1]} | \ + rpm -qpi --scripts --list $${RPMS[1]} | \ grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' >> $@ echo "===== sub RPM ======" >> $@ - rpm -qpi --list $${RPMS[2]} | \ + rpm -qpi --scripts --list $${RPMS[2]} | \ grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' >> $@ """, ) @@ -587,10 +594,10 @@ ############################################################################ cc_binary( name = "test_debuginfo", - copts = ["-g"], srcs = [ "test.c", ], + copts = ["-g"], ) pkg_files( @@ -602,15 +609,15 @@ pkg_rpm( name = "test_debuginfo_rpm", - srcs = [ + srcs = [ ":test_debuginfo_rpm_files", ], - release = "0", - version = "1", - license = "Some license", - summary = "Summary", - description = "Description", debuginfo = True, + description = "Description", + license = "Some license", + release = "0", + summary = "Summary", + version = "1", ) genrule(
diff --git a/tests/rpm/rpm_util.py b/tests/rpm/rpm_util.py index 5655fc5..fe27ad3 100644 --- a/tests/rpm/rpm_util.py +++ b/tests/rpm/rpm_util.py
@@ -66,8 +66,8 @@ - FILENAMES -> path (file absolute path) - FILEDIGESTS -> digest (hash of file. MD5 for compatibility) - - FILEUSERNAME -> user (UNIX owning user) - - FILEGROUPNAME -> group (UNIX owning group) + - FILEUSERNAME -> user (UNIX owning user) + - FILEGROUPNAME -> group (UNIX owning group) - FILEMODES:octal -> mode (UNIX mode, as an octal string) - FILEFLAGS:fflags -> fflags (RPM file flags as a string, see upstream documentation) - FILELINKTOS -> Symlink target, or nothing (something "falsy") if not provided
diff --git a/tests/rpm/test_sub_rpm_contents.txt.golden b/tests/rpm/test_sub_rpm_contents.txt.golden index 5daa5c0..526a40a 100755 --- a/tests/rpm/test_sub_rpm_contents.txt.golden +++ b/tests/rpm/test_sub_rpm_contents.txt.golden
@@ -42,4 +42,8 @@ Summary : Test subrpm2 Description : Test subrpm2 description +postinstall scriptlet (using /bin/sh): +echo post +postuninstall scriptlet (using /bin/sh): +echo postun /test_sub_rpm_file_input.txt
diff --git a/tests/tar/BUILD b/tests/tar/BUILD index cc5d72d..7801320 100644 --- a/tests/tar/BUILD +++ b/tests/tar/BUILD
@@ -93,9 +93,9 @@ pkg_tar( name = "test-respect-externally-defined-duplicates", - deps = ["//tests:testdata/duplicate_entries.tar"], - create_parents = False, allow_duplicates_from_deps = True, + create_parents = False, + deps = ["//tests:testdata/duplicate_entries.tar"], ) # @@ -290,7 +290,7 @@ "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/$", + ".*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 = [ @@ -330,9 +330,9 @@ fake_artifact( name = "a_program", + executable = True, files = ["//tests:testdata/executable.sh"], runfiles = ["BUILD"], - executable = True, ) pkg_tar( @@ -346,7 +346,6 @@ verify_archive_test( name = "runfiles_test", - target = ":test-tar-with-runfiles", must_contain = [ "a_program", "a_program.runfiles/_main/tests/tar/BUILD", @@ -363,8 +362,9 @@ "an_executable.runfiles/_main/tests/foo.cc", "an_executable.runfiles/_main/tests/an_executable", "an_executable.runfiles/_main/tests/testdata/hello.txt", - ] + ], }), + target = ":test-tar-with-runfiles", ) pkg_tar( @@ -464,6 +464,10 @@ ":test-pkg-tar-with-attributes", ":test-remap-paths-tree-artifact", ":test-respect-externally-defined-duplicates.tar", + ":test-tar-compression_level--1", + ":test-tar-compression_level-3", + ":test-tar-compression_level-6", + ":test-tar-compression_level-9", ":test-tar-empty_dirs.tar", ":test-tar-empty_files.tar", ":test-tar-files_dict.tar", @@ -477,10 +481,6 @@ ":test-tar-strip_prefix-substring.tar", ":test-tar-tree-artifact", ":test-tar-tree-artifact-noroot", - ":test-tar-compression_level--1", - ":test-tar-compression_level-3", - ":test-tar-compression_level-6", - ":test-tar-compression_level-9", ":test-tree-input-with-strip-prefix", ":test_tar_leading_dotslash", ":test_tar_package_dir_substitution.tar", @@ -722,6 +722,7 @@ "new/base/something/this": "that", }, ) + fake_artifact( name = "program_with_dir_runfiles", files = ["//tests:testdata/executable.sh"], @@ -764,8 +765,13 @@ [pkg_tar( name = "test-tar-compression_level-%s" % compression_level, compression_level = compression_level, + extension = "tgz", deps = [ "//tests:testdata/tar_test.tar", ], - extension = "tgz", -) for compression_level in [-1, 3, 6, 9]] +) for compression_level in [ + -1, + 3, + 6, + 9, +]]
diff --git a/tests/verify_archive/BUILD b/tests/verify_archive/BUILD new file mode 100644 index 0000000..dabdade --- /dev/null +++ b/tests/verify_archive/BUILD
@@ -0,0 +1,69 @@ +# Copyright 2025 The Bazel Authors. All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# -*- coding: utf-8 -*- +"""Tests for verify_archive.""" + +load("//pkg:tar.bzl", "pkg_tar") +load("//pkg:verify_archive.bzl", "verify_archive_test") + +# Test data + +pkg_tar( + name = "loremipsum_tar", + srcs = [ + "//tests:loremipsum_txt", + ], +) + +pkg_tar( + name = "loremipsum_tar_test_only", + testonly = True, + srcs = [ + "//tests:loremipsum_txt", + ], +) + +# Test cases + +verify_archive_test( + name = "test_py_test_attrs_is_allowed", + size = "small", + timeout = "moderate", + flaky = True, + target = ":loremipsum_tar", +) + +verify_archive_test( + name = "test_testonly_is_allowed", + testonly = True, + target = ":loremipsum_tar_test_only", +) + +verify_archive_test( + name = "test_visibility_is_allowed", + target = ":loremipsum_tar", + visibility = ["//visibility:private"], +) + +verify_archive_test( + name = "test_target_compatible_with_is_allowed", + target = ":loremipsum_tar", + target_compatible_with = ["@platforms//cpu:x86_64"], +) + +verify_archive_test( + name = "test_tags_are_allowed", + tags = ["test_tag"], + target = ":loremipsum_tar", +)
diff --git a/toolchains/rpm/BUILD b/toolchains/rpm/BUILD index 58ec5db..ae9e615 100644 --- a/toolchains/rpm/BUILD +++ b/toolchains/rpm/BUILD
@@ -33,7 +33,10 @@ srcs = glob([ "*", ]), - visibility = ["//distro:__pkg__"], + visibility = [ + "//distro:__pkg__", + "//doc_build:__pkg__", + ], ) exports_files(
diff --git a/toolchains/rpm/BUILD.tpl b/toolchains/rpm/BUILD.tpl index 5045bff..ca78929 100644 --- a/toolchains/rpm/BUILD.tpl +++ b/toolchains/rpm/BUILD.tpl
@@ -15,7 +15,7 @@ ) toolchain( - name = "zzz_rpmbuild_missing_toolchain", # keep name lexigraphically last + name = "zzz_rpmbuild_missing_toolchain", # keep name lexicographically last toolchain = "@rules_pkg//toolchains/rpm:no_rpmbuild", toolchain_type = "@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type", )
diff --git a/toolchains/rpm/rpmbuild.bzl b/toolchains/rpm/rpmbuild.bzl index 7cb4459..1b68c45 100644 --- a/toolchains/rpm/rpmbuild.bzl +++ b/toolchains/rpm/rpmbuild.bzl
@@ -60,7 +60,7 @@ doc = """ The underlying debuginfo configuration for the system rpmbuild. - One of centos7, fedora40, or none + One of `centos`, `fedora`, and `none` """, default = "none", ),
diff --git a/toolchains/rpm/rpmbuild_configure.bzl b/toolchains/rpm/rpmbuild_configure.bzl index 067333c..ffa4519 100644 --- a/toolchains/rpm/rpmbuild_configure.bzl +++ b/toolchains/rpm/rpmbuild_configure.bzl
@@ -57,19 +57,21 @@ return os_name, os_version -KNOWN_DEBUGINFO_VERSIONS = { - "almalinux": ["9.3"], - "centos": ["7", "9"], - "fedora": ["40"], +DEBUGINFO_TYPE_NONE = "none" +DEBUGINFO_TYPE_CENTOS = "centos" +DEBUGINFO_TYPE_FEDORA = "fedora" + +DEBUGINFO_TYPE_BY_OS_RELEASE = { + "almalinux": DEBUGINFO_TYPE_CENTOS, + "centos": DEBUGINFO_TYPE_CENTOS, + "fedora": DEBUGINFO_TYPE_FEDORA, } def _build_repo_for_rpmbuild_toolchain_impl(rctx): - debuginfo_type = "none" + debuginfo_type = DEBUGINFO_TYPE_NONE if rctx.path(RELEASE_PATH).exists: - os_name, os_version = _parse_release_info(rctx.read(RELEASE_PATH)) - if (os_name in KNOWN_DEBUGINFO_VERSIONS and - os_version in KNOWN_DEBUGINFO_VERSIONS[os_name]): - debuginfo_type = os_name + os_version + os_name, _ = _parse_release_info(rctx.read(RELEASE_PATH)) + debuginfo_type = DEBUGINFO_TYPE_BY_OS_RELEASE.get(os_name, debuginfo_type) rpmbuild_path = rctx.which("rpmbuild") if rctx.attr.verbose: @@ -110,7 +112,7 @@ doc = """ The underlying debuginfo configuration for the system rpmbuild. - One of centos7, fedora40, or none + One of `centos`, `fedora`, and `none` """, default = "none", ),
diff --git a/version.bzl b/version.bzl index 62b7ee1..d15d342 100644 --- a/version.bzl +++ b/version.bzl
@@ -13,4 +13,4 @@ # limitations under the License. """The version of rules_pkg.""" -version = "1.0.1" +version = "1.1.0"