summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-04-04 12:55:45 -0700
committerYifan Hong <elsk@google.com>2024-04-04 13:01:58 -0700
commit280d0f73a5da007297eb87dae0222470442599de (patch)
treed8cb4ccd312a62d49a6b8bb39bef02ed368faea8
parent429887dfd8db834498ad95e99043f771a3882af0 (diff)
parentd7ff3e6e52937fdeefbd41d91c54806488ef1c5f (diff)
downloadbazelbuild-rules_pkg-280d0f73a5da007297eb87dae0222470442599de.tar.gz
Upgrade rules_pkg to 0.10.1
This project was upgraded with external_updater. Usage: tools/external_updater/updater.sh update external/bazelbuild-rules_pkg For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md Update changelog and version numbers. (#819) Temporarily restore //mappings.bzl and //pkg.bzl (#817) Fix RPM package release and version files expansion (#816) Apply tar remap_paths to runfiles full paths (#812) Update build_tar.py doc and changelog update to go with 0.10.0 (#809) Fill out the CI matrix to cover the bazels that people use. (#807) Explicitly set the FILE bit in zip external attributes. (#804) Allow substitution of user-defined variables in RPM preamble (#787) update docs Add %posttrans scriptlet to RPM package (#799) Allow additional RPM macro defines (#794) back off try stardoc again Fall back to WORKSPACE.bzlmod for examples/naming. Something about a local_repository in MODULE.bazel and bazel 7.0.0 is wonky. turn off doc building in CI Explicitly set `%{_builddir}` macro (#792) Update CODEOWNERS (#791) Bring tar runfiles up to feature parity with pkg_files.runfiles. (#754) Only inject pre and post scriptlets when provided (#788) chore: suppress buildifier lint warnings (#776) CI fixes (#784) Add yun as CI owner (#785) Little fixes to stop lint warnings (#783) Add support for `Obsoletes` tag in RPM definition (#778) fix the imports on the filter directory test (#782) Don't load cc toolchain from rules_cc (#779) doc: Fixup external manual references (#777) chore: buildifier format all files (#775) chore: add a pre-commit hook config (#774) Refactor all the input processing code. (#756) Get bzlmod working in CI (#766) use runfiles from rules_python (#768) Use rules_cc to try to clean up CI runs which are failing on gcc (#764) When pkg_tar.prefix_dir == base of symlink path, don't double-dip. (#749) add imports to fix bazel --noexperimental_python_import_all_repositories flag (#630) Align pkg_rpm returned files with other rules (#692) pkg_deb: allow data.tar.zst (#761) fix(pkg_tar): properly normalize paths for empty files (#760) Add fixed releaser to because this will be done by a bot. (#757) remove --incompatible_use_platforms_repo_for_constraints from ci run (#755) Clean up some nits (#751) chore: update versions of dependencies (#730) Add support for failing on file conflicts. (#683) Remove PackageArtifactsInfo. (#752) Document that package_dir also uses package_variables (#747) include verify_archive_test_main.py.tpl in the distribution (#735) buildifier lint fixes (#744) make build_tar priavte (#748) pkg_tar remap_paths works for TreeArtifacts (bazelbuild#450) (#738) add docs for 0.9 (#740) update docs Fix handling paths with whitepsaces (#733) Add logging and extend doc Fix test on python 3.6 Fix python 3.6, doesn't support compresslevel Make pkg_zip compression configurable Append changelog to RPM spec file (#726) Fix pkg_deb changelog flag getter (#734) Add basic include_runfiles to pkg_files. (#724) Add changelog attribute to pkg_deb (#725) chore: automate publishing releases to BCR (#722) bump platforms because bazel at head requires it. sigh Use Gzip compress level 6 (#720) remove a ling to trtigger build Update CODEOWNERS (#721) default uid and guid on process_src to None fix load(py_library) => load(py_binary) remove unneeded py_binary load write debian Date field in UTC rather than local time (#712) fix import in rpm test. (#713) Create scorecard.yml (#710) Merge verify_archive_test_lib with verify_archive_test_main.py.tpl (#705) Add a MODULE.bazel hint to the release not generator (#709) docs: add a note in pkg_tar#strip_prefix docs (v.0.8.0) about flattening (#699) [pkg_deb] Fix multiline fields in changes file (#691) Add a check to ensure that version.bzl and MODULE.bazel remain in sync. (#697) Fix typos in doc strings in `verify_archive.bzl` (#700) fix working dir on integration tests (#701) Add support for setting uid/gid from pkg_attributes (#671) Fix spelling mistakes (#695) Remove top level .bzl files. They are all in //pkg. (#688) Replace reference to bazel-dev with GitHub Discussions. Test: TreeHugger Bug: 324907235 Change-Id: I921d16c3d7b6fdc7e6fbff25788caea704eefcb1
-rw-r--r--.bazelci/examples_naming.yml4
-rw-r--r--.bazelci/examples_rich_structure.yml2
-rw-r--r--.bazelci/examples_stamping.yml2
-rw-r--r--.bazelci/integration.yml24
-rw-r--r--.bazelci/tests.yml129
-rw-r--r--.bcr/README.md9
-rw-r--r--.bcr/config.yml3
-rw-r--r--.bcr/metadata.template.json12
-rw-r--r--.bcr/presubmit.yml17
-rw-r--r--.bcr/source.template.json4
-rw-r--r--.github/workflows/scorecard.yml72
-rw-r--r--.gitignore1
-rw-r--r--.pre-commit-config.yaml12
-rw-r--r--BUILD2
-rw-r--r--CHANGELOG.md87
-rw-r--r--CODEOWNERS17
-rw-r--r--METADATA19
-rw-r--r--MODULE.bazel16
-rw-r--r--README.md43
-rw-r--r--WORKSPACE17
-rw-r--r--WORKSPACE.bzlmod16
-rw-r--r--distro/BUILD8
-rw-r--r--distro/packaging_test.py21
-rw-r--r--doc_build/BUILD21
-rw-r--r--doc_build/common.md6
-rwxr-xr-xdoc_build/merge.py4
-rwxr-xr-xdocs/0.10.0/reference.md726
-rwxr-xr-xdocs/0.8.0/reference.md2
-rwxr-xr-xdocs/0.9.1/reference.md689
-rw-r--r--docs/index.md2
-rwxr-xr-xdocs/latest.md127
-rw-r--r--examples/naming_package_files/BUILD8
-rw-r--r--examples/naming_package_files/MODULE.bazel9
-rw-r--r--examples/naming_package_files/WORKSPACE2
-rw-r--r--examples/naming_package_files/WORKSPACE.bzlmod8
-rw-r--r--examples/naming_package_files/my_package_name.bzl7
-rw-r--r--examples/prebuilt_rpmbuild/test_rpm.spec2
-rw-r--r--examples/rich_structure/BUILD2
-rw-r--r--examples/rich_structure/WORKSPACE13
-rw-r--r--examples/rich_structure/docs/BUILD5
-rw-r--r--examples/rich_structure/resources/l10n/BUILD1
-rw-r--r--examples/rich_structure/src/client/BUILD1
-rw-r--r--examples/rich_structure/src/server/BUILD2
-rw-r--r--examples/time_stamping/BUILD4
-rw-r--r--examples/where_is_my_output/README.md2
-rw-r--r--examples/where_is_my_output/WORKSPACE2
-rw-r--r--examples/where_is_my_output/show_all_outputs.bzl12
-rw-r--r--install.bzl20
-rw-r--r--package_variables.bzl18
-rw-r--r--patching.md4
-rw-r--r--pkg/BUILD11
-rw-r--r--pkg/deps.bzl48
-rw-r--r--pkg/install.bzl30
-rw-r--r--pkg/legacy/rpm.bzl38
-rw-r--r--pkg/legacy/tests/rpm/test_rpm.spec2
-rw-r--r--pkg/make_rpm.py32
-rw-r--r--pkg/mappings.bzl123
-rw-r--r--pkg/package_variables.bzl4
-rw-r--r--pkg/path.bzl26
-rw-r--r--pkg/private/BUILD4
-rw-r--r--pkg/private/deb/BUILD2
-rw-r--r--pkg/private/deb/deb.bzl122
-rw-r--r--pkg/private/deb/make_deb.py51
-rw-r--r--pkg/private/helpers.py2
-rw-r--r--pkg/private/install.py.tpl2
-rw-r--r--pkg/private/manifest.py6
-rw-r--r--pkg/private/pkg_files.bzl397
-rw-r--r--pkg/private/tar/BUILD6
-rw-r--r--pkg/private/tar/build_tar.py22
-rw-r--r--pkg/private/tar/tar.bzl179
-rw-r--r--pkg/private/tar/tar_writer.py2
-rw-r--r--pkg/private/util.bzl18
-rw-r--r--pkg/private/zip/BUILD3
-rw-r--r--pkg/private/zip/build_zip.py52
-rw-r--r--pkg/private/zip/zip.bzl74
-rw-r--r--pkg/providers.bzl2
-rw-r--r--pkg/releasing/BUILD6
-rw-r--r--pkg/releasing/defs.bzl5
-rw-r--r--pkg/releasing/git.bzl3
-rw-r--r--pkg/releasing/print_rel_notes.py6
-rw-r--r--pkg/releasing/release_tools_test.py2
-rw-r--r--pkg/rpm.bzl4
-rw-r--r--pkg/rpm/augment_rpm_files_install.py14
-rw-r--r--pkg/rpm/template.spec.tpl4
-rw-r--r--pkg/rpm_pfg.bzl127
-rw-r--r--pkg/verify_archive.bzl40
-rw-r--r--pkg/verify_archive_test_lib.py107
-rw-r--r--pkg/verify_archive_test_main.py.tpl106
-rw-r--r--providers.bzl29
-rw-r--r--rpm.bzl18
-rw-r--r--tests/BUILD35
-rw-r--r--tests/a.cc1
-rw-r--r--tests/archive_test.py2
-rw-r--r--tests/b.cc1
-rw-r--r--tests/deb/BUILD14
-rw-r--r--tests/deb/control_field_test.py16
-rw-r--r--tests/deb/pkg_deb_test.py30
-rw-r--r--tests/foo.cc21
-rw-r--r--tests/install/BUILD1
-rw-r--r--tests/install/test.py2
-rw-r--r--tests/mappings/BUILD30
-rw-r--r--tests/mappings/all.manifest.golden8
-rw-r--r--tests/mappings/executable.manifest.golden10
-rw-r--r--tests/mappings/executable.manifest.windows.golden8
-rw-r--r--tests/mappings/external_repo/pkg/BUILD19
-rw-r--r--tests/mappings/external_repo/pkg/test.bzl4
-rw-r--r--tests/mappings/filter_directory/BUILD8
-rw-r--r--tests/mappings/filter_directory/inspect_directory.py.tpl2
-rw-r--r--tests/mappings/filter_directory/test_filter_directory.py18
-rw-r--r--tests/mappings/glob_for_texts_manifest.golden8
-rw-r--r--tests/mappings/manifest_test_lib.py56
-rw-r--r--tests/mappings/mappings_external_repo_test.bzl11
-rw-r--r--tests/mappings/mappings_test.bzl20
-rwxr-xr-xtests/mappings/node_modules_manifest.golden14
-rw-r--r--tests/mappings/utf8_manifest.golden12
-rw-r--r--tests/path_test.bzl5
-rw-r--r--tests/rpm/BUILD137
-rw-r--r--tests/rpm/analysis_tests.bzl68
-rw-r--r--tests/rpm/pkg_rpm_basic_test.py50
-rw-r--r--tests/rpm/source_date_epoch/BUILD4
-rw-r--r--tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py2
-rw-r--r--tests/rpm/template-test.spec.tpl2
-rw-r--r--tests/rpm/toolchain_tests.bzl1
-rw-r--r--tests/rpm/tree_artifacts/BUILD6
-rw-r--r--tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py2
-rw-r--r--tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py2
-rw-r--r--tests/stamp_test.py2
-rw-r--r--tests/tar/BUILD298
-rw-r--r--tests/tar/is_compressed_test.py2
-rw-r--r--tests/tar/pkg_tar_test.py48
-rw-r--r--tests/tar/tar_writer_test.py2
-rw-r--r--tests/util/defs.bzl28
-rw-r--r--tests/zip/BUILD49
-rw-r--r--tests/zip/zip_test.py30
-rw-r--r--tests/zip/zip_test_lib.py10
-rw-r--r--toolchains/git/BUILD2
-rw-r--r--toolchains/git/git_configure.bzl19
-rw-r--r--toolchains/rpm/BUILD2
-rw-r--r--toolchains/rpm/BUILD.tpl6
-rw-r--r--toolchains/rpm/rpmbuild.bzl1
-rw-r--r--toolchains/rpm/rpmbuild_configure.bzl27
-rw-r--r--version.bzl2
142 files changed, 3902 insertions, 1221 deletions
diff --git a/.bazelci/examples_naming.yml b/.bazelci/examples_naming.yml
index e6dac9d..0f55f60 100644
--- a/.bazelci/examples_naming.yml
+++ b/.bazelci/examples_naming.yml
@@ -5,7 +5,7 @@ common: &common
tasks:
centos7:
- platform: centos7
+ platform: centos7_java11_devtoolset10
<<: *common
ubuntu1804:
platform: ubuntu1804
@@ -20,5 +20,5 @@ tasks:
name: bzlmod
platform: ubuntu1804
build_flags:
- - "--experimental_enable_bzlmod"
+ - "--enable_bzlmod"
<<: *common
diff --git a/.bazelci/examples_rich_structure.yml b/.bazelci/examples_rich_structure.yml
index adbfce1..e6f2d17 100644
--- a/.bazelci/examples_rich_structure.yml
+++ b/.bazelci/examples_rich_structure.yml
@@ -5,7 +5,7 @@ common: &common
tasks:
centos7:
- platform: centos7
+ platform: centos7_java11_devtoolset10
<<: *common
ubuntu1804:
platform: ubuntu1804
diff --git a/.bazelci/examples_stamping.yml b/.bazelci/examples_stamping.yml
index 59e1d9c..0eebfaa 100644
--- a/.bazelci/examples_stamping.yml
+++ b/.bazelci/examples_stamping.yml
@@ -5,7 +5,7 @@ common: &common
tasks:
centos7:
- platform: centos7
+ platform: centos7_java11_devtoolset10
<<: *common
ubuntu1804:
platform: ubuntu1804
diff --git a/.bazelci/integration.yml b/.bazelci/integration.yml
index 07aebca..11b04d4 100644
--- a/.bazelci/integration.yml
+++ b/.bazelci/integration.yml
@@ -1,23 +1,17 @@
-lts: &lts
- bazel: latest
-
-rolling: &rolling
- bazel: rolling
-
+# These test the packaging of the product itself.
+# They only have to run on linux with a recent bazel
common: &common
- platform: ubuntu1804
- working_directory: /workdir
+ working_directory: ..
build_targets:
- - "distro:*"
+ - "//doc_build:all"
+ - "//distro/..."
tasks:
- rolling_ubuntu:
+ integration:
name: rolling_distro
- <<: *rolling
- <<: *common
- lts_ubuntu:
- name: lts_distro
platform: ubuntu1804
- <<: *lts
+ bazel: rolling
+ build_flags:
+ - "--noenable_bzlmod"
<<: *common
diff --git a/.bazelci/tests.yml b/.bazelci/tests.yml
index bc997e6..bd5ae61 100644
--- a/.bazelci/tests.yml
+++ b/.bazelci/tests.yml
@@ -1,19 +1,23 @@
+# These tests check the run-time behavior under various combinations
+#
+# - Tests: behavior only. release tools are in the integration tests
+# - Platforms: ubuntu, centos, macos, windows
+# - bzlmod enabled or not
+# - bazel: LTS-1, LTS, rolling
+#
+#
+
common: &common
working_directory: ..
-#
-# Bazel releases
-#
-lts: &lts
- bazel: latest
+bzlmod: &bzlmod
+ build_flags:
+ - "--enable_bzlmod"
-rolling: &rolling
- bazel: rolling
+nobzlmod: &nobzlmod
build_flags:
- - "--incompatible_use_platforms_repo_for_constraints"
- # Do this after stardoc is updated
- # - "--incompatible_disable_starlark_host_transitions"
+ - "--noenable_bzlmod"
#
# Groups of tests, by platform
@@ -22,7 +26,6 @@ rolling: &rolling
# rpmbuild(8) is not available or installed on most platforms
default_tests: &default_tests
test_targets:
- - "//distro/..."
- "//pkg/..."
- "//tests/..."
- "//toolchains/..."
@@ -31,12 +34,15 @@ default_tests: &default_tests
default_tests_with_rpm: &default_tests_with_rpm
test_targets:
- - "//distro/..."
- "//pkg/..."
- "//tests/..."
- "//toolchains/..."
win_tests: &win_tests
+ test_flags:
+ - "--test_tag_filters=-nowindows"
+ build_flags:
+ - "--build_tag_filters=-nowindows"
test_targets:
- "//pkg/..."
- "//tests/..."
@@ -55,19 +61,15 @@ win_tests: &win_tests
- "-//pkg/legacy/tests/rpm/..."
#
-# Commmon features by platform
+# Commmon features and tests by platform
#
ubuntu1804: &ubuntu
platform: ubuntu1804
<<: *common
<<: *default_tests
- build_targets:
- - "//distro:distro"
- - "//distro:relnotes"
- - "//doc_build:*"
centos7: &centos
- platform: centos7
+ platform: centos7_java11_devtoolset10
<<: *common
<<: *default_tests_with_rpm
@@ -85,32 +87,73 @@ windows: &windows
# Finally, the cross product of bazel releases X platforms
#
tasks:
- rolling_ubuntu:
- name: rolling_ubuntu
+ ub_head_bzlmod:
+ name: ub_head_bzlmod
+ bazel: rolling
<<: *ubuntu
- <<: *rolling
- rolling_macos:
- name: rolling_macos
- <<: *macos
- # It seems there is no rolling Bazel for macos.
- bazel: last_green
- rolling_windows:
- name: rolling_windows
- <<: *windows
- <<: *rolling
- lts_centos:
- name: lts_centos
+ <<: *bzlmod
+
+ ub_head_nobzlmod:
+ name: ub_head_nobzlmod
+ bazel: rolling
+ <<: *ubuntu
+ <<: *nobzlmod
+
+ ub_lts_bzlmod:
+ name: ub_lts_bzlmod
+ bazel: latest
+ <<: *ubuntu
+ <<: *bzlmod
+
+ ub_lts_nobzlmod:
+ name: ub_lts_nobzlmod
+ bazel: latest
+ <<: *ubuntu
+ <<: *nobzlmod
+
+ ub_lts1_nobzlmod:
+ name: ub_lts1_nobzlmod
+ bazel: latest-1
+ <<: *ubuntu
+ <<: *nobzlmod
+
+ cent_lts:
+ name: cent_lts
+ bazel: latest
<<: *centos
- <<: *lts
- lts_macos:
- name: lts_macos
+
+ mac_head_bzlmod:
+ name: mac_head_bzlmod
+ bazel: rolling
<<: *macos
- <<: *lts
- lts_ubuntu:
- name: lts_ubuntu
- <<: *ubuntu
- <<: *lts
- lts_windows:
- name: lts_windows
+ <<: *bzlmod
+
+ mac_lts_bzlmod:
+ name: mac_lts_bzlmod
+ bazel: latest
+ <<: *macos
+ <<: *bzlmod
+
+ mac_lts_nobzlmod:
+ name: mac_lts_nobzlmod
+ bazel: latest
+ <<: *macos
+ <<: *nobzlmod
+
+ win_head_bzlmod:
+ name: win_head_bzlmod
+ bazel: rolling
+ <<: *windows
+ <<: *bzlmod
+
+ win_lts_bzlmod:
+ name: win_lts_bzlmod
+ bazel: latest
+ <<: *windows
+ <<: *bzlmod
+
+ win_lts_nobzlmod:
+ name: win_lts_nobzlmod
+ bazel: latest
<<: *windows
- <<: *lts
+ <<: *nobzlmod
diff --git a/.bcr/README.md b/.bcr/README.md
new file mode 100644
index 0000000..44ae7fe
--- /dev/null
+++ b/.bcr/README.md
@@ -0,0 +1,9 @@
+# Bazel Central Registry
+
+When the ruleset is released, we want it to be published to the
+Bazel Central Registry automatically:
+<https://registry.bazel.build>
+
+This folder contains configuration files to automate the publish step.
+See <https://github.com/bazel-contrib/publish-to-bcr/blob/main/templates/README.md>
+for authoritative documentation about these files.
diff --git a/.bcr/config.yml b/.bcr/config.yml
new file mode 100644
index 0000000..b40ed20
--- /dev/null
+++ b/.bcr/config.yml
@@ -0,0 +1,3 @@
+fixedReleaser:
+ login: aiuto
+ email: aiuto@google.com
diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json
new file mode 100644
index 0000000..c330941
--- /dev/null
+++ b/.bcr/metadata.template.json
@@ -0,0 +1,12 @@
+{
+ "homepage": "https://github.com/bazelbuild/rules_pkg",
+ "maintainers": [
+ {
+ "email": "aiuto@google.com",
+ "name": "Tony Aiuto",
+ }
+ ],
+ "repository": ["github:bazelbuild/rules_pkg"],
+ "versions": [],
+ "yanked_versions": {}
+}
diff --git a/.bcr/presubmit.yml b/.bcr/presubmit.yml
new file mode 100644
index 0000000..962b770
--- /dev/null
+++ b/.bcr/presubmit.yml
@@ -0,0 +1,17 @@
+build_targets: &build_targets
+- '@rules_pkg//...'
+# Re-enable those targets when toolchain registration is supported.
+- '-@rules_pkg//toolchains/...'
+- '-@rules_pkg//pkg:make_rpm'
+
+platforms:
+ centos7_java11_devtoolset10:
+ build_targets: *build_targets
+ debian10:
+ build_targets: *build_targets
+ macos:
+ build_targets: *build_targets
+ ubuntu2004:
+ build_targets: *build_targets
+ windows:
+ build_targets: *build_targets
diff --git a/.bcr/source.template.json b/.bcr/source.template.json
new file mode 100644
index 0000000..7ea619a
--- /dev/null
+++ b/.bcr/source.template.json
@@ -0,0 +1,4 @@
+{
+ "integrity": "**leave this alone**",
+ "url": "https://github.com/{OWNER}/{REPO}/releases/download/{TAG}/rules_pkg-{TAG}.tar.gz"
+}
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
new file mode 100644
index 0000000..171697d
--- /dev/null
+++ b/.github/workflows/scorecard.yml
@@ -0,0 +1,72 @@
+# This workflow uses actions that are not certified by GitHub. They are provided
+# by a third-party and are governed by separate terms of service, privacy
+# policy, and support documentation.
+
+name: Scorecard supply-chain security
+on:
+ # For Branch-Protection check. Only the default branch is supported. See
+ # https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
+ branch_protection_rule:
+ # To guarantee Maintained check is occasionally updated. See
+ # https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
+ schedule:
+ - cron: '41 10 * * 4'
+ push:
+ branches: [ "main" ]
+
+# Declare default permissions as read only.
+permissions: read-all
+
+jobs:
+ analysis:
+ name: Scorecard analysis
+ runs-on: ubuntu-latest
+ permissions:
+ # Needed to upload the results to code-scanning dashboard.
+ security-events: write
+ # Needed to publish results and get a badge (see publish_results below).
+ id-token: write
+ # Uncomment the permissions below if installing in a private repository.
+ # contents: read
+ # actions: read
+
+ steps:
+ - name: "Checkout code"
+ uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
+ with:
+ persist-credentials: false
+
+ - name: "Run analysis"
+ uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
+ with:
+ results_file: results.sarif
+ results_format: sarif
+ # (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
+ # - you want to enable the Branch-Protection check on a *public* repository, or
+ # - you are installing Scorecard on a *private* repository
+ # To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
+ # repo_token: ${{ secrets.SCORECARD_TOKEN }}
+
+ # Public repositories:
+ # - Publish results to OpenSSF REST API for easy access by consumers
+ # - Allows the repository to include the Scorecard badge.
+ # - See https://github.com/ossf/scorecard-action#publishing-results.
+ # For private repositories:
+ # - `publish_results` will always be set to `false`, regardless
+ # of the value entered here.
+ publish_results: true
+
+ # Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
+ # format to the repository Actions tab.
+ - name: "Upload artifact"
+ uses: actions/upload-artifact@3cea5372237819ed00197afe530f5a7ea3e805c8 # v3.1.0
+ with:
+ name: SARIF file
+ path: results.sarif
+ retention-days: 5
+
+ # Upload the results to GitHub's code scanning dashboard.
+ - name: "Upload to code-scanning"
+ uses: github/codeql-action/upload-sarif@17573ee1cc1b9d061760f3a006fc4aac4f944fd5 # v2.2.4
+ with:
+ sarif_file: results.sarif
diff --git a/.gitignore b/.gitignore
index 716b1b3..be4f812 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,4 @@
.bazeliskrc
.ijwb
bazel-*
+MODULE.bazel.lock
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 0000000..52c7cd0
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,12 @@
+# Optional local setup for a git pre-commit hook to automatically format/lint.
+# This avoids sending a red PR and having to find the buildifier output on the CI results page.
+# See https://pre-commit.com for more information on installing pre-commit.
+# See https://pre-commit.com/hooks.html for more hooks.
+
+repos:
+ # Check formatting and lint for starlark code
+ - repo: https://github.com/keith/pre-commit-buildifier
+ rev: 6.3.3
+ hooks:
+ - id: buildifier
+ - id: buildifier-lint
diff --git a/BUILD b/BUILD
index 959335c..5d05b04 100644
--- a/BUILD
+++ b/BUILD
@@ -22,7 +22,7 @@ package(
license(
name = "license",
license_kinds = [
- "@rules_license//licenses/spdx:Apache-2.0"
+ "@rules_license//licenses/spdx:Apache-2.0",
],
license_text = "LICENSE",
)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ea494d7..31c91aa 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,84 @@
+# Release 0.10.1
+
+This is a bug fix release.
+
+**Bug Fixes**
+ * Temporarily restore //mappings.bzl and //pkg.bzl (#817)
+ * Fix RPM package release and version files expansion (#816)
+ * Apply tar remap_paths to runfiles full paths (#812)
+ * Use raw string for docstring that contains a backslash (for Python 3.12) (#815)
+
+Thanks to: Alex Bozhenko, Chuck Grindel, Diego Ortin, and Tomasz Wojno
+
+
+# Release 0.10.0
+
+**New Features**
+- Allow $(var) substitution in filenames (#620)
+- Rough prototype of @since processing. (#617)
+- First cut at runfiles support in pkg_* rules (#605)
+- Allow substitution of user-defined variables in RPM preamble (#787)
+- Add %posttrans scriptlet to RPM package (#799)
+- Allow additional RPM macro defines (#794)
+- Bring tar runfiles up to feature parity with pkg_files.runfiles. (#754)
+- Add support for `Obsoletes` tag in RPM definition (#778)
+- pkg_deb: allow data.tar.zst (#761)
+- Add support for failing on file conflicts. (#683)
+- Make pkg_zip compression configurable (#737)
+- Append changelog to RPM spec file (#726)
+- Add basic include_runfiles to pkg_files. (#724)
+- Add changelog attribute to pkg_deb (#725)
+- Add support for setting uid/gid from pkg_attributes (#671)
+
+**Bug Fixes**
+- Explicitly set the FILE bit in zip external attributes. (#802)
+- Explicitly set `%{_builddir}` macro (#792)
+- Only inject pre and post scriptlets when provided (#788)
+- Don't load cc toolchain from rules_cc (#779)
+- doc: Fixup external manual references (#777)
+- Get bzlmod working in CI (#766)
+- use runfiles from rules_python (#768)
+- When pkg_tar.prefix_dir == base of symlink path, don't double-dip. (#749)
+- add imports to fix bazel --noexperimental_python_import_all_repositories flag (#630)
+- 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 python 3.6, doesn't support compresslevel
+- Use Gzip compress level 6 (#720)
+- write debian Date field in UTC rather than local time (#712)
+- [pkg_deb] Fix multiline fields in changes file (#691)
+
+**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
+for contributions to this release.
+
+# Release 0.9.x
+
+**New Features**
+- Add OutputGroupInfo for pkg_rpm rule (#684)
+- Add verify_archive rule to do e2e tests on built archives. (#669)
+- Expose tar manifest as an output (#643)
+- Support license attribute in pkg_deb (#651)
+- Add support for the txz extension in pkg_tar (#653) (#654)
+
+**Bug Fixes**
+- pkg_tar should not prefix tree artifacts with ./ (#681)
+- Fix a potential TypeException caused by None type (#668)
+- pkg_zip: Some unicode file handling fixes and basic tests (#641)
+- pkg_tar, pkg_zip: improve support for long paths on Windows (#672)
+- Explicitly store implicit parent directories in zip files (#640)
+- Remove unnecessary `to_list()` calls (#639)
+
+Thanks to: Clint Harrison Qingyu Sui, Fabian Meumertzheim, Ryan Beasley, Andrew Psaltis
+Alex Eagle, Nils Semmelrock, and Doug Rabson
+for contributions to this release.
+
+
# Release 0.8.0
**New Features**
@@ -264,7 +345,7 @@ and Ulf Adams
- Author: aiuto <aiuto@google.com>
Date: Fri Aug 7 11:33:01 2020 -0400
use runfiles for pkg_tar_test to enable on Windows (#215)
- This is a precursor to geting pkg_tar_test to run on Windows.
+ This is a precursor to getting pkg_tar_test to run on Windows.
There are still problems to resolve.
- commit 933fa6fc7fc49788af04a60558722180818d091f
@@ -306,8 +387,8 @@ and Ulf Adams
Drop dependency on xzcat (#205)
We simply switch to use tarfile mode 'r:*' so that the Python runtime can pick the correct decompression.
This simplifies the code enormously.
- The removed lines expressed concerns about the peformance of the python3 implementaion of xz decompression.
- Those comments are fairly old, and were addressed in recent Python implementions as noted here: https://bugs.python.org/issue18003
+ The removed lines expressed concerns about the performance of the python3 implementation of xz decompression.
+ Those comments are fairly old, and were addressed in recent Python implementations as noted here: https://bugs.python.org/issue18003
- commit 67d64ba774b3e4c33061cf7a95215112c65657a9
- Author: aiuto <aiuto@google.com>
diff --git a/CODEOWNERS b/CODEOWNERS
index 1963edf..97604b8 100644
--- a/CODEOWNERS
+++ b/CODEOWNERS
@@ -1,14 +1,19 @@
-* @aiuto @nacl
+* @aiuto @cgrindel
+
+/.bazelci/ @meteorcloudy
+/.bcr/ @meteorcloudy
+/.github/ @meteorcloudy
+/.pre-commit-config.yaml @meteorcloudy
/deb_packages/ @aiuto
-/docs/ @aiuto @nacl @jylinv0 @gregestren
-/doc_build/ @aiuto @nacl @jylinv0
+/docs/ @aiuto @jylinv0
+/doc_build/ @aiuto @jylinv0
/pkg/rpm/ @nacl
/pkg/tests/rpm/ @nacl
/legacy/tests/rpm @nacl
/toolchains/rpm @nacl
-/pkg/deb.bzl @aiuto @dannysullivan @jylinv0
-/pkg/private/deb/ @aiuto @dannysullivan @jylinv0
-/pkg/tests/deb/ @aiuto @dannysullivan @jylinv0
+/pkg/deb.bzl @aiuto @dannysullivan
+/pkg/private/deb/ @aiuto @dannysullivan
+/pkg/tests/deb/ @aiuto @dannysullivan
diff --git a/METADATA b/METADATA
index a805312..5aed98d 100644
--- a/METADATA
+++ b/METADATA
@@ -1,14 +1,19 @@
-name: "rules_pkg"
-description:
- "Bazel package building"
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update external/bazelbuild-rules_pkg
+# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+name: "rules_pkg"
+description: "Bazel package building"
third_party {
+ license_type: NOTICE
+ last_upgrade_date {
+ year: 2024
+ month: 4
+ day: 4
+ }
identifier {
type: "Git"
value: "https://github.com/bazelbuild/rules_pkg"
- primary_source: true
+ version: "0.10.1"
}
- version: "0.9.1"
- last_upgrade_date { year: 2023 month: 12 day: 18 }
- license_type: NOTICE
}
diff --git a/MODULE.bazel b/MODULE.bazel
index cffbf62..16d9549 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,15 +1,25 @@
module(
name = "rules_pkg",
- version = "0.9.1", # Must sync with version.bzl.
- repo_name = "rules_pkg",
+ version = "0.10.1", # 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.4")
+bazel_dep(name = "rules_python", version = "0.24.0")
bazel_dep(name = "bazel_skylib", version = "1.2.0")
-bazel_dep(name = "rules_python", version = "0.10.2")
# Only for development
bazel_dep(name = "platforms", version = "0.0.5", dev_dependency = True)
bazel_dep(name = "stardoc", version = "0.5.3", dev_dependency = True)
+bazel_dep(name = "rules_cc", version = "0.0.9", 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/README.md b/README.md
index 175e5ec..aa621e8 100644
--- a/README.md
+++ b/README.md
@@ -23,6 +23,49 @@ As of Bazel 4.x, Bazel uses this rule set for packaging its distribution. Bazel
still contains a limited version of `pkg_tar` but its feature set is frozen.
Any new capabilities will be added here.
+
+## WORKSPACE setup
+
+Sample, but see [releases](https://github.com/bazelbuild/rules_pkg/releases) for the current release.
+
+```
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+http_archive(
+ name = "rules_pkg",
+ urls = [
+ "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
+ "https://github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
+ ],
+ sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
+)
+load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
+rules_pkg_dependencies()
+```
+
+To use `pkg_rpm()`, you must provide a copy of `rpmbuild`. You can use the
+system installed `rpmbuild` with this stanza.
+```
+load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
+
+find_system_rpmbuild(
+ name = "rules_pkg_rpmbuild",
+ verbose = False,
+)
+```
+
+## MODULE.bazel setup
+
+```
+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.
+```
+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")
+```
+
### For developers
* [Contributor information](CONTRIBUTING.md) (including contributor license agreements)
diff --git a/WORKSPACE b/WORKSPACE
index 58ab917..fe06be5 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -36,11 +36,11 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "platforms",
+ sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
- "https://github.com/bazelbuild/platforms/releases/download/0.0.5/platforms-0.0.5.tar.gz",
+ "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",
],
- sha256 = "379113459b0feaf6bfbb584a91874c065078aa673222846ac765f86661c27407",
)
# Find rpmbuild if it exists.
@@ -71,3 +71,14 @@ http_archive(
load("@bazel_stardoc//:setup.bzl", "stardoc_repositories")
stardoc_repositories()
+
+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/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
index e5300a3..3a25ac4 100644
--- a/WORKSPACE.bzlmod
+++ b/WORKSPACE.bzlmod
@@ -15,9 +15,13 @@ local_repository(
#)
# Needed for making our release notes
-#load("//toolchains/git:git_configure.bzl", "experimental_find_system_git")
-#
-#experimental_find_system_git(
-# name = "rules_pkg_git",
-# verbose = False,
-#)
+load("//toolchains/git:git_configure.bzl", "experimental_find_system_git_bzlmod")
+
+experimental_find_system_git_bzlmod(
+ name = "rules_pkg_git",
+ verbose = False,
+)
+register_toolchains(
+ "@rules_pkg_git//:git_auto_toolchain",
+ "//toolchains/git:git_missing_toolchain",
+)
diff --git a/distro/BUILD b/distro/BUILD
index 024faa2..47693f7 100644
--- a/distro/BUILD
+++ b/distro/BUILD
@@ -12,13 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("@rules_python//python:defs.bzl", "py_test")
load("//:version.bzl", "version")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg/releasing:defs.bzl", "print_rel_notes")
load("//pkg/releasing:git.bzl", "git_changelog")
-load("@rules_python//python:defs.bzl", "py_test")
-load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
-load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
package(
default_applicable_licenses = ["//:license"],
@@ -87,7 +85,9 @@ py_test(
data = [
"testdata/BUILD.tpl",
":distro",
+ "//:standard_package",
],
+ imports = [".."],
local = True,
python_version = "PY3",
tags = [
@@ -96,7 +96,7 @@ py_test(
],
deps = [
"//pkg/releasing:release_utils",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
diff --git a/distro/packaging_test.py b/distro/packaging_test.py
index e89bdd0..38c34c8 100644
--- a/distro/packaging_test.py
+++ b/distro/packaging_test.py
@@ -15,10 +15,11 @@
"""Test that the rules_pkg distribution is usable."""
import os
+import re
import subprocess
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.releasing import release_tools
from distro import release_version
@@ -34,6 +35,24 @@ class PackagingTest(unittest.TestCase):
self.dest_repo = 'not_named_rules_pkg'
self.version = release_version.RELEASE_VERSION
+ def testVersionsMatch(self):
+ """version.bzl must match MODULE.bazel"""
+ module_bazel_path = self.data_files.Rlocation(
+ 'rules_pkg/MODULE.bazel')
+ with open(module_bazel_path, encoding="utf-8") as inp:
+ want = 'version = "%s"' % self.version
+ content = inp.read()
+ if _VERBOSE:
+ print('=== Expect', want)
+ module_block_re = re.compile
+ m = re.search(
+ r"""module\([^)]+\)""",
+ content,
+ flags=re.MULTILINE|re.DOTALL)
+ self.assertTrue(m)
+ got = m.group()
+ self.assertIn(want, got, 'Expected <%s>, got <%s>' % (want, got))
+
def testBuild(self):
# Set up a fresh Bazel workspace using the currently build repo.
tempdir = os.path.join(os.environ['TEST_TMPDIR'], 'build')
diff --git a/doc_build/BUILD b/doc_build/BUILD
index 7e4b84b..725da8e 100644
--- a/doc_build/BUILD
+++ b/doc_build/BUILD
@@ -21,7 +21,6 @@ How to:
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
-load("@rules_python//python:defs.bzl", "py_library")
load("//:version.bzl", "version")
package(default_applicable_licenses = ["//:license"])
@@ -50,16 +49,16 @@ exports_files(
# pairs of rule name and the source file to get it from
# buildifier: leave-alone, do not sort
ORDER = [
- ("toc", None),
- ("common", None),
- ("pkg_deb", "//pkg/private/deb:deb.bzl"),
- ("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
- ("pkg_rpm", "//pkg:rpm_pfg.bzl"),
- ("pkg_tar", "//pkg/private/tar:tar.bzl"),
- ("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
- ("pkg_zip", "//pkg/private/zip:zip.bzl"),
- ("pkg_zip_impl", "//pkg/private/zip:zip.bzl"),
- ("mappings", None),
+ ("toc", None),
+ ("common", None),
+ ("pkg_deb", "//pkg/private/deb:deb.bzl"),
+ ("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
+ ("pkg_rpm", "//pkg:rpm_pfg.bzl"),
+ ("pkg_tar", "//pkg/private/tar:tar.bzl"),
+ ("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
+ ("pkg_zip", "//pkg/private/zip:zip.bzl"),
+ ("pkg_zip_impl", "//pkg/private/zip:zip.bzl"),
+ ("mappings", None),
("legacy_pkg_rpm", None),
]
diff --git a/doc_build/common.md b/doc_build/common.md
index d2be5ed..7933de1 100644
--- a/doc_build/common.md
+++ b/doc_build/common.md
@@ -8,9 +8,9 @@ These attributes are used in several rules within this module.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :-------------: | :-------------: | :------------- |
-| out | 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 | |
-| package_file_name | 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 |
-| package_variables | A target that provides `PackageVariablesInfo` to substitute into `package_file_name`. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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
diff --git a/doc_build/merge.py b/doc_build/merge.py
index ac9a2cf..02eb8f1 100755
--- a/doc_build/merge.py
+++ b/doc_build/merge.py
@@ -42,6 +42,7 @@ def merge_file(file: str, out, wrapper_map:typing.Dict[str, str]) -> None:
# If something wraps me, rewrite myself with the wrapper name.
if this_pkg in wrapper_map:
content = content.replace(this_pkg, wrapper_map[this_pkg])
+ del wrapper_map[this_pkg]
merge_text(content, out)
@@ -76,6 +77,9 @@ def main(argv: typing.Sequence[str]) -> None:
wrapper_map = {}
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)
+ sys.exit(1)
if __name__ == '__main__':
diff --git a/docs/0.10.0/reference.md b/docs/0.10.0/reference.md
new file mode 100755
index 0000000..5939363
--- /dev/null
+++ b/docs/0.10.0/reference.md
@@ -0,0 +1,726 @@
+# rules_pkg - 0.10.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>
+pkg_deb(<a href="#pkg_deb-name">name</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-data">data</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-out">out</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/docs/build-ref.html#name">Name</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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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-data"></a>data | A tar file that contains the data for the debian package. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <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 <code>depends</code>. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_deb-description"></a>description | The package description. Must not be used with <code>description_file</code>. | String | optional | "" |
+| <a id="pkg_deb-description_file"></a>description_file | The package description. Must not be used with <code>description</code>. | <a href="https://bazel.build/docs/build-ref.html#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-out"></a>out | See [Common Attributes](#out) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | 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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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 <code>version_file</code>. | String | optional | "" |
+| <a id="pkg_deb-version_file"></a>version_file | File that contains the package version. Must not be used with <code>version</code>. | <a href="https://bazel.build/docs/build-ref.html#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_rpm"></a>
+
+## pkg_rpm
+
+<pre>
+pkg_rpm(<a href="#pkg_rpm-name">name</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-defines">defines</a>,
+ <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</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-srcs">srcs</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_rpm-architecture"></a>architecture | Package architecture.<br><br> This currently sets the <code>BuildArch</code> tag, which influences the output architecture of the package.<br><br> Typically, <code>BuildArch</code> 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 <code>rpmbuild(8)</code> knows how to process, which will depend on the version of <code>rpmbuild</code> in use. The value corresponds to the <code>%_binary_payload</code> macro and is set on the <code>rpmbuild(8)</code> 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 <code>%_binary_payload</code> in <code>/usr/lib/rpm/macros</code>. Other systems have similar files and configurations.<br><br> If not provided, the compression mode will be computed by <code>rpmbuild</code> itself. Defaults may vary per distribution or build of <code>rpm</code>; 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/docs/build-ref.html#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-defines"></a>defines | Additional definitions to pass to rpmbuild | <a href="https://bazel.build/docs/skylark/lib/dict.html">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 <code>description</code> or <code>description_file</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-group"></a>group | Optional; RPM "Group" tag.<br><br> NOTE: some distributions (as of writing, Fedora &gt; 17 and CentOS/RHEL &gt; 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 <code>name</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet | RPM <code>%post</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>post_scriptlet</code> and <code>post_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file | File containing the RPM <code>%post</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet | RPM <code>%posttrans</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>posttrans_scriptlet</code> and <code>posttrans_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file | File containing the RPM <code>%posttrans</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet | RPM <code>%postun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>postun_scriptlet</code> and <code>postun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file | File containing the RPM <code>%postun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet | RPM <code>%pre</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>pre_scriptlet</code> and <code>pre_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file | File containing the RPM <code>%pre</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet | RPM <code>%preun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>preun_scriptlet</code> and <code>preun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file | File containing the RPM <code>%preun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#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 <code>release</code> or <code>release_file</code> must be provided. | String | optional | "" |
+| <a id="pkg_rpm-release_file"></a>release_file | File containing RPM "Release" tag. | <a href="https://bazel.build/docs/build-ref.html#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>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> - <code>pre</code> - <code>post</code> - <code>preun</code> - <code>postun</code> - <code>pretrans</code> - <code>posttrans</code><br><br> For capabilities that are always required by packages at runtime, use the <code>requires</code> attribute instead.<br><br> See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br> NOTE: <code>pkg_rpm</code> does not check if the keys of this dictionary are acceptable to <code>rpm(8)</code>. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path | Path to a <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> to facilitate more consistent in-RPM file timestamps. | <a href="https://bazel.build/docs/build-ref.html#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/docs/build-ref.html#labels">Label</a> | optional | //pkg/rpm:template.spec.tpl |
+| <a id="pkg_rpm-srcs"></a>srcs | Mapping groups to include in this RPM.<br><br> These are typically brought into life as <code>pkg_filegroup</code>s. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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 <code>version</code> or <code>version_file</code> must be provided. | String | optional | "" |
+| <a id="pkg_rpm-version_file"></a>version_file | File containing RPM "Version" tag. | <a href="https://bazel.build/docs/build-ref.html#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>
+pkg_tar(<a href="#pkg_tar-name">name</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-deps">deps</a>,
+ <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>,
+ <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>,
+ <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>,
+ <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
+</pre>
+
+
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_tar-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_tar-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-compressor"></a>compressor | External tool which can compress the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for <code>compressor</code>. | String | optional | "" |
+| <a id="pkg_tar-deps"></a>deps | tar files which will be unpacked and repacked into the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
+| <a id="pkg_tar-empty_files"></a>empty_files | - | List of strings | optional | [] |
+| <a id="pkg_tar-extension"></a>extension | - | String | optional | "tar" |
+| <a id="pkg_tar-files"></a>files | Obsolete. Do not use. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_tar-include_runfiles"></a>include_runfiles | 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/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | -1 |
+| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <a id="pkg_tar-owner"></a>owner | 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/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written.<br><br> This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See [package_file_name](#package_file_name) for examples. | String | optional | "" |
+| <a id="pkg_tar-package_dir_file"></a>package_dir_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name) | String | optional | "" |
+| <a id="pkg_tar-package_variables"></a>package_variables | See [Common Attributes](#package_variables) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
+| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
+| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-srcs"></a>srcs | Inputs which will become part of the tar archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-stamp"></a>stamp | Enable file time stamping. Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div> | Integer | optional | 0 |
+| <a id="pkg_tar-strip_prefix"></a>strip_prefix | (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.) | String | optional | "" |
+| <a id="pkg_tar-symlinks"></a>symlinks | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Zip archive creation rule and associated logic.
+
+<a id="#pkg_zip"></a>
+
+## pkg_zip
+
+<pre>
+pkg_zip(<a href="#pkg_zip-name">name</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-out">out</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-srcs">srcs</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/docs/build-ref.html#name">Name</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-out"></a>out | output file name. Default: name + ".zip". | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
+| <a id="pkg_zip-srcs"></a>srcs | List of files that should be included in the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <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>
+filter_directory(<a href="#filter_directory-name">name</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-src">src</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/docs/build-ref.html#name">Name</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 <code>src</code>.<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 <code>prefix</code> or <code>strip_prefix</code>). Files that are <code>exclude</code>d must not be renamed.<br><br> This currently only operates on individual files. <code>strip_prefix</code> does not apply to them.<br><br> All renames must be used. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="filter_directory-src"></a>src | Directory (TreeArtifact) to process. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <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>
+pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-prefix">prefix</a>, <a href="#pkg_filegroup-srcs">srcs</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/docs/build-ref.html#name">Name</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_filegroup-srcs"></a>srcs | A list of packaging specifications to be grouped together. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+
+
+<a id="#pkg_files"></a>
+
+## pkg_files
+
+<pre>
+pkg_files(<a href="#pkg_files-name">name</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-srcs">srcs</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_files-attributes"></a>attributes | Attributes to set on packaged files.<br><br> Always use <code>pkg_attributes()</code> 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 <code>filegroup</code>s. | <a href="https://bazel.build/docs/build-ref.html#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 <code>//my_prog:foo</code>, we would see files under paths like <code>foo.runfiles/&lt;repo name&gt;/my_prog/&lt;file&gt;</code> | 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 <code>%{_libdir}</code> 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 <code>pkg_filegroup</code> 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 <code>0755 root.root</code>).<br><br> It is possible to establish directory structures with arbitrary permissions using <code>pkg_mkdirs</code>. | 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 <code>pkg_file</code>s relative to the <code>prefix</code> attribute. Keys to the dict are source files/labels, values are destinations relative to the <code>prefix</code>, ignoring whatever value was provided for <code>strip_prefix</code>.<br><br> If the key refers to a TreeArtifact (directory output), you may specify the constant <code>REMOVE_BASE_DIRECTORY</code> as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the <code>prefix</code> and <code>strip_prefix</code> 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 <code>exclude</code>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/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_files-srcs"></a>srcs | Files/Labels to include in the outputs of these rules | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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 <code>prefix</code> attribute). Note that this is only applied to full directory names, see <code>strip_prefix</code> for more details.<br><br> Use the <code>strip_prefix</code> 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 (<code>strip_prefix.files_only()</code>).<br><br> If prefix stripping fails on any file provided in <code>srcs</code>, 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>
+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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_mkdirs-attributes"></a>attributes | Attributes to set on packaged directories.<br><br> Always use <code>pkg_attributes()</code> 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 <code>0755 root.root</code>). | List of strings | required | |
+
+
+<a id="#pkg_mklink_impl"></a>
+
+## pkg_mklink_impl
+
+<pre>
+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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_mklink_impl-attributes"></a>attributes | Attributes to set on packaged symbolic links.<br><br> Always use <code>pkg_attributes()</code> 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 <code>pkg_files</code>.<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>
+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. | <code>None</code> |
+| <a id="pkg_attributes-user"></a>user | string: Filesystem owning user name. | <code>None</code> |
+| <a id="pkg_attributes-group"></a>group | string: Filesystem owning group name. | <code>None</code> |
+| <a id="pkg_attributes-uid"></a>uid | int: Filesystem owning user id. | <code>None</code> |
+| <a id="pkg_attributes-gid"></a>gid | int: Filesystem owning group id. | <code>None</code> |
+| <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>
+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. | <code>None</code> |
+| <a id="pkg_mklink-src"></a>src | - | <code>None</code> |
+| <a id="pkg_mklink-kwargs"></a>kwargs | - | none |
+
+
+<a id="#strip_prefix.files_only"></a>
+
+## strip_prefix.files_only
+
+<pre>
+strip_prefix.files_only()
+</pre>
+
+
+
+
+
+<a id="#strip_prefix.from_pkg"></a>
+
+## strip_prefix.from_pkg
+
+<pre>
+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 | - | <code>""</code> |
+
+
+<a id="#strip_prefix.from_root"></a>
+
+## strip_prefix.from_root
+
+<pre>
+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 | - | <code>""</code> |
+
+
+
+<!-- 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>
+pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-data">data</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_rpm-architecture"></a>architecture | - | String | optional | "all" |
+| <a id="pkg_rpm-changelog"></a>changelog | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-data"></a>data | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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/docs/build-ref.html#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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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 d101362..4ba55cc 100755
--- a/docs/0.8.0/reference.md
+++ b/docs/0.8.0/reference.md
@@ -297,7 +297,7 @@ pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar
| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="pkg_tar-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="pkg_tar-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 | - | String | optional | "" |
+| <a id="pkg_tar-strip_prefix"></a>strip_prefix | (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.) | String | optional | "" |
| <a id="pkg_tar-symlinks"></a>symlinks | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
diff --git a/docs/0.9.1/reference.md b/docs/0.9.1/reference.md
new file mode 100755
index 0000000..52293be
--- /dev/null
+++ b/docs/0.9.1/reference.md
@@ -0,0 +1,689 @@
+# rules_pkg - 0.9.1
+
+<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 |
+| :------------- | :------------- | :-------------: | :-------------: | :------------- |
+| out | 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 | |
+| package_file_name | 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 |
+| package_variables | A target that provides `PackageVariablesInfo` to substitute into `package_file_name`. | <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>
+pkg_deb(<a href="#pkg_deb-name">name</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-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-data">data</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-out">out</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>
+
+
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_deb-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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-data"></a>data | A tar file that contains the data for the debian package. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <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 <code>depends</code>. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_deb-description"></a>description | The package description. Must not be used with <code>description_file</code>. | String | optional | "" |
+| <a id="pkg_deb-description_file"></a>description_file | The package description. Must not be used with <code>description</code>. | <a href="https://bazel.build/docs/build-ref.html#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-out"></a>out | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | 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. Default: "{package}-{version}-{architecture}.deb | String | optional | "" |
+| <a id="pkg_deb-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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 <code>version_file</code>. | String | optional | "" |
+| <a id="pkg_deb-version_file"></a>version_file | File that contains the package version. Must not be used with <code>version</code>. | <a href="https://bazel.build/docs/build-ref.html#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_rpm"></a>
+
+## pkg_rpm
+
+<pre>
+pkg_rpm(<a href="#pkg_rpm-name">name</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-description">description</a>,
+ <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</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-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-srcs">srcs</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.
+
+
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_rpm-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_rpm-architecture"></a>architecture | Package architecture.<br><br> This currently sets the <code>BuildArch</code> tag, which influences the output architecture of the package.<br><br> Typically, <code>BuildArch</code> 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 <code>rpmbuild(8)</code> knows how to process, which will depend on the version of <code>rpmbuild</code> in use. The value corresponds to the <code>%_binary_payload</code> macro and is set on the <code>rpmbuild(8)</code> 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 <code>%_binary_payload</code> in <code>/usr/lib/rpm/macros</code>. Other systems have similar files and configurations.<br><br> If not provided, the compression mode will be computed by <code>rpmbuild</code> itself. Defaults may vary per distribution or build of <code>rpm</code>; 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/docs/build-ref.html#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.org/user_doc/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-description"></a>description | Multi-line description of this package, corresponds to RPM %description.<br><br> Exactly one of <code>description</code> or <code>description_file</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-group"></a>group | Optional; RPM "Group" tag.<br><br> NOTE: some distributions (as of writing, Fedora &gt; 17 and CentOS/RHEL &gt; 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-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 <code>name</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet | RPM <code>%post</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>post_scriptlet</code> and <code>post_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file | File containing the RPM <code>%post</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet | RPM <code>%postun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>postun_scriptlet</code> and <code>postun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file | File containing the RPM <code>%postun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet | RPM <code>%pre</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>pre_scriptlet</code> and <code>pre_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file | File containing the RPM <code>%pre</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet | RPM <code>%preun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>preun_scriptlet</code> and <code>preun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file | File containing the RPM <code>%preun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#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.org/user_doc/dependencies.html | List of strings | optional | [] |
+| <a id="pkg_rpm-release"></a>release | RPM "Release" tag<br><br> Exactly one of <code>release</code> or <code>release_file</code> must be provided. | String | optional | "" |
+| <a id="pkg_rpm-release_file"></a>release_file | File containing RPM "Release" tag. | <a href="https://bazel.build/docs/build-ref.html#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.org/user_doc/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>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> - <code>pre</code> - <code>post</code> - <code>preun</code> - <code>postun</code> - <code>pretrans</code> - <code>posttrans</code><br><br> For capabilities that are always required by packages at runtime, use the <code>requires</code> attribute instead.<br><br> See also: https://rpm.org/user_doc/more_dependencies.html<br><br> NOTE: <code>pkg_rpm</code> does not check if the keys of this dictionary are acceptable to <code>rpm(8)</code>. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path | Path to a <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> to facilitate more consistent in-RPM file timestamps. | <a href="https://bazel.build/docs/build-ref.html#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/docs/build-ref.html#labels">Label</a> | optional | //pkg/rpm:template.spec.tpl |
+| <a id="pkg_rpm-srcs"></a>srcs | Mapping groups to include in this RPM.<br><br> These are typically brought into life as <code>pkg_filegroup</code>s. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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 <code>version</code> or <code>version_file</code> must be provided. | String | optional | "" |
+| <a id="pkg_rpm-version_file"></a>version_file | File containing RPM "Version" tag. | <a href="https://bazel.build/docs/build-ref.html#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>
+pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>,
+ <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>,
+ <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>, <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>,
+ <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
+</pre>
+
+
+
+**ATTRIBUTES**
+
+
+| Name | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_tar-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_tar-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private/tar:build_tar |
+| <a id="pkg_tar-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-compressor_args"></a>compressor_args | - | String | optional | "" |
+| <a id="pkg_tar-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
+| <a id="pkg_tar-empty_files"></a>empty_files | - | List of strings | optional | [] |
+| <a id="pkg_tar-extension"></a>extension | - | String | optional | "tar" |
+| <a id="pkg_tar-files"></a>files | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_tar-include_runfiles"></a>include_runfiles | - | Boolean | optional | False |
+| <a id="pkg_tar-mode"></a>mode | - | String | optional | "0555" |
+| <a id="pkg_tar-modes"></a>modes | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | -1 |
+| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <a id="pkg_tar-owner"></a>owner | - | String | optional | "0.0" |
+| <a id="pkg_tar-ownername"></a>ownername | - | String | optional | "." |
+| <a id="pkg_tar-ownernames"></a>ownernames | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written. | String | optional | "" |
+| <a id="pkg_tar-package_dir_file"></a>package_dir_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
+| <a id="pkg_tar-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
+| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
+| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-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 | - | String | optional | "" |
+| <a id="pkg_tar-symlinks"></a>symlinks | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">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>
+pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-out">out</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-srcs">srcs</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_zip-mode"></a>mode | The default mode for all files in the archive. | String | optional | "0555" |
+| <a id="pkg_zip-out"></a>out | output file name. Default: name + ".zip". | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <a id="pkg_zip-package_dir"></a>package_dir | The prefix to add to all all paths in the archive. | String | optional | "/" |
+| <a id="pkg_zip-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
+| <a id="pkg_zip-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
+| <a id="pkg_zip-srcs"></a>srcs | List of files that should be included in the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <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>
+filter_directory(<a href="#filter_directory-name">name</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-src">src</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/docs/build-ref.html#name">Name</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 <code>src</code>.<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 <code>prefix</code> or <code>strip_prefix</code>). Files that are <code>exclude</code>d must not be renamed.<br><br> This currently only operates on individual files. <code>strip_prefix</code> does not apply to them.<br><br> All renames must be used. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="filter_directory-src"></a>src | Directory (TreeArtifact) to process. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <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>
+pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-prefix">prefix</a>, <a href="#pkg_filegroup-srcs">srcs</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/docs/build-ref.html#name">Name</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_filegroup-srcs"></a>srcs | A list of packaging specifications to be grouped together. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+
+
+<a id="#pkg_files"></a>
+
+## pkg_files
+
+<pre>
+pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-srcs">srcs</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_files-attributes"></a>attributes | Attributes to set on packaged files.<br><br> Always use <code>pkg_attributes()</code> 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 <code>filegroup</code>s. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <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 <code>%{_libdir}</code> 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 <code>pkg_filegroup</code> 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 <code>0755 root.root</code>).<br><br> It is possible to establish directory structures with arbitrary permissions using <code>pkg_mkdirs</code>. | 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 <code>pkg_file</code>s relative to the <code>prefix</code> attribute. Keys to the dict are source files/labels, values are destinations relative to the <code>prefix</code>, ignoring whatever value was provided for <code>strip_prefix</code>.<br><br> If the key refers to a TreeArtifact (directory output), you may specify the constant <code>REMOVE_BASE_DIRECTORY</code> as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the <code>prefix</code> and <code>strip_prefix</code> 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 <code>exclude</code>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/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_files-srcs"></a>srcs | Files/Labels to include in the outputs of these rules | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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 <code>prefix</code> attribute). Note that this is only applied to full directory names, see <code>strip_prefix</code> for more details.<br><br> Use the <code>strip_prefix</code> 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 (<code>strip_prefix.files_only()</code>).<br><br> If prefix stripping fails on any file provided in <code>srcs</code>, 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>
+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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_mkdirs-attributes"></a>attributes | Attributes to set on packaged directories.<br><br> Always use <code>pkg_attributes()</code> 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 <code>0755 root.root</code>). | List of strings | required | |
+
+
+<a id="#pkg_mklink_impl"></a>
+
+## pkg_mklink_impl
+
+<pre>
+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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_mklink_impl-attributes"></a>attributes | Attributes to set on packaged symbolic links.<br><br> Always use <code>pkg_attributes()</code> 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 <code>pkg_files</code>.<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>
+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-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", or "group" 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. | <code>None</code> |
+| <a id="pkg_attributes-user"></a>user | string: Filesystem owning user. | <code>None</code> |
+| <a id="pkg_attributes-group"></a>group | string: Filesystem owning group. | <code>None</code> |
+| <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>
+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.
+
+**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. | <code>None</code> |
+| <a id="pkg_mklink-src"></a>src | - | <code>None</code> |
+| <a id="pkg_mklink-kwargs"></a>kwargs | - | none |
+
+
+<a id="#strip_prefix.files_only"></a>
+
+## strip_prefix.files_only
+
+<pre>
+strip_prefix.files_only()
+</pre>
+
+
+
+
+
+<a id="#strip_prefix.from_pkg"></a>
+
+## strip_prefix.from_pkg
+
+<pre>
+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 | - | <code>""</code> |
+
+
+<a id="#strip_prefix.from_root"></a>
+
+## strip_prefix.from_root
+
+<pre>
+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 | - | <code>""</code> |
+
+
+
+<!-- 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>
+pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-data">data</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/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_rpm-architecture"></a>architecture | - | String | optional | "all" |
+| <a id="pkg_rpm-changelog"></a>changelog | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-data"></a>data | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
+| <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/docs/build-ref.html#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/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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/index.md b/docs/index.md
index 1d0f1c0..b7b0259 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -16,6 +16,8 @@ attributes only defined in the "Legacy" documentation. You may have to
consult more than one place to get a complete picture.
* [Latest Snapshot at head](latest.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)
* [Version 0.7.0](0.7.0/reference.md)
* [Version 0.6.0](0.6.0/reference.md)
diff --git a/docs/latest.md b/docs/latest.md
index f32040a..eea6982 100755
--- a/docs/latest.md
+++ b/docs/latest.md
@@ -1,4 +1,4 @@
-# rules_pkg - 0.8.2
+# rules_pkg - 0.10.1
<div class="toc">
<h2>Common Attributes</h2>
@@ -37,9 +37,9 @@ These attributes are used in several rules within this module.
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :-------------: | :-------------: | :------------- |
-| out | 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 | |
-| package_file_name | 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 |
-| package_variables | A target that provides `PackageVariablesInfo` to substitute into `package_file_name`. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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
@@ -91,14 +91,25 @@ Rule for creating Debian packages.
<pre>
pkg_deb(<a href="#pkg_deb-name">name</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-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-data">data</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-out">out</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>)
+ <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-data">data</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-out">out</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**
@@ -111,6 +122,7 @@ pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-architecture">archit
| <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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#labels">Label</a> | optional | None |
@@ -125,10 +137,10 @@ pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-architecture">archit
| <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-out"></a>out | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
+| <a id="pkg_deb-out"></a>out | See [Common Attributes](#out) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | 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. Default: "{package}-{version}-{architecture}.deb | String | optional | "" |
-| <a id="pkg_deb-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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/docs/build-ref.html#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/docs/build-ref.html#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/docs/build-ref.html#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 | [] |
@@ -168,9 +180,10 @@ find_system_rpmbuild(name="rules_pkg_rpmbuild")
## pkg_rpm
<pre>
-pkg_rpm(<a href="#pkg_rpm-name">name</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-description">description</a>,
- <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</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-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>,
+pkg_rpm(<a href="#pkg_rpm-name">name</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-defines">defines</a>,
+ <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</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-srcs">srcs</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>)
@@ -204,6 +217,14 @@ Creates an RPM format package via `pkg_filegroup` and friends.
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**
@@ -215,28 +236,32 @@ Creates an RPM format package via `pkg_filegroup` and friends.
| <a id="pkg_rpm-architecture"></a>architecture | Package architecture.<br><br> This currently sets the <code>BuildArch</code> tag, which influences the output architecture of the package.<br><br> Typically, <code>BuildArch</code> 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 <code>rpmbuild(8)</code> knows how to process, which will depend on the version of <code>rpmbuild</code> in use. The value corresponds to the <code>%_binary_payload</code> macro and is set on the <code>rpmbuild(8)</code> 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 <code>%_binary_payload</code> in <code>/usr/lib/rpm/macros</code>. Other systems have similar files and configurations.<br><br> If not provided, the compression mode will be computed by <code>rpmbuild</code> itself. Defaults may vary per distribution or build of <code>rpm</code>; 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/docs/build-ref.html#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.org/user_doc/dependencies.html | List of strings | optional | [] |
+| <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-defines"></a>defines | Additional definitions to pass to rpmbuild | <a href="https://bazel.build/docs/skylark/lib/dict.html">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 <code>description</code> or <code>description_file</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_rpm-group"></a>group | Optional; RPM "Group" tag.<br><br> NOTE: some distributions (as of writing, Fedora &gt; 17 and CentOS/RHEL &gt; 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 <code>name</code> 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/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet | RPM <code>%post</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>post_scriptlet</code> and <code>post_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file | File containing the RPM <code>%post</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet | RPM <code>%posttrans</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>posttrans_scriptlet</code> and <code>posttrans_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
+| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file | File containing the RPM <code>%posttrans</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet | RPM <code>%postun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>postun_scriptlet</code> and <code>postun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file | File containing the RPM <code>%postun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet | RPM <code>%pre</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>pre_scriptlet</code> and <code>pre_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file | File containing the RPM <code>%pre</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet | RPM <code>%preun</code> scriptlet. Currently only allowed to be a shell script.<br><br> <code>preun_scriptlet</code> and <code>preun_scriptlet_file</code> are mutually exclusive. | String | optional | "" |
| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file | File containing the RPM <code>%preun</code> scriptlet | <a href="https://bazel.build/docs/build-ref.html#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.org/user_doc/dependencies.html | List of strings | optional | [] |
+| <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 <code>release</code> or <code>release_file</code> must be provided. | String | optional | "" |
| <a id="pkg_rpm-release_file"></a>release_file | File containing RPM "Release" tag. | <a href="https://bazel.build/docs/build-ref.html#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.org/user_doc/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>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> - <code>pre</code> - <code>post</code> - <code>preun</code> - <code>postun</code> - <code>pretrans</code> - <code>posttrans</code><br><br> For capabilities that are always required by packages at runtime, use the <code>requires</code> attribute instead.<br><br> See also: https://rpm.org/user_doc/more_dependencies.html<br><br> NOTE: <code>pkg_rpm</code> does not check if the keys of this dictionary are acceptable to <code>rpm(8)</code>. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
+| <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>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> - <code>pre</code> - <code>post</code> - <code>preun</code> - <code>postun</code> - <code>pretrans</code> - <code>posttrans</code><br><br> For capabilities that are always required by packages at runtime, use the <code>requires</code> attribute instead.<br><br> See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br> NOTE: <code>pkg_rpm</code> does not check if the keys of this dictionary are acceptable to <code>rpm(8)</code>. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path | Path to a <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> 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 <code>%clamp_mtime_to_source_date_epoch</code> in the subordinate call to <code>rpmbuild</code> to facilitate more consistent in-RPM file timestamps. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
@@ -258,10 +283,11 @@ Rules for making .tar files.
## pkg_tar
<pre>
-pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>,
- <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>,
- <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>, <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>,
- <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
+pkg_tar(<a href="#pkg_tar-name">name</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-deps">deps</a>,
+ <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>,
+ <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>,
+ <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>,
+ <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
</pre>
@@ -272,33 +298,33 @@ pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-build_tar">build_tar
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="pkg_tar-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| <a id="pkg_tar-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private/tar:build_tar |
-| <a id="pkg_tar-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-compressor_args"></a>compressor_args | - | String | optional | "" |
-| <a id="pkg_tar-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-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-compressor"></a>compressor | External tool which can compress the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-compressor_args"></a>compressor_args | Arg list for <code>compressor</code>. | String | optional | "" |
+| <a id="pkg_tar-deps"></a>deps | tar files which will be unpacked and repacked into the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="pkg_tar-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
| <a id="pkg_tar-empty_files"></a>empty_files | - | List of strings | optional | [] |
| <a id="pkg_tar-extension"></a>extension | - | String | optional | "tar" |
-| <a id="pkg_tar-files"></a>files | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
-| <a id="pkg_tar-include_runfiles"></a>include_runfiles | - | Boolean | optional | False |
+| <a id="pkg_tar-files"></a>files | Obsolete. Do not use. | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
+| <a id="pkg_tar-include_runfiles"></a>include_runfiles | 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/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="pkg_tar-mtime"></a>mtime | - | Integer | optional | -1 |
| <a id="pkg_tar-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_tar-owner"></a>owner | - | String | optional | "0.0" |
+| <a id="pkg_tar-owner"></a>owner | Default numeric owner.group to apply to files when not set via pkg_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/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written. | String | optional | "" |
+| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written.<br><br> This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See [package_file_name](#package_file_name) for examples. | String | optional | "" |
| <a id="pkg_tar-package_dir_file"></a>package_dir_file | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
-| <a id="pkg_tar-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_tar-package_file_name"></a>package_file_name | See [Common Attributes](#package_file_name) | String | optional | "" |
+| <a id="pkg_tar-package_variables"></a>package_variables | See [Common Attributes](#package_variables) | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_tar-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
| <a id="pkg_tar-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
+| <a id="pkg_tar-srcs"></a>srcs | Inputs which will become part of the tar archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <a id="pkg_tar-stamp"></a>stamp | Enable file time stamping. Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div> | Integer | optional | 0 |
-| <a id="pkg_tar-strip_prefix"></a>strip_prefix | - | String | optional | "" |
+| <a id="pkg_tar-strip_prefix"></a>strip_prefix | (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.) | String | optional | "" |
| <a id="pkg_tar-symlinks"></a>symlinks | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
@@ -312,7 +338,8 @@ Zip archive creation rule and associated logic.
## pkg_zip
<pre>
-pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-out">out</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>,
+pkg_zip(<a href="#pkg_zip-name">name</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-out">out</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-srcs">srcs</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>
@@ -324,11 +351,15 @@ pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-mode">mode</a>, <a h
| Name | Description | Type | Mandatory | Default |
| :------------- | :------------- | :------------- | :------------- | :------------- |
| <a id="pkg_zip-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
+| <a id="pkg_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-out"></a>out | output file name. Default: name + ".zip". | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_zip-package_dir"></a>package_dir | The prefix to add to all all paths in the archive. | String | optional | "/" |
-| <a id="pkg_zip-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
-| <a id="pkg_zip-package_variables"></a>package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <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/docs/build-ref.html#labels">Label</a> | optional | None |
| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
| <a id="pkg_zip-srcs"></a>srcs | List of files that should be included in the archive. | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
| <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 |
@@ -434,7 +465,7 @@ Package contents grouping rule.
## pkg_files
<pre>
-pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>)
+pkg_files(<a href="#pkg_files-name">name</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-srcs">srcs</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>)
</pre>
General-purpose package target-to-destination mapping rule.
@@ -459,6 +490,7 @@ General-purpose package target-to-destination mapping rule.
| <a id="pkg_files-name"></a>name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
| <a id="pkg_files-attributes"></a>attributes | Attributes to set on packaged files.<br><br> Always use <code>pkg_attributes()</code> 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 <code>filegroup</code>s. | <a href="https://bazel.build/docs/build-ref.html#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 <code>//my_prog:foo</code>, we would see files under paths like <code>foo.runfiles/&lt;repo name&gt;/my_prog/&lt;file&gt;</code> | 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 <code>%{_libdir}</code> 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 <code>pkg_filegroup</code> 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 <code>0755 root.root</code>).<br><br> It is possible to establish directory structures with arbitrary permissions using <code>pkg_mkdirs</code>. | 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 <code>pkg_file</code>s relative to the <code>prefix</code> attribute. Keys to the dict are source files/labels, values are destinations relative to the <code>prefix</code>, ignoring whatever value was provided for <code>strip_prefix</code>.<br><br> If the key refers to a TreeArtifact (directory output), you may specify the constant <code>REMOVE_BASE_DIRECTORY</code> as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the <code>prefix</code> and <code>strip_prefix</code> 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 <code>exclude</code>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/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
| <a id="pkg_files-srcs"></a>srcs | Files/Labels to include in the outputs of these rules | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required | |
@@ -533,7 +565,7 @@ Define a symlink within packages
## 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-kwargs">kwargs</a>)
+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.
@@ -542,8 +574,8 @@ 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", or "group" will result in the package builder
-choosing one for you. The chosen value should not be relied upon.
+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.
@@ -558,8 +590,10 @@ rules (e.g. `pkg_files`).
| Name | Description | Default Value |
| :------------- | :------------- | :------------- |
| <a id="pkg_attributes-mode"></a>mode | string: UNIXy octal permissions, as a string. | <code>None</code> |
-| <a id="pkg_attributes-user"></a>user | string: Filesystem owning user. | <code>None</code> |
-| <a id="pkg_attributes-group"></a>group | string: Filesystem owning group. | <code>None</code> |
+| <a id="pkg_attributes-user"></a>user | string: Filesystem owning user name. | <code>None</code> |
+| <a id="pkg_attributes-group"></a>group | string: Filesystem owning group name. | <code>None</code> |
+| <a id="pkg_attributes-uid"></a>uid | int: Filesystem owning user id. | <code>None</code> |
+| <a id="pkg_attributes-gid"></a>gid | int: Filesystem owning group id. | <code>None</code> |
| <a id="pkg_attributes-kwargs"></a>kwargs | any other desired attributes. | none |
**RETURNS**
@@ -577,6 +611,9 @@ pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">
Create a symlink.
+Wraps [pkg_mklink_impl](#pkg_mklink_impl)
+
+
**PARAMETERS**
diff --git a/examples/naming_package_files/BUILD b/examples/naming_package_files/BUILD
index 2230c19..9b9f88a 100644
--- a/examples/naming_package_files/BUILD
+++ b/examples/naming_package_files/BUILD
@@ -13,12 +13,12 @@
# limitations under the License.
# -*- coding: utf-8 -*-
-licenses(["notice"])
-
load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-load(":package_upload.bzl", "debian_upload")
load(":my_package_name.bzl", "basic_naming", "name_part_from_command_line", "names_from_toolchains")
+load(":package_upload.bzl", "debian_upload")
+
+licenses(["notice"])
config_setting(
name = "special_build",
@@ -97,7 +97,7 @@ pkg_tar(
)
#
-#
+#
#
pkg_tar(
name = "using_variable_from_ctx_var",
diff --git a/examples/naming_package_files/MODULE.bazel b/examples/naming_package_files/MODULE.bazel
index 705b549..3bc4f13 100644
--- a/examples/naming_package_files/MODULE.bazel
+++ b/examples/naming_package_files/MODULE.bazel
@@ -3,9 +3,10 @@ module(
version = "0.0.1",
)
-local_path_override(
- module_name = "rules_pkg",
- path = "../..",
-)
+# 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_cc", version = "0.0.2")
diff --git a/examples/naming_package_files/WORKSPACE b/examples/naming_package_files/WORKSPACE
index be5819a..0e5b0d9 100644
--- a/examples/naming_package_files/WORKSPACE
+++ b/examples/naming_package_files/WORKSPACE
@@ -27,7 +27,7 @@ rules_pkg_dependencies()
http_archive(
name = "rules_cc",
- url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
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
new file mode 100644
index 0000000..ac785ff
--- /dev/null
+++ b/examples/naming_package_files/WORKSPACE.bzlmod
@@ -0,0 +1,8 @@
+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/my_package_name.bzl b/examples/naming_package_files/my_package_name.bzl
index 1e3d0b6..6a64de6 100644
--- a/examples/naming_package_files/my_package_name.bzl
+++ b/examples/naming_package_files/my_package_name.bzl
@@ -14,8 +14,8 @@
"""Example rules to show package naming techniques."""
-load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
load("@rules_cc//cc:find_cc_toolchain.bzl", "find_cc_toolchain")
+load("@rules_pkg//pkg:providers.bzl", "PackageVariablesInfo")
def _basic_naming_impl(ctx):
values = {}
@@ -71,12 +71,12 @@ def _names_from_toolchains_impl(ctx):
return PackageVariablesInfo(values = values)
#
-# Extracting variables from the toolchain to use in the pacakge name.
+# Extracting variables from the toolchain to use in the package name.
#
names_from_toolchains = rule(
implementation = _names_from_toolchains_impl,
# Going forward, the preferred way to depend on a toolchain through the
- # toolchains atttribute. The current C++ toolchains, however, are still not
+ # toolchains attribute. The current C++ toolchains, however, are still not
# using toolchain resolution, so we have to depend on the toolchain
# directly.
# TODO(https://github.com/bazelbuild/bazel/issues/7260): Delete the
@@ -97,6 +97,7 @@ names_from_toolchains = rule(
#
def _name_part_from_command_line_naming_impl(ctx):
values = {"name_part": ctx.build_setting_value}
+
# Just pass the value from the command line through. An implementation
# could also perform validation, such as done in
# https://github.com/bazelbuild/bazel-skylib/blob/master/rules/common_settings.bzl
diff --git a/examples/prebuilt_rpmbuild/test_rpm.spec b/examples/prebuilt_rpmbuild/test_rpm.spec
index 691c1cd..c52dc24 100644
--- a/examples/prebuilt_rpmbuild/test_rpm.spec
+++ b/examples/prebuilt_rpmbuild/test_rpm.spec
@@ -6,7 +6,7 @@ License: Apache License, v2.0
# Do not try to use magic to determine file types
%define __spec_install_post %{nil}
-# Do not die becuse we give it more input files than are in the files section
+# Do not die because we give it more input files than are in the files section
%define _unpackaged_files_terminate_build 0
%description
diff --git a/examples/rich_structure/BUILD b/examples/rich_structure/BUILD
index 6bff0f6..dce188e 100644
--- a/examples/rich_structure/BUILD
+++ b/examples/rich_structure/BUILD
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix")
+load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
diff --git a/examples/rich_structure/WORKSPACE b/examples/rich_structure/WORKSPACE
index e2cdda3..4986594 100644
--- a/examples/rich_structure/WORKSPACE
+++ b/examples/rich_structure/WORKSPACE
@@ -14,6 +14,8 @@
workspace(name = "rich_structure")
+load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+
local_repository(
name = "rules_pkg",
path = "../..",
@@ -22,3 +24,14 @@ local_repository(
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/BUILD b/examples/rich_structure/docs/BUILD
index a0868d3..e33258c 100644
--- a/examples/rich_structure/docs/BUILD
+++ b/examples/rich_structure/docs/BUILD
@@ -2,6 +2,9 @@
filegroup(
name = "docs",
- srcs = glob(["**/*"], exclude=["BUILD"]),
+ srcs = glob(
+ ["**/*"],
+ exclude = ["BUILD"],
+ ),
visibility = ["//visibility:public"],
)
diff --git a/examples/rich_structure/resources/l10n/BUILD b/examples/rich_structure/resources/l10n/BUILD
index 823cab8..9a19b99 100644
--- a/examples/rich_structure/resources/l10n/BUILD
+++ b/examples/rich_structure/resources/l10n/BUILD
@@ -14,7 +14,6 @@
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "strip_prefix")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
load("//:foo_defs.bzl", "shared_object_path_selector")
# There are localized message catalogs for all the components.
diff --git a/examples/rich_structure/src/client/BUILD b/examples/rich_structure/src/client/BUILD
index 28a84d5..9d9f545 100644
--- a/examples/rich_structure/src/client/BUILD
+++ b/examples/rich_structure/src/client/BUILD
@@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mklink")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
load("//:foo_defs.bzl", "shared_object_path_selector")
diff --git a/examples/rich_structure/src/server/BUILD b/examples/rich_structure/src/server/BUILD
index aaf9383..70f3da7 100644
--- a/examples/rich_structure/src/server/BUILD
+++ b/examples/rich_structure/src/server/BUILD
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs")
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-load("//:foo_defs.bzl", "shared_object_path_selector")
cc_library(
name = "foolib",
diff --git a/examples/time_stamping/BUILD b/examples/time_stamping/BUILD
index 91d0121..802df2e 100644
--- a/examples/time_stamping/BUILD
+++ b/examples/time_stamping/BUILD
@@ -13,10 +13,10 @@
# limitations under the License.
# -*- coding: utf-8 -*-
-licenses(["notice"])
-
load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
+licenses(["notice"])
+
pkg_tar(
name = "never_stamped",
srcs = [
diff --git a/examples/where_is_my_output/README.md b/examples/where_is_my_output/README.md
index feb1f86..c977ec8 100644
--- a/examples/where_is_my_output/README.md
+++ b/examples/where_is_my_output/README.md
@@ -78,7 +78,7 @@ created file, we can do that with a filegroup that specifies the specific
output group containing that file.
In the example below, `:deb` is a rule producing an explicit .deb output
-and an implict .changes output. We refer to the .changes file using the
+and an implicit .changes output. We refer to the .changes file using the
`filegroup` and specifying the desired output group name. Then, any rule
can use this `filegroup` as an input.
diff --git a/examples/where_is_my_output/WORKSPACE b/examples/where_is_my_output/WORKSPACE
index 50f3c24..e2cdda3 100644
--- a/examples/where_is_my_output/WORKSPACE
+++ b/examples/where_is_my_output/WORKSPACE
@@ -14,8 +14,6 @@
workspace(name = "rich_structure")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
local_repository(
name = "rules_pkg",
path = "../..",
diff --git a/examples/where_is_my_output/show_all_outputs.bzl b/examples/where_is_my_output/show_all_outputs.bzl
index 12d658d..7391d9c 100644
--- a/examples/where_is_my_output/show_all_outputs.bzl
+++ b/examples/where_is_my_output/show_all_outputs.bzl
@@ -12,16 +12,18 @@
# 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.
+"""
+Extract the paths to the various outputs of pkg_deb
-# Extract the paths to the various outputs of pkg_deb
-#
-# Usage:
-# bazel cquery //pkg:deb --output=starlark --starlark:file=show_all_outputs.bzl
-#
+Usage:
+ bazel cquery //pkg:deb --output=starlark --starlark:file=show_all_outputs.bzl
+"""
+# buildifier: disable=function-docstring
def format(target):
provider_map = providers(target)
output_group_info = provider_map["OutputGroupInfo"]
+
# Look at the attributes of the provider. Visit the depsets.
ret = []
for attr in dir(output_group_info):
diff --git a/install.bzl b/install.bzl
deleted file mode 100644
index 9106a44..0000000
--- a/install.bzl
+++ /dev/null
@@ -1,20 +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.
-
-load(
- "//pkg:install.bzl",
- _pkg_install = "pkg_install"
-)
-
-pkg_install = _pkg_install
diff --git a/package_variables.bzl b/package_variables.bzl
deleted file mode 100644
index fb77d07..0000000
--- a/package_variables.bzl
+++ /dev/null
@@ -1,18 +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.
-
-load("//pkg/package_variables.bzl",
- _add_ctx_variables = "add_ctx_variables",
-)
-add_ctx_variables = _add_ctx_variables
diff --git a/patching.md b/patching.md
index b537ffc..0c616c3 100644
--- a/patching.md
+++ b/patching.md
@@ -23,8 +23,8 @@
repository](https://help.github.com/articles/working-with-forks/).
- Wait for a repository owner to assign you a reviewer. We strive to do that
within 4 business days, but it may take longer. If your review gets lost
- you can escalate by sending a mail to
- [bazel-dev@googlegroups.com](mailto:bazel-dev@googlegroups.com).
+ you can escalate by starting a thread on
+ [GitHub Discussions](https://github.com/bazelbuild/bazel/discussions).
- Work with the reviewer to complete a code review. For each change, create a
new commit and push it to make changes to your pull request.
- A maintainer will approve the PR and merge it.
diff --git a/pkg/BUILD b/pkg/BUILD
index e24fc6b..b3115f5 100644
--- a/pkg/BUILD
+++ b/pkg/BUILD
@@ -12,9 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")
+
# -*- coding: utf-8 -*-
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
-load("@rules_pkg//pkg/private:make_starlark_library.bzl", "starlark_library")
package(default_applicable_licenses = ["//:license"])
@@ -38,6 +39,7 @@ filegroup(
srcs = glob([
"*.bzl",
"*.py",
+ "*.tpl",
]) + [
"BUILD",
"//pkg/legacy:standard_package",
@@ -67,6 +69,7 @@ starlark_library(
py_binary(
name = "make_rpm",
srcs = ["make_rpm.py"],
+ imports = [".."],
python_version = "PY3",
srcs_version = "PY3",
target_compatible_with = select({
@@ -83,6 +86,7 @@ py_binary(
py_library(
name = "make_rpm_lib",
srcs = ["make_rpm.py"],
+ imports = [".."],
srcs_version = "PY3",
visibility = [
"//experimental:__subpackages__",
@@ -101,10 +105,9 @@ py_binary(
visibility = ["//visibility:public"],
)
-# This might be public, but use at your own risk
py_library(
- name = "verify_archive_test_lib",
- srcs = ["verify_archive_test_lib.py"],
+ name = "filter_directory_lib",
+ srcs = ["filter_directory.py"],
srcs_version = "PY3",
visibility = ["//visibility:public"],
)
diff --git a/pkg/deps.bzl b/pkg/deps.bzl
index 352bff6..1fecfbf 100644
--- a/pkg/deps.bzl
+++ b/pkg/deps.bzl
@@ -14,40 +14,46 @@
"""WORKSPACE dependencies for rules_pkg/pkg."""
-load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
+load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-# @federation: BEGIN @rules_pkg
+def http_archive(**kwargs):
+ maybe(_http_archive, **kwargs)
def rules_pkg_dependencies():
- maybe(
- http_archive,
+ http_archive(
name = "bazel_skylib",
+ sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.1.1/bazel-skylib-1.1.1.tar.gz",
+ "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",
],
- sha256 = "c6966ec828da198c5d9adbaa94c05e3a1c7f21bd012a0b29ba8ddbccb2c93b0d",
)
- maybe(
- http_archive,
+
+ 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",
+ ],
+ sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
+ )
+
+ http_archive(
name = "rules_python",
- url = "https://github.com/bazelbuild/rules_python/releases/download/0.1.0/rules_python-0.1.0.tar.gz",
- sha256 = "b6d46438523a3ec0f3cead544190ee13223a52f6a6765a29eae7b7cc24cc83a0",
+ 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",
)
- maybe(
- http_archive,
+
+ http_archive(
name = "rules_license",
urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
- "https://github.com/bazelbuild/rules_license/releases/download/0.0.4/rules_license-0.0.4.tar.gz",
- ],
- sha256 = "6157e1e68378532d0241ecd15d3c45f6e5cfd98fc10846045509fb2a7cc9e381",
+ "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",
+ ],
+ sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
)
-
def rules_pkg_register_toolchains():
pass
-
-# @federation: END @rules_pkg
diff --git a/pkg/install.bzl b/pkg/install.bzl
index fcf4ac8..e7b0e42 100644
--- a/pkg/install.bzl
+++ b/pkg/install.bzl
@@ -17,24 +17,20 @@ This module provides an interface (`pkg_install`) for creating a `bazel
run`-able installation script.
"""
-load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
-load("//pkg/private:pkg_files.bzl", "process_src", "write_manifest")
load("@rules_python//python:defs.bzl", "py_binary")
+load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
+load("//pkg/private:pkg_files.bzl", "create_mapping_context_from_ctx", "process_src", "write_manifest")
def _pkg_install_script_impl(ctx):
script_file = ctx.actions.declare_file(ctx.attr.name + ".py")
- fragments = []
- files_to_run = []
- content_map = {}
+ mapping_context = create_mapping_context_from_ctx(ctx, label = ctx.label, default_mode = "0644")
for src in ctx.attr.srcs:
- process_src(content_map,
- files_to_run,
- src = src,
- origin = src.label,
- default_mode = "0644",
- default_user = None,
- default_group = None)
+ process_src(
+ mapping_context,
+ src = src,
+ origin = src.label,
+ )
manifest_file = ctx.actions.declare_file(ctx.attr.name + "-install-manifest.json")
@@ -44,14 +40,14 @@ def _pkg_install_script_impl(ctx):
# Note that these paths are different when used as tools run within a build.
# See also
# https://docs.bazel.build/versions/4.1.0/skylark/rules.html#tools-with-runfiles
- write_manifest(ctx, manifest_file, content_map, use_short_path = True)
+ write_manifest(ctx, manifest_file, mapping_context.content_map, use_short_path = True)
# Get the label of the actual py_binary used to run this script.
#
# This is super brittle, but I don't know how to otherwise get this
# information without creating a circular dependency given the current state
# of rules_python.
-
+
# The name of the binary is the name of this target, minus
# "_install_script".
label_str = str(ctx.label)[:-len("_install_script")]
@@ -72,7 +68,7 @@ def _pkg_install_script_impl(ctx):
my_runfiles = ctx.runfiles(
files = [manifest_file],
- transitive_files = depset(transitive = files_to_run),
+ transitive_files = depset(transitive = mapping_context.file_deps),
)
return [
@@ -87,7 +83,7 @@ _pkg_install_script = rule(
doc = """Create an executable package installation script.
The outputs of this rule are a single python script intended to be used as
- an input to a `py_binary` target. All files necesary to run the script are
+ an input to a `py_binary` target. All files necessary to run the script are
included as runfiles.
""",
implementation = _pkg_install_script_impl,
@@ -142,7 +138,7 @@ def pkg_install(name, srcs, **kwargs):
```
bazel run -- //path/to:install --help
```
-
+
WARNING: While this rule does function when being run from within a bazel
rule, such use is not recommended. If you do, **always** use the
`--destdir` argument to specify the desired location for the installation to
diff --git a/pkg/legacy/rpm.bzl b/pkg/legacy/rpm.bzl
index 3211bbd..74f1730 100644
--- a/pkg/legacy/rpm.bzl
+++ b/pkg/legacy/rpm.bzl
@@ -36,10 +36,10 @@ def _pkg_rpm_impl(ctx):
tools = []
args = ["--name=" + ctx.label.name]
if ctx.attr.debug:
- args += ["--debug"]
+ args.append("--debug")
if ctx.attr.rpmbuild_path:
- args += ["--rpmbuild=" + ctx.attr.rpmbuild_path]
+ args.append("--rpmbuild=" + ctx.attr.rpmbuild_path)
# buildifier: disable=print
print("rpmbuild_path is deprecated. See the README for instructions on how" +
@@ -50,7 +50,7 @@ def _pkg_rpm_impl(ctx):
fail("The rpmbuild_toolchain is not properly configured: " +
toolchain.name)
if toolchain.path:
- args += ["--rpmbuild=" + toolchain.path]
+ args.append("--rpmbuild=" + toolchain.path)
else:
executable_files = toolchain.label[DefaultInfo].files_to_run
tools.append(executable_files)
@@ -60,31 +60,31 @@ def _pkg_rpm_impl(ctx):
if ctx.attr.version_file:
if ctx.attr.version:
fail("Both version and version_file attributes were specified")
- args += ["--version=@" + ctx.file.version_file.path]
- files += [ctx.file.version_file]
+ args.append("--version=@" + ctx.file.version_file.path)
+ files.append(ctx.file.version_file)
elif ctx.attr.version:
- args += ["--version=" + ctx.attr.version]
+ args.append("--version=" + ctx.attr.version)
# Release can be specified by a file or inlined.
if ctx.attr.release_file:
if ctx.attr.release:
fail("Both release and release_file attributes were specified")
- args += ["--release=@" + ctx.file.release_file.path]
- files += [ctx.file.release_file]
+ args.append("--release=@" + ctx.file.release_file.path)
+ files.append(ctx.file.release_file)
elif ctx.attr.release:
- args += ["--release=" + ctx.attr.release]
+ args.append("--release=" + ctx.attr.release)
# SOURCE_DATE_EPOCH can be specified by a file or inlined.
if ctx.attr.source_date_epoch_file:
if ctx.attr.source_date_epoch:
fail("Both source_date_epoch and source_date_epoch_file attributes were specified")
- args += ["--source_date_epoch=@" + ctx.file.source_date_epoch_file.path]
- files += [ctx.file.source_date_epoch_file]
+ args.append("--source_date_epoch=@" + ctx.file.source_date_epoch_file.path)
+ files.append(ctx.file.source_date_epoch_file)
elif ctx.attr.source_date_epoch != None:
- args += ["--source_date_epoch=" + str(ctx.attr.source_date_epoch)]
+ args.append("--source_date_epoch=" + str(ctx.attr.source_date_epoch))
if ctx.attr.architecture:
- args += ["--arch=" + ctx.attr.architecture]
+ args.append("--arch=" + ctx.attr.architecture)
if not ctx.attr.spec_file:
fail("spec_file was not specified")
@@ -102,19 +102,19 @@ def _pkg_rpm_impl(ctx):
output = spec_file,
substitutions = substitutions,
)
- args += ["--spec_file=" + spec_file.path]
- files += [spec_file]
+ args.append("--spec_file=" + spec_file.path)
+ files.append(spec_file)
- args += ["--out_file=" + ctx.outputs.rpm.path]
+ args.append("--out_file=" + ctx.outputs.rpm.path)
# Add data files.
if ctx.file.changelog:
- files += [ctx.file.changelog]
- args += [ctx.file.changelog.path]
+ files.append(ctx.file.changelog)
+ args.append(ctx.file.changelog.path)
files += ctx.files.data
for f in ctx.files.data:
- args += [f.path]
+ args.append(f.path)
# Call the generator script.
ctx.actions.run(
diff --git a/pkg/legacy/tests/rpm/test_rpm.spec b/pkg/legacy/tests/rpm/test_rpm.spec
index 9cfb5da..efaeb6f 100644
--- a/pkg/legacy/tests/rpm/test_rpm.spec
+++ b/pkg/legacy/tests/rpm/test_rpm.spec
@@ -7,7 +7,7 @@ License: Apache License, v2.0
# Do not try to use magic to determine file types
%define __spec_install_post %{nil}
-# Do not die becuse we give it more input files than are in the files section
+# Do not die because we give it more input files than are in the files section
%define _unpackaged_files_terminate_build 0
%description
diff --git a/pkg/make_rpm.py b/pkg/make_rpm.py
index e2ffca0..dd30a49 100644
--- a/pkg/make_rpm.py
+++ b/pkg/make_rpm.py
@@ -198,6 +198,7 @@ class RpmBuilder(object):
self.description_file = None
self.install_script_file = None
self.file_list_path = None
+ self.changelog = None
self.pre_scriptlet = None
self.post_scriptlet = None
@@ -230,6 +231,8 @@ class RpmBuilder(object):
post_scriptlet_path=None,
preun_scriptlet_path=None,
postun_scriptlet_path=None,
+ posttrans_scriptlet_path=None,
+ changelog_file=None,
file_list_path=None):
"""Create the needed structure in the workdir."""
@@ -262,16 +265,24 @@ class RpmBuilder(object):
SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path is not None else ''
self.postun_scriptlet = \
SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path is not None else ''
+ self.posttrans_scriptlet = \
+ SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path is not None else ''
# Then prepare for textual substitution. This is typically only the case for the
# experimental `pkg_rpm`.
tpl_replacements = {
- 'PRE_SCRIPTLET': "%pre\n" + self.pre_scriptlet,
- 'POST_SCRIPTLET': "%post\n" + self.post_scriptlet,
- 'PREUN_SCRIPTLET': "%preun\n" + self.preun_scriptlet,
- 'POSTUN_SCRIPTLET': "%postun\n" + self.postun_scriptlet,
+ 'PRE_SCRIPTLET': ("%pre\n" + self.pre_scriptlet) if self.pre_scriptlet else "",
+ 'POST_SCRIPTLET': ("%post\n" + self.post_scriptlet) if self.post_scriptlet else "",
+ 'PREUN_SCRIPTLET': ("%preun\n" + self.preun_scriptlet) if self.preun_scriptlet else "",
+ 'POSTUN_SCRIPTLET': ("%postun\n" + self.postun_scriptlet) if self.postun_scriptlet else "",
+ 'POSTTRANS_SCRIPTLET': ("%posttrans\n" + self.posttrans_scriptlet) if self.posttrans_scriptlet else "",
+ 'CHANGELOG': ""
}
+ if changelog_file:
+ self.changelog = SlurpFile(os.path.join(original_dir, changelog_file))
+ tpl_replacements["CHANGELOG"] = "%changelog\n" + self.changelog
+
# If the spec file has "Version" and "Release" tags specified in the spec
# file's preamble, the values are filled in immediately afterward. These go
# into "replacements". This is typically only the case for the "original"
@@ -350,6 +361,7 @@ class RpmBuilder(object):
args += [
'--define', '_topdir %s' % dirname,
'--define', '_tmppath %s/TMP' % dirname,
+ '--define', '_builddir %s/BUILD' % dirname,
'--bb',
'--buildroot=%s' % buildroot,
] # yapf: disable
@@ -422,7 +434,9 @@ class RpmBuilder(object):
post_scriptlet_path=None,
preun_scriptlet_path=None,
postun_scriptlet_path=None,
+ posttrans_scriptlet_path=None,
file_list_path=None,
+ changelog_file=None,
rpmbuild_args=None):
"""Build the RPM described by the spec_file, with other metadata in keyword arguments"""
@@ -442,7 +456,9 @@ class RpmBuilder(object):
pre_scriptlet_path=pre_scriptlet_path,
post_scriptlet_path=post_scriptlet_path,
preun_scriptlet_path=preun_scriptlet_path,
- postun_scriptlet_path=postun_scriptlet_path)
+ postun_scriptlet_path=postun_scriptlet_path,
+ posttrans_scriptlet_path=posttrans_scriptlet_path,
+ changelog_file=changelog_file)
status = self.CallRpmBuild(dirname, rpmbuild_args or [])
self.SaveResult(out_file)
@@ -491,6 +507,10 @@ def main(argv):
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')
+ parser.add_argument('--posttrans_scriptlet',
+ 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')
@@ -514,6 +534,8 @@ def main(argv):
post_scriptlet_path=options.post_scriptlet,
preun_scriptlet_path=options.preun_scriptlet,
postun_scriptlet_path=options.postun_scriptlet,
+ posttrans_scriptlet_path=options.posttrans_scriptlet,
+ changelog_file=options.changelog,
rpmbuild_args=options.rpmbuild_args)
except NoRpmbuildFoundError:
print('ERROR: rpmbuild is required but is not present in PATH')
diff --git a/pkg/mappings.bzl b/pkg/mappings.bzl
index e49acd0..704a8db 100644
--- a/pkg/mappings.bzl
+++ b/pkg/mappings.bzl
@@ -27,8 +27,8 @@ Rules that actually make use of the outputs of the above rules are not specified
here.
"""
-load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
+load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
# TODO(#333): strip_prefix module functions should produce unique outputs. In
# particular, this one and `_sp_from_pkg` can overlap.
@@ -72,15 +72,21 @@ strip_prefix = struct(
from_root = _sp_from_root,
)
-def pkg_attributes(mode = None, user = None, group = None, **kwargs):
+def pkg_attributes(
+ mode = None,
+ user = None,
+ group = None,
+ uid = None,
+ gid = None,
+ **kwargs):
"""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", or "group" will result in the package builder
- choosing one for you. The chosen value should not be relied upon.
+ 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.
@@ -90,8 +96,10 @@ def pkg_attributes(mode = None, user = None, group = None, **kwargs):
Args:
mode: string: UNIXy octal permissions, as a string.
- user: string: Filesystem owning user.
- group: string: Filesystem owning group.
+ user: string: Filesystem owning user name.
+ group: string: Filesystem owning group name.
+ uid: int: Filesystem owning user id.
+ gid: int: Filesystem owning group id.
**kwargs: any other desired attributes.
Returns:
@@ -105,6 +113,23 @@ def pkg_attributes(mode = None, user = None, group = None, **kwargs):
ret["user"] = user
if group:
ret["group"] = group
+ if uid != None:
+ if type(uid) != type(0):
+ fail('Got "' + str(uid) + '" instead of integer uid')
+ ret["uid"] = uid
+ if gid != None:
+ if type(gid) != type(0):
+ fail('Got "' + str(gid) + '" instead of integer gid')
+ ret["gid"] = gid
+
+ if user != None and user.isdigit() and uid == None:
+ # buildifier: disable=print
+ print("Warning: found numeric username and no uid, did you mean to specify the uid instead?")
+
+ if group != None and group.isdigit() and gid == None:
+ # buildifier: disable=print
+ print("Warning: found numeric group and no gid, did you mean to specify the gid instead?")
+
return json.encode(ret)
####
@@ -122,8 +147,8 @@ def _do_strip_prefix(path, to_strip, src_file):
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:
- return ''
+ elif 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.
@@ -196,7 +221,13 @@ def _pkg_files_impl(ctx):
# The input sources are already known. Let's calculate the destinations...
# Exclude excludes
- srcs = [f for f in ctx.files.srcs if f not in ctx.files.excludes]
+ srcs = [] # srcs is source File objects, not Targets
+ file_to_target = {}
+ for src in ctx.attr.srcs:
+ for f in src[DefaultInfo].files.to_list():
+ if f not in ctx.files.excludes:
+ srcs.append(f)
+ file_to_target[f] = src
if ctx.attr.strip_prefix == _PKGFILEGROUP_STRIP_ALL:
src_dest_paths_map = {src: paths.join(ctx.attr.prefix, src.basename) for src in srcs}
@@ -260,6 +291,26 @@ def _pkg_files_impl(ctx):
else:
src_dest_paths_map[src_file] = paths.join(ctx.attr.prefix, rename_dest)
+ # At this point, we have a fully valid src -> dest mapping for all the
+ # explicitly named targets in srcs. Now we can fill in their runfiles.
+ if ctx.attr.include_runfiles:
+ for src in srcs:
+ target = file_to_target[src]
+ runfiles = target[DefaultInfo].default_runfiles
+ if runfiles:
+ base_path = src_dest_paths_map[src] + ".runfiles"
+ for rf in runfiles.files.to_list():
+ dest_path = paths.join(base_path, rf.short_path)
+
+ # print("Add runfile:", rf.path, 'as', dest_path)
+ have_it = src_dest_paths_map.get(rf)
+ if have_it:
+ if have_it != dest_path:
+ # buildifier: disable=print
+ print("same source mapped to different locations", rf, have_it, dest_path)
+ else:
+ src_dest_paths_map[rf] = dest_path
+
# At this point, we have a fully valid src -> dest mapping in src_dest_paths_map.
#
# Construct the inverse of this mapping to pass to the output providers, and
@@ -403,6 +454,14 @@ pkg_files = rule(
default = {},
allow_files = True,
),
+ "include_runfiles": attr.bool(
+ doc = """Add runfiles for all srcs.
+
+ 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>`
+ """,
+ ),
},
provides = [PackageFilesInfo],
)
@@ -537,30 +596,32 @@ pkg_mklink_impl = rule(
provides = [PackageSymlinkInfo],
)
-def pkg_mklink(name, link_name, target, attributes=None, src=None, **kwargs):
- """Create a symlink.
-
- Args:
- name: target name
- target: target path that the link should point to.
- link_name: the path in the package that should point to the target.
- attributes: file attributes.
- """
- if src:
- if target:
- fail("You can not specify both target and src.")
- # buildifier: disable=print
- print("Warning: pkg_mklink.src is deprecated. Use target.")
- target = src
- pkg_mklink_impl(
- name = name,
- target = target,
- link_name = link_name,
- attributes = attributes,
- **kwargs,
- )
+#buildifier: disable=function-docstring-args
+def pkg_mklink(name, link_name, target, attributes = None, src = None, **kwargs):
+ """Create a symlink.
+ Wraps [pkg_mklink_impl](#pkg_mklink_impl)
+ Args:
+ name: target name
+ target: target path that the link should point to.
+ link_name: the path in the package that should point to the target.
+ attributes: file attributes.
+ """
+ if src:
+ if target:
+ fail("You can not specify both target and src.")
+
+ # buildifier: disable=print
+ print("Warning: pkg_mklink.src is deprecated. Use target.")
+ target = src
+ pkg_mklink_impl(
+ name = name,
+ target = target,
+ link_name = link_name,
+ attributes = attributes,
+ **kwargs
+ )
def _pkg_filegroup_impl(ctx):
files = []
diff --git a/pkg/package_variables.bzl b/pkg/package_variables.bzl
index 865fefd..28f62c9 100644
--- a/pkg/package_variables.bzl
+++ b/pkg/package_variables.bzl
@@ -16,6 +16,6 @@
def add_ctx_variables(ctx, values):
"""Add selected variables from ctx."""
- values['target_cpu'] = ctx.var.get("TARGET_CPU")
- values['compilation_mode'] = ctx.var.get("COMPILATION_MODE")
+ values["target_cpu"] = ctx.var.get("TARGET_CPU")
+ values["compilation_mode"] = ctx.var.get("COMPILATION_MODE")
return values
diff --git a/pkg/path.bzl b/pkg/path.bzl
index c933ccd..f384398 100644
--- a/pkg/path.bzl
+++ b/pkg/path.bzl
@@ -11,8 +11,10 @@
# 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.
-"""Helper functions that don't depend on Skylark, so can be unit tested."""
+"""Helper functions that don't depend on Starlark, so can be unit tested."""
+# buildifier: disable=function-docstring-args
+# buildifier: disable=function-docstring-return
def safe_short_path(file_):
"""Like `File.short_path` but safe for use with files from external repositories.
"""
@@ -27,9 +29,10 @@ def safe_short_path(file_):
# Beginning with `file_.path`, remove optional `F.root.path`.
working_path = file_.path
if not file_.is_source:
- working_path = working_path[len(file_.root.path)+1:]
+ working_path = working_path[len(file_.root.path) + 1:]
return working_path
+# buildifier: disable=function-docstring-args,function-docstring-return
def _short_path_dirname(path):
"""Returns the directory's name of the short path of an artifact."""
sp = safe_short_path(path)
@@ -39,6 +42,8 @@ def _short_path_dirname(path):
return ""
return sp[:last_pkg]
+# buildifier: disable=function-docstring-args
+# buildifier: disable=function-docstring-return
def dest_path(f, strip_prefix, data_path_without_prefix = ""):
"""Returns the short path of f, stripped of strip_prefix."""
f_short_path = safe_short_path(f)
@@ -56,32 +61,33 @@ def dest_path(f, strip_prefix, data_path_without_prefix = ""):
# Avoid stripping prefix if final directory is incomplete
if prefix_last_dir not in f_short_path.split("/"):
- strip_prefix = data_path_without_prefix
+ strip_prefix = data_path_without_prefix
return f_short_path[len(strip_prefix):]
return f_short_path
-def compute_data_path(ctx, data_path):
+def compute_data_path(label, data_path):
"""Compute the relative data path prefix from the data_path attribute.
Args:
- ctx: rule implementation ctx.
- data_path: path to a file, relative to the package of the rule ctx.
+ label: target label
+ data_path: path to a file, relative to the package of the label.
+ Returns:
+ str
"""
- build_dir = ctx.label.package
if data_path:
# Strip ./ from the beginning if specified.
# There is no way to handle .// correctly (no function that would make
- # that possible and Skylark is not turing complete) so just consider it
+ # that possible and Starlark is not turing complete) so just consider it
# as an absolute path.
if len(data_path) >= 2 and data_path[0:2] == "./":
data_path = data_path[2:]
if not data_path or data_path == ".": # Relative to current package
- return build_dir
+ return label.package
elif data_path[0] == "/": # Absolute path
return data_path[1:]
else: # Relative to a sub-directory
- tmp_short_path_dirname = build_dir
+ tmp_short_path_dirname = label.package
if tmp_short_path_dirname:
return tmp_short_path_dirname + "/" + data_path
return data_path
diff --git a/pkg/private/BUILD b/pkg/private/BUILD
index 85096bc..8f3ca4c 100644
--- a/pkg/private/BUILD
+++ b/pkg/private/BUILD
@@ -65,6 +65,7 @@ py_library(
srcs = [
"build_info.py",
],
+ imports = ["../.."],
srcs_version = "PY3",
visibility = [
"//:__subpackages__",
@@ -78,6 +79,7 @@ py_library(
"__init__.py",
"archive.py",
],
+ imports = ["../.."],
srcs_version = "PY3",
visibility = [
"//:__subpackages__",
@@ -91,6 +93,7 @@ py_library(
"__init__.py",
"helpers.py",
],
+ imports = ["../.."],
srcs_version = "PY3",
visibility = [
"//:__subpackages__",
@@ -101,6 +104,7 @@ py_library(
py_library(
name = "manifest",
srcs = ["manifest.py"],
+ imports = ["../.."],
srcs_version = "PY3",
visibility = ["//visibility:public"],
)
diff --git a/pkg/private/deb/BUILD b/pkg/private/deb/BUILD
index c38da64..646877b 100644
--- a/pkg/private/deb/BUILD
+++ b/pkg/private/deb/BUILD
@@ -48,6 +48,7 @@ exports_files(
py_binary(
name = "make_deb",
srcs = ["make_deb.py"],
+ imports = ["../../.."],
python_version = "PY3",
visibility = ["//visibility:public"],
deps = [
@@ -58,6 +59,7 @@ py_binary(
py_library(
name = "make_deb_lib",
srcs = ["make_deb.py"],
+ imports = ["../../.."],
srcs_version = "PY3",
visibility = ["//tests/deb:__pkg__"],
deps = [
diff --git a/pkg/private/deb/deb.bzl b/pkg/private/deb/deb.bzl
index 2541d86..53bc2eb 100644
--- a/pkg/private/deb/deb.bzl
+++ b/pkg/private/deb/deb.bzl
@@ -13,10 +13,10 @@
# limitations under the License.
"""Rule for creating Debian packages."""
-load("//pkg:providers.bzl", "PackageArtifactInfo", "PackageVariablesInfo")
+load("//pkg:providers.bzl", "PackageVariablesInfo")
load("//pkg/private:util.bzl", "setup_output_files")
-_tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz"]
+_tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz", "tar.zst"]
def _pkg_deb_impl(ctx):
"""The implementation for the pkg_deb rule."""
@@ -50,39 +50,39 @@ def _pkg_deb_impl(ctx):
if ctx.attr.architecture_file:
if ctx.attr.architecture != "all":
fail("Both architecture and architecture_file attributes were specified")
- args += ["--architecture=@" + ctx.file.architecture_file.path]
- files += [ctx.file.architecture_file]
+ args.append("--architecture=@" + ctx.file.architecture_file.path)
+ files.append(ctx.file.architecture_file)
else:
- args += ["--architecture=" + ctx.attr.architecture]
+ args.append("--architecture=" + ctx.attr.architecture)
if ctx.attr.preinst:
- args += ["--preinst=@" + ctx.file.preinst.path]
- files += [ctx.file.preinst]
+ args.append("--preinst=@" + ctx.file.preinst.path)
+ files.append(ctx.file.preinst)
if ctx.attr.postinst:
- args += ["--postinst=@" + ctx.file.postinst.path]
- files += [ctx.file.postinst]
+ args.append("--postinst=@" + ctx.file.postinst.path)
+ files.append(ctx.file.postinst)
if ctx.attr.prerm:
- args += ["--prerm=@" + ctx.file.prerm.path]
- files += [ctx.file.prerm]
+ args.append("--prerm=@" + ctx.file.prerm.path)
+ files.append(ctx.file.prerm)
if ctx.attr.postrm:
- args += ["--postrm=@" + ctx.file.postrm.path]
- files += [ctx.file.postrm]
+ args.append("--postrm=@" + ctx.file.postrm.path)
+ files.append(ctx.file.postrm)
if ctx.attr.config:
- args += ["--config=@" + ctx.file.config.path]
- files += [ctx.file.config]
+ args.append("--config=@" + ctx.file.config.path)
+ files.append(ctx.file.config)
if ctx.attr.templates:
- args += ["--templates=@" + ctx.file.templates.path]
- files += [ctx.file.templates]
+ args.append("--templates=@" + ctx.file.templates.path)
+ files.append(ctx.file.templates)
if ctx.attr.triggers:
- args += ["--triggers=@" + ctx.file.triggers.path]
- files += [ctx.file.triggers]
+ args.append("--triggers=@" + ctx.file.triggers.path)
+ files.append(ctx.file.triggers)
# Conffiles can be specified by a file or a string list
if ctx.attr.conffiles_file:
if ctx.attr.conffiles:
fail("Both conffiles and conffiles_file attributes were specified")
- args += ["--conffile=@" + ctx.file.conffiles_file.path]
- files += [ctx.file.conffiles_file]
+ args.append("--conffile=@" + ctx.file.conffiles_file.path)
+ files.append(ctx.file.conffiles_file)
elif ctx.attr.conffiles:
args += ["--conffile=%s" % cf for cf in ctx.attr.conffiles]
@@ -90,51 +90,55 @@ def _pkg_deb_impl(ctx):
if ctx.attr.version_file:
if ctx.attr.version:
fail("Both version and version_file attributes were specified")
- args += ["--version=@" + ctx.file.version_file.path]
- files += [ctx.file.version_file]
+ args.append("--version=@" + ctx.file.version_file.path)
+ files.append(ctx.file.version_file)
elif ctx.attr.version:
- args += ["--version=" + ctx.attr.version]
+ args.append("--version=" + ctx.attr.version)
else:
fail("Neither version_file nor version attribute was specified")
if ctx.attr.description_file:
if ctx.attr.description:
fail("Both description and description_file attributes were specified")
- args += ["--description=@" + ctx.file.description_file.path]
- files += [ctx.file.description_file]
+ args.append("--description=@" + ctx.file.description_file.path)
+ files.append(ctx.file.description_file)
elif ctx.attr.description:
- args += ["--description=" + ctx.attr.description]
+ args.append("--description=" + ctx.attr.description)
else:
fail("Neither description_file nor description attribute was specified")
+ if ctx.attr.changelog:
+ args.append("--changelog=@" + ctx.file.changelog.path)
+ files.append(ctx.file.changelog)
+
# Built using can also be specified by a file or inlined (but is not mandatory)
if ctx.attr.built_using_file:
if ctx.attr.built_using:
fail("Both build_using and built_using_file attributes were specified")
- args += ["--built_using=@" + ctx.file.built_using_file.path]
- files += [ctx.file.built_using_file]
+ args.append("--built_using=@" + ctx.file.built_using_file.path)
+ files.append(ctx.file.built_using_file)
elif ctx.attr.built_using:
- args += ["--built_using=" + ctx.attr.built_using]
+ args.append("--built_using=" + ctx.attr.built_using)
if ctx.attr.depends_file:
if ctx.attr.depends:
fail("Both depends and depends_file attributes were specified")
- args += ["--depends=@" + ctx.file.depends_file.path]
- files += [ctx.file.depends_file]
+ args.append("--depends=@" + ctx.file.depends_file.path)
+ files.append(ctx.file.depends_file)
elif ctx.attr.depends:
args += ["--depends=" + d for d in ctx.attr.depends]
if ctx.attr.priority:
- args += ["--priority=" + ctx.attr.priority]
+ args.append("--priority=" + ctx.attr.priority)
if ctx.attr.section:
- args += ["--section=" + ctx.attr.section]
+ args.append("--section=" + ctx.attr.section)
if ctx.attr.homepage:
- args += ["--homepage=" + ctx.attr.homepage]
+ args.append("--homepage=" + ctx.attr.homepage)
if ctx.attr.license:
- args += ["--license=" + ctx.attr.license]
+ args.append("--license=" + ctx.attr.license)
- args += ["--distribution=" + ctx.attr.distribution]
- args += ["--urgency=" + ctx.attr.urgency]
+ args.append("--distribution=" + ctx.attr.distribution)
+ args.append("--urgency=" + ctx.attr.urgency)
args += ["--suggests=" + d for d in ctx.attr.suggests]
args += ["--enhances=" + d for d in ctx.attr.enhances]
args += ["--conflicts=" + d for d in ctx.attr.conflicts]
@@ -168,16 +172,23 @@ def _pkg_deb_impl(ctx):
files = depset([output_file]),
runfiles = ctx.runfiles(files = outputs),
),
- PackageArtifactInfo(
- label = ctx.label.name,
- file = output_file,
- file_name = output_name,
- ),
]
# A rule for creating a deb file, see README.md
pkg_deb_impl = rule(
implementation = _pkg_deb_impl,
+ doc = """
+ 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.
+ """,
attrs = {
# @unsorted-dict-items
"data": attr.label(
@@ -215,12 +226,17 @@ pkg_deb_impl = rule(
See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.""",
allow_single_file = True,
),
+ "changelog": attr.label(
+ doc = """The package changelog.
+ See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.""",
+ allow_single_file = True,
+ ),
"description": attr.string(
doc = """The package description. Must not be used with `description_file`.""",
),
"description_file": attr.label(
doc = """The package description. Must not be used with `description`.""",
- allow_single_file = True
+ allow_single_file = True,
),
"distribution": attr.string(
doc = """"distribution: See http://www.debian.org/doc/debian-policy.""",
@@ -261,11 +277,11 @@ pkg_deb_impl = rule(
allow_single_file = True,
),
"built_using": attr.string(
- doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file)."""
+ doc = """The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
),
"built_using_file": attr.label(
- doc="""The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
- allow_single_file = True
+ doc = """The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).""",
+ allow_single_file = True,
),
"conffiles": attr.string_list(
doc = """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.
@@ -287,7 +303,6 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
),
"homepage": attr.string(doc = """The homepage of the project."""),
"license": attr.string(doc = """The license of the project."""),
-
"breaks": attr.string_list(
doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
default = [],
@@ -332,15 +347,15 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
# Common attributes
"out": attr.output(
- doc = """See Common Attributes""",
- mandatory = True
+ doc = """See [Common Attributes](#out)""",
+ mandatory = True,
),
"package_file_name": attr.string(
- doc = """See Common Attributes.
+ doc = """See [Common Attributes](#package_file_name).
Default: "{package}-{version}-{architecture}.deb""",
),
"package_variables": attr.label(
- doc = """See Common Attributes""",
+ doc = """See [Common Attributes](#package_variables)""",
providers = [PackageVariablesInfo],
),
@@ -352,13 +367,12 @@ See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
allow_files = True,
),
},
- provides = [PackageArtifactInfo],
)
def pkg_deb(name, out = None, **kwargs):
"""@wraps(pkg_deb_impl)."""
if not out:
- out = name + ".deb"
+ out = name + ".deb"
pkg_deb_impl(
name = name,
out = out,
diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py
index 9e2e5c5..9d10c4b 100644
--- a/pkg/private/deb/make_deb.py
+++ b/pkg/private/deb/make_deb.py
@@ -14,6 +14,7 @@
"""A simple cross-platform helper to create a debian package."""
import argparse
+from enum import Enum
import gzip
import hashlib
import io
@@ -30,6 +31,8 @@ else:
from pkg.private import helpers
+Multiline = Enum('Multiline', ['NO', 'YES', 'YES_ADD_NEWLINE'])
+
# list of debian fields : (name, mandatory, is_multiline[, default])
# see http://www.debian.org/doc/debian-policy/ch-controlfields.html
@@ -118,7 +121,7 @@ def AddArFileEntry(fileobj, filename,
fileobj.write(b'\n') # 2-byte alignment padding
-def MakeDebianControlField(name: str, value: str, is_multiline:bool=False) -> str:
+def MakeDebianControlField(name: str, value: str, multiline:Multiline=Multiline.NO) -> str:
"""Add a field to a debian control file.
https://www.debian.org/doc/debian-policy/ch-controlfields.html#syntax-of-control-files
@@ -132,15 +135,20 @@ def MakeDebianControlField(name: str, value: str, is_multiline:bool=False) -> st
if isinstance(value, list):
value = u', '.join(value)
value = value.rstrip()
- if not is_multiline:
+ if multiline == Multiline.NO:
value = value.strip()
if '\n' in value:
raise ValueError(
'\\n is not allowed in simple control fields (%s)' % value)
lines = value.split('\n')
- result = name + ': ' +lines[0].strip() + '\n'
- for line in lines[1:]:
+ i = 0
+ if multiline != Multiline.YES_ADD_NEWLINE:
+ result = name + ': ' + lines[i].strip() + '\n'
+ i = 1
+ else:
+ result = name + ':\n'
+ for line in lines[i:]:
if not line.startswith(' '):
result += ' '
result += line
@@ -155,10 +163,10 @@ def CreateDebControl(extrafiles=None, **kwargs):
for values in DEBIAN_FIELDS:
fieldname = values[0]
mandatory = values[1]
- is_multiline = values[2]
+ multiline = Multiline.YES if values[2] else Multiline.NO
key = fieldname[0].lower() + fieldname[1:].replace('-', '')
if mandatory or (key in kwargs and kwargs[key]):
- controlfile += MakeDebianControlField(fieldname, kwargs[key], is_multiline)
+ controlfile += MakeDebianControlField(fieldname, kwargs[key], multiline)
# Create the control.tar file
tar = io.BytesIO()
with gzip.GzipFile('control.tar.gz', mode='w', fileobj=tar, mtime=0) as gz:
@@ -190,6 +198,7 @@ def CreateDeb(output,
templates=None,
triggers=None,
conffiles=None,
+ changelog=None,
**kwargs):
"""Create a full debian package."""
extrafiles = OrderedDict()
@@ -209,6 +218,8 @@ def CreateDeb(output,
extrafiles['triggers'] = (triggers, 0o644)
if conffiles:
extrafiles['conffiles'] = ('\n'.join(conffiles) + '\n', 0o644)
+ if changelog:
+ extrafiles['changelog'] = (changelog, 0o644)
control = CreateDebControl(extrafiles=extrafiles, **kwargs)
# Write the final AR archive (the deb package)
@@ -226,7 +237,7 @@ def CreateDeb(output,
ext = 'tar.bz2'
else:
ext = '.'.join(ext)
- if ext not in ['tar.bz2', 'tar.gz', 'tar.xz', 'tar.lzma']:
+ if ext not in ['tar.bz2', 'tar.gz', 'tar.xz', 'tar.lzma', 'tar.zst']:
ext = 'tar'
data_size = os.stat(data).st_size
with open(data, 'rb') as datafile:
@@ -280,7 +291,7 @@ def CreateChanges(output,
changesdata = u''.join([
MakeDebianControlField('Format', '1.8'),
- MakeDebianControlField('Date', time.ctime(timestamp)),
+ MakeDebianControlField('Date', time.asctime(time.gmtime(timestamp))),
MakeDebianControlField('Source', package),
MakeDebianControlField('Binary', package),
MakeDebianControlField('Architecture', architecture),
@@ -290,21 +301,27 @@ def CreateChanges(output,
MakeDebianControlField('Maintainer', maintainer),
MakeDebianControlField('Changed-By', maintainer),
# The description in the changes file is strange
- 'Description:\n %s - %s\n' % (package, description.split('\n')[0]),
+ MakeDebianControlField('Description', (
+ '%s - %s\n') % (
+ package, description.split('\n')[0]),
+ multiline=Multiline.YES_ADD_NEWLINE),
MakeDebianControlField('Changes', (
- '\n %s (%s) %s; urgency=%s'
+ '%s (%s) %s; urgency=%s'
'\n Changes are tracked in revision control.') % (
package, version, distribution, urgency),
- is_multiline=True),
+ multiline=Multiline.YES_ADD_NEWLINE),
MakeDebianControlField(
- 'Files', '\n ' + ' '.join(
- [checksums['md5'], debsize, section, priority, deb_basename])),
+ 'Files', ' '.join(
+ [checksums['md5'], debsize, section, priority, deb_basename]),
+ multiline=Multiline.YES_ADD_NEWLINE),
MakeDebianControlField(
'Checksums-Sha1',
- '\n ' + ' '.join([checksums['sha1'], debsize, deb_basename])),
+ ' '.join([checksums['sha1'], debsize, deb_basename]),
+ multiline=Multiline.YES_ADD_NEWLINE),
MakeDebianControlField(
'Checksums-Sha256',
- '\n ' + ' '.join([checksums['sha256'], debsize, deb_basename]))
+ ' '.join([checksums['sha256'], debsize, deb_basename]),
+ multiline=Multiline.YES_ADD_NEWLINE)
])
with open(output, 'wb') as changes_fh:
changes_fh.write(changesdata.encode('utf-8'))
@@ -353,6 +370,9 @@ def main():
parser.add_argument(
'--conffile', action='append',
help='List of conffiles (prefix item with @ to provide a path)')
+ parser.add_argument(
+ '--changelog',
+ help='The changelog file (prefix item with @ to provide a path).')
AddControlFlags(parser)
options = parser.parse_args()
@@ -367,6 +387,7 @@ def main():
templates=helpers.GetFlagValue(options.templates, False),
triggers=helpers.GetFlagValue(options.triggers, False),
conffiles=GetFlagValues(options.conffile),
+ changelog=helpers.GetFlagValue(options.changelog, False),
package=options.package,
version=helpers.GetFlagValue(options.version),
description=helpers.GetFlagValue(options.description),
diff --git a/pkg/private/helpers.py b/pkg/private/helpers.py
index 0ad8e93..5147cc2 100644
--- a/pkg/private/helpers.py
+++ b/pkg/private/helpers.py
@@ -52,7 +52,7 @@ def GetFlagValue(flagvalue, strip=True):
"""Converts a raw flag string to a useable value.
1. Expand @filename style flags to the content of filename.
- 2. Cope with Python3 strangness of sys.argv.
+ 2. Cope with Python3 strangeness of sys.argv.
sys.argv is not actually proper str types on Unix with Python3
The bytes of the arg are each directly transcribed to the characters of
the str. It is actually more complex than that, as described in the docs.
diff --git a/pkg/private/install.py.tpl b/pkg/private/install.py.tpl
index 612908a..b0517f4 100644
--- a/pkg/private/install.py.tpl
+++ b/pkg/private/install.py.tpl
@@ -186,7 +186,7 @@ def main(args):
installer = NativeInstaller(destdir=args.destdir)
if not CALLED_FROM_BAZEL_RUN and RUNFILE_PREFIX is None:
- logging.critical("RUNFILES_DIR must be set in your enviornment when this is run as a bazel build tool.")
+ logging.critical("RUNFILES_DIR must be set in your environment when this is run as a bazel build tool.")
logging.critical("This is most likely an issue on Windows. See https://github.com/bazelbuild/rules_pkg/issues/387.")
return 1
diff --git a/pkg/private/manifest.py b/pkg/private/manifest.py
index 57b7ddd..6bfd387 100644
--- a/pkg/private/manifest.py
+++ b/pkg/private/manifest.py
@@ -33,15 +33,19 @@ class ManifestEntry(object):
mode: str
user: str
group: str
+ uid: int
+ gid: int
origin: str = None
- def __init__(self, type, dest, src, mode, user, group, origin = None):
+ def __init__(self, type, dest, src, mode, user, group, uid = None, gid = None, origin = None):
self.type = type
self.dest = dest
self.src = src
self.mode = mode
self.user = user
self.group = group
+ self.uid = uid
+ self.gid = gid
self.origin = origin
def __repr__(self):
diff --git a/pkg/private/pkg_files.bzl b/pkg/private/pkg_files.bzl
index f0fe60b..6fc0971 100644
--- a/pkg/private/pkg_files.bzl
+++ b/pkg/private/pkg_files.bzl
@@ -34,7 +34,6 @@ Concepts and terms:
load("//pkg:path.bzl", "compute_data_path", "dest_path")
load(
"//pkg:providers.bzl",
- "PackageArtifactInfo",
"PackageDirsInfo",
"PackageFilegroupInfo",
"PackageFilesInfo",
@@ -44,9 +43,10 @@ load(
ENTRY_IS_FILE = "file" # Entry is a file: take content from <src>
ENTRY_IS_LINK = "symlink" # Entry is a symlink: dest -> <src>
ENTRY_IS_DIR = "dir" # Entry is an empty dir
-ENTRY_IS_TREE = "tree" # Entry is a tree artifact: take tree from <src>
+ENTRY_IS_TREE = "tree" # Entry is a tree artifact: take tree from <src>
ENTRY_IS_EMPTY_FILE = "empty-file" # Entry is a an empty file
+# buildifier: disable=name-conventions
_DestFile = provider(
doc = """Information about each destination in the final package.""",
fields = {
@@ -57,10 +57,79 @@ _DestFile = provider(
"link_to": "path to link to. src must not be set",
"entry_type": "string. See ENTRY_IS_* values above.",
"origin": "target which added this",
+ "uid": "uid, or empty",
+ "gid": "gid, or empty",
},
)
-def _check_dest(content_map, dest, src, origin):
+# buildifier: disable=name-conventions
+_MappingContext = provider(
+ doc = """Fields passed to process_* methods.""",
+ fields = {
+ "content_map": "in/out The content_map we are building up",
+ "file_deps": "in/out list of file Depsets represented in the map",
+ "label": "ctx.label",
+
+ # Behaviors
+ "allow_duplicates_with_different_content": "bool: don't fail when you double mapped files",
+ "include_runfiles": "bool: include runfiles",
+ "strip_prefix": "strip_prefix",
+
+ "path_mapper": "function to map destination paths",
+
+ # Defaults
+ "default_mode": "Default mode to apply to file without a mode setting",
+ "default_user": "Default user name to apply to file without a user",
+ "default_group": "Default group name to apply to file without a group",
+ "default_uid": "Default numeric uid to apply to file without a uid",
+ "default_gid": "Default numeric gid to apply to file without a gid",
+ },
+)
+
+# buildifier: disable=function-docstring-args
+def create_mapping_context_from_ctx(
+ ctx,
+ label,
+ allow_duplicates_with_different_content = None,
+ strip_prefix = None,
+ include_runfiles = None,
+ default_mode = None,
+ path_mapper = None
+ ):
+ """Construct a MappingContext.
+
+ Args: See the provider definition.
+
+ Returns:
+ _MappingContext
+ """
+ if allow_duplicates_with_different_content == None:
+ allow_duplicates_with_different_content = ctx.attr.allow_duplicates_with_different_content if hasattr(ctx.attr, "allow_duplicates_with_different_content") else False
+ if strip_prefix == None:
+ strip_prefix = ctx.attr.strip_prefix if hasattr(ctx.attr, "strip_prefix") else ""
+ if include_runfiles == None:
+ include_runfiles = ctx.attr.include_runfiles if hasattr(ctx.attr, "include_runfiles") else False
+ if default_mode == None:
+ default_mode = ctx.attr.mode if hasattr(ctx.attr, "default_mode") else ""
+
+ return _MappingContext(
+ content_map = dict(),
+ file_deps = list(),
+ label = label,
+ allow_duplicates_with_different_content = allow_duplicates_with_different_content,
+ strip_prefix = strip_prefix,
+ include_runfiles = include_runfiles,
+ default_mode = default_mode,
+ path_mapper = path_mapper or (lambda x: x),
+ # TODO(aiuto): allow these to be passed in as needed. But, before doing
+ # that, explore defauilt_uid/gid as 0 rather than None
+ default_user = "",
+ default_group = "",
+ default_uid = None,
+ default_gid = None,
+ )
+
+def _check_dest(content_map, dest, src, origin, allow_duplicates_with_different_content = False):
old_entry = content_map.get(dest)
if not old_entry:
return
@@ -72,96 +141,116 @@ def _check_dest(content_map, dest, src, origin):
# people specify the owner in one place, but another overly broad glob
# brings in the file with a different owner.
if old_entry.src.path != src.path:
- # buildifier: disable=print
- print(
- "Duplicate output path: <%s>, declared in %s and %s" % (
- dest,
- origin,
- content_map[dest].origin,
- ),
- "\n SRC:",
+ msg = "Duplicate output path: <%s>, declared in %s and %s\n SRC: %s" % (
+ dest,
+ origin,
+ content_map[dest].origin,
src,
)
+ if allow_duplicates_with_different_content:
+ # buildifier: disable=print
+ print("WARNING:", msg)
+ else:
+ # When we default to this behaviour, we should consider telling
+ # users the attribute to set to deal with this.
+ # For now though, let's not, since they've explicitly opted in.
+ fail(msg)
-def _merge_attributes(info, mode, user, group):
+def _merge_attributes(info, mode, user, group, uid, gid):
if hasattr(info, "attributes"):
attrs = info.attributes
mode = attrs.get("mode") or mode
user = attrs.get("user") or user
group = attrs.get("group") or group
- return (mode, user, group)
-def _process_pkg_dirs(content_map, pkg_dirs_info, origin, default_mode, default_user, default_group):
- attrs = _merge_attributes(pkg_dirs_info, default_mode, default_user, default_group)
+ new_uid = attrs.get("uid")
+ if new_uid != None:
+ uid = new_uid
+ new_gid = attrs.get("gid")
+ if new_gid != None:
+ gid = new_gid
+ return (mode, user, group, uid, gid)
+
+def _merge_context_attributes(info, mapping_context):
+ """Merge defaults from mapping context with those in the source provider.
+
+ Args:
+ info: provider from a pkt_* target
+ mapping_context: MappingContext with the defaults.
+ """
+ default_mode = mapping_context.default_mode if hasattr(mapping_context, "default_mode") else ""
+ default_user = mapping_context.default_user if hasattr(mapping_context, "default_user") else ""
+ default_group = mapping_context.default_group if hasattr(mapping_context, "default_group") else ""
+ default_uid = mapping_context.default_uid if hasattr(mapping_context, "default_uid") else ""
+ default_gid = mapping_context.default_gid if hasattr(mapping_context, "default_gid") else ""
+ return _merge_attributes(info, default_mode, default_user, default_group, default_uid, default_gid)
+
+def _process_pkg_dirs(mapping_context, pkg_dirs_info, origin):
+ attrs = _merge_context_attributes(pkg_dirs_info, mapping_context)
for dir in pkg_dirs_info.dirs:
dest = dir.strip("/")
- _check_dest(content_map, dest, None, origin)
- content_map[dest] = _DestFile(
+ _check_dest(mapping_context.content_map, dest, None, origin, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[dest] = _DestFile(
src = None,
entry_type = ENTRY_IS_DIR,
mode = attrs[0],
user = attrs[1],
group = attrs[2],
+ uid = attrs[3],
+ gid = attrs[4],
origin = origin,
)
-def _process_pkg_files(content_map, pkg_files_info, origin, default_mode, default_user, default_group):
- attrs = _merge_attributes(pkg_files_info, default_mode, default_user, default_group)
+def _process_pkg_files(mapping_context, pkg_files_info, origin):
+ attrs = _merge_context_attributes(pkg_files_info, mapping_context)
for filename, src in pkg_files_info.dest_src_map.items():
dest = filename.strip("/")
- _check_dest(content_map, dest, src, origin)
- content_map[dest] = _DestFile(
+ _check_dest(mapping_context.content_map, dest, src, origin, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[dest] = _DestFile(
src = src,
entry_type = ENTRY_IS_TREE if src.is_directory else ENTRY_IS_FILE,
mode = attrs[0],
user = attrs[1],
group = attrs[2],
+ uid = attrs[3],
+ gid = attrs[4],
origin = origin,
)
-def _process_pkg_symlink(content_map, pkg_symlink_info, origin, default_mode, default_user, default_group):
+def _process_pkg_symlink(mapping_context, pkg_symlink_info, origin):
dest = pkg_symlink_info.destination.strip("/")
- attrs = _merge_attributes(pkg_symlink_info, default_mode, default_user, default_group)
- _check_dest(content_map, dest, None, origin)
- content_map[dest] = _DestFile(
+ attrs = _merge_context_attributes(pkg_symlink_info, mapping_context)
+ _check_dest(mapping_context.content_map, dest, None, origin, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[dest] = _DestFile(
src = None,
entry_type = ENTRY_IS_LINK,
mode = attrs[0],
user = attrs[1],
group = attrs[2],
+ uid = attrs[3],
+ gid = attrs[4],
origin = origin,
link_to = pkg_symlink_info.target,
)
-def _process_pkg_filegroup(content_map, pkg_filegroup_info, origin, default_mode, default_user, default_group):
+def _process_pkg_filegroup(mapping_context, pkg_filegroup_info):
if hasattr(pkg_filegroup_info, "pkg_dirs"):
for d in pkg_filegroup_info.pkg_dirs:
- _process_pkg_dirs(content_map, d[0], d[1], default_mode, default_user, default_group)
+ _process_pkg_dirs(mapping_context, d[0], d[1])
if hasattr(pkg_filegroup_info, "pkg_files"):
for pf in pkg_filegroup_info.pkg_files:
- _process_pkg_files(content_map, pf[0], pf[1], default_mode, default_user, default_group)
+ _process_pkg_files(mapping_context, pf[0], pf[1])
if hasattr(pkg_filegroup_info, "pkg_symlinks"):
for psl in pkg_filegroup_info.pkg_symlinks:
- _process_pkg_symlink(content_map, psl[0], psl[1], default_mode, default_user, default_group)
+ _process_pkg_symlink(mapping_context, psl[0], psl[1])
-def process_src(
- content_map,
- files,
- src,
- origin,
- default_mode,
- default_user,
- default_group):
+def process_src(mapping_context, src, origin):
"""Add an entry to the content map.
Args:
- content_map: in/out The content map
- files: in/out list of file Depsets represented in the map
+ mapping_context: (r/w) a MappingContext
src: Source Package*Info object
origin: The rule instance adding this entry
- default_mode: fallback mode to use for Package*Info elements without mode
- default_user: fallback user to use for Package*Info elements without user
- default_group: fallback mode to use for Package*Info elements without group
Returns:
True if src was a Package*Info and added to content_map.
@@ -170,168 +259,133 @@ def process_src(
# Gather the files for every srcs entry here, even if it is not from
# a pkg_* rule.
if DefaultInfo in src:
- files.append(src[DefaultInfo].files)
+ mapping_context.file_deps.append(src[DefaultInfo].files)
found_info = False
if PackageFilesInfo in src:
_process_pkg_files(
- content_map,
+ mapping_context,
src[PackageFilesInfo],
origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
)
found_info = True
if PackageFilegroupInfo in src:
_process_pkg_filegroup(
- content_map,
+ mapping_context,
src[PackageFilegroupInfo],
- origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
)
found_info = True
if PackageSymlinkInfo in src:
_process_pkg_symlink(
- content_map,
+ mapping_context,
src[PackageSymlinkInfo],
origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
)
found_info = True
if PackageDirsInfo in src:
_process_pkg_dirs(
- content_map,
+ mapping_context,
src[PackageDirsInfo],
origin,
- default_mode = "0555",
- default_user = default_user,
- default_group = default_group,
)
found_info = True
return found_info
-def add_directory(content_map, dir_path, origin, mode = None, user = None, group = None):
+def add_directory(mapping_context, dir_path, origin, mode = None, user = None, group = None, uid = None, gid = None):
"""Add an empty directory to the content map.
Args:
- content_map: The content map
+ mapping_context: (r/w) a MappingContext
dir_path: Where to place the file in the package.
origin: The rule instance adding this entry
mode: fallback mode to use for Package*Info elements without mode
user: fallback user to use for Package*Info elements without user
group: fallback mode to use for Package*Info elements without group
+ uid: numeric uid
+ gid: numeric gid
"""
- content_map[dir_path.strip("/")] = _DestFile(
+ mapping_context.content_map[dir_path.strip("/")] = _DestFile(
src = None,
entry_type = ENTRY_IS_DIR,
origin = origin,
mode = mode,
- user = user,
- group = group,
+ user = user or mapping_context.default_user,
+ group = group or mapping_context.default_group,
+ uid = uid or mapping_context.default_uid,
+ gid = gid or mapping_context.default_gid,
)
-def add_empty_file(content_map, dest_path, origin, mode = None, user = None, group = None):
+def add_empty_file(mapping_context, dest_path, origin, mode = None, user = None, group = None, uid = None, gid = None):
"""Add a single file to the content map.
Args:
- content_map: The content map
+ mapping_context: (r/w) a MappingContext
dest_path: Where to place the file in the package.
origin: The rule instance adding this entry
mode: fallback mode to use for Package*Info elements without mode
user: fallback user to use for Package*Info elements without user
group: fallback mode to use for Package*Info elements without group
+ uid: numeric uid
+ gid: numeric gid
"""
dest = dest_path.strip("/")
- _check_dest(content_map, dest, None, origin)
- content_map[dest] = _DestFile(
+ _check_dest(mapping_context.content_map, dest, None, origin)
+ mapping_context.content_map[dest] = _DestFile(
src = None,
entry_type = ENTRY_IS_EMPTY_FILE,
origin = origin,
mode = mode,
- user = user,
- group = group,
+ user = user or mapping_context.default_user,
+ group = group or mapping_context.default_group,
+ uid = uid or mapping_context.default_uid,
+ gid = gid or mapping_context.default_gid,
)
-def add_label_list(
- ctx,
- content_map,
- file_deps,
- srcs,
- default_mode = None,
- default_user = None,
- default_group = None):
+def add_label_list(mapping_context, srcs):
"""Helper method to add a list of labels (typically 'srcs') to a content_map.
Args:
- ctx: rule context.
- content_map: (r/w) The content map to update.
- file_deps: (r/w) The list of file Depsets that srcs depend on.
- srcs: List of source objects.
- default_mode: fallback mode to use for Package*Info elements without mode
- default_user: fallback user to use for Package*Info elements without user
- default_group: fallback mode to use for Package*Info elements without group
+ mapping_context: (r/w) a MappingContext
+ srcs: List of source objects
"""
- if hasattr(ctx.attr, "include_runfiles"):
- include_runfiles = ctx.attr.include_runfiles
- else:
- include_runfiles = False
-
# Compute the relative path
data_path = compute_data_path(
- ctx,
- ctx.attr.strip_prefix if hasattr(ctx.attr, "strip_prefix") else "",
+ mapping_context.label,
+ mapping_context.strip_prefix,
+ )
+ data_path_without_prefix = compute_data_path(
+ mapping_context.label,
+ ".",
)
- data_path_without_prefix = compute_data_path(ctx, ".")
for src in srcs:
if not process_src(
- content_map,
- file_deps,
+ mapping_context,
src = src,
origin = src.label,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
):
# Add in the files of srcs which are not pkg_* types
add_from_default_info(
- content_map,
- file_deps,
+ mapping_context,
src,
data_path,
data_path_without_prefix,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- include_runfiles = include_runfiles,
+ include_runfiles = mapping_context.include_runfiles,
)
def add_from_default_info(
- content_map,
- file_deps,
+ mapping_context,
src,
data_path,
data_path_without_prefix,
- default_mode = None,
- default_user = None,
- default_group = None,
include_runfiles = False):
"""Helper method to add the DefaultInfo of a target to a content_map.
Args:
- content_map: (r/w) The content map to update.
- file_deps: (r/w) The list of file Depsets that srcs depend on.
+ mapping_context: (r/w) a MappingContext
src: A source object.
data_path: path to package
data_path_without_prefix: path to the package after prefix stripping
- default_mode: fallback mode to use for Package*Info elements without mode
- default_user: fallback user to use for Package*Info elements without user
- default_group: fallback mode to use for Package*Info elements without group
include_runfiles: Include runfiles
"""
if not DefaultInfo in src:
@@ -341,43 +395,54 @@ def add_from_default_info(
the_executable = get_my_executable(src)
all_files = src[DefaultInfo].files.to_list()
for f in all_files:
- d_path = dest_path(f, data_path, data_path_without_prefix)
+ d_path = mapping_context.path_mapper(
+ dest_path(f, data_path, data_path_without_prefix))
if f.is_directory:
add_tree_artifact(
- content_map,
- d_path,
- f,
+ mapping_context.content_map,
+ dest_path = d_path,
+ src = f,
origin = src.label,
- mode = default_mode,
- user = default_user,
- group = default_group,
+ mode = mapping_context.default_mode,
+ user = mapping_context.default_user,
+ group = mapping_context.default_group,
)
else:
- fmode = "0755" if f == the_executable else default_mode
+ fmode = "0755" if f == the_executable else mapping_context.default_mode
add_single_file(
- content_map,
+ mapping_context,
dest_path = d_path,
src = f,
origin = src.label,
mode = fmode,
- user = default_user,
- group = default_group,
+ user = mapping_context.default_user,
+ group = mapping_context.default_group,
)
if include_runfiles:
runfiles = src[DefaultInfo].default_runfiles
if runfiles:
- base_path = d_path + ".runfiles"
+ mapping_context.file_deps.append(runfiles.files)
+
+ # Computing the runfiles root is subtle. It should be based off of
+ # the executable, but that is not always obvious. When in doubt,
+ # the first file of DefaultInfo.files should be the right target.
+ base_file = the_executable or all_files[0]
+ base_file_path = dest_path(base_file, data_path, data_path_without_prefix)
+ base_path = base_file_path + ".runfiles"
+
for rf in runfiles.files.to_list():
- d_path = base_path + "/" + rf.short_path
- fmode = "0755" if rf == the_executable else default_mode
- _check_dest(content_map, d_path, rf, src.label)
- content_map[d_path] = _DestFile(
+ d_path = mapping_context.path_mapper(base_path + "/" + rf.short_path)
+ fmode = "0755" if rf == the_executable else mapping_context.default_mode
+ _check_dest(mapping_context.content_map, d_path, rf, src.label, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[d_path] = _DestFile(
src = rf,
entry_type = ENTRY_IS_FILE,
origin = src.label,
mode = fmode,
- user = default_user,
- group = default_group,
+ user = mapping_context.default_user,
+ group = mapping_context.default_group,
+ uid = mapping_context.default_uid,
+ gid = mapping_context.default_gid,
)
def get_my_executable(src):
@@ -409,54 +474,61 @@ def get_my_executable(src):
return ftr.executable
return None
-def add_single_file(content_map, dest_path, src, origin, mode = None, user = None, group = None):
+def add_single_file(mapping_context, dest_path, src, origin, mode = None, user = None, group = None, uid = None, gid = None):
"""Add an single file to the content map.
Args:
- content_map: The content map
+ mapping_context: the MappingContext
dest_path: Where to place the file in the package.
src: Source object. Must have len(src[DefaultInfo].files) == 1
origin: The rule instance adding this entry
mode: fallback mode to use for Package*Info elements without mode
user: fallback user to use for Package*Info elements without user
group: fallback mode to use for Package*Info elements without group
+ uid: numeric uid
+ gid: numeric gid
"""
dest = dest_path.strip("/")
- _check_dest(content_map, dest, src, origin)
- content_map[dest] = _DestFile(
+ _check_dest(mapping_context.content_map, dest, src, origin, mapping_context.allow_duplicates_with_different_content)
+ mapping_context.content_map[dest] = _DestFile(
src = src,
entry_type = ENTRY_IS_FILE,
origin = origin,
mode = mode,
- user = user,
- group = group,
+ user = user or mapping_context.default_user,
+ group = group or mapping_context.default_group,
+ uid = uid or mapping_context.default_uid,
+ gid = gid or mapping_context.default_gid,
)
-def add_symlink(content_map, dest_path, src, origin, mode = None, user = None, group = None):
+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
+ converge code by having pkg_tar be a macro that expands symlinks to
+ pkg_symlink targets and srcs them in.
+
Args:
- content_map: The content map
+ mapping_context: the MappingContext
dest_path: Where to place the file in the package.
src: Path to link to.
origin: The rule instance adding this entry
- mode: fallback mode to use for Package*Info elements without mode
- user: fallback user to use for Package*Info elements without user
- group: fallback mode to use for Package*Info elements without group
"""
dest = dest_path.strip("/")
- _check_dest(content_map, dest, None, origin)
- content_map[dest] = _DestFile(
+ _check_dest(mapping_context.content_map, dest, None, origin)
+ mapping_context.content_map[dest] = _DestFile(
src = None,
link_to = src,
entry_type = ENTRY_IS_LINK,
origin = origin,
- mode = mode,
- user = user,
- group = group,
+ mode = mapping_context.default_mode,
+ user = mapping_context.default_user,
+ group = mapping_context.default_group,
+ uid = mapping_context.default_uid,
+ gid = mapping_context.default_gid,
)
-def add_tree_artifact(content_map, dest_path, src, origin, mode = None, user = None, group = None):
+def add_tree_artifact(content_map, dest_path, src, origin, mode = None, user = None, group = None, uid = None, gid = None):
"""Add an tree artifact (directory output) to the content map.
Args:
@@ -465,8 +537,10 @@ def add_tree_artifact(content_map, dest_path, src, origin, mode = None, user = N
src: Source object. Must have len(src[DefaultInfo].files) == 1
origin: The rule instance adding this entry
mode: fallback mode to use for Package*Info elements without mode
- user: fallback user to use for Package*Info elements without user
- group: fallback mode to use for Package*Info elements without group
+ user: User name for the entry (probably unused)
+ group: group name for the entry (probably unused)
+ uid: User id for the entry (probably unused)
+ gid: Group id for the entry (probably unused)
"""
content_map[dest_path] = _DestFile(
src = src,
@@ -475,9 +549,11 @@ def add_tree_artifact(content_map, dest_path, src, origin, mode = None, user = N
mode = mode,
user = user,
group = group,
+ uid = uid,
+ gid = gid,
)
-def write_manifest(ctx, manifest_file, content_map, use_short_path=False, pretty_print=False):
+def write_manifest(ctx, manifest_file, content_map, use_short_path = False, pretty_print = False):
"""Write a content map to a manifest file.
The format of this file is currently undocumented, as it is a private
@@ -491,6 +567,7 @@ def write_manifest(ctx, manifest_file, content_map, use_short_path=False, pretty
manifest_file: File object used as the output destination
content_map: content_map (see concepts at top of file)
use_short_path: write out the manifest file destinations in terms of "short" paths, suitable for `bazel run`.
+ pretty_print: indent the output nicely. Takes more space so it is off by default.
"""
ctx.actions.write(
manifest_file,
@@ -498,11 +575,11 @@ def write_manifest(ctx, manifest_file, content_map, use_short_path=False, pretty
[
_encode_manifest_entry(dst, content_map[dst], use_short_path, pretty_print)
for dst in sorted(content_map.keys())
- ]
- ) + "\n]\n"
+ ],
+ ) + "\n]\n",
)
-def _encode_manifest_entry(dest, df, use_short_path, pretty_print=False):
+def _encode_manifest_entry(dest, df, use_short_path, pretty_print = False):
entry_type = df.entry_type if hasattr(df, "entry_type") else ENTRY_IS_FILE
if df.src:
src = df.src.short_path if use_short_path else df.src.path
@@ -522,16 +599,18 @@ def _encode_manifest_entry(dest, df, use_short_path, pretty_print=False):
# Since this causes all sorts of chaos with our tests, be consistent across
# all Bazel versions.
origin_str = str(df.origin)
- if not origin_str.startswith('@'):
- origin_str = '@' + origin_str
+ if not origin_str.startswith("@"):
+ origin_str = "@" + origin_str
data = {
- "type": df.entry_type,
+ "type": entry_type,
"src": src,
"dest": dest.strip("/"),
"mode": df.mode or "",
"user": df.user or None,
"group": df.group or None,
+ "uid": df.uid,
+ "gid": df.gid,
"origin": origin_str,
}
diff --git a/pkg/private/tar/BUILD b/pkg/private/tar/BUILD
index fb9ab50..b4eee99 100644
--- a/pkg/private/tar/BUILD
+++ b/pkg/private/tar/BUILD
@@ -18,6 +18,10 @@ All interfaces are subject to change at any time.
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
+package(
+ default_applicable_licenses = ["//:license"],
+)
+
licenses(["notice"])
filegroup(
@@ -45,6 +49,7 @@ exports_files(
py_binary(
name = "build_tar",
srcs = ["build_tar.py"],
+ imports = ["../../.."],
python_version = "PY3",
srcs_version = "PY3",
visibility = ["//visibility:public"],
@@ -62,6 +67,7 @@ py_library(
srcs = [
"tar_writer.py",
],
+ imports = ["../../.."],
srcs_version = "PY3",
visibility = [
"//tests:__subpackages__",
diff --git a/pkg/private/tar/build_tar.py b/pkg/private/tar/build_tar.py
index cea2167..f4b9f0d 100644
--- a/pkg/private/tar/build_tar.py
+++ b/pkg/private/tar/build_tar.py
@@ -26,7 +26,7 @@ from pkg.private.tar import tar_writer
def normpath(path):
- """Normalize a path to the format we need it.
+ r"""Normalize a path to the format we need it.
os.path.normpath changes / to \ on windows, but tarfile needs / style paths.
@@ -70,7 +70,14 @@ class TarFile(object):
# No path should ever come in with slashs on either end, but protect
# against that anyway.
dest = dest.strip('/')
- if self.directory:
+ # This prevents a potential problem for users with both a prefix_dir and
+ # symlinks that also repeat the prefix_dir. The old behavior was that we
+ # would get just the symlink path. Now we are prefixing with the prefix,
+ # so you get the file in the wrong place.
+ # We silently de-dup that. If people come up with a real use case for
+ # the /a/b/a/b/rest... output we can start an issue and come up with a
+ # solution at that time.
+ if self.directory and not dest.startswith(self.directory):
dest = self.directory + dest
return dest
@@ -293,7 +300,7 @@ class TarFile(object):
gname=names[1])
def add_manifest_entry(self, entry, file_attributes):
- # Use the pkg_tar mode/owner remaping as a fallback
+ # Use the pkg_tar mode/owner remapping as a fallback
non_abs_path = entry.dest.strip('/')
if file_attributes:
attrs = file_attributes(non_abs_path)
@@ -308,14 +315,19 @@ class TarFile(object):
else:
# Use group that legacy tar process would assign
attrs['names'] = (entry.user, attrs.get('names')[1])
+ if entry.uid is not None:
+ if entry.gid is not None:
+ attrs['ids'] = (entry.uid, entry.gid)
+ else:
+ attrs['ids'] = (entry.uid, entry.uid)
if entry.type == manifest.ENTRY_IS_LINK:
self.add_link(entry.dest, entry.src, **attrs)
elif entry.type == manifest.ENTRY_IS_DIR:
- self.add_empty_dir(entry.dest, **attrs)
+ self.add_empty_dir(self.normalize_path(entry.dest), **attrs)
elif entry.type == manifest.ENTRY_IS_TREE:
self.add_tree(entry.src, entry.dest, **attrs)
elif entry.type == manifest.ENTRY_IS_EMPTY_FILE:
- self.add_empty_file(entry.dest, **attrs)
+ self.add_empty_file(self.normalize_path(entry.dest), **attrs)
else:
self.add_file(entry.src, entry.dest, **attrs)
diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl
index dc901a5..963cb5a 100644
--- a/pkg/private/tar/tar.bzl
+++ b/pkg/private/tar/tar.bzl
@@ -13,8 +13,7 @@
# limitations under the License.
"""Rules for making .tar files."""
-load("//pkg:path.bzl", "compute_data_path", "dest_path")
-load("//pkg:providers.bzl", "PackageArtifactInfo", "PackageVariablesInfo")
+load("//pkg:providers.bzl", "PackageVariablesInfo")
load(
"//pkg/private:pkg_files.bzl",
"add_directory",
@@ -22,8 +21,7 @@ load(
"add_label_list",
"add_single_file",
"add_symlink",
- "add_tree_artifact",
- "process_src",
+ "create_mapping_context_from_ctx",
"write_manifest",
)
load("//pkg/private:util.bzl", "setup_output_files", "substitute_package_variables")
@@ -58,15 +56,7 @@ def _pkg_tar_impl(ctx):
# Files needed by rule implementation at runtime
files = []
-
- outputs, output_file, output_name = setup_output_files(ctx)
-
- # Compute the relative path
- data_path = compute_data_path(ctx, ctx.attr.strip_prefix)
- data_path_without_prefix = compute_data_path(ctx, ".")
-
- # Find a list of path remappings to apply.
- remap_paths = ctx.attr.remap_paths
+ outputs, output_file, _ = setup_output_files(ctx)
# Start building the arguments.
args = ctx.actions.args()
@@ -112,46 +102,36 @@ def _pkg_tar_impl(ctx):
args.add("--mtime", "%d" % ctx.attr.mtime)
if ctx.attr.portable_mtime:
args.add("--mtime", "portable")
+ if ctx.attr.modes:
+ for key in ctx.attr.modes:
+ args.add("--modes", "%s=%s" % (_quote(key), ctx.attr.modes[key]))
+ if ctx.attr.owners:
+ for key in ctx.attr.owners:
+ args.add("--owners", "%s=%s" % (_quote(key), ctx.attr.owners[key]))
+ if ctx.attr.ownernames:
+ for key in ctx.attr.ownernames:
+ args.add(
+ "--owner_names",
+ "%s=%s" % (_quote(key), ctx.attr.ownernames[key]),
+ )
# Now we begin processing the files.
- file_deps = [] # inputs we depend on
- content_map = {} # content handled in the manifest
+ path_mapper = None
+ if ctx.attr.remap_paths:
+ path_mapper = lambda path: _remap(ctx.attr.remap_paths, path)
- # Start with all the pkg_* inputs
- for src in ctx.attr.srcs:
- if not process_src(
- content_map,
- file_deps,
- src = src,
- origin = src.label,
- default_mode = None,
- default_user = None,
- default_group = None,
- ):
- src_files = src[DefaultInfo].files.to_list()
- if ctx.attr.include_runfiles:
- runfiles = src[DefaultInfo].default_runfiles
- if runfiles:
- file_deps.append(runfiles.files)
- src_files.extend(runfiles.files.to_list())
-
- # Add in the files of srcs which are not pkg_* types
- for f in src_files:
- d_path = dest_path(f, data_path, data_path_without_prefix)
- if f.is_directory:
- add_tree_artifact(content_map, d_path, f, src.label)
- else:
- # Note: This extra remap is the bottleneck preventing this
- # large block from being a utility method as shown below.
- # Should we disallow mixing pkg_files in srcs with remap?
- # I am fine with that if it makes the code more readable.
- dest = _remap(remap_paths, d_path)
- add_single_file(content_map, dest, f, src.label)
+ mapping_context = create_mapping_context_from_ctx(
+ ctx,
+ label = ctx.label,
+ include_runfiles = ctx.attr.include_runfiles,
+ strip_prefix = ctx.attr.strip_prefix,
+ # build_tar does the default modes. Consider moving attribute mapping
+ # into mapping_context.
+ default_mode = None,
+ path_mapper = path_mapper,
+ )
- # TODO(aiuto): I want the code to look like this, but we don't have lambdas.
- # transform_path = lambda f: _remap(
- # remap_paths, dest_path(f, data_path, data_path_without_prefix))
- # add_label_list(ctx, content_map, file_deps, ctx.attr.srcs, transform_path)
+ add_label_list(mapping_context, srcs = ctx.attr.srcs)
# The files attribute is a map of labels to destinations. We can add them
# directly to the content map.
@@ -159,35 +139,23 @@ def _pkg_tar_impl(ctx):
target_files = target.files.to_list()
if len(target_files) != 1:
fail("Each input must describe exactly one file.", attr = "files")
- file_deps.append(depset([target_files[0]]))
+ mapping_context.file_deps.append(depset([target_files[0]]))
add_single_file(
- content_map,
+ mapping_context,
f_dest_path,
target_files[0],
target.label,
)
- if ctx.attr.modes:
- for key in ctx.attr.modes:
- args.add("--modes", "%s=%s" % (_quote(key), ctx.attr.modes[key]))
- if ctx.attr.owners:
- for key in ctx.attr.owners:
- args.add("--owners", "%s=%s" % (_quote(key), ctx.attr.owners[key]))
- if ctx.attr.ownernames:
- for key in ctx.attr.ownernames:
- args.add(
- "--owner_names",
- "%s=%s" % (_quote(key), ctx.attr.ownernames[key]),
- )
for empty_file in ctx.attr.empty_files:
- add_empty_file(content_map, empty_file, ctx.label)
+ add_empty_file(mapping_context, empty_file, ctx.label)
for empty_dir in ctx.attr.empty_dirs or []:
- add_directory(content_map, empty_dir, ctx.label)
+ add_directory(mapping_context, empty_dir, ctx.label)
for f in ctx.files.deps:
args.add("--tar", f.path)
for link in ctx.attr.symlinks:
add_symlink(
- content_map,
+ mapping_context,
link,
ctx.attr.symlinks[link],
ctx.label,
@@ -199,20 +167,23 @@ def _pkg_tar_impl(ctx):
manifest_file = ctx.actions.declare_file(ctx.label.name + ".manifest")
files.append(manifest_file)
- write_manifest(ctx, manifest_file, content_map)
+ write_manifest(ctx, manifest_file, mapping_context.content_map)
args.add("--manifest", manifest_file.path)
args.set_param_file_format("flag_per_line")
args.use_param_file("@%s", use_always = False)
- inputs = depset(direct = ctx.files.deps + files, transitive = file_deps)
+ inputs = depset(
+ direct = ctx.files.deps + files,
+ transitive = mapping_context.file_deps,
+ )
ctx.actions.run(
mnemonic = "PackageTar",
progress_message = "Writing: %s" % output_file.path,
inputs = inputs,
tools = [ctx.executable.compressor] if ctx.executable.compressor else [],
- executable = ctx.executable.build_tar,
+ executable = ctx.executable._build_tar,
arguments = [args],
outputs = [output_file],
env = {
@@ -233,12 +204,7 @@ def _pkg_tar_impl(ctx):
# or this OutputGroup might be totally removed.
# Depend on it at your own risk!
OutputGroupInfo(
- manifest = [manifest_file],
- ),
- PackageArtifactInfo(
- label = ctx.label.name,
- file = output_file,
- file_name = output_name,
+ manifest = [manifest_file],
),
]
@@ -246,38 +212,74 @@ def _pkg_tar_impl(ctx):
pkg_tar_impl = rule(
implementation = _pkg_tar_impl,
attrs = {
- "strip_prefix": attr.string(),
+ "strip_prefix": attr.string(
+ doc = """(note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)""",
+ ),
"package_dir": attr.string(
- doc = """Prefix to be prepend to all paths written."""
+ doc = """Prefix to be prepend to all paths written.
+
+ This is applied as a final step, while writing to the archive.
+ Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir.
+ The value may contain variables. See [package_file_name](#package_file_name) for examples.
+ """,
),
"package_dir_file": attr.label(allow_single_file = True),
- "deps": attr.label_list(allow_files = tar_filetype),
- "srcs": attr.label_list(allow_files = True),
- "files": attr.label_keyed_string_dict(allow_files = True),
+ "deps": attr.label_list(
+ doc = """tar files which will be unpacked and repacked into the archive.""",
+ allow_files = tar_filetype,
+ ),
+ "srcs": attr.label_list(
+ doc = """Inputs which will become part of the tar archive.""",
+ allow_files = True,
+ ),
+ "files": attr.label_keyed_string_dict(
+ doc = """Obsolete. Do not use.""",
+ allow_files = True,
+ ),
"mode": attr.string(default = "0555"),
"modes": attr.string_dict(),
"mtime": attr.int(default = _DEFAULT_MTIME),
"portable_mtime": attr.bool(default = True),
- "owner": attr.string(default = "0.0"),
+ "owner": attr.string(
+ doc = """Default numeric owner.group to apply to files when not set via pkg_attributes.""",
+ default = "0.0",
+ ),
"ownername": attr.string(default = "."),
"owners": attr.string_dict(),
"ownernames": attr.string_dict(),
"extension": attr.string(default = "tar"),
"symlinks": attr.string_dict(),
"empty_files": attr.string_list(),
- "include_runfiles": attr.bool(),
+ "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'."""),
+ ),
"empty_dirs": attr.string_list(),
"remap_paths": attr.string_dict(),
- "compressor": attr.label(executable = True, cfg = "exec"),
- "compressor_args": attr.string(),
+ "compressor": attr.label(
+ doc = """External tool which can compress the archive.""",
+ executable = True,
+ cfg = "exec",
+ ),
+ "compressor_args": attr.string(
+ doc = """Arg list for `compressor`.""",
+ ),
# Common attributes
"out": attr.output(mandatory = True),
- "package_file_name": attr.string(doc = "See Common Attributes"),
+ "package_file_name": attr.string(doc = "See [Common Attributes](#package_file_name)"),
"package_variables": attr.label(
- doc = "See Common Attributes",
+ doc = "See [Common Attributes](#package_variables)",
providers = [PackageVariablesInfo],
),
+ "allow_duplicates_with_different_content": attr.bool(
+ default = True,
+ doc = """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.
+""",
+ ),
"stamp": attr.int(
doc = """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.
@@ -292,21 +294,22 @@ pkg_tar_impl = rule(
"private_stamp_detect": attr.bool(default = False),
# Implicit dependencies.
- "build_tar": attr.label(
+ "_build_tar": attr.label(
default = Label("//pkg/private/tar:build_tar"),
cfg = "exec",
executable = True,
allow_files = True,
),
},
- provides = [PackageArtifactInfo],
)
+# buildifier: disable=function-docstring-args
def pkg_tar(name, **kwargs):
"""Creates a .tar file. See pkg_tar_impl.
@wraps(pkg_tar_impl)
"""
+
# Compatibility with older versions of pkg_tar that define files as
# a flat list of labels.
if "srcs" not in kwargs:
diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py
index 1cef38f..325db76 100644
--- a/pkg/private/tar/tar_writer.py
+++ b/pkg/private/tar/tar_writer.py
@@ -87,7 +87,7 @@ class TarFileWriter(object):
# The Tarfile class doesn't allow us to specify gzip's mtime attribute.
# Instead, we manually reimplement gzopen from tarfile.py and set mtime.
self.fileobj = gzip.GzipFile(
- filename=name, mode='w', compresslevel=9, mtime=self.default_mtime)
+ filename=name, mode='w', compresslevel=6, mtime=self.default_mtime)
self.compressor_proc = None
if self.compressor_cmd:
mode = 'w|'
diff --git a/pkg/private/util.bzl b/pkg/private/util.bzl
index b51598e..7225456 100644
--- a/pkg/private/util.bzl
+++ b/pkg/private/util.bzl
@@ -29,10 +29,7 @@ def setup_output_files(ctx, package_file_name = None, default_output_file = None
Callers should:
- write to `output_file`
- add `outputs` to their returned `DefaultInfo(files)` provider
- - return a `PackageArtifactInfo` provider of the form:
- label: `ctx.label.name`
- file: `output_file`
- file_name: `output_name`
+ - Possibly add a distinguishing element to OutputGroups
Args:
ctx: rule context
@@ -85,5 +82,14 @@ def substitute_package_variables(ctx, attribute_value):
# Map $(var) to {x} and then use format for substitution.
# This is brittle and I hate it. We should have template substitution
- # in the Starlark runtime.
- return attribute_value.replace("$(", "{").replace(")", "}").format(**vars)
+ # in the Starlark runtime. This loop compensates for mismatched counts
+ # of $(foo) so that we don't try replace things like (bar) because we
+ # have no regex matching
+ for _ in range(attribute_value.count("$(")):
+ if attribute_value.find(")") == -1:
+ fail("mismatched variable declaration")
+
+ attribute_value = attribute_value.replace("$(", "{", 1)
+ attribute_value = attribute_value.replace(")", "}", 1)
+
+ return attribute_value.format(**vars) \ No newline at end of file
diff --git a/pkg/private/zip/BUILD b/pkg/private/zip/BUILD
index eba4709..4823e90 100644
--- a/pkg/private/zip/BUILD
+++ b/pkg/private/zip/BUILD
@@ -16,7 +16,7 @@
All interfaces are subject to change at any time.
"""
-load("@rules_python//python:defs.bzl", "py_library")
+load("@rules_python//python:defs.bzl", "py_binary")
package(default_applicable_licenses = ["//:license"])
@@ -48,6 +48,7 @@ exports_files(
py_binary(
name = "build_zip",
srcs = ["build_zip.py"],
+ imports = ["../../.."],
python_version = "PY3",
srcs_version = "PY3",
visibility = ["//visibility:public"],
diff --git a/pkg/private/zip/build_zip.py b/pkg/private/zip/build_zip.py
index 64c4206..5a191b7 100644
--- a/pkg/private/zip/build_zip.py
+++ b/pkg/private/zip/build_zip.py
@@ -15,7 +15,9 @@
import argparse
import datetime
+import logging
import os
+import sys
import zipfile
from pkg.private import build_info
@@ -24,9 +26,10 @@ from pkg.private import manifest
ZIP_EPOCH = 315532800
# Unix dir bit and Windows dir bit. Magic from zip spec
-UNIX_DIR_BIT = 0o40000
-MSDOS_DIR_BIT = 0x10
+UNIX_FILE_BIT = 0o100000
UNIX_SYMLINK_BIT = 0o120000
+UNIX_DIR_BIT = 0o040000
+MSDOS_DIR_BIT = 0x10
def _create_argument_parser():
"""Creates the command line arg parser."""
@@ -46,6 +49,12 @@ def _create_argument_parser():
parser.add_argument(
'-m', '--mode',
help='The file system mode to use for files added into the zip.')
+ parser.add_argument(
+ '-c', '--compression_type',
+ help='The compression type to use')
+ parser.add_argument(
+ '-l', '--compression_level',
+ help='The compression level to use')
parser.add_argument('--manifest',
help='manifest of contents to add to the layer.',
required=True)
@@ -71,7 +80,7 @@ def parse_date(ts):
class ZipWriter(object):
- def __init__(self, output_path: str, time_stamp: int, default_mode: int):
+ def __init__(self, output_path: str, time_stamp: int, default_mode: int, compression_type: str, compression_level: int):
"""Create a writer.
You must close() after use or use in a 'with' statement.
@@ -84,7 +93,15 @@ class ZipWriter(object):
self.output_path = output_path
self.time_stamp = time_stamp
self.default_mode = default_mode
- self.zip_file = zipfile.ZipFile(self.output_path, mode='w')
+ compressions = {
+ "deflated": zipfile.ZIP_DEFLATED,
+ "lzma": zipfile.ZIP_LZMA,
+ "bzip2": zipfile.ZIP_BZIP2,
+ "stored": zipfile.ZIP_STORED
+ }
+ self.compression_type = compressions[compression_type]
+ self.compression_level = compression_level
+ self.zip_file = zipfile.ZipFile(self.output_path, mode='w', compression=self.compression_type)
def __enter__(self):
return self
@@ -96,6 +113,15 @@ class ZipWriter(object):
self.zip_file.close()
self.zip_file = None
+ def writestr(self, entry_info, content: str, compresslevel: int):
+ if sys.version_info >= (3, 7):
+ self.zip_file.writestr(entry_info, content, compresslevel=compresslevel)
+ else:
+ # Python 3.6 and lower don't support compresslevel
+ self.zip_file.writestr(entry_info, content)
+ if compresslevel != 6:
+ logging.warn("Custom compresslevel is not supported with python < 3.7")
+
def make_zipinfo(self, path: str, mode: str):
"""Create a Zipinfo.
@@ -134,17 +160,18 @@ class ZipWriter(object):
user = entry.user
group = entry.group
- # Use the pkg_tar mode/owner remaping as a fallback
+ # Use the pkg_tar mode/owner remapping as a fallback
dst_path = dest.strip('/')
if entry_type == manifest.ENTRY_IS_DIR and not dst_path.endswith('/'):
dst_path += '/'
entry_info = self.make_zipinfo(path=dst_path, mode=mode)
if entry_type == manifest.ENTRY_IS_FILE:
- entry_info.compress_type = zipfile.ZIP_DEFLATED
+ entry_info.compress_type = self.compression_type
# Using utf-8 for the file names is for python <3.7 compatibility.
+ entry_info.external_attr |= UNIX_FILE_BIT << 16
with open(src.encode('utf-8'), 'rb') as src_content:
- self.zip_file.writestr(entry_info, src_content.read())
+ self.writestr(entry_info, src_content.read(), compresslevel=self.compression_level)
elif entry_type == manifest.ENTRY_IS_DIR:
entry_info.compress_type = zipfile.ZIP_STORED
# Set directory bits
@@ -158,7 +185,7 @@ class ZipWriter(object):
elif entry_type == manifest.ENTRY_IS_TREE:
self.add_tree(src, dst_path, mode)
elif entry_type == manifest.ENTRY_IS_EMPTY_FILE:
- entry_info.compress_type = zipfile.ZIP_DEFLATED
+ entry_info.compress_type = zipfile.ZIP_STORED
self.zip_file.writestr(entry_info, '')
else:
raise Exception('Unknown type for manifest entry:', entry)
@@ -213,9 +240,9 @@ class ZipWriter(object):
else:
f_mode = mode
entry_info = self.make_zipinfo(path=path, mode=f_mode)
- entry_info.compress_type = zipfile.ZIP_DEFLATED
+ entry_info.compress_type = self.compression_type
with open(content_path, 'rb') as src:
- self.zip_file.writestr(entry_info, src.read())
+ self.writestr(entry_info, src.read(), compresslevel=self.compression_level)
else:
# Implicitly created directory
dir_path = path
@@ -251,6 +278,8 @@ def _load_manifest(prefix, manifest_path):
mode = "0o755",
user = None,
group = None,
+ uid = None,
+ gid = None,
origin = "parent directory of {}".format(manifest_map[dest].origin),
)
@@ -264,10 +293,11 @@ def main(args):
default_mode = None
if args.mode:
default_mode = int(args.mode, 8)
+ compression_level = int(args.compression_level)
manifest = _load_manifest(args.directory, args.manifest)
with ZipWriter(
- args.output, time_stamp=ts, default_mode=default_mode) as zip_out:
+ args.output, time_stamp=ts, default_mode=default_mode, compression_type=args.compression_type, compression_level=compression_level) as zip_out:
for entry in manifest:
zip_out.add_manifest_entry(entry)
diff --git a/pkg/private/zip/zip.bzl b/pkg/private/zip/zip.bzl
index d66e536..5531bc2 100644
--- a/pkg/private/zip/zip.bzl
+++ b/pkg/private/zip/zip.bzl
@@ -13,54 +13,57 @@
# limitations under the License.
"""Zip archive creation rule and associated logic."""
-load("//pkg:path.bzl", "compute_data_path", "dest_path")
load(
"//pkg:providers.bzl",
- "PackageArtifactInfo",
"PackageVariablesInfo",
)
load(
- "//pkg/private:util.bzl",
- "setup_output_files",
- "substitute_package_variables",
-)
-load(
"//pkg/private:pkg_files.bzl",
"add_label_list",
+ "create_mapping_context_from_ctx",
"write_manifest",
)
+load(
+ "//pkg/private:util.bzl",
+ "setup_output_files",
+ "substitute_package_variables",
+)
_stamp_condition = Label("//pkg/private:private_stamp_detect")
def _pkg_zip_impl(ctx):
- outputs, output_file, output_name = setup_output_files(ctx)
+ outputs, output_file, _ = setup_output_files(ctx)
args = ctx.actions.args()
args.add("-o", output_file.path)
args.add("-d", substitute_package_variables(ctx, ctx.attr.package_dir))
args.add("-t", ctx.attr.timestamp)
args.add("-m", ctx.attr.mode)
+ args.add("-c", str(ctx.attr.compression_type))
+ args.add("-l", ctx.attr.compression_level)
inputs = []
if ctx.attr.stamp == 1 or (ctx.attr.stamp == -1 and
ctx.attr.private_stamp_detect):
args.add("--stamp_from", ctx.version_file.path)
inputs.append(ctx.version_file)
- data_path = compute_data_path(ctx, ctx.attr.strip_prefix)
- data_path_without_prefix = compute_data_path(ctx, ".")
-
- content_map = {} # content handled in the manifest
- file_deps = [] # list of Depsets needed by srcs
- add_label_list(ctx, content_map, file_deps, srcs = ctx.attr.srcs)
+ mapping_context = create_mapping_context_from_ctx(
+ ctx,
+ label = ctx.label,
+ include_runfiles = ctx.attr.include_runfiles,
+ strip_prefix = ctx.attr.strip_prefix,
+ default_mode = ctx.attr.mode,
+ )
+ add_label_list(mapping_context, srcs = ctx.attr.srcs)
manifest_file = ctx.actions.declare_file(ctx.label.name + ".manifest")
inputs.append(manifest_file)
- write_manifest(ctx, manifest_file, content_map)
+ write_manifest(ctx, manifest_file, mapping_context.content_map)
args.add("--manifest", manifest_file.path)
args.set_param_file_format("multiline")
args.use_param_file("@%s")
- all_inputs = depset(direct = inputs, transitive = file_deps)
+ all_inputs = depset(direct = inputs, transitive = mapping_context.file_deps)
ctx.actions.run(
mnemonic = "PackageZip",
@@ -81,11 +84,6 @@ def _pkg_zip_impl(ctx):
files = depset([output_file]),
runfiles = ctx.runfiles(files = outputs),
),
- PackageArtifactInfo(
- label = ctx.label.name,
- file = output_file,
- file_name = output_name,
- ),
]
pkg_zip_impl = rule(
@@ -101,10 +99,14 @@ pkg_zip_impl = rule(
default = "0555",
),
"package_dir": attr.string(
- doc = """The prefix to add to all all paths in the archive.""",
+ doc = """Prefix to be prepend to all paths written.
+The name may contain variables, same as [package_file_name](#package_file_name)""",
default = "/",
),
"strip_prefix": attr.string(),
+ "include_runfiles": attr.bool(
+ doc = """See standard attributes.""",
+ ),
"timestamp": attr.int(
doc = """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,
@@ -115,15 +117,25 @@ Jan 1, 1980 will be rounded up and the precision in the zip file is
limited to a granularity of 2 seconds.""",
default = 315532800,
),
+ "compression_level": attr.int(
+ default = 6,
+ doc = "The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used",
+ ),
+ "compression_type": attr.string(
+ default = "deflated",
+ doc = """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""",
+ values = ["deflated", "lzma", "bzip2", "stored"],
+ ),
# Common attributes
"out": attr.output(
doc = """output file name. Default: name + ".zip".""",
mandatory = True,
),
- "package_file_name": attr.string(doc = "See Common Attributes"),
+ "package_file_name": attr.string(doc = "See [Common Attributes](#package_file_name)"),
"package_variables": attr.label(
- doc = "See Common Attributes",
+ doc = "See [Common Attributes](#package_variables)",
providers = [PackageVariablesInfo],
),
"stamp": attr.int(
@@ -134,7 +146,14 @@ limited to a granularity of 2 seconds.""",
""",
default = 0,
),
-
+ "allow_duplicates_with_different_content": attr.bool(
+ default = True,
+ doc = """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.
+""",
+ ),
# Is --stamp set on the command line?
# TODO(https://github.com/bazelbuild/rules_pkg/issues/340): Remove this.
"private_stamp_detect": attr.bool(default = False),
@@ -147,7 +166,6 @@ limited to a granularity of 2 seconds.""",
allow_files = True,
),
},
- provides = [PackageArtifactInfo],
)
def pkg_zip(name, out = None, **kwargs):
@@ -156,7 +174,9 @@ def pkg_zip(name, out = None, **kwargs):
@wraps(pkg_zip_impl)
Args:
- out: output file name. Default: name + ".zip".
+ name: name
+ out: output file name. Default: name + ".zip".
+ **kwargs: the rest
"""
if not out:
out = name + ".zip"
diff --git a/pkg/providers.bzl b/pkg/providers.bzl
index 459a064..6d5fc27 100644
--- a/pkg/providers.bzl
+++ b/pkg/providers.bzl
@@ -37,7 +37,7 @@ PackageFilesInfo = provider(
Keys are strings representing attribute identifiers, values are
arbitrary data structures that represent the associated data. These are
-most often strings, but are not explicity defined.
+most often strings, but are not explicitly defined.
For known attributes and data type expectations, see the Common
Attributes documentation in the `rules_pkg` reference.
diff --git a/pkg/releasing/BUILD b/pkg/releasing/BUILD
index 2a38667..4036c0f 100644
--- a/pkg/releasing/BUILD
+++ b/pkg/releasing/BUILD
@@ -1,5 +1,4 @@
load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
-load("git.bzl", "git_changelog")
package(
default_applicable_licenses = ["//:license"],
@@ -19,8 +18,7 @@ package(
filegroup(
name = "standard_package",
- srcs = glob([
- "BUILD",
+ srcs = ["BUILD"] + glob([
"*.bzl",
"*.py",
]),
@@ -36,6 +34,7 @@ py_library(
"__init__.py",
"release_tools.py",
],
+ imports = ["../.."],
srcs_version = "PY3",
)
@@ -44,6 +43,7 @@ py_binary(
srcs = [
"print_rel_notes.py",
],
+ imports = ["../.."],
python_version = "PY3",
deps = [
":release_utils",
diff --git a/pkg/releasing/defs.bzl b/pkg/releasing/defs.bzl
index 9f381a6..52f3cd4 100644
--- a/pkg/releasing/defs.bzl
+++ b/pkg/releasing/defs.bzl
@@ -1,5 +1,6 @@
-"""Impementation for print_rel_notes."""
+"""Implementation for print_rel_notes."""
+# buildifier: disable=function-docstring
def print_rel_notes(
name,
repo,
@@ -14,6 +15,7 @@ def print_rel_notes(
mirror_host = None):
if not artifact_name:
artifact_name = ":%s-%s.tar.gz" % (repo, version)
+
# Must use Label to get a path relative to the rules_pkg repository,
# instead of the calling BUILD file.
print_rel_notes_helper = Label("//pkg/releasing:print_rel_notes")
@@ -33,6 +35,7 @@ def print_rel_notes(
cmd.append("--toolchains_method=%s" % toolchains_method)
if changelog:
cmd.append("--changelog=$(location %s)" % changelog)
+
# We should depend on a changelog as a tool so that it is always built
# for the host configuration. If the changelog is generated on the fly,
# then we would have to run commands against our revision control
diff --git a/pkg/releasing/git.bzl b/pkg/releasing/git.bzl
index 2952e6c..787e75b 100644
--- a/pkg/releasing/git.bzl
+++ b/pkg/releasing/git.bzl
@@ -83,7 +83,6 @@ _git_changelog = rule(
toolchains = ["@rules_pkg//toolchains/git:git_toolchain_type"],
)
-
def git_changelog(name, **kwargs):
_git_changelog(
name = name,
@@ -93,5 +92,5 @@ def git_changelog(name, **kwargs):
str(Label("//toolchains/git:have_git")): [],
"//conditions:default": ["//:not_compatible"],
}),
- **kwargs,
+ **kwargs
)
diff --git a/pkg/releasing/print_rel_notes.py b/pkg/releasing/print_rel_notes.py
index 7e1c29f..379d0c0 100644
--- a/pkg/releasing/print_rel_notes.py
+++ b/pkg/releasing/print_rel_notes.py
@@ -46,6 +46,12 @@ def print_notes(org, repo, version, tarball_path, mirror_host=None,
**Change Log**
${changelog}
+ **MODULE.bazel setup**
+
+ ```
+ bazel_dep(name = "${repo}", version = "${version}")
+ ```
+
**WORKSPACE setup**
```
diff --git a/pkg/releasing/release_tools_test.py b/pkg/releasing/release_tools_test.py
index 7ca80d1..7b2b443 100644
--- a/pkg/releasing/release_tools_test.py
+++ b/pkg/releasing/release_tools_test.py
@@ -14,7 +14,7 @@
import unittest
-import release_tools
+from pkg.releasing import release_tools
class ReleaseToolsTest(unittest.TestCase):
diff --git a/pkg/rpm.bzl b/pkg/rpm.bzl
index ea5df1c..2fc5804 100644
--- a/pkg/rpm.bzl
+++ b/pkg/rpm.bzl
@@ -29,8 +29,8 @@ The mechanism for choosing between the two is documented in the function itself.
"""
-load("//pkg/legacy:rpm.bzl", pkg_rpm_legacy = "pkg_rpm")
load("//pkg:rpm_pfg.bzl", pkg_rpm_pfg = "pkg_rpm")
+load("//pkg/legacy:rpm.bzl", pkg_rpm_legacy = "pkg_rpm")
def pkg_rpm(name, srcs = None, spec_file = None, **kwargs):
"""pkg_rpm wrapper
@@ -47,7 +47,7 @@ def pkg_rpm(name, srcs = None, spec_file = None, **kwargs):
name: rule name
srcs: pkg_rpm_pfg `srcs` attribute
spec_file: pkg_rpm_legacy `spec_file` attribute
- **kwargs: arguments to eihter `pkg_rpm_pfg` or `pkg_rpm_legacy`,
+ **kwargs: arguments to either `pkg_rpm_pfg` or `pkg_rpm_legacy`,
depending on mode
"""
diff --git a/pkg/rpm/augment_rpm_files_install.py b/pkg/rpm/augment_rpm_files_install.py
index 35bf729..6f0762b 100644
--- a/pkg/rpm/augment_rpm_files_install.py
+++ b/pkg/rpm/augment_rpm_files_install.py
@@ -22,10 +22,14 @@ import os
import sys
import json
-# NOTE: Keep this in sync with the same variable in rpm.bzl
+# NOTE: Keep those two in sync with the same variables in rpm_pfg.bzl
_INSTALL_FILE_STANZA_FMT = """
-install -d %{{buildroot}}/$(dirname {1})
-cp {0} %{{buildroot}}/{1}
+install -d "%{{buildroot}}/$(dirname '{1}')"
+cp '{0}' '%{{buildroot}}/{1}'
+""".strip()
+
+_FILE_MODE_STANZA_FMT = """
+{0} "{1}"
""".strip()
# Cheapo arg parsing. Currently this script is single-purpose.
@@ -69,9 +73,7 @@ with open(dir_data_path, 'r') as fh:
os.path.join(root, f),
full_dest
))
- dir_files_segments.append(
- d["tags"] + " " + full_dest
- )
+ dir_files_segments.append(_FILE_MODE_STANZA_FMT.format(d["tags"], full_dest))
with open(existing_install_script_path, 'r') as fh:
existing_install_script = fh.read()
diff --git a/pkg/rpm/template.spec.tpl b/pkg/rpm/template.spec.tpl
index ca2aa46..ba25db8 100644
--- a/pkg/rpm/template.spec.tpl
+++ b/pkg/rpm/template.spec.tpl
@@ -18,3 +18,7 @@ ${POST_SCRIPTLET}
${PREUN_SCRIPTLET}
${POSTUN_SCRIPTLET}
+
+${POSTTRANS_SCRIPTLET}
+
+${CHANGELOG}
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl
index 1e3450c..0ccdbaf 100644
--- a/pkg/rpm_pfg.bzl
+++ b/pkg/rpm_pfg.bzl
@@ -27,14 +27,13 @@ find_system_rpmbuild(name="rules_pkg_rpmbuild")
load(
"//pkg:providers.bzl",
- "PackageArtifactInfo",
"PackageDirsInfo",
"PackageFilegroupInfo",
"PackageFilesInfo",
"PackageSymlinkInfo",
"PackageVariablesInfo",
)
-load("//pkg/private:util.bzl", "setup_output_files")
+load("//pkg/private:util.bzl", "setup_output_files", "substitute_package_variables")
rpm_filetype = [".rpm"]
@@ -45,9 +44,9 @@ spec_filetype = [".spec", ".spec.in", ".spec.tpl"]
#
# TODO(nacl, #292): cp -r does not do the right thing with TreeArtifacts
_INSTALL_FILE_STANZA_FMT = """
-install -d %{{buildroot}}/$(dirname {1})
-cp {0} %{{buildroot}}/{1}
-"""
+install -d "%{{buildroot}}/$(dirname '{1}')"
+cp '{0}' '%{{buildroot}}/{1}'
+""".strip()
# TODO(nacl): __install
# {0} is the directory name
@@ -55,8 +54,8 @@ cp {0} %{{buildroot}}/{1}
# This may not be strictly necessary, given that they'll be created in the
# CPIO when rpmbuild processes the `%files` list.
_INSTALL_DIR_STANZA_FMT = """
-install -d %{{buildroot}}/{0}
-"""
+install -d '%{{buildroot}}/{0}'
+""".strip()
# {0} is the name of the link, {1} is the target, {2} is the desired symlink "mode".
#
@@ -74,12 +73,17 @@ install -d %{{buildroot}}/{0}
# XXX: This may not apply all that well to users of cygwin and mingw. We'll
# deal with that when the time comes.
_INSTALL_SYMLINK_STANZA_FMT = """
-%{{__install}} -d %{{buildroot}}/$(dirname {0})
-%{{__ln_s}} {1} %{{buildroot}}/{0}
+%{{__install}} -d "%{{buildroot}}/$(dirname '{0}')"
+%{{__ln_s}} '{1}' '%{{buildroot}}/{0}'
%if "%_host_os" != "linux"
- %{{__chmod}} -h {2} %{{buildroot}}/{0}
+ %{{__chmod}} -h {2} '%{{buildroot}}/{0}'
%endif
-"""
+""".strip()
+
+# {0} is the file tag, {1} is the the path to file
+_FILE_MODE_STANZA_FMT = """
+{0} "{1}"
+""".strip()
def _package_contents_metadata(origin_label, grouping_label):
"""Named construct for helping to identify conflicting packaged contents"""
@@ -142,7 +146,7 @@ def _make_absolute_if_not_already_or_is_macro(path):
# this can be inlined easily.
return path if path.startswith(("/", "%")) else "/" + path
-#### Input processing helper functons.
+#### Input processing helper functions.
# TODO(nacl, #459): These are redundant with functions and structures in
# pkg/private/pkg_files.bzl. We should really use the infrastructure provided
@@ -170,13 +174,13 @@ def _process_files(pfi, origin_label, grouping_label, file_base, dest_check_map,
})
else:
# Files are well-known. Take care of them right here.
- rpm_files_list.append(file_base + " " + abs_dest)
+ rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dest))
install_script_pieces.append(_INSTALL_FILE_STANZA_FMT.format(
src.path,
abs_dest,
))
-def _process_dirs(pdi, origin_label, grouping_label, file_base, dest_check_map, packaged_directories, rpm_files_list, install_script_pieces):
+def _process_dirs(pdi, origin_label, grouping_label, file_base, dest_check_map, _, rpm_files_list, install_script_pieces):
for dest in pdi.dirs:
metadata = _package_contents_metadata(origin_label, grouping_label)
if dest in dest_check_map:
@@ -185,13 +189,13 @@ def _process_dirs(pdi, origin_label, grouping_label, file_base, dest_check_map,
dest_check_map[dest] = metadata
abs_dirname = _make_absolute_if_not_already_or_is_macro(dest)
- rpm_files_list.append(file_base + " " + abs_dirname)
+ rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dirname))
install_script_pieces.append(_INSTALL_DIR_STANZA_FMT.format(
abs_dirname,
))
-def _process_symlink(psi, origin_label, grouping_label, file_base, dest_check_map, packaged_directories, rpm_files_list, install_script_pieces):
+def _process_symlink(psi, origin_label, grouping_label, file_base, dest_check_map, _, rpm_files_list, install_script_pieces):
metadata = _package_contents_metadata(origin_label, grouping_label)
if psi.destination in dest_check_map:
_conflicting_contents_error(psi.destination, metadata, dest_check_map[psi.destination])
@@ -199,7 +203,7 @@ def _process_symlink(psi, origin_label, grouping_label, file_base, dest_check_ma
dest_check_map[psi.destination] = metadata
abs_dest = _make_absolute_if_not_already_or_is_macro(psi.destination)
- rpm_files_list.append(file_base + " " + abs_dest)
+ rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dest))
install_script_pieces.append(_INSTALL_SYMLINK_STANZA_FMT.format(
abs_dest,
psi.target,
@@ -254,7 +258,7 @@ def _pkg_rpm_impl(ctx):
ctx.attr.architecture,
)
- outputs, output_file, output_name = setup_output_files(
+ _, output_file, _ = setup_output_files(
ctx,
package_file_name = package_file_name,
default_output_file = default_file,
@@ -270,7 +274,7 @@ def _pkg_rpm_impl(ctx):
if ctx.attr.version:
fail("Both version and version_file attributes were specified")
- preamble_pieces.append("Version: ${VERSION_FROM_FILE}")
+ preamble_pieces.append("Version: ${{VERSION_FROM_FILE}}")
args.append("--version=@" + ctx.file.version_file.path)
files.append(ctx.file.version_file)
elif ctx.attr.version:
@@ -283,7 +287,7 @@ def _pkg_rpm_impl(ctx):
if ctx.attr.release:
fail("Both release and release_file attributes were specified")
- preamble_pieces.append("Release: ${RELEASE_FROM_FILE}")
+ preamble_pieces.append("Release: ${{RELEASE_FROM_FILE}}")
args.append("--release=@" + ctx.file.release_file.path)
files.append(ctx.file.release_file)
elif ctx.attr.release:
@@ -317,6 +321,8 @@ def _pkg_rpm_impl(ctx):
preamble_pieces.extend(["Provides: " + p for p in ctx.attr.provides])
if ctx.attr.conflicts:
preamble_pieces.extend(["Conflicts: " + c for c in ctx.attr.conflicts])
+ if ctx.attr.obsoletes:
+ preamble_pieces.extend(["Obsoletes: " + o for o in ctx.attr.obsoletes])
if ctx.attr.requires:
preamble_pieces.extend(["Requires: " + r for r in ctx.attr.requires])
if ctx.attr.requires_contextual:
@@ -343,7 +349,7 @@ def _pkg_rpm_impl(ctx):
)
ctx.actions.write(
output = preamble_file,
- content = "\n".join(preamble_pieces),
+ content = substitute_package_variables(ctx, "\n".join(preamble_pieces)),
)
files.append(preamble_file)
args.append("--preamble=" + preamble_file.path)
@@ -368,6 +374,10 @@ def _pkg_rpm_impl(ctx):
files.append(description_file)
args.append("--description=" + description_file.path)
+ if ctx.attr.changelog:
+ files.append(ctx.file.changelog)
+ args.append("--changelog=" + ctx.file.changelog.path)
+
#### Non-procedurally-generated scriptlets
substitutions = {}
@@ -419,6 +429,18 @@ def _pkg_rpm_impl(ctx):
ctx.actions.write(scriptlet_file, ctx.attr.postun_scriptlet)
args.append("--postun_scriptlet=" + scriptlet_file.path)
+ if ctx.attr.posttrans_scriptlet_file:
+ if ctx.attr.posttrans_scriptlet:
+ fail("Both posttrans_scriptlet and posttrans_scriptlet_file attributes were specified")
+ posttrans_scriptlet_file = ctx.file.posttrans_scriptlet_file
+ files.append(posttrans_scriptlet_file)
+ args.append("--posttrans_scriptlet=" + posttrans_scriptlet_file.path)
+ elif ctx.attr.posttrans_scriptlet:
+ scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".posttrans_scriptlet")
+ files.append(scriptlet_file)
+ ctx.actions.write(scriptlet_file, ctx.attr.posttrans_scriptlet)
+ args.append("--posttrans_scriptlet=" + scriptlet_file.path)
+
#### Expand the spec file template; prepare data files
spec_file = ctx.actions.declare_file("%s.spec" % rpm_name)
@@ -432,11 +454,7 @@ def _pkg_rpm_impl(ctx):
args.append("--out_file=" + output_file.path)
- # Add data files.
- if ctx.file.changelog:
- files.append(ctx.file.changelog)
- args.append(ctx.file.changelog.path)
-
+ # Add data files
files += ctx.files.srcs
#### Consistency checking; input processing
@@ -636,6 +654,12 @@ def _pkg_rpm_impl(ctx):
"_binary_payload {}".format(ctx.attr.binary_payload_compression),
])
+ for key, value in ctx.attr.defines.items():
+ additional_rpmbuild_args.extend([
+ "--define",
+ "{} {}".format(key, value),
+ ])
+
args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args])
for f in ctx.files.srcs:
@@ -660,23 +684,18 @@ def _pkg_rpm_impl(ctx):
)
changes = []
- if ctx.attr.changelog:
- changes = [ctx.attr.changelog]
+ if ctx.file.changelog:
+ changes = [ctx.file.changelog]
output_groups = {
"out": [default_file],
"rpm": [output_file],
- "changes": changes
+ "changes": changes,
}
return [
OutputGroupInfo(**output_groups),
DefaultInfo(
- files = depset(outputs),
- ),
- PackageArtifactInfo(
- file = output_file,
- file_name = output_name,
- label = ctx.label.name,
+ files = depset([output_file]),
),
]
@@ -710,6 +729,14 @@ pkg_rpm = rule(
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.
""",
# @unsorted-dict-items
attrs = {
@@ -901,12 +928,22 @@ pkg_rpm = rule(
doc = """File containing the RPM `%postun` scriptlet""",
allow_single_file = True,
),
+ "posttrans_scriptlet": attr.string(
+ doc = """RPM `%posttrans` scriptlet. Currently only allowed to be a shell script.
+
+ `posttrans_scriptlet` and `posttrans_scriptlet_file` are mutually exclusive.
+ """,
+ ),
+ "posttrans_scriptlet_file": attr.label(
+ doc = """File containing the RPM `%posttrans` scriptlet""",
+ allow_single_file = True,
+ ),
"conflicts": attr.string_list(
doc = """List of capabilities that conflict with this package when it is installed.
Corresponds to the "Conflicts" preamble tag.
- See also: https://rpm.org/user_doc/dependencies.html
+ See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html
""",
),
"provides": attr.string_list(
@@ -914,15 +951,23 @@ pkg_rpm = rule(
Corresponds to the "Provides" preamble tag.
- See also: https://rpm.org/user_doc/dependencies.html
+ See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html
""",
),
+ "obsoletes": attr.string_list(
+ doc = """List of rpm capability expressions that this package obsoletes.
+
+ Corresponds to the "Obsoletes" preamble tag.
+
+ See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html
+ """,
+ ),
"requires": attr.string_list(
doc = """List of rpm capability expressions that this package requires.
Corresponds to the "Requires" preamble tag.
- See also: https://rpm.org/user_doc/dependencies.html
+ See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html
""",
),
"requires_contextual": attr.string_list_dict(
@@ -957,7 +1002,7 @@ pkg_rpm = rule(
For capabilities that are always required by packages at runtime,
use the `requires` attribute instead.
- See also: https://rpm.org/user_doc/more_dependencies.html
+ See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html
NOTE: `pkg_rpm` does not check if the keys of this dictionary are
acceptable to `rpm(8)`.
@@ -998,6 +1043,9 @@ pkg_rpm = rule(
overcommitting your system.
""",
),
+ "defines": attr.string_dict(
+ doc = """Additional definitions to pass to rpmbuild""",
+ ),
"rpmbuild_path": attr.string(
doc = """Path to a `rpmbuild` binary. Deprecated in favor of the rpmbuild toolchain""",
),
@@ -1017,6 +1065,5 @@ pkg_rpm = rule(
},
executable = False,
implementation = _pkg_rpm_impl,
- provides = [PackageArtifactInfo],
toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
)
diff --git a/pkg/verify_archive.bzl b/pkg/verify_archive.bzl
index e31d539..d132d49 100644
--- a/pkg/verify_archive.bzl
+++ b/pkg/verify_archive.bzl
@@ -23,7 +23,6 @@ The execution time is O(# expected patterns * size of archive).
load("@rules_python//python:defs.bzl", "py_test")
-
def _gen_verify_archive_test_main_impl(ctx):
ctx.actions.expand_template(
template = ctx.file._template,
@@ -38,6 +37,7 @@ def _gen_verify_archive_test_main_impl(ctx):
"${MUST_NOT_CONTAIN_REGEX}": str(ctx.attr.must_not_contain_regex),
"${MIN_SIZE}": str(ctx.attr.min_size),
"${MAX_SIZE}": str(ctx.attr.max_size),
+ "${VERIFY_LINKS}": str(ctx.attr.verify_links),
},
)
return [
@@ -55,7 +55,6 @@ _gen_verify_archive_test_main = rule(
allow_single_file = True,
mandatory = True,
),
-
"must_contain": attr.string_list(
doc = "List of paths which all must appear in the archive.",
),
@@ -69,10 +68,13 @@ _gen_verify_archive_test_main = rule(
doc = """List of regexes that must not be in the archive.""",
),
"min_size": attr.int(
- doc = """Miniumn number of entries in the archive."""
+ doc = """Minimum number of entries in the archive.""",
),
"max_size": attr.int(
- doc = """Miniumn number of entries in the archive."""
+ doc = """Maximum number of entries in the archive.""",
+ ),
+ "verify_links": attr.string_dict(
+ doc = """Dict keyed by paths which must appear, and be symlinks to their values.""",
),
# Implicit dependencies.
@@ -83,10 +85,18 @@ _gen_verify_archive_test_main = rule(
},
)
-def verify_archive_test(name, target,
- must_contain=None, must_contain_regex=None,
- must_not_contain=None, must_not_contain_regex=None,
- min_size=1, max_size=-1):
+# buildifier: disable=function-docstring-args
+def verify_archive_test(
+ name,
+ target,
+ must_contain = None,
+ must_contain_regex = None,
+ must_not_contain = None,
+ must_not_contain_regex = None,
+ min_size = 1,
+ max_size = -1,
+ tags = None,
+ verify_links = None):
"""Tests that an archive contains specific file patterns.
This test is used to verify that an archive contains the expected content.
@@ -99,12 +109,14 @@ def verify_archive_test(name, target,
must_not_contain_regex: A list of path regexes which must not appear in the archive.
min_size: The minimum number of entries which must be in the archive.
max_size: The maximum number of entries which must be in the archive.
+ tags: standard meaning
+ verify_links: Dict keyed by paths which must appear, and be symlinks to their values.
"""
- test_src = name + "__internal_main.py"
+ test_src = name + "__internal_main.py"
_gen_verify_archive_test_main(
name = name + "_internal_main",
target = target,
- test_name = name.replace('-', '_') + "Test",
+ test_name = name.replace("-", "_") + "Test",
out = test_src,
must_contain = must_contain,
must_contain_regex = must_contain_regex,
@@ -112,17 +124,13 @@ def verify_archive_test(name, target,
must_not_contain_regex = must_not_contain_regex,
min_size = min_size,
max_size = max_size,
+ tags = tags,
+ verify_links = verify_links,
)
py_test(
name = name,
- # Hey reviewer!!! What if we just added the source to the test lib
- # here, so we would not have to make the library for that public?
srcs = [":" + test_src],
main = test_src,
data = [target],
python_version = "PY3",
- deps = [
- "//pkg:verify_archive_test_lib",
- "@bazel_tools//tools/python/runfiles",
- ],
)
diff --git a/pkg/verify_archive_test_lib.py b/pkg/verify_archive_test_lib.py
deleted file mode 100644
index 5d66948..0000000
--- a/pkg/verify_archive_test_lib.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2023 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.
-"""Compare to content manifest files."""
-
-import json
-import re
-import tarfile
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-
-
-class VerifyArchiveTest(unittest.TestCase):
- """Test harness to see if we wrote the content manifest correctly."""
-
- #run_files = runfiles.Create()
- #target_path = VerifyArchiveTest.run_files.Rlocation('rules_pkg/' + target)
-
- def setUp(self):
- super(VerifyArchiveTest, self).setUp()
-
- def scan_target(self, target):
- parts = target.split('.')
- ext = parts[-1]
- if ext[0] == 't' or parts[-2] == 'tar':
- self.load_tar(target)
- elif ext[0] == 'z':
- self.fail('Can not process zip yet')
- else:
- self.fail('Can not figure out the archive type for (%s)' % target)
-
- def load_tar(self, path):
- self.paths = []
- with tarfile.open(path, 'r:*') as f:
- i = 0
- for info in f:
- self.paths.append(info.name)
-
- def assertMinSize(self, min_size):
- """Check that the archive contains at least min_size entries.
-
- Args:
- min_size: The minium number of targets we expect.
- """
- actual_size = len(self.paths)
- self.assertGreaterEqual(
- len(self.paths),
- min_size,
- msg = "Expected at least %d files, but found only %d" % (
- min_size, actual_size))
-
- def assertMaxSize(self, max_size):
- """Check that the archive contains at most max_size entries.
-
- Args:
- max_size: The maximum number of targets we expect.
- """
- actual_size = len(self.paths)
- self.assertLessEqual(
- len(self.paths),
- max_size,
- msg = "Expected at most %d files, but found %d" % (
- max_size, actual_size))
-
- def check_must_contain(self, must_contain):
- plain_patterns = set(must_contain)
- for path in self.paths:
- if path in plain_patterns:
- plain_patterns.remove(path)
- if len(plain_patterns) > 0:
- self.fail('These required paths were not found: %s' % ','.join(plain_patterns))
-
- def check_must_not_contain(self, must_not_contain):
- plain_patterns = set(must_not_contain)
- for path in self.paths:
- if path in plain_patterns:
- self.fail('Found disallowed path (%s) in the archive' % path)
-
- def check_must_contain_regex(self, must_contain_regex):
- for pattern in must_contain_regex:
- r_comp = re.compile(pattern)
- matched = False
- for path in self.paths:
- if r_comp.match(path):
- matched = True
- break
- if not match:
- 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)
diff --git a/pkg/verify_archive_test_main.py.tpl b/pkg/verify_archive_test_main.py.tpl
index d9b17cc..f831ecb 100644
--- a/pkg/verify_archive_test_main.py.tpl
+++ b/pkg/verify_archive_test_main.py.tpl
@@ -13,11 +13,110 @@
# limitations under the License.
"""Tests for generated content manifest."""
+import re
+import tarfile
import unittest
-from pkg import verify_archive_test_lib
+class VerifyArchiveTest(unittest.TestCase):
+ """Test harness to see if we wrote the content manifest correctly."""
-class ${TEST_NAME}(verify_archive_test_lib.VerifyArchiveTest):
+
+ def setUp(self):
+ super(VerifyArchiveTest, self).setUp()
+
+ def scan_target(self, target):
+ parts = target.split('.')
+ ext = parts[-1]
+ if ext[0] == 't' or parts[-2] == 'tar':
+ self.load_tar(target)
+ elif ext[0] == 'z':
+ self.fail('Can not process zip yet')
+ else:
+ self.fail('Can not figure out the archive type for (%s)' % target)
+
+ def load_tar(self, path):
+ self.paths = []
+ self.links = {}
+ with tarfile.open(path, 'r:*') as f:
+ i = 0
+ for info in f:
+ self.paths.append(info.name)
+ if info.linkname:
+ self.links[info.name] = info.linkname
+
+ def assertMinSize(self, min_size):
+ """Check that the archive contains at least min_size entries.
+
+ Args:
+ min_size: The minimum number of targets we expect.
+ """
+ if min_size <= 0:
+ return
+ actual_size = len(self.paths)
+ self.assertGreaterEqual(
+ len(self.paths),
+ min_size,
+ msg = "Expected at least %d files, but found only %d" % (
+ min_size, actual_size))
+
+ def assertMaxSize(self, max_size):
+ """Check that the archive contains at most max_size entries.
+
+ Args:
+ max_size: The maximum number of targets we expect.
+ """
+ if max_size <= 0:
+ return
+ actual_size = len(self.paths)
+ self.assertLessEqual(
+ len(self.paths),
+ max_size,
+ msg = "Expected at most %d files, but found %d" % (
+ max_size, actual_size))
+
+ def check_must_contain(self, must_contain):
+ plain_patterns = set(must_contain)
+ for path in self.paths:
+ if path in plain_patterns:
+ plain_patterns.remove(path)
+ if len(plain_patterns) > 0:
+ self.fail('These required paths were not found: %s' % ','.join(plain_patterns) + ' in [%s]' % ','.join(self.paths))
+
+ def check_must_not_contain(self, must_not_contain):
+ plain_patterns = set(must_not_contain)
+ for path in self.paths:
+ if path in plain_patterns:
+ self.fail('Found disallowed path (%s) in the archive' % path)
+
+ def check_must_contain_regex(self, must_contain_regex):
+ for pattern in must_contain_regex:
+ r_comp = re.compile(pattern)
+ matched = False
+ for path in self.paths:
+ if r_comp.match(path):
+ matched = True
+ break
+ if not match:
+ 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)
+
+ def verify_links(self, verify_links):
+ for link, target in verify_links.items():
+ if link not in self.paths:
+ self.fail('Required link (%s) is not in the archive' % link)
+ if self.links[link] != target:
+ self.fail('link (%s) points to the wrong place. Expected (%s) got (%s)' %
+ (link, target, self.links[link]))
+
+
+class ${TEST_NAME}(VerifyArchiveTest):
def setUp(self):
super(${TEST_NAME}, self).setUp()
@@ -41,6 +140,9 @@ class ${TEST_NAME}(verify_archive_test_lib.VerifyArchiveTest):
def test_must_not_contain(self):
self.check_must_not_contain_regex(${MUST_NOT_CONTAIN_REGEX})
+ def test_verify_links(self):
+ self.verify_links(${VERIFY_LINKS})
+
if __name__ == '__main__':
unittest.main()
diff --git a/providers.bzl b/providers.bzl
deleted file mode 100644
index 5ef7bc6..0000000
--- a/providers.bzl
+++ /dev/null
@@ -1,29 +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.
-
-load("//pkg:providers.bzl",
- _PackageArtifactInfo = "PackageArtifactInfo",
- _PackageDirsInfo = "PackageDirsInfo",
- _PackageFilegroupInfo = "PackageFilegroupInfo",
- _PackageFilesInfo = "PackageFilesInfo",
- _PackageSymlinkInfo = "PackageSymlinkInfo",
- _PackageVariablesInfo = "PackageVariablesInfo",
-)
-
-PackageArtifactInfo = _PackageArtifactInfo
-PackageDirsInfo = _PackageDirsInfo
-PackageFilegroupInfo = _PackageFilegroupInfo
-PackageFilesInfo = _PackageFilesInfo
-PackageSymlinkInfo = _PackageSymlinkInfo
-PackageVariablesInfo = _PackageVariablesInfo
diff --git a/rpm.bzl b/rpm.bzl
deleted file mode 100644
index c26ecef..0000000
--- a/rpm.bzl
+++ /dev/null
@@ -1,18 +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.
-
-load("//pkg:rpm.bzl",
- _pkg_rpm = "pkg_rpm",
-)
-pkg_rpm = _pkg_rpm
diff --git a/tests/BUILD b/tests/BUILD
index 21b6396..f6ab2b0 100644
--- a/tests/BUILD
+++ b/tests/BUILD
@@ -13,13 +13,14 @@
# limitations under the License.
# -*- coding: utf-8 -*-
+load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library")
load("@rules_python//python:defs.bzl", "py_test")
-load(":my_package_name.bzl", "my_package_naming")
-load(":path_test.bzl", "path_tests")
load("//pkg:deb.bzl", "pkg_deb")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "strip_prefix")
load("//pkg:tar.bzl", "pkg_tar")
load("//pkg:zip.bzl", "pkg_zip")
+load(":my_package_name.bzl", "my_package_naming")
+load(":path_test.bzl", "path_tests")
package(
default_applicable_licenses = ["//:license"],
@@ -75,19 +76,20 @@ py_test(
"archive_test.py",
],
data = [
- "//tests:testdata/empty.ar",
- "//tests:testdata/a_ab.ar",
"//tests:testdata/a.ar",
- "//tests:testdata/a_b_ab.ar",
+ "//tests:testdata/a_ab.ar",
"//tests:testdata/a_b.ar",
+ "//tests:testdata/a_b_ab.ar",
"//tests:testdata/ab.ar",
"//tests:testdata/b.ar",
+ "//tests:testdata/empty.ar",
],
+ imports = [".."],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//pkg/private:archive",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -99,15 +101,32 @@ py_test(
srcs_version = "PY3",
)
+cc_library(
+ name = "liba",
+ srcs = ["a.cc"],
+ data = ["testdata/hello.txt"],
+)
+
+cc_library(
+ name = "libb",
+ srcs = ["b.cc"],
+ data = ["testdata/hello.txt"],
+)
+
cc_binary(
name = "an_executable",
srcs = ["foo.cc"],
- data = ["BUILD"],
+ data = ["foo.cc"],
+ deps = [
+ ":liba",
+ ":libb",
+ ],
)
py_test(
name = "helpers_test",
srcs = ["helpers_test.py"],
+ imports = [".."],
python_version = "PY3",
srcs_version = "PY3",
deps = [
@@ -189,7 +208,7 @@ py_test(
],
python_version = "PY3",
deps = [
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
diff --git a/tests/a.cc b/tests/a.cc
new file mode 100644
index 0000000..d46545e
--- /dev/null
+++ b/tests/a.cc
@@ -0,0 +1 @@
+int a = 1;
diff --git a/tests/archive_test.py b/tests/archive_test.py
index 21ddd5e..4c604c6 100644
--- a/tests/archive_test.py
+++ b/tests/archive_test.py
@@ -15,7 +15,7 @@
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.private import archive
diff --git a/tests/b.cc b/tests/b.cc
new file mode 100644
index 0000000..b20302a
--- /dev/null
+++ b/tests/b.cc
@@ -0,0 +1 @@
+int b = 2;
diff --git a/tests/deb/BUILD b/tests/deb/BUILD
index cfdbbf3..5df0ab2 100644
--- a/tests/deb/BUILD
+++ b/tests/deb/BUILD
@@ -16,11 +16,11 @@
# Tests for pkg_deb specific behavior
load("@rules_python//python:defs.bzl", "py_test")
-load(":deb_tests.bzl", "package_naming_test")
-load("//pkg:mappings.bzl", "pkg_mklink")
load("//pkg:deb.bzl", "pkg_deb")
+load("//pkg:mappings.bzl", "pkg_mklink")
load("//pkg:tar.bzl", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming")
+load(":deb_tests.bzl", "package_naming_test")
package(default_applicable_licenses = ["//:license"])
@@ -100,10 +100,11 @@ py_test(
# The target includes both the .deb and .changes files in DefaultInfo
":test_deb",
],
+ imports = ["../.."],
python_version = "PY3",
deps = [
"//pkg/private:archive",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -119,6 +120,7 @@ py_test(
srcs = [
"control_field_test.py",
],
+ imports = ["../.."],
python_version = "PY3",
deps = [
"//pkg/private/deb:make_deb_lib",
@@ -128,6 +130,9 @@ py_test(
# Test case for expanding $(var) constructions and for using ctx.var directly
pkg_deb(
name = "deb_using_ctxvar",
+ # This does not make sense for architecture, but for testing, compilation
+ # mode is more stable than cpu.
+ architecture = "$(COMPILATION_MODE)",
config = "config",
data = ":tar_input",
description = "Compiled with $(COMPILATION_MODE)",
@@ -135,9 +140,6 @@ pkg_deb(
maintainer = "soméone@somewhere.com",
package = "fizzbuzz",
version = "7",
- # This does not make sense for architecture, but for testing, compilation
- # mode is more stable thatn cpu.
- architecture = "$(COMPILATION_MODE)",
)
package_naming_test(
diff --git a/tests/deb/control_field_test.py b/tests/deb/control_field_test.py
index a469141..5f4f5e9 100644
--- a/tests/deb/control_field_test.py
+++ b/tests/deb/control_field_test.py
@@ -52,23 +52,31 @@ class MakeControlFieldTest(unittest.TestCase):
self.assertEqual(
'Description: fizzbuzz\n',
make_deb.MakeDebianControlField(
- 'Description', 'fizzbuzz', is_multiline=True))
+ 'Description', 'fizzbuzz', multiline=make_deb.Multiline.YES))
self.assertEqual(
'Description: fizz\n buzz\n',
make_deb.MakeDebianControlField(
- 'Description', 'fizz\n buzz\n', is_multiline=True))
+ 'Description', 'fizz\n buzz\n', multiline=make_deb.Multiline.YES))
+ self.assertEqual(
+ 'Description:\n fizz\n buzz\n',
+ make_deb.MakeDebianControlField(
+ 'Description', ' fizz\n buzz\n', multiline=make_deb.Multiline.YES_ADD_NEWLINE))
def test_multiline_add_required_space(self):
self.assertEqual(
'Description: fizz\n buzz\n',
make_deb.MakeDebianControlField(
- 'Description', 'fizz\nbuzz', is_multiline=True))
+ 'Description', 'fizz\nbuzz', multiline=make_deb.Multiline.YES))
+ self.assertEqual(
+ 'Description:\n fizz\n buzz\n',
+ make_deb.MakeDebianControlField(
+ 'Description', 'fizz\nbuzz\n', multiline=make_deb.Multiline.YES_ADD_NEWLINE))
def test_multiline_add_trailing_newline(self):
self.assertEqual(
'Description: fizz\n buzz\n baz\n',
make_deb.MakeDebianControlField(
- 'Description', 'fizz\n buzz\n baz', is_multiline=True))
+ 'Description', 'fizz\n buzz\n baz', multiline=make_deb.Multiline.YES))
if __name__ == '__main__':
diff --git a/tests/deb/pkg_deb_test.py b/tests/deb/pkg_deb_test.py
index 3334413..8a2e653 100644
--- a/tests/deb/pkg_deb_test.py
+++ b/tests/deb/pkg_deb_test.py
@@ -22,7 +22,7 @@ import sys
import tarfile
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.private import archive
@@ -111,7 +111,7 @@ class PkgDebTest(unittest.TestCase):
if k == 'data':
value = f.extractfile(info).read()
elif k == 'name':
- # The test data uses / as path sep, but the tarbal is in OS native
+ # The test data uses / as path sep, but the tarball is in OS native
# format. This aligns the tarball name back to what we expect.
value = name_in_tar_file.replace(os.path.sep, '/')
elif k == 'isdir':
@@ -249,6 +249,32 @@ class PkgDebTest(unittest.TestCase):
content[d_start + len(d_expect)].isupper(),
'Description has unexpected characters at end (%s)' % content)
+ self.maxDiff = None
+ expect = '''Format: 1\.8
+Date: Thu Jan 1 \d{2}:00:00 1970
+Source: fizzbuzz
+Binary: fizzbuzz
+Architecture: all
+Version: 4\.5\.6
+Distribution: trusty
+Urgency: low
+Maintainer: soméone@somewhere.com
+Changed-By: soméone@somewhere.com
+Description:
+ fizzbuzz - toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é
+Changes:
+ fizzbuzz \(4\.5\.6\) trusty; urgency=low
+ Changes are tracked in revision control\.
+Files:
+ [a-f0-9]{32} \d{4} contrib/devel optional fizzbuzz_4\.5\.6_all\.deb
+Checksums-Sha1:
+ [a-f0-9]{40} \d{4} fizzbuzz_4\.5\.6_all\.deb
+Checksums-Sha256:
+ [a-f0-9]{64} \d{4} fizzbuzz_4\.5\.6_all\.deb
+'''
+
+ self.assertRegex(content, expect)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/foo.cc b/tests/foo.cc
index 4359267..3274cf8 100644
--- a/tests/foo.cc
+++ b/tests/foo.cc
@@ -1 +1,20 @@
-int main(int argc, char* argv[]) { return 0; }
+#include <fstream>
+#include <iostream>
+#include <string>
+
+extern int a, b;
+
+// A very roundabout hello world.
+int main(int argc, char* argv[]) {
+ std::string runfiles(argv[0]);
+ runfiles.append(".runfiles");
+ std::string hello(runfiles + "/rules_pkg/tests/testdata/hello.txt");
+ std::fstream fs;
+ fs.open(hello, std::iostream::in);
+ char tmp[1000];
+ fs.read(tmp, sizeof(tmp));
+ fs.close();
+ std::cout << tmp;
+
+ return (a + b > 0) ? 0 : 1;
+}
diff --git a/tests/install/BUILD b/tests/install/BUILD
index f083b3f..5a2c127 100644
--- a/tests/install/BUILD
+++ b/tests/install/BUILD
@@ -26,6 +26,7 @@ py_test(
data = [
":test_installer",
],
+ imports = ["../.."],
main = "test.py",
tags = [
# TODO(nacl): investigate this. See also
diff --git a/tests/install/test.py b/tests/install/test.py
index 996ae09..bbb02ab 100644
--- a/tests/install/test.py
+++ b/tests/install/test.py
@@ -20,7 +20,7 @@ import unittest
import stat
import subprocess
-from rules_python.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.private import manifest
diff --git a/tests/mappings/BUILD b/tests/mappings/BUILD
index 44752cb..fd3469b 100644
--- a/tests/mappings/BUILD
+++ b/tests/mappings/BUILD
@@ -13,31 +13,30 @@
# limitations under the License.
load(
- ":mappings_test.bzl",
- "manifest_golden_test",
- "mappings_analysis_tests",
- "mappings_unit_tests",
-)
-load(":mappings_external_repo_test.bzl", "mappings_external_repo_analysis_tests")
-load(
"//pkg:mappings.bzl",
"pkg_attributes",
- "pkg_filegroup",
"pkg_files",
"pkg_mkdirs",
"strip_prefix",
)
load("//tests/util:defs.bzl", "directory", "link_tree", "write_content_manifest")
-load("@rules_python//python:defs.bzl", "py_test")
+load(":mappings_external_repo_test.bzl", "mappings_external_repo_analysis_tests")
+load(
+ ":mappings_test.bzl",
+ "manifest_golden_test",
+ "mappings_analysis_tests",
+ "mappings_unit_tests",
+)
package(default_applicable_licenses = ["//:license"])
py_library(
name = "manifest_test_lib",
srcs = ["manifest_test_lib.py"],
+ imports = ["../.."],
srcs_version = "PY3",
deps = [
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -129,17 +128,18 @@ manifest_golden_test(
write_content_manifest(
name = "executable_manifest",
srcs = [
+ "mappings_test.bzl",
"//tests:an_executable",
],
include_runfiles = True,
)
alias(
- name = "executable_test_expected",
- actual = select({
- "@platforms//os:windows": "executable.manifest.windows.golden",
- "//conditions:default": "executable.manifest.golden",
- }),
+ name = "executable_test_expected",
+ actual = select({
+ "@platforms//os:windows": "executable.manifest.windows.golden",
+ "//conditions:default": "executable.manifest.golden",
+ }),
)
manifest_golden_test(
diff --git a/tests/mappings/all.manifest.golden b/tests/mappings/all.manifest.golden
index 475ec96..6a5f107 100644
--- a/tests/mappings/all.manifest.golden
+++ b/tests/mappings/all.manifest.golden
@@ -1,7 +1,7 @@
[
- {"type": "file", "dest": "BUILD", "src": "tests/mappings/BUILD", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:BUILD"},
- {"type": "dir", "dest": "foodir", "src": null, "mode": "711", "user": "foo", "group": "bar", "origin": "@//tests/mappings:dirs"},
+ {"type": "file", "dest": "BUILD", "src": "tests/mappings/BUILD", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:BUILD"},
+ {"type": "dir", "dest": "foodir", "src": null, "mode": "711", "user": "foo", "group": "bar", "uid": null, "gid": null, "origin": "@//tests/mappings:dirs"},
- {"type": "file", "dest": "mappings_test.bzl", "src": "tests/mappings/mappings_test.bzl", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:files"},
- {"type": "tree", "dest": "treeartifact", "src": "tests/mappings/treeartifact", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:directory-with-contents"}
+ {"type": "file", "dest": "mappings_test.bzl", "src": "tests/mappings/mappings_test.bzl", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:files"},
+ {"type": "tree", "dest": "treeartifact", "src": "tests/mappings/treeartifact", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:directory-with-contents"}
]
diff --git a/tests/mappings/executable.manifest.golden b/tests/mappings/executable.manifest.golden
index 7f85aab..9219554 100644
--- a/tests/mappings/executable.manifest.golden
+++ b/tests/mappings/executable.manifest.golden
@@ -1,5 +1,7 @@
[
- {"type": "file", "dest": "an_executable.runfiles/tests/BUILD", "src": "tests/BUILD", "mode": "", "user": null, "group": null, "origin": "@//tests:an_executable"},
- {"type": "file", "dest": "an_executable.runfiles/tests/an_executable", "src": "tests/an_executable", "mode": "0755", "user": null, "group": null, "origin": "@//tests:an_executable"},
- {"type": "file", "dest": "an_executable", "src": "tests/an_executable", "mode": "0755", "user": null, "group": null, "origin": "@//tests:an_executable"}
-] \ No newline at end of file
+{"dest":"an_executable.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
+{"dest":"an_executable.runfiles/tests/an_executable","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable","type":"file","uid":null,"user":null},
+{"dest":"an_executable.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null},
+{"dest":"an_executable","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable","type":"file","uid":null,"user":null},
+{"dest":"mappings_test.bzl","gid":null,"group":null,"mode":"","origin":"@//tests/mappings:mappings_test.bzl","src":"tests/mappings/mappings_test.bzl","type":"file","uid":null,"user":null}
+]
diff --git a/tests/mappings/executable.manifest.windows.golden b/tests/mappings/executable.manifest.windows.golden
index 55b0804..150f477 100644
--- a/tests/mappings/executable.manifest.windows.golden
+++ b/tests/mappings/executable.manifest.windows.golden
@@ -1,5 +1,7 @@
[
- {"type": "file", "dest": "an_executable.exe.runfiles/tests/BUILD", "src": "tests/BUILD", "mode": "", "user": null, "group": null, "origin": "@//tests:an_executable"},
- {"type": "file", "dest": "an_executable.exe.runfiles/tests/an_executable.exe", "src": "tests/an_executable.exe", "mode": "0755", "user": null, "group": null, "origin": "@//tests:an_executable"},
- {"type": "file", "dest": "an_executable.exe", "src": "tests/an_executable.exe", "mode": "0755", "user": null, "group": null, "origin": "@//tests:an_executable"}
+{"dest":"an_executable.exe.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
+{"dest":"an_executable.exe.runfiles/tests/an_executable.exe","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable.exe","type":"file","uid":null,"user":null},
+{"dest":"an_executable.exe.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null},
+{"dest":"an_executable.exe","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable.exe","type":"file","uid":null,"user":null},
+{"dest":"mappings_test.bzl","gid":null,"group":null,"mode":"","origin":"@//tests/mappings:mappings_test.bzl","src":"tests/mappings/mappings_test.bzl","type":"file","uid":null,"user":null}
]
diff --git a/tests/mappings/external_repo/pkg/BUILD b/tests/mappings/external_repo/pkg/BUILD
index 8800ce3..33db6a8 100644
--- a/tests/mappings/external_repo/pkg/BUILD
+++ b/tests/mappings/external_repo/pkg/BUILD
@@ -12,7 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-load("@//:mappings.bzl", "pkg_files", "strip_prefix")
+load("@//pkg:mappings.bzl", "pkg_files", "strip_prefix")
+load("@//pkg:tar.bzl", "pkg_tar")
+load("@//pkg:verify_archive.bzl", "verify_archive_test")
load("@//tests/util:defs.bzl", "fake_artifact")
load("test.bzl", "test_referencing_remote_file")
@@ -39,3 +41,18 @@ pkg_files(
test_referencing_remote_file(
name = "pf_local_file_in_extrepo",
)
+
+# Add a target to ensure verify_archive_test can be
+# called from another workspace
+pkg_tar(
+ name = "external_archive",
+ srcs = ["dir/extproj.sh"],
+)
+
+verify_archive_test(
+ name = "external_archive_test",
+ max_size = 1,
+ min_size = 1,
+ must_contain = ["extproj.sh"],
+ target = ":external_archive",
+)
diff --git a/tests/mappings/external_repo/pkg/test.bzl b/tests/mappings/external_repo/pkg/test.bzl
index 4951cd7..c0a7713 100644
--- a/tests/mappings/external_repo/pkg/test.bzl
+++ b/tests/mappings/external_repo/pkg/test.bzl
@@ -18,8 +18,8 @@ Test implementation copied from pkg/mappings.bzl
"""
-load("@//:mappings.bzl", "pkg_files", "strip_prefix")
-load("@//:providers.bzl", "PackageFilesInfo")
+load("@//pkg:mappings.bzl", "pkg_files", "strip_prefix")
+load("@//pkg:providers.bzl", "PackageFilesInfo")
load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
diff --git a/tests/mappings/filter_directory/BUILD b/tests/mappings/filter_directory/BUILD
index 4b0399b..a1ff831 100644
--- a/tests/mappings/filter_directory/BUILD
+++ b/tests/mappings/filter_directory/BUILD
@@ -13,9 +13,9 @@
# limitations under the License.
load("@rules_python//python:defs.bzl", "py_test")
-load(":defs.bzl", "inspect_directory_test")
load("//pkg:mappings.bzl", "filter_directory")
load("//tests/util:defs.bzl", "directory")
+load(":defs.bzl", "inspect_directory_test")
# TODO: the below tests only check for rule success and confirmation that
# directory structure matches expectations. A more thorough test implementation
@@ -227,7 +227,9 @@ directory(
py_test(
name = "negative_tests",
srcs = ["test_filter_directory.py"],
- data = ["//pkg:filter_directory"],
main = "test_filter_directory.py",
- deps = ["@rules_python//python/runfiles"],
+ deps = [
+ "//pkg:filter_directory_lib",
+ "@rules_python//python/runfiles",
+ ],
)
diff --git a/tests/mappings/filter_directory/inspect_directory.py.tpl b/tests/mappings/filter_directory/inspect_directory.py.tpl
index 938ddd7..cc935cf 100644
--- a/tests/mappings/filter_directory/inspect_directory.py.tpl
+++ b/tests/mappings/filter_directory/inspect_directory.py.tpl
@@ -17,7 +17,7 @@
import json
import os
import unittest
-from rules_python.python.runfiles import runfiles
+from python.runfiles import runfiles
DIRECTORY_ROOT = "%DIRECTORY_ROOT%"
# This is JSON, which shouldn't have any triple quotes in it.
diff --git a/tests/mappings/filter_directory/test_filter_directory.py b/tests/mappings/filter_directory/test_filter_directory.py
index 96b1220..8426905 100644
--- a/tests/mappings/filter_directory/test_filter_directory.py
+++ b/tests/mappings/filter_directory/test_filter_directory.py
@@ -24,20 +24,8 @@ import sys
import tempfile
import unittest
-from rules_python.python.runfiles import runfiles
-
-# Get the filter_directory script into the import path. There might be a
-# better way to do this, but it works.
-
-rf = runfiles.Create()
-filter_directory_script = rf.Rlocation('/'.join([
- os.environ["TEST_WORKSPACE"],
- "pkg",
- "filter_directory"
-]))
-
-sys.path.append(os.path.dirname(filter_directory_script))
-import filter_directory # noqa: E402
+from pkg import filter_directory
+from python.runfiles import runfiles
# TODO: These tests are largely to ensure that filter_directory fails, but it
@@ -109,7 +97,7 @@ class FilterDirectoryInternalTest(unittest.TestCase):
def test_invalid_prefixes(self):
self.assertFilterDirectoryFails(
prefix="/absolute/path",
- message="--prefix with aboslute paths should be rejected",
+ message="--prefix with absolute paths should be rejected",
)
self.assertFilterDirectoryFails(
diff --git a/tests/mappings/glob_for_texts_manifest.golden b/tests/mappings/glob_for_texts_manifest.golden
index c144b83..9ff7e21 100644
--- a/tests/mappings/glob_for_texts_manifest.golden
+++ b/tests/mappings/glob_for_texts_manifest.golden
@@ -1,6 +1,6 @@
[
- {"type": "file", "dest": "file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt", "src": "tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt", "mode": "", "user": null, "group": null, "origin": "@//tests:glob_for_texts"},
- {"type": "file", "dest": "hello.txt", "src": "tests/testdata/hello.txt", "mode": "", "user": null, "group": null, "origin": "@//tests:glob_for_texts"},
- {"type": "file", "dest": "loremipsum.txt", "src": "tests/testdata/loremipsum.txt", "mode": "", "user": null, "group": null, "origin": "@//tests:glob_for_texts"},
- {"type": "file", "dest": "test_tar_package_dir_file.txt", "src": "tests/testdata/test_tar_package_dir_file.txt", "mode": "", "user": null, "group": null, "origin": "@//tests:glob_for_texts"}
+ {"type": "file", "dest": "file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt", "src": "tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests:glob_for_texts"},
+ {"type": "file", "dest": "hello.txt", "src": "tests/testdata/hello.txt", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests:glob_for_texts"},
+ {"type": "file", "dest": "loremipsum.txt", "src": "tests/testdata/loremipsum.txt", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests:glob_for_texts"},
+ {"type": "file", "dest": "test_tar_package_dir_file.txt", "src": "tests/testdata/test_tar_package_dir_file.txt", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests:glob_for_texts"}
]
diff --git a/tests/mappings/manifest_test_lib.py b/tests/mappings/manifest_test_lib.py
index 0534ebe..b668439 100644
--- a/tests/mappings/manifest_test_lib.py
+++ b/tests/mappings/manifest_test_lib.py
@@ -16,26 +16,56 @@
import json
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
class ContentManifestTest(unittest.TestCase):
"""Test harness to see if we wrote the content manifest correctly."""
run_files = runfiles.Create()
- def assertManifestsMatch(self, expected, got):
+ def assertManifestsMatch(self, expected_path, got_path):
"""Check two manifest files for equality.
Args:
- expected: The path to the content we expect.
- got: The path to the content we got.
+ expected_path: The path to the content we expect.
+ got_path: The path to the content we got.
"""
- e_file = ContentManifestTest.run_files.Rlocation('rules_pkg/' + expected)
- with open(e_file, mode='rb') as e_fp:
- expected = json.load(e_fp)
- expected_dict = {x["dest"]: x for x in expected}
- g_file = ContentManifestTest.run_files.Rlocation('rules_pkg/' + got)
- with open(g_file, mode='rb') as g_fp:
- got = json.load(g_fp)
- got_dict = {x["dest"]: x for x in got}
- self.assertEqual(expected_dict, got_dict)
+ e_file = ContentManifestTest.run_files.Rlocation('rules_pkg/' + expected_path)
+ with open(e_file, mode='rt', encoding='utf-8') as e_fp:
+ expected = json.loads(e_fp.read())
+ expected_dict = {x['dest']: x for x in expected}
+ g_file = ContentManifestTest.run_files.Rlocation('rules_pkg/' + got_path)
+ with open(g_file, mode='rt', encoding='utf-8') as g_fp:
+ got = json.loads(g_fp.read())
+ got_dict = {x['dest']: x for x in got}
+
+ ok = True
+ expected_dests = set(expected_dict.keys())
+ got_dests = set(got_dict.keys())
+ for dest, what in expected_dict.items():
+ got = got_dict.get(dest)
+ if got:
+ # bzlmod mode changes root to @@//, but older version give @//
+ origin = got.get('origin')
+ if origin and origin.startswith('@@//'):
+ got['origin'] = origin[1:]
+ self.assertDictEqual(what, got)
+ else:
+ print('Missing expected path "%s" in manifest' % dest)
+ ok = False
+ for dest, what in got_dict.items():
+ expected = expected_dict.get(dest)
+ if expected:
+ self.assertDictEqual(expected, what)
+ else:
+ print('Got unexpected path "%s" in manifest:' % dest, what)
+ ok = False
+
+ if not ok:
+ print('To update the golden file:')
+ print(' cp bazel-bin/%s %s' % (got_path, expected_path))
+ print('or')
+ print('============= snip ==========')
+ print(got_dict.values())
+ print('============= snip ==========')
+ self.assertTrue(ok)
diff --git a/tests/mappings/mappings_external_repo_test.bzl b/tests/mappings/mappings_external_repo_test.bzl
index aeb3223..7b9b0ac 100644
--- a/tests/mappings/mappings_external_repo_test.bzl
+++ b/tests/mappings/mappings_external_repo_test.bzl
@@ -14,11 +14,8 @@
"""Tests for file mapping routines in pkg/mappings.bzl"""
-load("@bazel_skylib//lib:new_sets.bzl", "sets")
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
-load(":mappings_test.bzl", "pkg_files_contents_test")
-load("//pkg:providers.bzl", "PackageFilegroupInfo", "PackageFilesInfo")
load("//pkg:mappings.bzl", "pkg_files", "strip_prefix")
+load(":mappings_test.bzl", "pkg_files_contents_test")
##########
# pkg_files tests involving external repositories
@@ -109,6 +106,7 @@ def _test_pkg_files_extrepo():
expected_dests = ["usr/bin/dir/extproj.sh"],
)
+# buildifier: disable=unnamed-macro
def mappings_external_repo_analysis_tests():
"""Declare mappings.bzl analysis tests"""
_test_pkg_files_extrepo()
@@ -133,5 +131,10 @@ def mappings_external_repo_analysis_tests():
# The main purpose behind it is to verify cases wherein we build a
# 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
+ # 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 fcb4639..d5dc0c2 100644
--- a/tests/mappings/mappings_test.bzl
+++ b/tests/mappings/mappings_test.bzl
@@ -14,14 +14,9 @@
"""Tests for file mapping routines in pkg/mappings.bzl"""
+load("@bazel_skylib//lib:new_sets.bzl", "sets")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
-load(
- "//pkg:providers.bzl",
- "PackageDirsInfo",
- "PackageFilegroupInfo",
- "PackageFilesInfo",
- "PackageSymlinkInfo",
-)
+load("@rules_python//python:defs.bzl", "py_test")
load(
"//pkg:mappings.bzl",
"REMOVE_BASE_DIRECTORY",
@@ -33,14 +28,19 @@ load(
"strip_prefix",
)
load(
+ "//pkg:providers.bzl",
+ "PackageDirsInfo",
+ "PackageFilegroupInfo",
+ "PackageFilesInfo",
+ "PackageSymlinkInfo",
+)
+load(
"//tests/util:defs.bzl",
"directory",
"fake_artifact",
"generic_base_case_test",
"generic_negative_test",
)
-load("@bazel_skylib//lib:new_sets.bzl", "sets")
-load("@rules_python//python:defs.bzl", "py_test")
##########
# Helpers
@@ -883,6 +883,7 @@ def _strip_prefix_test_impl(ctx):
strip_prefix_test = unittest.make(_strip_prefix_test_impl)
+# buildifier: disable=unnamed-macro
def mappings_analysis_tests():
"""Declare mappings.bzl analysis tests"""
_test_pkg_files_contents()
@@ -969,6 +970,7 @@ _gen_manifest_test_main = rule(
},
)
+# buildifier: disable=function-docstring-args
def manifest_golden_test(name, target, expected):
"""Tests that a content manifest file matches a golden copy.
diff --git a/tests/mappings/node_modules_manifest.golden b/tests/mappings/node_modules_manifest.golden
index 436128b..b234629 100755
--- a/tests/mappings/node_modules_manifest.golden
+++ b/tests/mappings/node_modules_manifest.golden
@@ -1,9 +1,9 @@
[
- {"type": "symlink", "dest": "node_modules/.pnpm/bar@1.0.0/node_modules/bar", "src": "STORE/bar", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/.pnpm/bar@1.0.0/node_modules/qar", "src": "../../qar@2.0.0/node_modules/qar", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/bar", "src": "../../bar@1.0.0/node_modules/bar", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/foo", "src": "STORE/foo", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/qar", "src": "../../qar@2.0.0/node_modules/qar", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/.pnpm/qar@2.0.0/node_modules/qar", "src": "STORE/qar", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"},
- {"type": "symlink", "dest": "node_modules/foo", "src": ".pnpm/foo@1.0.0/node_modules/foo", "mode": "", "user": null, "group": null, "origin": "@//tests/mappings:node_modules"}
+ {"type": "symlink", "dest": "node_modules/.pnpm/bar@1.0.0/node_modules/bar", "src": "STORE/bar", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/.pnpm/bar@1.0.0/node_modules/qar", "src": "../../qar@2.0.0/node_modules/qar", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/bar", "src": "../../bar@1.0.0/node_modules/bar", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/foo", "src": "STORE/foo", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/.pnpm/foo@1.0.0/node_modules/qar", "src": "../../qar@2.0.0/node_modules/qar", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/.pnpm/qar@2.0.0/node_modules/qar", "src": "STORE/qar", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"},
+ {"type": "symlink", "dest": "node_modules/foo", "src": ".pnpm/foo@1.0.0/node_modules/foo", "mode": "", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:node_modules"}
]
diff --git a/tests/mappings/utf8_manifest.golden b/tests/mappings/utf8_manifest.golden
index a875085..11352ca 100644
--- a/tests/mappings/utf8_manifest.golden
+++ b/tests/mappings/utf8_manifest.golden
@@ -1,8 +1,8 @@
[
- {"type": "file", "dest": "1-a", "src": "tests/testdata/utf8/1-a", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"},
- {"type": "file", "dest": "2-λ", "src": "tests/testdata/utf8/2-λ", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"},
- {"type": "file", "dest": "3-世", "src": "tests/testdata/utf8/3-世", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"},
- {"type": "file", "dest": "BUILD", "src": "tests/testdata/utf8/BUILD", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"},
- {"type": "file", "dest": "sübdir/2-λ", "src": "tests/testdata/utf8/sübdir/2-λ", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"},
- {"type": "file", "dest": "sübdir/hello", "src": "tests/testdata/utf8/sübdir/hello", "mode": "0644", "user": null, "group": null, "origin": "@//tests/mappings:utf8_files"}
+ {"type": "file", "dest": "1-a", "src": "tests/testdata/utf8/1-a", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"},
+ {"type": "file", "dest": "2-λ", "src": "tests/testdata/utf8/2-λ", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"},
+ {"type": "file", "dest": "3-世", "src": "tests/testdata/utf8/3-世", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"},
+ {"type": "file", "dest": "BUILD", "src": "tests/testdata/utf8/BUILD", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"},
+ {"type": "file", "dest": "sübdir/2-λ", "src": "tests/testdata/utf8/sübdir/2-λ", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"},
+ {"type": "file", "dest": "sübdir/hello", "src": "tests/testdata/utf8/sübdir/hello", "mode": "0644", "user": null, "group": null, "uid": null, "gid": null, "origin": "@//tests/mappings:utf8_files"}
]
diff --git a/tests/path_test.bzl b/tests/path_test.bzl
index a2a46d2..2a01383 100644
--- a/tests/path_test.bzl
+++ b/tests/path_test.bzl
@@ -14,16 +14,15 @@
"""Tests for path.bzl"""
+load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load("//pkg:mappings.bzl", "pkg_mkdirs")
load("//pkg:path.bzl", "compute_data_path")
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
##########
# Test compute_data_path
##########
def _compute_data_path_test_impl(ctx):
env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
# Subtle: This allows you to vendor the library into your own repo at some
# arbitrary path.
@@ -33,7 +32,7 @@ def _compute_data_path_test_impl(ctx):
asserts.equals(
env,
expect,
- compute_data_path(ctx, ctx.attr.in_path),
+ compute_data_path(ctx.label, ctx.attr.in_path),
)
return analysistest.end(env)
diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD
index 5f91da8..f51d75b 100644
--- a/tests/rpm/BUILD
+++ b/tests/rpm/BUILD
@@ -124,6 +124,50 @@ pkg_filegroup(
)
############################################################################
+# scriptlets for testing
+############################################################################
+
+_POST_SCRIPTLET = "echo post"
+_POSTUN_SCRIPTLET = "echo postun"
+_PRE_SCRIPTLET = "echo pre"
+_PREUN_SCRIPTLET = "echo preun"
+_POSTTRANS_SCRIPTLET = "echo posttrans"
+
+[
+ genrule(
+ name = name,
+ outs = ["{}.sh".format(name)],
+ cmd = "echo '{}' > $@".format(content),
+ )
+ for name, content in [
+ ("post", _POST_SCRIPTLET),
+ ("postun", _POSTUN_SCRIPTLET),
+ ("pre", _PRE_SCRIPTLET),
+ ("preun", _PREUN_SCRIPTLET),
+ ("posttrans", _POSTTRANS_SCRIPTLET),
+ ]
+]
+
+############################################################################
+# versionfile for testing
+############################################################################
+
+_VERSION = "1.1.1"
+_RELEASE = "2222"
+
+genrule(
+ name = "version_file",
+ outs = ["version"],
+ cmd = "echo '{}' > $@".format(_VERSION),
+)
+
+genrule(
+ name = "release_file",
+ outs = ["release"],
+ cmd = "echo '{}' > $@".format(_RELEASE),
+)
+
+############################################################################
# Test RPMs
############################################################################
@@ -136,22 +180,23 @@ pkg_rpm(
conflicts = ["not-a-test"],
description = """pkg_rpm test rpm description""",
license = "Apache 2.0",
- post_scriptlet = """echo post""",
- postun_scriptlet = """echo postun""",
- pre_scriptlet = """echo pre""",
- preun_scriptlet = """echo preun""",
+ post_scriptlet = _POST_SCRIPTLET,
+ postun_scriptlet = _POSTUN_SCRIPTLET,
+ pre_scriptlet = _PRE_SCRIPTLET,
+ preun_scriptlet = _PREUN_SCRIPTLET,
+ posttrans_scriptlet = _POSTTRANS_SCRIPTLET,
provides = ["test"],
- release = "2222",
+ release = _RELEASE,
requires = ["test-lib > 1.0"],
requires_contextual = {"preun": ["bash"]},
spec_template = "template-test.spec.tpl",
summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
+ version = _VERSION,
)
# Just like the above one, except the compression is changed.
pkg_rpm(
- name = "test_rpm-bzip2",
+ name = "test_rpm_bzip2",
srcs = [
":test_pfg",
],
@@ -160,17 +205,18 @@ pkg_rpm(
conflicts = ["not-a-test"],
description = """pkg_rpm test rpm description""",
license = "Apache 2.0",
- post_scriptlet = """echo post""",
- postun_scriptlet = """echo postun""",
- pre_scriptlet = """echo pre""",
- preun_scriptlet = """echo preun""",
+ post_scriptlet = _POST_SCRIPTLET,
+ postun_scriptlet = _POSTUN_SCRIPTLET,
+ pre_scriptlet = _PRE_SCRIPTLET,
+ preun_scriptlet = _PREUN_SCRIPTLET,
+ posttrans_scriptlet = _POSTTRANS_SCRIPTLET,
provides = ["test"],
- release = "2222",
+ release = _RELEASE,
requires = ["test-lib > 1.0"],
requires_contextual = {"preun": ["bash"]},
spec_template = "template-test.spec.tpl",
summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
+ version = _VERSION,
)
# Like the first one, except `srcs` is now passed in without using a
@@ -187,17 +233,66 @@ pkg_rpm(
conflicts = ["not-a-test"],
description = """pkg_rpm test rpm description""",
license = "Apache 2.0",
- post_scriptlet = """echo post""",
- postun_scriptlet = """echo postun""",
- pre_scriptlet = """echo pre""",
- preun_scriptlet = """echo preun""",
+ post_scriptlet = _POST_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"],
+ requires_contextual = {"preun": ["bash"]},
+ spec_template = "template-test.spec.tpl",
+ summary = "pkg_rpm test rpm summary",
+ version = _VERSION,
+)
+
+# Like the first one, except we use files for scriptlets
+pkg_rpm(
+ name = "test_rpm_scriptlets_files",
+ srcs = [
+ ":test_pfg",
+ ],
+ architecture = "noarch",
+ conflicts = ["not-a-test"],
+ description = """pkg_rpm test rpm description""",
+ license = "Apache 2.0",
+ post_scriptlet_file = ":post",
+ 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"],
requires_contextual = {"preun": ["bash"]},
spec_template = "template-test.spec.tpl",
summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
+ version = _VERSION,
+)
+
+# Like the first one, except we use release and version files
+pkg_rpm(
+ name = "test_rpm_release_version_files",
+ srcs = [
+ ":test_pfg",
+ ],
+ architecture = "noarch",
+ conflicts = ["not-a-test"],
+ description = """pkg_rpm test rpm description""",
+ license = "Apache 2.0",
+ post_scriptlet_file = ":post",
+ 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"],
+ requires_contextual = {"preun": ["bash"]},
+ spec_template = "template-test.spec.tpl",
+ summary = "pkg_rpm test rpm summary",
+ version_file = ":version_file",
)
############################################################################
@@ -285,6 +380,7 @@ genrule(
# NOTE: excludes 'rpmlib' requires that may be version-dependent
echo 'capability:sense'
# Common, automatically generated
+ echo '/bin/sh:interp,posttrans'
echo '/bin/sh:pre,interp'
echo '/bin/sh:post,interp'
echo '/bin/sh:preun,interp'
@@ -305,10 +401,12 @@ sh_library(
testonly = True,
srcs = [
":test_rpm",
- ":test_rpm-bzip2",
+ ":test_rpm_bzip2",
":test_rpm_direct",
":test_rpm_manifest",
":test_rpm_metadata",
+ ":test_rpm_scriptlets_files",
+ ":test_rpm_release_version_files",
],
)
@@ -373,6 +471,7 @@ diff_test(
py_library(
name = "rpm_util",
srcs = ["rpm_util.py"],
+ imports = ["../.."],
visibility = [":__subpackages__"],
)
diff --git a/tests/rpm/analysis_tests.bzl b/tests/rpm/analysis_tests.bzl
index 52f4c5e..fd3317f 100644
--- a/tests/rpm/analysis_tests.bzl
+++ b/tests/rpm/analysis_tests.bzl
@@ -14,6 +14,7 @@
"""Tests for RPM generation analysis"""
+load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
load(
"//pkg:mappings.bzl",
"pkg_filegroup",
@@ -21,10 +22,9 @@ load(
"pkg_mkdirs",
"pkg_mklink",
)
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-load("//pkg:providers.bzl", "PackageArtifactInfo", "PackageVariablesInfo")
+load("//pkg:providers.bzl", "PackageVariablesInfo")
load("//pkg:rpm.bzl", "pkg_rpm")
-load("//tests/util:defs.bzl", "directory", "generic_base_case_test", "generic_negative_test")
+load("//tests/util:defs.bzl", "generic_base_case_test", "generic_negative_test")
def _declare_pkg_rpm(name, srcs_ungrouped, tags = None, **kwargs):
pfg_name = "{}_pfg".format(name)
@@ -49,7 +49,7 @@ def _declare_pkg_rpm(name, srcs_ungrouped, tags = None, **kwargs):
**kwargs
)
-def _declare_conflicts_test(name, srcs, **kwargs):
+def _declare_conflicts_test(name, srcs):
rpm_name = name + "_rpm"
_declare_pkg_rpm(
name = rpm_name,
@@ -167,46 +167,53 @@ def _package_naming_test_impl(ctx):
env = analysistest.begin(ctx)
target_under_test = analysistest.target_under_test(env)
- pai = target_under_test[PackageArtifactInfo]
+ ogi = target_under_test[OutputGroupInfo]
- pai_file = pai.file
- pai_name = pai.file_name
+ out_file = ogi.out.to_list()[0]
+ rpm_file = ogi.rpm.to_list()[0]
+ changes_file = ogi.changes.to_list()[0] if ogi.changes else None
asserts.equals(
env,
- pai_name,
+ rpm_file.basename,
ctx.attr.expected_name,
- "PackageArtifactInfo file name does not match expected value.",
+ "OutputGroupInfo rpm name does not match expected value.",
)
- # Try to find the expected files in the DefaultInfo. We have to look for
- # them; PackageArtifactInfo only gives a file name, not a File structure.
- packaged_file = None
- packaged_file_found = False
+ # Try to find the expected files in the DefaultInfo.
+ out_file_found = False
+ rpm_file_found = False
+ changes_file_found = False
default_name_found = False
+
for f in target_under_test[DefaultInfo].files.to_list():
- if f == pai.file:
- packaged_file_found = True
- if f.basename == pai_name:
- packaged_file = f
- elif f.basename == ctx.attr.expected_default_name and not default_name_found:
+ if f == out_file:
+ out_file_found = True
+ if f == rpm_file:
+ rpm_file_found = True
+ if f == changes_file:
+ changes_file_found = True
+ if f.basename == ctx.attr.expected_name:
default_name_found = True
asserts.true(
env,
- packaged_file != None,
- "File name mentioned in PackageArtifactInfo '{}' is not in DefaultInfo".format(pai_name),
+ rpm_file_found,
+ "rpm component of OutputGroupInfo '{}' is not in DefaultInfo".format(rpm_file),
)
-
- asserts.true(
+ asserts.false(
env,
- packaged_file_found,
- "File object mentioned in PackageArtifactInfo '{}' missing from DefaultInfo".format(pai_name),
+ out_file_found,
+ "out component of OutputGroupInfo '{}' is not in DefaultInfo".format(out_file),
+ )
+ asserts.false(
+ env,
+ changes_file_found,
+ "changes component of OutputGroupInfo '{}' is not in DefaultInfo".format(changes_file),
)
-
asserts.true(
env,
default_name_found,
- "Expected package file with default name '{}' is not in DefaultInfo".format(ctx.attr.expected_default_name),
+ "Expected package file with default name '{}' is not in DefaultInfo".format(ctx.attr.expected_name),
)
return analysistest.end(env)
@@ -215,12 +222,11 @@ package_naming_test = analysistest.make(
_package_naming_test_impl,
attrs = {
"expected_name": attr.string(),
- "expected_default_name": attr.string(),
},
)
# Dummy substitution set, used in below test cases
-def _dummy_pkg_variables_impl(ctx):
+def _dummy_pkg_variables_impl(_):
return [
PackageVariablesInfo(
values = {
@@ -239,7 +245,7 @@ dummy_pkg_variables = rule(
def _test_naming(name):
# Test whether name templating via PackageVariablesInfo functions as expected, and ensure that
- # outputs are passed through to PackageArtifactsInfo.
+ # outputs are passed through to OutputGroupInfo.
pkg_files(
name = "{}_file_base".format(name),
srcs = ["foo"],
@@ -256,7 +262,6 @@ def _test_naming(name):
name = name + "_no_extra",
target_under_test = ":" + name + "_no_extra_rpm",
expected_name = name + "_no_extra_rpm-1.0-1.noarch.rpm",
- expected_default_name = name + "_no_extra_rpm" + ".rpm",
)
##################################################
@@ -280,7 +285,6 @@ def _test_naming(name):
name = name + "_with_different_name",
target_under_test = ":" + name + "_with_different_name_rpm",
expected_name = name + "-foo-bar.rpm",
- expected_default_name = name + "_with_different_name_rpm" + ".rpm",
)
##################################################
@@ -298,7 +302,7 @@ def _test_naming(name):
],
)
-def analysis_tests(name, **kwargs):
+def analysis_tests(name):
# Need to test:
#
# - Mutual exclusivity of certain options (low priority)
diff --git a/tests/rpm/pkg_rpm_basic_test.py b/tests/rpm/pkg_rpm_basic_test.py
index a152f06..8b29934 100644
--- a/tests/rpm/pkg_rpm_basic_test.py
+++ b/tests/rpm/pkg_rpm_basic_test.py
@@ -19,8 +19,9 @@ import subprocess
import csv
import io
import os
-import rpm_util
-from rules_python.python.runfiles import runfiles
+
+from python.runfiles import runfiles
+from tests.rpm import rpm_util
# This provides some tests for built RPMs, mostly by taking the built RPM and
# running rpm queries on it.
@@ -42,11 +43,15 @@ class PkgRpmBasicTest(unittest.TestCase):
def setUp(self):
self.runfiles = runfiles.Create()
self.test_rpm_path = self.runfiles.Rlocation(
- "rules_pkg/tests/rpm/test_rpm.rpm")
+ "rules_pkg/tests/rpm/test_rpm-1.1.1-2222.noarch.rpm")
self.test_rpm_direct_path = self.runfiles.Rlocation(
- "rules_pkg/tests/rpm/test_rpm_direct.rpm")
+ "rules_pkg/tests/rpm/test_rpm_direct-1.1.1-2222.noarch.rpm")
self.test_rpm_bzip2_path = self.runfiles.Rlocation(
- "rules_pkg/tests/rpm/test_rpm-bzip2.rpm")
+ "rules_pkg/tests/rpm/test_rpm_bzip2-1.1.1-2222.noarch.rpm")
+ self.test_rpm_scriptlets_files_path = self.runfiles.Rlocation(
+ "rules_pkg/tests/rpm/test_rpm_scriptlets_files-1.1.1-2222.noarch.rpm")
+ self.test_rpm_release_version_files = self.runfiles.Rlocation(
+ "rules_pkg/tests/rpm/test_rpm_release_version_files--.noarch.rpm")
self.maxDiff = None
def test_scriptlet_content(self):
@@ -59,31 +64,36 @@ preuninstall scriptlet (using /bin/sh):
echo preun
postuninstall scriptlet (using /bin/sh):
echo postun
+posttrans scriptlet (using /bin/sh):
+echo posttrans
"""
- output = subprocess.check_output(
- ["rpm", "-qp", "--scripts", self.test_rpm_path])
-
- self.assertEqual(output, expected)
+ for path in (self.test_rpm_path, self.test_rpm_scriptlets_files_path):
+ output = subprocess.check_output(["rpm", "-qp", "--scripts", path])
+ self.assertEqual(output, expected)
def test_basic_headers(self):
- fields = {
- "NAME": b"test_rpm",
+ common_fields = {
"VERSION": b"1.1.1",
"RELEASE": b"2222",
"ARCH": b"noarch",
"GROUP": b"Unspecified",
"SUMMARY": b"pkg_rpm test rpm summary",
}
- for fieldname, expected in fields.items():
- output = subprocess.check_output([
- "rpm", "-qp", "--queryformat", "%{" + fieldname + "}",
- self.test_rpm_path
- ])
-
- self.assertEqual(
- output, expected,
- "RPM Tag {} does not match expected value".format(fieldname))
+ for rpm, fields in [
+ (self.test_rpm_path, {"NAME": b"test_rpm"}),
+ (self.test_rpm_release_version_files, {"NAME": b"test_rpm_release_version_files"}),
+ ]:
+ fields.update(common_fields)
+ for fieldname, expected in fields.items():
+ output = subprocess.check_output([
+ "rpm", "-qp", "--queryformat", "%{" + fieldname + "}",
+ rpm,
+ ])
+
+ self.assertEqual(
+ output, expected,
+ "RPM Tag {} does not match expected value".format(fieldname))
def test_contents(self):
manifest_file = self.runfiles.Rlocation(
diff --git a/tests/rpm/source_date_epoch/BUILD b/tests/rpm/source_date_epoch/BUILD
index c6baced..156f844 100644
--- a/tests/rpm/source_date_epoch/BUILD
+++ b/tests/rpm/source_date_epoch/BUILD
@@ -28,7 +28,7 @@ py_test(
name = "source_date_epoch_insource",
srcs = ["rpm_contents_vs_manifest_test.py"],
data = [":rpm_sde_insource_data"],
- env = {"TEST_RPM": "rpm_sde_insource.rpm"},
+ env = {"TEST_RPM": "rpm_sde_insource-1.1.1-2222.noarch.rpm"},
main = "rpm_contents_vs_manifest_test.py",
tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
@@ -94,7 +94,7 @@ py_test(
name = "source_date_epoch_from_file",
srcs = ["rpm_contents_vs_manifest_test.py"],
data = [":rpm_sde_fromfile_data"],
- env = {"TEST_RPM": "rpm_sde_fromfile.rpm"},
+ env = {"TEST_RPM": "rpm_sde_fromfile-1.1.1-2222.noarch.rpm"},
main = "rpm_contents_vs_manifest_test.py",
tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
diff --git a/tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py b/tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py
index ca249c7..22db9b0 100644
--- a/tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py
+++ b/tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py
@@ -19,7 +19,7 @@ import io
import os
import unittest
-from rules_python.python.runfiles import runfiles
+from python.runfiles import runfiles
from tests.rpm import rpm_util
# Tue Mar 23 00:00:00 EDT 2021
diff --git a/tests/rpm/template-test.spec.tpl b/tests/rpm/template-test.spec.tpl
index f771f37..3f975f9 100644
--- a/tests/rpm/template-test.spec.tpl
+++ b/tests/rpm/template-test.spec.tpl
@@ -43,3 +43,5 @@ ${POST_SCRIPTLET}
${PREUN_SCRIPTLET}
${POSTUN_SCRIPTLET}
+
+${POSTTRANS_SCRIPTLET}
diff --git a/tests/rpm/toolchain_tests.bzl b/tests/rpm/toolchain_tests.bzl
index 0f6a499..9fffa8e 100644
--- a/tests/rpm/toolchain_tests.bzl
+++ b/tests/rpm/toolchain_tests.bzl
@@ -119,5 +119,6 @@ def _create_toolchain_creation_tests():
expect_path = "/usr/bin/foo",
)
+# buildifier: disable=unnamed-macro
def create_toolchain_analysis_tests():
_create_toolchain_creation_tests()
diff --git a/tests/rpm/tree_artifacts/BUILD b/tests/rpm/tree_artifacts/BUILD
index 04d7d8e..d295a1a 100644
--- a/tests/rpm/tree_artifacts/BUILD
+++ b/tests/rpm/tree_artifacts/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_test")
load(
"//pkg:mappings.bzl",
"REMOVE_BASE_DIRECTORY",
@@ -22,7 +23,6 @@ load(
)
load("//pkg:rpm.bzl", "pkg_rpm")
load("//tests/util:defs.bzl", "directory")
-load("@rules_python//python:defs.bzl", "py_test")
############################################################################
# Test handling of directory outputs
@@ -44,6 +44,7 @@ py_test(
name = "layer_with_files",
srcs = ["rpm_contents_vs_manifest_test.py"],
data = [":layer_with_files_test_data"],
+ env = {"TEST_RPM": "test_dirs_rpm-1.1.1-2222.noarch.rpm"},
main = "rpm_contents_vs_manifest_test.py",
tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
@@ -152,7 +153,7 @@ py_test(
name = "layer_with_files_reversed",
srcs = ["rpm_contents_vs_manifest_test.py"],
data = [":layer_with_files_reversed_test_data"],
- env = {"TEST_RPM": "test_dirs_rpm_reversed.rpm"},
+ env = {"TEST_RPM": "test_dirs_rpm_reversed-1.1.1-2222.noarch.rpm"},
main = "rpm_contents_vs_manifest_test.py",
tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
@@ -204,6 +205,7 @@ py_test(
name = "treeartifact_ops",
srcs = ["rpm_treeartifact_ops_test.py"],
data = [":treeartifact_ops_rpm_test_data"],
+ env = {"TEST_RPM": "treeartifact_ops_rpm-1.1.1-2222.noarch.rpm"},
main = "rpm_treeartifact_ops_test.py",
tags = [
"no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
diff --git a/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py b/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py
index f0f8b3a..2b1dabc 100644
--- a/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py
+++ b/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py
@@ -19,7 +19,7 @@ import csv
import io
import os
-from rules_python.python.runfiles import runfiles
+from python.runfiles import runfiles
from tests.rpm import rpm_util
EXPECTED_RPM_MANIFEST_CSV = """
diff --git a/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py b/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py
index 2f74bc9..6810368 100644
--- a/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py
+++ b/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py
@@ -19,7 +19,7 @@ import io
import os
import unittest
-from rules_python.python.runfiles import runfiles
+from python.runfiles import runfiles
from tests.rpm import rpm_util
EXPECTED_RPM_MANIFEST_CSV = """
diff --git a/tests/stamp_test.py b/tests/stamp_test.py
index 7ba722b..3709a1b 100644
--- a/tests/stamp_test.py
+++ b/tests/stamp_test.py
@@ -19,7 +19,7 @@ import time
import unittest
import zipfile
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
# keep in sync with archive.py
PORTABLE_MTIME = 946684800 # 2000-01-01 00:00:00.000 UTC
diff --git a/tests/tar/BUILD b/tests/tar/BUILD
index bd3712b..d0fc200 100644
--- a/tests/tar/BUILD
+++ b/tests/tar/BUILD
@@ -14,14 +14,16 @@
# -*- coding: utf-8 -*-
"""Tests for pkg_tar."""
+load("@rules_python//python:defs.bzl", "py_binary", "py_test")
+
# buildifier: disable=bzl-visibility
-load("//pkg:mappings.bzl", "pkg_files", "pkg_mklink", "strip_prefix")
+load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "pkg_mkdirs", "pkg_mklink")
load("//pkg:verify_archive.bzl", "verify_archive_test")
+
+# buildifier: disable=bzl-visibility
load("//pkg/private/tar:tar.bzl", "SUPPORTED_TAR_COMPRESSIONS", "pkg_tar")
load("//tests:my_package_name.bzl", "my_package_naming")
load("//tests/util:defs.bzl", "directory", "fake_artifact", "link_tree")
-load("@rules_python//python:defs.bzl", "py_test")
-load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
package(
default_applicable_licenses = ["//:license"],
@@ -44,11 +46,12 @@ py_test(
"//tests:testdata/tar_test.tar.xz",
"//tests:testdata/test_tar_package_dir_file.txt",
],
+ imports = ["../.."],
python_version = "PY3",
srcs_version = "PY3",
deps = [
"//pkg/private/tar:tar_writer",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -105,10 +108,18 @@ pkg_tar(
package_variables = ":my_package_variables",
)
+pkg_mkdirs(
+ name = "mydir",
+ dirs = [
+ "mydir",
+ ],
+)
+
pkg_tar(
name = "test_tar_package_dir_substitution",
srcs = [
":BUILD",
+ ":mydir",
],
package_dir = "level1/{label}/level3",
package_variables = ":my_package_variables",
@@ -123,8 +134,8 @@ pkg_mklink(
pkg_tar(
name = "test_tar_package_dir",
srcs = [
- ":mylink",
":etc/nsswitch.conf",
+ ":mylink",
],
package_dir = "/my/package",
)
@@ -165,7 +176,6 @@ pkg_tar(
[pkg_tar(
name = "test-tar-inclusion-%s" % ext,
- build_tar = "//pkg/private/tar:build_tar",
deps = [
":test-tar-basic-%s" % ext,
":test_tar_naming",
@@ -199,7 +209,7 @@ pkg_tar(
name = "test-tar-strip_prefix-dot",
srcs = [
":etc/nsswitch.conf",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
strip_prefix = ".",
)
@@ -268,21 +278,21 @@ pkg_tar(
verify_archive_test(
name = "repackaging_long_filename_test",
- target = ":test-tar-repackaging-long-filename",
+ max_size = 2,
must_contain = [
"can_i_repackage_a_file_with_a_long_name/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt",
],
+ must_contain_regex = [
+ ".*can_i_repackage_a_file_with_a_long_name/$",
+ ],
# there is really no need for these cases. I just want to use all the test capabilities.
must_not_contain = [
"i_am_not here",
],
- must_contain_regex = [
- ".*can_i_repackage_a_file_with_a_long_name/$",
- ],
must_not_contain_regex = [
"^five.is.right.out",
],
- max_size = 2,
+ target = ":test-tar-repackaging-long-filename",
)
pkg_tar(
@@ -315,14 +325,117 @@ fake_artifact(
name = "a_program",
files = ["//tests:testdata/executable.sh"],
runfiles = ["BUILD"],
+ executable = True,
)
pkg_tar(
name = "test-tar-with-runfiles",
srcs = [
":a_program",
+ "//tests:an_executable",
+ ],
+ include_runfiles = True,
+)
+
+verify_archive_test(
+ name = "runfiles_test",
+ target = ":test-tar-with-runfiles",
+ must_contain = [
+ "a_program",
+ "a_program.runfiles/tests/tar/BUILD",
+ "executable.sh",
+ ] + select({
+ "@platforms//os:windows": [
+ "an_executable.exe",
+ "an_executable.exe.runfiles/tests/foo.cc",
+ "an_executable.exe.runfiles/tests/an_executable.exe",
+ "an_executable.exe.runfiles/tests/testdata/hello.txt",
+ ],
+ "//conditions:default": [
+ "an_executable",
+ "an_executable.runfiles/tests/foo.cc",
+ "an_executable.runfiles/tests/an_executable",
+ "an_executable.runfiles/tests/testdata/hello.txt",
+ ]
+ }),
+)
+
+pkg_tar(
+ name = "test-tar-remap-runfiles-base-path",
+ srcs = [
+ ":a_program",
+ "//tests:an_executable",
+ ],
+ include_runfiles = True,
+ remap_paths = {
+ "/a_program": "/new_name",
+ "/an_executable": "/other/different_name",
+ },
+)
+
+verify_archive_test(
+ name = "runfiles_remap_base_path_test",
+ must_contain = [
+ "new_name",
+ "new_name.runfiles/tests/tar/BUILD",
+ "executable.sh",
+ ] + select({
+ "@platforms//os:windows": [
+ "other/different_name.exe",
+ "other/different_name.exe.runfiles/tests/foo.cc",
+ "other/different_name.exe.runfiles/tests/an_executable.exe",
+ "other/different_name.exe.runfiles/tests/testdata/hello.txt",
+ ],
+ "//conditions:default": [
+ "other/different_name",
+ "other/different_name.runfiles/tests/foo.cc",
+ "other/different_name.runfiles/tests/an_executable",
+ "other/different_name.runfiles/tests/testdata/hello.txt",
+ ],
+ }),
+ target = ":test-tar-remap-runfiles-base-path",
+)
+
+pkg_tar(
+ name = "test-tar-remap-runfiles-full-paths",
+ srcs = [
+ ":a_program",
+ "//tests:an_executable",
],
include_runfiles = True,
+ remap_paths = {
+ # rename the entire runfiles directory
+ "/a_program.runfiles/": "/a/program/runfiles/",
+ # rename a specific file
+ "/an_executable.runfiles/tests/testdata/hello.txt": "/myfiles/hello.txt",
+ "/an_executable.exe.runfiles/tests/testdata/hello.txt": "/myfiles/hello.txt",
+ # rename a specific subdirectory
+ "/an_executable.runfiles/tests/": "/mytests/",
+ "/an_executable.exe.runfiles/tests/": "/mytests/",
+ },
+)
+
+verify_archive_test(
+ name = "runfiles_remap_full_paths_test",
+ must_contain = [
+ "a_program",
+ "a/program/runfiles/tests/tar/BUILD",
+ "executable.sh",
+ ] + select({
+ "@platforms//os:windows": [
+ "an_executable.exe",
+ "mytests/foo.cc",
+ "mytests/an_executable.exe",
+ "myfiles/hello.txt",
+ ],
+ "//conditions:default": [
+ "an_executable",
+ "mytests/foo.cc",
+ "mytests/an_executable",
+ "myfiles/hello.txt",
+ ],
+ }),
+ target = ":test-tar-remap-runfiles-full-paths",
)
pkg_tar(
@@ -340,23 +453,25 @@ py_test(
"pkg_tar_test.py",
],
data = [
+ ":test-pkg-tar-from-pkg-files-with-attributes",
+ ":test-pkg-tar-with-attributes",
+ ":test-remap-paths-tree-artifact",
":test-tar-empty_dirs.tar",
":test-tar-empty_files.tar",
":test-tar-files_dict.tar",
+ ":test-tar-long-filename",
":test-tar-mtime.tar",
+ ":test-tar-repackaging-long-filename.tar",
":test-tar-strip_prefix-dot.tar",
":test-tar-strip_prefix-empty.tar",
":test-tar-strip_prefix-etc.tar",
":test-tar-strip_prefix-none.tar",
":test-tar-strip_prefix-substring.tar",
- ":test_tar_leading_dotslash",
- ":test_tar_package_dir_substitution.tar",
- ":test-tar-long-filename",
- ":test-tar-repackaging-long-filename.tar",
":test-tar-tree-artifact",
":test-tar-tree-artifact-noroot",
- ":test-tar-with-runfiles",
":test-tree-input-with-strip-prefix",
+ ":test_tar_leading_dotslash",
+ ":test_tar_package_dir_substitution.tar",
"//tests:testdata/tar_test.tar",
"//tests:testdata/tar_test.tar.bz2",
"//tests:testdata/tar_test.tar.gz",
@@ -369,10 +484,11 @@ py_test(
":test-tar-inclusion-%s" % compression
for compression in SUPPORTED_TAR_COMPRESSIONS
],
+ imports = ["../.."],
python_version = "PY3",
deps = [
"//pkg/private/tar:tar_writer",
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -397,6 +513,37 @@ pkg_tar(
extension = ".tar.gz",
)
+pkg_files(
+ name = "test-pkg-files-with-attributes",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ attributes = pkg_attributes(
+ gid = 1000,
+ group = "grp",
+ mode = "0440",
+ uid = 0,
+ user = "person",
+ ),
+ prefix = "/foo/bar",
+)
+
+pkg_tar(
+ name = "test-pkg-tar-from-pkg-files-with-attributes",
+ srcs = [
+ ":test-pkg-files-with-attributes",
+ ],
+)
+
+pkg_tar(
+ name = "test-pkg-tar-with-attributes",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ owner = "0.1000",
+ package_dir = "/foo/bar",
+)
+
pkg_tar(
name = "test-tar-compression-from-extension-tgz",
srcs = [
@@ -424,10 +571,52 @@ py_test(
python_version = "PY3",
srcs_version = "PY3",
deps = [
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
+directory(
+ name = "generate_tree_with_prefix",
+ contents = "hello there",
+ filenames = [
+ "a/a",
+ "a/b",
+ ],
+ outdir = "tree_prefix_to_strip",
+)
+
+pkg_tar(
+ name = "test-tree-input-with-strip-prefix",
+ srcs = [
+ ":generate_tree_with_prefix",
+ ],
+ strip_prefix = "tree_prefix_to_strip",
+)
+
+directory(
+ name = "tree_artifact_to_rename",
+ contents = "hello there",
+ filenames = [
+ "a",
+ "rename_me/should_not_rename",
+ ],
+ outdir = "rename_me",
+)
+
+pkg_tar(
+ name = "test-remap-paths-tree-artifact",
+ srcs = [
+ ":tree_artifact_to_rename",
+ ],
+ remap_paths = {
+ "/rename_me": "a_new_name",
+ },
+)
+
+#
+# Test with symlinks
+#
+
link_tree(
name = "node_modules",
links = {
@@ -446,11 +635,12 @@ directory(
"foo/hello.txt",
"foo/bar/baz",
],
- links = {
- "foo/bar/hello": "../hello.txt",
- "foo/bar/alt_baz": "baz",
- "foo/alt_baz": "bar/baz",
- },
+ # TODO(https://github.com/bazelbuild/rules_pkg/issues/750)
+ #links = {
+ # "foo/bar/hello": "../hello.txt",
+ # "foo/bar/alt_baz": "baz",
+ # "foo/alt_baz": "bar/baz",
+ #},
)
# This target has symlinks 3 ways.
@@ -464,29 +654,59 @@ pkg_tar(
":tree_artifact_with_links",
"//tests:file_and_link",
],
+ symlinks = {
+ "tree_artifact/toss_in_another": "/foo",
+ },
+)
+
+verify_archive_test(
+ name = "relative_links_test",
+ min_size = 10,
+ must_contain = [
+ "BUILD",
+ "outer_BUILD",
+ "node_modules/.pnpm/bar@1.0.0/node_modules/bar",
+ ],
+ tags = ["nowindows"],
+ target = ":relative_links_tar",
+ verify_links = {
+ "node_modules/.pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
+ "tree_artifact/toss_in_another": "/foo",
+ },
)
pkg_tar(
name = "relative_links_re_tar",
+ package_dir = "new/base",
+ symlinks = {
+ # We expect package_dir to apply to this
+ "tree_artifact/toss_in_another": "some_target",
+ # But we protect the user from duplicating package_dir in their
+ # link. That was the old behavior of symlink.
+ "new/base/something/this": "that",
+ },
deps = [
":relative_links_tar",
],
)
-directory(
- name = "generate_tree_with_prefix",
- contents = "hello there",
- filenames = [
- "a/a",
- "a/b",
+verify_archive_test(
+ name = "relative_links_re_test",
+ min_size = 10,
+ must_contain = [
+ "new/base/BUILD",
+ "new/base/outer_BUILD",
+ "new/base/node_modules/.pnpm/bar@1.0.0/node_modules/bar",
],
- outdir = "tree_prefix_to_strip",
+ must_not_contain = [
+ "BUILD",
+ "new/base/new/base/something/this",
+ ],
+ tags = ["nowindows"],
+ target = ":relative_links_re_tar",
+ verify_links = {
+ "new/base/node_modules/.pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
+ "new/base/tree_artifact/toss_in_another": "some_target",
+ "new/base/something/this": "that",
+ },
)
-
-pkg_tar(
- name = "test-tree-input-with-strip-prefix",
- srcs = [
- ":generate_tree_with_prefix",
- ],
- strip_prefix = "tree_prefix_to_strip",
-) \ No newline at end of file
diff --git a/tests/tar/is_compressed_test.py b/tests/tar/is_compressed_test.py
index 6ed7386..5e55a06 100644
--- a/tests/tar/is_compressed_test.py
+++ b/tests/tar/is_compressed_test.py
@@ -15,7 +15,7 @@
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
class IsCompressedTest(unittest.TestCase):
diff --git a/tests/tar/pkg_tar_test.py b/tests/tar/pkg_tar_test.py
index fabdffc..d18c49c 100644
--- a/tests/tar/pkg_tar_test.py
+++ b/tests/tar/pkg_tar_test.py
@@ -16,7 +16,7 @@
import tarfile
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.private.tar import tar_writer
PORTABLE_MTIME = 946684800 # 2000-01-01 00:00:00.000 UTC
@@ -104,17 +104,16 @@ class PkgTarTest(unittest.TestCase):
]
self.assertTarFileContent('test-tar-strip_prefix-substring.tar', content)
- def test_strip_prefix_dot(self):
+ def disabled_test_strip_prefix_dot(self):
content = [
{'name': 'etc'},
{'name': 'etc/nsswitch.conf'},
{'name': 'external'},
- {'name': 'external/bazel_tools'},
- {'name': 'external/bazel_tools/tools'},
- {'name': 'external/bazel_tools/tools/python'},
- {'name': 'external/bazel_tools/tools/python/runfiles'},
+ {'name': 'external/rules_python'},
+ {'name': 'external/rules_python/python'},
+ {'name': 'external/rules_python/python/runfiles'},
# This is brittle. In old bazel the next file would be
- # external/bazel_tools/tools/python/runfiles/runfiles.py, but there
+ # external/rules_python/python/runfiles/runfiles.py, but there
# is now _runfiles_constants.py, first. So this is too brittle.
{'halt': None},
]
@@ -195,6 +194,7 @@ class PkgTarTest(unittest.TestCase):
{'name': 'level1/some_value'},
{'name': 'level1/some_value/level3'},
{'name': 'level1/some_value/level3/BUILD'},
+ {'name': 'level1/some_value/level3/mydir'},
]
self.assertTarFileContent('test_tar_package_dir_substitution.tar', content)
@@ -244,20 +244,29 @@ class PkgTarTest(unittest.TestCase):
self.assertTarFileContent('test-tar-tree-artifact-noroot.tar',
noroot_content)
- def test_tar_with_runfiles(self):
- content = [
- {'name': 'BUILD' },
- {'name': 'a_program' },
- {'name': 'executable.sh' },
- ]
- self.assertTarFileContent('test-tar-with-runfiles.tar', content)
-
def test_tar_leading_dotslash(self):
content = [
{'name': './loremipsum.txt'},
]
self.assertTarFileContent('test_tar_leading_dotslash.tar', content)
+
+ def test_pkg_tar_with_attributes(self):
+ content = [
+ {'name': 'foo','uid': 0, 'gid': 1000, 'uname': '', 'gname': ''},
+ {'name': 'foo/bar','uid': 0, 'gid': 1000, 'uname': '', 'gname': ''},
+ {'name': 'foo/bar/loremipsum.txt','uid': 0, 'gid': 1000, 'uname': '', 'gname': ''},
+ ]
+ self.assertTarFileContent('test-pkg-tar-with-attributes.tar', content)
+
+ def test_pkg_files_with_attributes(self):
+ content = [
+ {'name': 'foo','uid': 0, 'gid': 1000, 'uname': 'person', 'gname': 'grp'},
+ {'name': 'foo/bar','uid': 0, 'gid': 1000, 'uname': 'person', 'gname': 'grp'},
+ {'name': 'foo/bar/loremipsum.txt','uid': 0, 'gid': 1000, 'uname': 'person', 'gname': 'grp'},
+ ]
+ self.assertTarFileContent('test-pkg-tar-from-pkg-files-with-attributes.tar', content)
+
def test_tar_with_tree_artifact_and_strip_prefix(self):
content = [
{'name': 'a', 'isdir': True},
@@ -266,6 +275,15 @@ class PkgTarTest(unittest.TestCase):
]
self.assertTarFileContent('test-tree-input-with-strip-prefix.tar', content)
+ def test_remap_paths_tree_artifact(self):
+ content = [
+ {'name': 'a_new_name', 'isdir': True},
+ {'name': 'a_new_name/a'},
+ {'name': 'a_new_name/rename_me', 'isdir': True},
+ {'name': 'a_new_name/rename_me/should_not_rename'},
+ ]
+ self.assertTarFileContent('test-remap-paths-tree-artifact.tar', content)
+
if __name__ == '__main__':
unittest.main()
diff --git a/tests/tar/tar_writer_test.py b/tests/tar/tar_writer_test.py
index 39008ea..ad31b0c 100644
--- a/tests/tar/tar_writer_test.py
+++ b/tests/tar/tar_writer_test.py
@@ -17,7 +17,7 @@ import os
import tarfile
import unittest
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from pkg.private.tar import tar_writer
from tests.tar import compressor
diff --git a/tests/util/defs.bzl b/tests/util/defs.bzl
index 463525c..34fea03 100644
--- a/tests/util/defs.bzl
+++ b/tests/util/defs.bzl
@@ -11,13 +11,11 @@
# 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 to aid testing"""
-load("//pkg/private:pkg_files.bzl", "add_label_list", "write_manifest")
-load("//pkg:providers.bzl", "PackageFilegroupInfo", "PackageSymlinkInfo")
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-load("@rules_python//python:defs.bzl", "py_binary")
+load("//pkg:providers.bzl", "PackageFilegroupInfo", "PackageSymlinkInfo")
+load("//pkg/private:pkg_files.bzl", "add_label_list", "create_mapping_context_from_ctx", "write_manifest") # buildifier: disable=bzl-visibility
def _directory_impl(ctx):
out_dir_file = ctx.actions.declare_directory(ctx.attr.outdir or ctx.attr.name)
@@ -32,7 +30,7 @@ def _directory_impl(ctx):
for link, target in ctx.attr.links.items():
args.add(link)
- args.add('@@' + target)
+ args.add("@@" + target)
ctx.actions.run(
outputs = [out_dir_file],
@@ -115,13 +113,16 @@ cc_binary in complexity, but does not depend on a large toolchain.""",
def _link_tree_impl(ctx):
links = []
prefix = ctx.attr.package_dir or ""
- if prefix and not prefix.endswith('/'):
+ if prefix and not prefix.endswith("/"):
prefix = prefix + "/"
for link, target in ctx.attr.links.items():
- print(' %s -> %s ' % (link, target))
+ # DBG print(' %s -> %s ' % (link, target))
links.append(
- (PackageSymlinkInfo(destination = prefix + link, target = target),
- ctx.label))
+ (
+ PackageSymlinkInfo(destination = prefix + link, target = target),
+ ctx.label,
+ ),
+ )
return [PackageFilegroupInfo(pkg_symlinks = links)]
link_tree = rule(
@@ -144,10 +145,9 @@ The keys of links are paths to create. The values are the target of the links."
)
def _write_content_manifest_impl(ctx):
- content_map = {} # content handled in the manifest
- file_deps = [] # inputs we depend on
- add_label_list(ctx, content_map, file_deps, ctx.attr.srcs)
- write_manifest(ctx, ctx.outputs.out, content_map, use_short_path = ctx.attr.use_short_path)
+ mapping_context = create_mapping_context_from_ctx(ctx, ctx.label)
+ add_label_list(mapping_context, ctx.attr.srcs)
+ write_manifest(ctx, ctx.outputs.out, mapping_context.content_map, use_short_path = ctx.attr.use_short_path)
_write_content_manifest = rule(
doc = """Helper rule to write the content manifest for a pkg_*.
@@ -183,7 +183,7 @@ def write_content_manifest(name, srcs, **kwargs):
srcs = srcs,
out = out,
use_short_path = use_short_path,
- **kwargs,
+ **kwargs
)
############################################################
diff --git a/tests/zip/BUILD b/tests/zip/BUILD
index 0a545ec..0727b2e 100644
--- a/tests/zip/BUILD
+++ b/tests/zip/BUILD
@@ -13,12 +13,12 @@
# limitations under the License.
# -*- coding: utf-8 -*-
+load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
+load("@rules_python//python:defs.bzl", "py_library", "py_test")
load("//pkg:mappings.bzl", "pkg_attributes", "pkg_mkdirs", "pkg_mklink")
load("//pkg:zip.bzl", "pkg_zip")
load("//tests:my_package_name.bzl", "my_package_naming")
-load("//tests/util:defs.bzl", "directory", "fake_artifact")
-load("@rules_python//python:defs.bzl", "py_library", "py_test")
-load("@bazel_skylib//rules:copy_file.bzl", "copy_file")
+load("//tests/util:defs.bzl", "directory")
package(default_applicable_licenses = ["//:license"])
@@ -29,9 +29,10 @@ py_library(
srcs = [
"zip_test_lib.py",
],
+ imports = ["../.."],
srcs_version = "PY3",
deps = [
- "@bazel_tools//tools/python/runfiles",
+ "@rules_python//python/runfiles",
],
)
@@ -235,6 +236,40 @@ pkg_zip(
package_variables = ":my_package_variables",
)
+# Different compressions
+pkg_zip(
+ name = "test_zip_deflated_level_3",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ compression_level = 3,
+ compression_type = "deflated",
+)
+
+pkg_zip(
+ name = "test_zip_bzip2",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ compression_type = "bzip2",
+)
+
+pkg_zip(
+ name = "test_zip_lzma",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ compression_type = "lzma",
+)
+
+pkg_zip(
+ name = "test_zip_stored",
+ srcs = [
+ "//tests:testdata/loremipsum.txt",
+ ],
+ compression_type = "stored",
+)
+
py_test(
name = "zip_test",
srcs = [
@@ -246,10 +281,14 @@ py_test(
":test-zip-strip_prefix-none.zip",
":test-zip-strip_prefix-zipcontent.zip",
":test_zip_basic.zip",
+ ":test_zip_bzip2",
+ ":test_zip_deflated_level_3",
":test_zip_empty.zip",
+ ":test_zip_lzma",
":test_zip_package_dir0.zip",
":test_zip_package_dir_substitution.zip",
":test_zip_permissions.zip",
+ ":test_zip_stored",
":test_zip_timestamp.zip",
":test_zip_tree.zip",
],
@@ -284,7 +323,7 @@ py_test(
pkg_zip(
name = "unicode_names",
- srcs = ["//tests:utf8_files"]
+ srcs = ["//tests:utf8_files"],
)
py_test(
diff --git a/tests/zip/zip_test.py b/tests/zip/zip_test.py
index f110ef7..6978dc5 100644
--- a/tests/zip/zip_test.py
+++ b/tests/zip/zip_test.py
@@ -15,10 +15,11 @@
import datetime
import filecmp
import os
+import sys
import unittest
import zipfile
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
from tests.zip import zip_test_lib
HELLO_CRC = 2069210904
@@ -123,6 +124,33 @@ class ZipContentsTests(zip_test_lib.ZipContentsTestBase):
{"filename": "generate_tree/b/e"},
])
+ def test_compression_deflated(self):
+ if sys.version_info >= (3, 7):
+ self.assertZipFileContent("test_zip_deflated_level_3.zip", [
+ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 312},
+ ])
+ else:
+ # Python 3.6 doesn't support setting compresslevel, so the file size differs
+ self.assertZipFileContent("test_zip_deflated_level_3.zip", [
+ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 309},
+ ])
+
+ def test_compression_bzip2(self):
+ self.assertZipFileContent("test_zip_bzip2.zip", [
+ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 340},
+ ])
+
+ def test_compression_lzma(self):
+ self.assertZipFileContent("test_zip_lzma.zip", [
+ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 378},
+ ])
+
+ def test_compression_stored(self):
+ self.assertZipFileContent("test_zip_stored.zip", [
+ {"filename": "loremipsum.txt", "crc": LOREM_CRC, "size": 543},
+ ])
+
+
if __name__ == "__main__":
unittest.main()
diff --git a/tests/zip/zip_test_lib.py b/tests/zip/zip_test_lib.py
index ada8303..ebb0b60 100644
--- a/tests/zip/zip_test_lib.py
+++ b/tests/zip/zip_test_lib.py
@@ -17,7 +17,7 @@ import filecmp
import unittest
import zipfile
-from bazel_tools.tools.python.runfiles import runfiles
+from python.runfiles import runfiles
# Unix dir bit and Windows dir bit. Magic from zip spec
@@ -44,9 +44,7 @@ class ZipTest(unittest.TestCase):
def get_test_zip(self, zip_file):
"""Get the file path to a generated zip in the runfiles."""
- return self.data_files.Rlocation(
- "rules_pkg/tests/zip/" + zip_file
- )
+ return self.data_files.Rlocation("rules_pkg/tests/zip/" + zip_file)
class ZipContentsTestBase(ZipTest):
@@ -80,6 +78,8 @@ class ZipContentsTestBase(ZipTest):
elif "isexe" in expected:
got_mode = (info.external_attr >> 16) & UNIX_RX_BITS
self.assertEqual(oct(got_mode), oct(UNIX_RX_BITS))
+ elif "size" in expected:
+ self.assertEqual(info.compress_size, expected["size"])
else:
if "attr" in expected:
@@ -87,7 +87,7 @@ class ZipContentsTestBase(ZipTest):
if "attr_mask" in expected:
attr &= expected.get("attr_mask")
else:
- # I would argue this is a dumb choice, but it matchs the
+ # I would argue this is a dumb choice, but it matches the
# legacy rule implementation.
attr = 0o555
self.assertEqual(oct((info.external_attr >> 16) & UNIX_RWX_BITS),
diff --git a/toolchains/git/BUILD b/toolchains/git/BUILD
index bf1fa75..7d1596e 100644
--- a/toolchains/git/BUILD
+++ b/toolchains/git/BUILD
@@ -16,7 +16,7 @@
Type: @rules_pkg//toolchains/git:git_toolchain_type
Toolchains:
-- git_missing_toolchain: provides a fallback toolchain for exec plaforms
+- git_missing_toolchain: provides a fallback toolchain for exec platforms
where git might not be available.
- git_auto_toolchain: a toolchain that uses the installed git. See
diff --git a/toolchains/git/git_configure.bzl b/toolchains/git/git_configure.bzl
index 4ad26d7..f537c1a 100644
--- a/toolchains/git/git_configure.bzl
+++ b/toolchains/git/git_configure.bzl
@@ -48,7 +48,7 @@ _find_system_git = repository_rule(
local = True,
attrs = {
"workspace_file": attr.label(
- doc = "Referece to calling repository WORKSPACE file.",
+ doc = "Reference to calling repository WORKSPACE file.",
allow_single_file = True,
mandatory = True,
),
@@ -58,6 +58,7 @@ _find_system_git = repository_rule(
},
)
+# buildifier: disable=function-docstring-args
def experimental_find_system_git(name, workspace_file = None, verbose = False):
"""Create a toolchain that lets you run git.
@@ -76,3 +77,19 @@ def experimental_find_system_git(name, workspace_file = None, verbose = False):
"@%s//:git_auto_toolchain" % name,
"@rules_pkg//toolchains/git:git_missing_toolchain",
)
+
+# buildifier: disable=function-docstring-args
+def experimental_find_system_git_bzlmod(name, workspace_file = None, verbose = False):
+ """Create a toolchain that lets you run git.
+
+ WARNING: This is experimental. The API and behavior are subject to change
+ at any time.
+
+ This presumes that your Bazel WORKSPACE file is located under your git
+ client. That is often true, but might not be in a multi-repo where you
+ might weave together a Bazel workspace from several git repos that are
+ all rooted under the WORKSPACE file.
+ """
+ if not workspace_file:
+ workspace_file = Label("//:MODULE.bazel")
+ _find_system_git(name = name, workspace_file = workspace_file, verbose = verbose)
diff --git a/toolchains/rpm/BUILD b/toolchains/rpm/BUILD
index 10a9bdc..58ec5db 100644
--- a/toolchains/rpm/BUILD
+++ b/toolchains/rpm/BUILD
@@ -17,7 +17,7 @@
Type: @rules_pkg//toolchains/rpm:rpmbuild_toolchain_type
Toolchains:
-- rpmbuild_missing_toolchain: provides a fallback toolchain for exec plaforms
+- rpmbuild_missing_toolchain: provides a fallback toolchain for exec platforms
where rpmbuild might not be available.
- rpmbuild_auto_toolchain: a toolchain that uses the installed rpmbuild. See
diff --git a/toolchains/rpm/BUILD.tpl b/toolchains/rpm/BUILD.tpl
index ca4b218..8547062 100644
--- a/toolchains/rpm/BUILD.tpl
+++ b/toolchains/rpm/BUILD.tpl
@@ -12,3 +12,9 @@ toolchain(
toolchain = ":rpmbuild_auto",
toolchain_type = "@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type",
)
+
+toolchain(
+ name = "zzz_rpmbuild_missing_toolchain", # keep name lexigraphically 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 3aa0ea0..7e22752 100644
--- a/toolchains/rpm/rpmbuild.bzl
+++ b/toolchains/rpm/rpmbuild.bzl
@@ -70,5 +70,6 @@ is_rpmbuild_available = rule(
toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
)
+# buildifier: disable=unnamed-macro
def rpmbuild_register_toolchains():
native.register_toolchains("@rules_pkg//toolchains/rpm:rpmbuild_missing_toolchain")
diff --git a/toolchains/rpm/rpmbuild_configure.bzl b/toolchains/rpm/rpmbuild_configure.bzl
index f50a9ad..a3cb83a 100644
--- a/toolchains/rpm/rpmbuild_configure.bzl
+++ b/toolchains/rpm/rpmbuild_configure.bzl
@@ -13,6 +13,11 @@
# limitations under the License.
"""Repository rule to autoconfigure a toolchain using the system rpmbuild."""
+# NOTE: this must match the name used by register_toolchains in consuming
+# MODULE.bazel files. It seems like we should have a better interface that
+# allows for this module name to be specified from a single point.
+NAME = "rules_pkg_rpmbuild"
+
def _write_build(rctx, path, version):
if not path:
path = ""
@@ -27,13 +32,13 @@ def _write_build(rctx, path, version):
executable = False,
)
-def _find_system_rpmbuild_impl(rctx):
+def _build_repo_for_rpmbuild_toolchain_impl(rctx):
rpmbuild_path = rctx.which("rpmbuild")
if rctx.attr.verbose:
if rpmbuild_path:
print("Found rpmbuild at '%s'" % rpmbuild_path) # buildifier: disable=print
else:
- print("No system rpmbuild found.") # buildifier: disable=print
+ print("No system rpmbuild found.") # buildifier: disable=print
version = "unknown"
if rpmbuild_path:
res = rctx.execute([rpmbuild_path, "--version"])
@@ -44,8 +49,8 @@ def _find_system_rpmbuild_impl(rctx):
version = parts[2]
_write_build(rctx = rctx, path = rpmbuild_path, version = version)
-_find_system_rpmbuild = repository_rule(
- implementation = _find_system_rpmbuild_impl,
+build_repo_for_rpmbuild_toolchain = repository_rule(
+ implementation = _build_repo_for_rpmbuild_toolchain_impl,
doc = """Create a repository that defines an rpmbuild toolchain based on the system rpmbuild.""",
local = True,
environ = ["PATH"],
@@ -56,8 +61,12 @@ _find_system_rpmbuild = repository_rule(
},
)
-def find_system_rpmbuild(name, verbose=False):
- _find_system_rpmbuild(name=name, verbose=verbose)
- native.register_toolchains(
- "@%s//:rpmbuild_auto_toolchain" % name,
- "@rules_pkg//toolchains/rpm:rpmbuild_missing_toolchain")
+# For use from WORKSPACE
+def find_system_rpmbuild(name, verbose = False):
+ build_repo_for_rpmbuild_toolchain(name = name, verbose = verbose)
+ native.register_toolchains("@%s//:all" % name)
+
+# For use from MODULE.bzl
+find_system_rpmbuild_bzlmod = module_extension(
+ implementation = lambda ctx: build_repo_for_rpmbuild_toolchain(name = NAME),
+)
diff --git a/version.bzl b/version.bzl
index 5b589f3..7e93127 100644
--- a/version.bzl
+++ b/version.bzl
@@ -13,4 +13,4 @@
# limitations under the License.
"""The version of rules_pkg."""
-version = "0.9.1"
+version = "0.10.1"