aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYifan Hong <elsk@google.com>2024-01-03 09:32:22 -0800
committerYifan Hong <elsk@google.com>2024-01-04 13:49:10 -0800
commit727182a720fcb5c8ec1b4cc523c32c49b0824250 (patch)
tree8034de2b58193e5b23ba8b935d01dd5cb0a1fa37
parent1d38077f1ca6bc8698f31c68e9678d4075538d71 (diff)
downloadrules_pkg-main.tar.gz
Move project to bazelbuild-rules_pkg.HEADmastermain
This git repository is deprecated and moved to bazelbuild-rules_pkg. Also remove METADATA file. Also update README.md to point to the new repository. The following files are kept unchanged: - LICENSE - MODULE_LICENSE_APACHE2 - OWNERS Test: TH Bug: 315857945 Bug: 306192195 Change-Id: I64ab31d8adc3bd566280fb6aba6f43f36b2c18d8
-rw-r--r--.bazelci/examples_naming.yml24
-rw-r--r--.bazelci/examples_rich_structure.yml16
-rw-r--r--.bazelci/examples_stamping.yml16
-rw-r--r--.bazelci/expand_yml.py41
-rw-r--r--.bazelci/integration.yml23
-rw-r--r--.bazelci/presubmit.yml6
-rw-r--r--.bazelci/tests.yml116
-rw-r--r--.bazelignore5
-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--.gitignore3
-rw-r--r--AUTHORS9
-rw-r--r--BUILD50
-rw-r--r--CHANGELOG.md571
-rw-r--r--CODEOWNERS14
-rw-r--r--CONTRIBUTING.md32
-rw-r--r--CONTRIBUTORS12
-rw-r--r--METADATA17
-rw-r--r--MODULE.bazel15
-rw-r--r--README.md36
-rw-r--r--WORKSPACE73
-rw-r--r--WORKSPACE.bzlmod23
-rw-r--r--deb_packages/README.md5
-rw-r--r--deps.bzl25
-rw-r--r--developers.md108
-rw-r--r--distro/BUILD109
-rw-r--r--distro/__init__.py0
-rw-r--r--distro/packaging_test.py107
-rw-r--r--distro/testdata/BUILD.tpl14
-rw-r--r--doc_build/BUILD130
-rw-r--r--doc_build/common.md53
-rwxr-xr-xdoc_build/merge.py86
-rw-r--r--doc_build/toc.md.tpl28
-rw-r--r--docs/0.4.0/reference.md676
-rw-r--r--docs/0.5.0/reference.md722
-rwxr-xr-xdocs/0.6.0/reference.md750
-rwxr-xr-xdocs/0.7.0/reference.md686
-rwxr-xr-xdocs/0.8.0/reference.md690
-rwxr-xr-xdocs/0.9.1/reference.md689
-rw-r--r--docs/_config.yml1
-rw-r--r--docs/_includes/head-custom.html6
-rw-r--r--docs/_includes/head.html3
-rwxr-xr-xdocs/favicon.icobin5430 -> 0 bytes
-rw-r--r--docs/index.md25
-rwxr-xr-xdocs/latest.md697
-rwxr-xr-xdocs/pkg_deb.md83
-rw-r--r--docs/robots.txt3
-rw-r--r--examples/BUILD1
-rw-r--r--examples/naming_package_files/BUILD168
-rw-r--r--examples/naming_package_files/MODULE.bazel11
-rw-r--r--examples/naming_package_files/WORKSPACE33
-rw-r--r--examples/naming_package_files/my_package_name.bzl112
-rw-r--r--examples/naming_package_files/package_upload.bzl50
-rw-r--r--examples/naming_package_files/readme.md107
-rw-r--r--examples/prebuilt_rpmbuild/BUILD38
-rw-r--r--examples/prebuilt_rpmbuild/WORKSPACE28
-rw-r--r--examples/prebuilt_rpmbuild/local/BUILD27
-rw-r--r--examples/prebuilt_rpmbuild/local/rpmbuild.bzl19
-rwxr-xr-xexamples/prebuilt_rpmbuild/local/rpmbuild_binary3
-rw-r--r--examples/prebuilt_rpmbuild/readme.md10
-rw-r--r--examples/prebuilt_rpmbuild/test_rpm.spec24
-rw-r--r--examples/readme.md3
-rw-r--r--examples/rich_structure/BUILD69
-rw-r--r--examples/rich_structure/README.md50
-rw-r--r--examples/rich_structure/README.txt1
-rw-r--r--examples/rich_structure/WORKSPACE24
-rw-r--r--examples/rich_structure/copyright13
-rw-r--r--examples/rich_structure/docs/BUILD7
-rw-r--r--examples/rich_structure/docs/index.md4
-rw-r--r--examples/rich_structure/docs/reference/index.md1
-rw-r--r--examples/rich_structure/docs/user_guide.md1
-rw-r--r--examples/rich_structure/foo_defs.bzl21
-rw-r--r--examples/rich_structure/resources/l10n/BUILD74
-rw-r--r--examples/rich_structure/resources/l10n/foo/en/msg.cat1
-rw-r--r--examples/rich_structure/resources/l10n/foo/it/msg.cat1
-rw-r--r--examples/rich_structure/resources/l10n/fooctl/en/msg.cat1
-rw-r--r--examples/rich_structure/resources/l10n/fooctl/it/msg.cat1
-rw-r--r--examples/rich_structure/resources/l10n/food/en/msg.cat1
-rw-r--r--examples/rich_structure/resources/l10n/food/it/msg.cat1
-rw-r--r--examples/rich_structure/src/client/BUILD109
-rw-r--r--examples/rich_structure/src/client/bar.rules1
-rw-r--r--examples/rich_structure/src/client/baz.rules1
-rw-r--r--examples/rich_structure/src/client/foo.113
-rw-r--r--examples/rich_structure/src/client/foo.cc5
-rw-r--r--examples/rich_structure/src/client/foo.h1
-rw-r--r--examples/rich_structure/src/client/foocore.cc5
-rw-r--r--examples/rich_structure/src/client/fooctl.cc6
-rw-r--r--examples/rich_structure/src/server/BUILD95
-rw-r--r--examples/rich_structure/src/server/foo.h1
-rw-r--r--examples/rich_structure/src/server/foocore.cc1
-rw-r--r--examples/rich_structure/src/server/food.810
-rw-r--r--examples/rich_structure/src/server/food.cc5
-rw-r--r--examples/time_stamping/BUILD41
-rw-r--r--examples/time_stamping/WORKSPACE24
-rw-r--r--examples/time_stamping/readme.md46
-rw-r--r--examples/where_is_my_output/BUILD56
-rw-r--r--examples/where_is_my_output/README.md101
-rw-r--r--examples/where_is_my_output/WORKSPACE26
-rw-r--r--examples/where_is_my_output/show_all_outputs.bzl34
-rw-r--r--patching.md43
-rw-r--r--pkg/.bazelignore1
-rw-r--r--pkg/BUILD107
-rw-r--r--pkg/__init__.py0
-rw-r--r--pkg/deb.bzl18
-rw-r--r--pkg/deps.bzl59
-rw-r--r--pkg/filter_directory.py285
-rw-r--r--pkg/install.bzl185
-rw-r--r--pkg/legacy/BUILD27
-rw-r--r--pkg/legacy/rpm.bzl246
-rw-r--r--pkg/legacy/tests/rpm/BUILD30
-rw-r--r--pkg/legacy/tests/rpm/test_rpm.spec25
-rw-r--r--pkg/make_rpm.py538
-rw-r--r--pkg/mappings.bzl878
-rw-r--r--pkg/package_variables.bzl21
-rw-r--r--pkg/path.bzl89
-rw-r--r--pkg/pkg.bzl22
-rw-r--r--pkg/private/BUILD110
-rw-r--r--pkg/private/__init__.py0
-rw-r--r--pkg/private/archive.py89
-rw-r--r--pkg/private/build_info.py37
-rw-r--r--pkg/private/deb/BUILD68
-rw-r--r--pkg/private/deb/deb.bzl381
-rw-r--r--pkg/private/deb/make_deb.py422
-rw-r--r--pkg/private/helpers.py89
-rw-r--r--pkg/private/install.py.tpl203
-rw-r--r--pkg/private/make_starlark_library.bzl35
-rw-r--r--pkg/private/manifest.py79
-rw-r--r--pkg/private/pkg_files.bzl610
-rw-r--r--pkg/private/tar/BUILD71
-rw-r--r--pkg/private/tar/build_tar.py459
-rw-r--r--pkg/private/tar/tar.bzl372
-rw-r--r--pkg/private/tar/tar_writer.py338
-rw-r--r--pkg/private/util.bzl86
-rw-r--r--pkg/private/zip/BUILD60
-rw-r--r--pkg/private/zip/__init__.py0
-rw-r--r--pkg/private/zip/build_zip.py305
-rw-r--r--pkg/private/zip/zip.bzl185
-rw-r--r--pkg/providers.bzl91
-rw-r--r--pkg/releasing/BUILD73
-rw-r--r--pkg/releasing/__init__.py0
-rw-r--r--pkg/releasing/defs.bzl53
-rw-r--r--pkg/releasing/git.bzl97
-rw-r--r--pkg/releasing/git_changelog_private.py72
-rw-r--r--pkg/releasing/print_rel_notes.py144
-rw-r--r--pkg/releasing/release_tools.py103
-rw-r--r--pkg/releasing/release_tools_test.py82
-rw-r--r--pkg/rpm.bzl74
-rw-r--r--pkg/rpm/BUILD45
-rw-r--r--pkg/rpm/augment_rpm_files_install.py93
-rw-r--r--pkg/rpm/template.spec.tpl22
-rw-r--r--pkg/rpm_pfg.bzl1028
-rw-r--r--pkg/tar.bzl18
-rw-r--r--pkg/verify_archive.bzl135
-rw-r--r--pkg/verify_archive_test_main.py.tpl146
-rw-r--r--pkg/zip.bzl18
-rw-r--r--tests/BUILD214
-rw-r--r--tests/a.cc1
-rw-r--r--tests/archive_test.py98
-rw-r--r--tests/b.cc1
-rw-r--r--tests/deb/BUILD150
-rw-r--r--tests/deb/config1
-rw-r--r--tests/deb/control_field_test.py83
-rw-r--r--tests/deb/deb_preinst3
-rw-r--r--tests/deb/deb_tests.bzl51
-rw-r--r--tests/deb/deb_triggers2
-rw-r--r--tests/deb/pkg_deb_test.py280
-rw-r--r--tests/deb/templates6
-rw-r--r--tests/foo.cc20
-rw-r--r--tests/helpers_test.py92
-rw-r--r--tests/install/BUILD77
-rw-r--r--tests/install/test.py186
-rw-r--r--tests/mappings/BUILD189
-rw-r--r--tests/mappings/all.manifest.golden7
-rw-r--r--tests/mappings/executable.manifest.golden7
-rw-r--r--tests/mappings/executable.manifest.windows.golden7
-rw-r--r--tests/mappings/external_repo/WORKSPACE15
-rw-r--r--tests/mappings/external_repo/pkg/BUILD58
-rw-r--r--tests/mappings/external_repo/pkg/dir/extproj.sh17
-rw-r--r--tests/mappings/external_repo/pkg/test.bzl68
-rw-r--r--tests/mappings/filter_directory/BUILD233
-rw-r--r--tests/mappings/filter_directory/defs.bzl73
-rw-r--r--tests/mappings/filter_directory/inspect_directory.py.tpl62
-rw-r--r--tests/mappings/filter_directory/test_filter_directory.py183
-rw-r--r--tests/mappings/glob_for_texts_manifest.golden6
-rw-r--r--tests/mappings/manifest_test_lib.py68
-rw-r--r--tests/mappings/manifest_test_main.py.tpl27
-rw-r--r--tests/mappings/mappings_external_repo_test.bzl142
-rw-r--r--tests/mappings/mappings_test.bzl1002
-rwxr-xr-xtests/mappings/node_modules_manifest.golden9
-rw-r--r--tests/mappings/testdata/a_script.sh1
-rw-r--r--tests/mappings/testdata/config1
-rw-r--r--tests/mappings/testdata/hello.txt1
-rw-r--r--tests/mappings/utf8_manifest.golden8
-rw-r--r--tests/my_package_name.bzl31
-rwxr-xr-xtests/package_naming_aggregate_test.sh27
-rw-r--r--tests/path_test.bzl92
-rw-r--r--tests/path_test.py140
-rw-r--r--tests/rpm/BUILD423
-rw-r--r--tests/rpm/analysis_tests.bzl318
-rw-r--r--tests/rpm/make_rpm_test.py179
-rw-r--r--tests/rpm/pkg_rpm_basic_test.py255
-rw-r--r--tests/rpm/rpm_util.py130
-rw-r--r--tests/rpm/source_date_epoch/BUILD131
-rw-r--r--tests/rpm/source_date_epoch/epoch.txt1
-rw-r--r--tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py104
-rw-r--r--tests/rpm/template-test.spec.tpl45
-rw-r--r--tests/rpm/test_rpm_dirs_contents.txt.golden2
-rw-r--r--tests/rpm/toolchain_tests.bzl123
-rw-r--r--tests/rpm/tree_artifacts/BUILD257
-rw-r--r--tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py64
-rw-r--r--tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py59
-rw-r--r--tests/stamp_test.py114
-rw-r--r--tests/tar/BUILD609
-rw-r--r--tests/tar/compressor.py10
-rw-r--r--tests/tar/is_compressed_test.py60
-rw-r--r--tests/tar/pkg_tar_test.py298
-rw-r--r--tests/tar/tar_writer_test.py253
-rw-r--r--tests/testdata/README.md20
-rw-r--r--tests/testdata/a.ar3
-rw-r--r--tests/testdata/a_ab.ar5
-rw-r--r--tests/testdata/a_b.ar5
-rw-r--r--tests/testdata/a_b_ab.ar7
-rw-r--r--tests/testdata/ab.ar3
-rw-r--r--tests/testdata/b.ar3
-rw-r--r--tests/testdata/config1
-rw-r--r--tests/testdata/deb_preinst3
-rw-r--r--tests/testdata/deb_triggers2
-rw-r--r--tests/testdata/empty.ar1
-rwxr-xr-xtests/testdata/executable.sh2
-rw-r--r--tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt1
-rw-r--r--tests/testdata/hello.txt1
-rw-r--r--tests/testdata/loremipsum.txt7
l---------tests/testdata/outer_BUILD1
-rw-r--r--tests/testdata/tar_test.tarbin10240 -> 0 bytes
-rw-r--r--tests/testdata/tar_test.tar.bz2bin134 -> 0 bytes
-rw-r--r--tests/testdata/tar_test.tar.gzbin158 -> 0 bytes
-rw-r--r--tests/testdata/tar_test.tar.xzbin192 -> 0 bytes
-rw-r--r--tests/testdata/templates6
-rwxr-xr-xtests/testdata/test_tar_package_dir_file.txt1
-rw-r--r--tests/testdata/utf8/1-a1
-rw-r--r--tests/testdata/utf8/2-λ1
-rw-r--r--tests/testdata/utf8/3-世1
-rw-r--r--tests/testdata/utf8/BUILD21
-rw-r--r--tests/testdata/utf8/sübdir/2-λ1
-rw-r--r--tests/testdata/utf8/sübdir/hello1
-rw-r--r--tests/testdata/utf8_linux.tarbin10240 -> 0 bytes
-rw-r--r--tests/testdata/utf8_linux.zipbin1804 -> 0 bytes
-rw-r--r--tests/testdata/utf8_mac.tarbin13824 -> 0 bytes
-rw-r--r--tests/testdata/utf8_mac.zipbin1804 -> 0 bytes
-rwxr-xr-xtests/testdata/utf8_win.tarbin13824 -> 0 bytes
-rwxr-xr-xtests/testdata/utf8_win.zipbin1682 -> 0 bytes
-rw-r--r--tests/util/BUILD39
-rw-r--r--tests/util/create_directory_with_contents.py48
-rw-r--r--tests/util/defs.bzl219
-rw-r--r--tests/util/md5.py29
-rw-r--r--tests/zip/BUILD338
-rw-r--r--tests/zip/unicode_test.py34
-rw-r--r--tests/zip/zip_byte_for_byte_test.py58
-rw-r--r--tests/zip/zip_test.py156
-rw-r--r--tests/zip/zip_test_lib.py97
-rw-r--r--toolchains/BUILD27
-rw-r--r--toolchains/git/BUILD75
-rw-r--r--toolchains/git/BUILD.tpl16
-rw-r--r--toolchains/git/git.bzl81
-rw-r--r--toolchains/git/git_configure.bzl78
-rw-r--r--toolchains/rpm/BUILD78
-rw-r--r--toolchains/rpm/BUILD.tpl14
-rw-r--r--toolchains/rpm/rpmbuild.bzl74
-rw-r--r--toolchains/rpm/rpmbuild_configure.bzl63
-rw-r--r--version.bzl16
274 files changed, 3 insertions, 26077 deletions
diff --git a/.bazelci/examples_naming.yml b/.bazelci/examples_naming.yml
deleted file mode 100644
index e6dac9d..0000000
--- a/.bazelci/examples_naming.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-common: &common
- working_directory: ../examples/naming_package_files
- build_targets:
- - "..."
-
-tasks:
- centos7:
- platform: centos7
- <<: *common
- ubuntu1804:
- platform: ubuntu1804
- <<: *common
- macos:
- platform: macos
- <<: *common
- windows:
- platform: windows
- <<: *common
- bzlmod:
- name: bzlmod
- platform: ubuntu1804
- build_flags:
- - "--experimental_enable_bzlmod"
- <<: *common
diff --git a/.bazelci/examples_rich_structure.yml b/.bazelci/examples_rich_structure.yml
deleted file mode 100644
index adbfce1..0000000
--- a/.bazelci/examples_rich_structure.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-common: &common
- working_directory: ../examples/rich_structure
- build_targets:
- - "..."
-
-tasks:
- centos7:
- platform: centos7
- <<: *common
- ubuntu1804:
- platform: ubuntu1804
- <<: *common
- macos:
- <<: *common
- windows:
- <<: *common
diff --git a/.bazelci/examples_stamping.yml b/.bazelci/examples_stamping.yml
deleted file mode 100644
index 59e1d9c..0000000
--- a/.bazelci/examples_stamping.yml
+++ /dev/null
@@ -1,16 +0,0 @@
-common: &common
- working_directory: ../examples/time_stamping
- build_targets:
- - "..."
-
-tasks:
- centos7:
- platform: centos7
- <<: *common
- ubuntu1804:
- platform: ubuntu1804
- <<: *common
- macos:
- <<: *common
- windows:
- <<: *common
diff --git a/.bazelci/expand_yml.py b/.bazelci/expand_yml.py
deleted file mode 100644
index 8248769..0000000
--- a/.bazelci/expand_yml.py
+++ /dev/null
@@ -1,41 +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.
-"""expand_yml.py - read .yml and dump as json.
-
-This is a debugging tool to expand a Yaml file and print the full expansion in
-a more readable form.
-
-Usage:
- python expand_ym.py [file ...]
-
- It no input files a provided, use tests.yml
-"""
-
-import json
-import sys
-import yaml
-
-
-def show_expanded(path):
- with open(path, mode='r') as f:
- yml = yaml.load(f, Loader=yaml.FullLoader)
- print(json.dumps(yml, indent=2, sort_keys=True))
-
-
-if __name__ == '__main__':
- if len(sys.argv) < 2:
- show_expanded('tests.yml')
- else:
- for f in sys.argv[1:]:
- show_expanded(f)
diff --git a/.bazelci/integration.yml b/.bazelci/integration.yml
deleted file mode 100644
index d73a4d7..0000000
--- a/.bazelci/integration.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-lts: &lts
- bazel: latest
-
-rolling: &rolling
- bazel: rolling
-
-
-common: &common
- platform: ubuntu1804
- working_directory: ..
- build_targets:
- - "distro:*"
-
-tasks:
- rolling_ubuntu:
- name: rolling_distro
- <<: *rolling
- <<: *common
- lts_ubuntu:
- name: lts_distro
- platform: ubuntu1804
- <<: *lts
- <<: *common
diff --git a/.bazelci/presubmit.yml b/.bazelci/presubmit.yml
deleted file mode 100644
index d2276a6..0000000
--- a/.bazelci/presubmit.yml
+++ /dev/null
@@ -1,6 +0,0 @@
-imports:
-- tests.yml
-- examples_naming.yml
-- examples_rich_structure.yml
-- examples_stamping.yml
-- integration.yml
diff --git a/.bazelci/tests.yml b/.bazelci/tests.yml
deleted file mode 100644
index 953283d..0000000
--- a/.bazelci/tests.yml
+++ /dev/null
@@ -1,116 +0,0 @@
-
-common: &common
- working_directory: ..
-
-#
-# Bazel releases
-#
-lts: &lts
- bazel: latest
-
-rolling: &rolling
- bazel: rolling
-
-#
-# Groups of tests, by platform
-#
-
-# rpmbuild(8) is not available or installed on most platforms
-default_tests: &default_tests
- test_targets:
- - "//distro/..."
- - "//pkg/..."
- - "//tests/..."
- - "//toolchains/..."
- - "-//tests/rpm/..."
- - "-//pkg/legacy/tests/rpm/..."
-
-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/..."
- - "//toolchains/..."
- - "-//tests:package_naming_aggregate_test"
- - "-//tests:path_test"
- # Bazel might be broken w.r.t. Unicode processing for windows. Multiple issues:
- # https://github.com/bazelbuild/bazel/issues?q=is%3Aissue+is%3Aopen+%2Bunicode+%2Bwindows+
- - "-//tests/mappings:utf8_manifest_test"
- - "-//tests/mappings/filter_directory/..."
- - "-//tests/zip:unicode_test"
- # See #387
- - "-//tests/install/..."
- # rpmbuild(8) is not supported on Windows
- - "-//tests/rpm/..."
- - "-//pkg/legacy/tests/rpm/..."
-
-#
-# Commmon features by platform
-#
-ubuntu1804: &ubuntu
- platform: ubuntu1804
- <<: *common
- <<: *default_tests
- build_targets:
- - "//distro:distro"
- - "//distro:relnotes"
- - "//doc_build:*"
-
-centos7: &centos
- platform: centos7
- <<: *common
- <<: *default_tests_with_rpm
-
-macos: &macos
- platform: macos
- <<: *common
- <<: *default_tests
-
-windows: &windows
- platform: windows
- <<: *common
- <<: *win_tests
-
-#
-# Finally, the cross product of bazel releases X platforms
-#
-tasks:
- rolling_ubuntu:
- name: rolling_ubuntu
- <<: *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
- <<: *centos
- <<: *lts
- lts_macos:
- name: lts_macos
- <<: *macos
- <<: *lts
- lts_ubuntu:
- name: lts_ubuntu
- <<: *ubuntu
- <<: *lts
- lts_windows:
- name: lts_windows
- <<: *windows
- <<: *lts
diff --git a/.bazelignore b/.bazelignore
deleted file mode 100644
index 912ca10..0000000
--- a/.bazelignore
+++ /dev/null
@@ -1,5 +0,0 @@
-# The following directories have their own WORKSPACEs (or contain WORKSPACEs),
-# so they shouldn't be built when in the main part of the rules_pkg repository.
-
-deb_packages/
-examples/
diff --git a/.bcr/README.md b/.bcr/README.md
deleted file mode 100644
index 44ae7fe..0000000
--- a/.bcr/README.md
+++ /dev/null
@@ -1,9 +0,0 @@
-# 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
deleted file mode 100644
index b40ed20..0000000
--- a/.bcr/config.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-fixedReleaser:
- login: aiuto
- email: aiuto@google.com
diff --git a/.bcr/metadata.template.json b/.bcr/metadata.template.json
deleted file mode 100644
index c330941..0000000
--- a/.bcr/metadata.template.json
+++ /dev/null
@@ -1,12 +0,0 @@
-{
- "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
deleted file mode 100644
index a8599e5..0000000
--- a/.bcr/presubmit.yml
+++ /dev/null
@@ -1,17 +0,0 @@
-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:
- 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
deleted file mode 100644
index 7ea619a..0000000
--- a/.bcr/source.template.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "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
deleted file mode 100644
index 171697d..0000000
--- a/.github/workflows/scorecard.yml
+++ /dev/null
@@ -1,72 +0,0 @@
-# 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
deleted file mode 100644
index 716b1b3..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.bazeliskrc
-.ijwb
-bazel-*
diff --git a/AUTHORS b/AUTHORS
deleted file mode 100644
index 8f95963..0000000
--- a/AUTHORS
+++ /dev/null
@@ -1,9 +0,0 @@
-# This the official list of Bazel authors for copyright purposes.
-# This file is distinct from the CONTRIBUTORS files.
-# See the latter for an explanation.
-
-# Names should be added to this file as:
-# Name or Organization <email address>
-# The email address is not required for organizations.
-
-Google Inc.
diff --git a/BUILD b/BUILD
deleted file mode 100644
index 959335c..0000000
--- a/BUILD
+++ /dev/null
@@ -1,50 +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("@rules_license//rules:license.bzl", "license")
-
-package(
- default_applicable_licenses = [":license"],
- default_visibility = ["//visibility:public"],
-)
-
-license(
- name = "license",
- license_kinds = [
- "@rules_license//licenses/spdx:Apache-2.0"
- ],
- license_text = "LICENSE",
-)
-
-exports_files(
- ["WORKSPACE"],
-)
-
-exports_files(
- glob([
- "*.bzl",
- ]),
-)
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*.bzl",
- ]) + [
- "BUILD",
- "LICENSE",
- "MODULE.bazel",
- ],
- visibility = ["//distro:__pkg__"],
-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index 4dbef8f..0000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,571 +0,0 @@
-# Release 0.8.0
-
-**New Features**
-- Allow $(var) substitution in filenames (#620)
- * Allow $(var) substitution in filenames and include everything in ctx.var in the substitution dictionary.
- Fixes #20
-- Basic bzlmod setup
- - CI runs for both traditional and bzlmod
- - Shows it working for one example
- - Has only runtime deps
- - rpm and git toolchains not done yet
-- Rough prototype of @since processing. (#617)
-- First cut at runfiles support in pkg_* rules (#605)
-
-**Bug Fixes**
-- Fix config_setting visibility failure when using `--incompatible_config_setting_private_default_visibility`
-- Cosmetic. Improve the error messageing for duplicate files in check_dest. (#616)
-- Adjust tar tests to have a test case for #297 (#618)
-- Do not warn if the origin paths are the same. (#615)
-
-# Release 0.7.0
-
-## New Features
-- Make the .bzl files available as input to a bzl_library (#567)
-- Allow pkg_files.strip_prefix to work on tree artifact without having to use `renames`.
-- Add @rules_license style license declarations (#508)
-- Better looking [documentation](https://bazelbuild.github.io/rules_pkg/0.7.0/reference.html)
-- Add `artifact_name` to `print_relnotes` (#541)
-- pkg_{deb,rpm,tar,zip} are now available via individual .bzl files, so you
- only need to load what you actually need.
-- Add tree artifact support to pkg_zip (#537)
-- symlink support to pkg_zip (#499)
-
-## Potentially breaking changes
-
-- Get rid of the long deprecated archive_name and extension from pkg_zip. (#552)
- - Make 'out' work in a reasonable way. Fixes #414
- - Partial fix for #284
-
-## Bug fixes:
-
-- Only allow .deb Description to be multiline. (#573)
- Fixes: https://github.com/bazelbuild/rules_pkg/issues/572
-- Fix pkg_tar to not add the ./ to the prefix of every member. (#554). Closes: #531
-- Stop stripping tree artifact root name in pkg_tar and pkg_zip. (#555). Closes #404
-- Fix RPM source date epoch for rpmbuild 4.17+ (#529)
-
-
-## Contributors
-
-Thanks to: Andrew Psaltis, Gunnar Wagenknecht, and Sven Mueller
-for contributions to this release.
-
-
-# Release 0.6.0
-
-This revision requires Bazel 4.x or greater
-
-## Visible changes
-- Enable nested pkg_filegroups (#420)
-- Restore `include_runfiles` support for pkg_tar. (#398)
-- Change the Debian example to reflect standard Debian naming. (#389)
-- More support for TreeArtifacts in PackageFilesInfo (#421)
-- Improved docs
- - Provide on https://bazelbuild.github.io/rules_pkg/0.6.0/reference.html
- - Provide an example for using the new packaging rules (#375)
- - Create "where is my output" example (#432)
- - post process docs to work around stardoc bugs.
-- eliminate need to load all rules if you only need one.
-
-## Bug fixes:
-- [pkg_deb] fix computation of changes file file name (#418)
-- Fix use of name parameter to pkg_tar (#469)
-- Fix missing `%dir` RPM filetag when `PackageDirsInfo` is provided (#473)
-- pkg_rpm: Don't have source_date_epoch apply by default; test modularity cleanup (#487)
-
-## Internal changes
-- Remove legacy command line options to tar builder. Everything is now in the manifest.
-- Unify template files names as .tpl (#383)
-- Modularize manifest python code (#384)
-- many code refactorings to make tests more isolated and allow more ownership by domain
-
-## Contributors
-Thanks to: Andrew Psaltis, Grant Monroe, Gunnar Wagenknecht, Ken Conley, Motiejus Jakštys, and Ryan Beasley
-for contributions to this release.
-
-
-# Release 0.5.1
-
-## New features
-- Add `pkg_deb(architecture_file)` to provide a way to set the Debian package architecture from the content of a file created at build time. (#390)
-- Provide `pkg_install` for a "make install"-like experience in Bazel (#380)
- - Note: This feature is still in development. Read the PR for more information.
-- Initial support for the `pkg_filegroup` framework in `pkg_zip` (#373)
-
-## Closed bugs
-
-- Change the Debian example to reflect standard Debian naming. (#389)
-- pkg_tar(include_runfiles) now works again (#392)
-
-# Release 0.5.0
-
-## New Features
-
-- Initial support for `pkg_*` rules as srcs of `pkg_tar` (#367)
- Adds support for `pkg_mklink`, `pkg_mkdirs`, `pkg_files` and `pkg_filegroup` to `pkg_tar`.
- - Provide `filter_directory` for basic TreeArtifact processing (#331)
-- `stamp` support to `pkg_tar` (#288) and `pkg_zip` (#365)
- Done in the style of cc_binary
- - `stamp` attribute (1=stamp, 0=no stamp, -1=follow `--stamp`)
- - Use existing `--stamp` command line option
-- Significant `pkg_rpm` changes
- - Graduate experimental `pkg_rpm` to mainline (#338)
- - Deprecate pkg/rpm.bzl and move it to pkg/legacy/rpm.bzl (#337)
- - Make `find_system_rpmbuild` repo rule depend on `PATH` (#348)
- - Support SOURCE_DATE_EPOCH in rpm.bzl; enable file clamping in make_rpm.py (#322)
- - Allow runfiles to be used alongside the `rpmbuild` toolchain (#329)
-- `pkg_tar` support for custom compression program (#320)
-- Support long file names in `pkg_tar` by ignoring 'path' PAX header. (#250) (#326)
-- (experimental) Capability to gather the git commit log since the last release (#357)
- This needs user feedback to discover the most pleasing mode. For this
- release, I did `blaze build distro:changelog.txt` then took the result to
- update this file (CHANGELOG.md). I would like to do better than that. Thoughts
- from users are welcome.
-
-## Internal changes
-
-- Add a rule to make artifacts that mimic binaries (#366)
-- Stop importing single methods from modules. Use the entire thing. (#361)
-- Fix some things that Google's strident buildifier warns about. (#363)
-- Enable more tests on windows (#364)
- - Fix most mapping tests to work on windows. (#350)
-- refactor `path.bzl` and improve testing (#359)
-- Fix and refactor pkg_tar compression logic (#358) (#345)
-- Move `build_tar`, `build_zip` and helpers to //private (#353)
-
-## Incompatible changes
-
-- Remove the capability to have the Debian .changes file have a different (#342)
-
-## Contributors
-
-This release contains contributions and fixes from aiuto, Alex Eagle,
-Andrew Psaltis, Greg Bowyer, katre, Michael Hackner, and Rafael Marinheiro
-
-# Release 0.4.0
-
-## New Features
-
-- `package_file_name` & `package_variables` to allow dynamically named output files.
-- `rpmbuild` is now a toolchain allowing you better control using your own vs. the system one
-- Portions of the `pkg_filegroup` rule suite are available in @rules_pkg//:mappings.bzl, but there are no packaging rules that use it at this time. Rules that use it will be added in 1.0
-
-## Incompatible Changes
-- `archive_name` is now deprecated. To be removed before 1.0 `WORKSPACE` setup
-
-## Contributors
-This release contains contributions and fixes from Andrew Psaltis, dmayle, Konstantin Erman, Martin Medler, Motiejus Jakštys, Thi Doãn, Thomas Gish, and Xavier Bonaventura.
-
-# Release 0.3.0
-
-This release features contributions by the Bazel team and
-andreas-0815-qwertz, Andrew Psaltis, Daniel Sullivan, David Schneider,
-Elliot Murphy, Matthias Frei, Matt Mikitka, Pras Velagapudi, Shimin Guo,
-and Ulf Adams
-
-**New Features**
-- commit a4296dac48144dd839da1f093dce00fd3078eaf5
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Thu Oct 1 17:55:20 2020 -0400
- experimental/rpm.bzl: Make compression settings configurable (#240)
- This change adds a new attribute binary_payload_compression to the
- experimental pkg_rpm rule. It is implemented in terms of command-line options
- to rpmbuild(8), which are passed in via make_rpm.py.
- We do this by instructing rpmbuild to define the _binary_payload macro on its command line. Tests are also provided.
- This can also be added to the non-experimental pkg_rpm rule in the future; the
- code would be similar.
- Fixes #239.
-- commit aa18e176673d03f05f1d3f0537bae424cfc225fe
-
-- Author: aiuto <aiuto@google.com>
- Date: Tue Sep 29 22:32:00 2020 -0400
- Provide capability to rename archives based on configuration values (#198)
- TODO for later
- - create cookbook style examples
- - emit PkgFilegroupInfo when that is available
- - implement for pkg_deb, rpm, zip
-- commit 55a1a9b2eca5b78a44fb940f3143a1d88423c2e2
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Thu Sep 24 15:16:00 2020 -0400
- Use symlink actions for RPM packages instead of custom actions (#236)
- Like #232, but in the RPM builders. No other callouts to `ln(1)` are made
- directly by `rules_pkg`.
-- commit effac40a51fea25bd566f266f6b7b1d23327f02a
-
-- Author: aiuto <aiuto@google.com>
- Date: Thu Sep 24 08:16:35 2020 -0400
- Add LICENSE to distribution tarball (#233)
- Fixes #231
-- commit bd9c7712163c03133b086e4efa0e19ed802aa956
-
-- Author: Ulf Adams <ulfjack@users.noreply.github.com>
- Date: Thu Sep 24 03:35:39 2020 +0200
- Use a symlink action, not a shell script (#232)
- Using a shell script is not portable and also causes issues with
- build-without-the-bytes, which can handle local symlink actions (at least in
- principle), but cannot handle symlinks returned from remote execution.
- Also see https://github.com/bazelbuild/bazel/issues/11532.
-- commit 60fbda7768d16e0c5c87f9efdc775f0586001657
-
-- Author: Daniel Sullivan <danielalexandersullivan@gmail.com>
- Date: Thu Sep 10 10:00:48 2020 -0400
- Avoid stripping prefixes with incomplete directory names.
-- commit e0d807d0ec4edfc5370f87259ae3461f86f0edb5
-
-- Author: David Schneider <dschneider@tableau.com>
- Date: Tue Sep 8 18:02:30 2020 -0700
- Add attribute strip_prefix to pkg_zip (#221) (#230)
-- commit 2ad5bd8fa4dc034081c616521bc7d6a45eb21818
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Wed Aug 26 23:02:56 2020 -0400
- `pkg_rpm_ex`: Provide in-rule dependency specifications (#224)
- This change provides four additional attributes to the experimental `pkg_rpm`
- rule, namely:
- - `conflicts`, `string_list`, corresponding the `Conflicts` tag
- - `provides`, `string_list`, corresponding the `Provides` tag
- - `requires`, `string_list`, corresponding the `Requires` tag
- Additionally:
- - `requires_contextual`, `string_list_dict`, providing the capability to specify
- tags like `Requires(postun)`.
- Unit tests were also provided. Non-rpm input files for the `pkg_rpm_ex` output
- test have now been given the ".csv" extension to better help identify that they
- are delimited files (but not strictly comma-delimited).
- Note that these changes only impact the "strong" dependencies between packages;
- [weak dependencies] like "Suggests" and "Recommends" are not explicitly
- supported, but can be added in the future following a similar pattern.
- Fixes #223.
- [weak dependencies]: https://rpm.org/user_doc/dependencies.html#weak-dependencies
-- commit 30bb5b27d11d117259a41d9356ddce0272932d60
-
-- Author: Shimin Guo <shimin.guo@mixpanel.com>
- Date: Wed Aug 26 19:30:29 2020 -0700
- Support "provides" in pkg_deb (#225)
-- commit 569a0e57e98e96f7075f500fcc76609d68b465e2
-
-- Author: dannysullivan <danielalexandersullivan@gmail.com>
- Date: Mon Aug 24 18:23:12 2020 -0400
- Avoid stripping prefixes with incomplete directory names.
-- commit f7cec56170384450c06004c37520b72e22952999
-
-- Author: Daniel Sullivan <danielalexandersullivan@gmail.com>
- Date: Thu Aug 20 10:44:46 2020 -0400
- Remove support for Python 2 (#222)
-- commit 4ad8aa08e02694b71bfc0713da4793150aa4f4bc
-
-- Author: Tony Aiuto <aiuto@google.com>
- Date: Fri Aug 7 11:46:28 2020 -0400
- Remove testenv.sh. It is no longer used.
-- commit e1b3bea742bc9b2b9d4c7862deafe82a749386cf
-
-- 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 getting pkg_tar_test to run on Windows.
- There are still problems to resolve.
-- commit 933fa6fc7fc49788af04a60558722180818d091f
-
-- Author: aiuto <aiuto@google.com>
- Date: Fri Aug 7 11:22:20 2020 -0400
- Convert pkg_deb tests from shell to python (#211)
-- commit dbd2c4b1f3186703c0b933429fc03924cafb8e4c
-
-- Author: aiuto <aiuto@google.com>
- Date: Fri Aug 7 11:17:32 2020 -0400
- write debian control tarball in GNU_FORMAT. (#217)
- This addresses part 1 of #216
-- commit 5985cfff16486f52bb029edd2732ad5868622b94
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Mon Aug 3 23:26:00 2020 -0400
- Consolidate make_rpm.bzl and experimental/make_rpm.bzl (#179)
- * Consolidate make_rpm.bzl and experimental/make_rpm.bzl
- This change consolidates all of new features/fixes from
- pkg/experimental/make_rpm.bzl into pkg/make_rpm.bzl.
- Code used specifically by experimental/rpm.bzl is marked as such, and is grouped
- as to be generally obvious.
- Features now supported by non-experimental `pkg_rpm`:
- - Support for older versions of `rpm(8)` (creation of `RPMS` output directory)
- Features supported by non-experimental `pkg_rpm` not supported by experimental
- `pkg_rpm`:
- - Support for `SOURCE_DATE_EPOCH`
- Fixes #173
-- commit 4b0b9f4679484f107f750a60190ff5ec6b164a5f
-
-- Author: aiuto <aiuto@google.com>
- Date: Wed Jul 15 14:59:02 2020 -0400
- Add windows to presubmit tests. (#206)
- * add windows to CI. Not everything, but enough to get started
-- commit dede700a2f4aea9854238cad1833b54585f65d43
-
-- Author: aiuto <aiuto@google.com>
- Date: Wed Jul 15 12:47:59 2020 -0400
- 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 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>
- Date: Wed Jul 15 12:21:48 2020 -0400
- Convert build_tar_test to python for readability and portability (#196)
-- commit 154479d9284535c77a781b5be26354f6d46cfe63
-
-- Author: Elliot Murphy <statik@users.noreply.github.com>
- Date: Thu Jul 9 16:01:27 2020 -0400
- Control mode on zip inputs (#96) (#97)
-- commit f00b356970524f53d928503ca5443c6108e883e5
-
-
-- Author: David Schneider <dschneider@tableau.com>
- Date: Wed Jul 1 07:28:00 2020 -0700
- Allow custom archive name for pkg_tar, pkg_deb, and pkg_zip targets (#194)
-- commit b5add5bf465c626407ad0ded679a0e2c14dad801
-
-- Author: aiuto <aiuto@google.com>
- Date: Thu May 28 10:42:00 2020 -0400
- Add licenses clauses to BUILD files (#186)
-- commit 2977b089a6cd45038d39a5498f0a6cabb11774bf
-
-- Author: aiuto <aiuto@google.com>
- Date: Fri May 22 14:50:42 2020 -0400
- Add a minimal WORKSPACE file to the distributon. (#182)
- We extract this from the top level workspace so it is easier to keep in sync.
-- commit 808c192a0c48f292e6dfaaeb3bfa3d4378f6996d
-
-- Author: andreas-0815-qwertz <57450822+andreas-0815-qwertz@users.noreply.github.com>
- Date: Tue May 19 18:51:17 2020 +0200
- Make sequence of filenames in control.tar predictable (#120)
- Replacing plain Python dict by an OrderedDict for Python versions
- before 3.7, so that iteration order of "extrafiles" is determined by
- insertion order. Since 3.7 iteration order of plain dict itself is
- stable.
- https://github.com/bazelbuild/rules_pkg/issues/114
-- commit eab297c6931260e283a3daaf2cdc438f0c6a1cfc
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Mon May 18 22:40:49 2020 -0400
- Fix `pkg_rpm` `source_date_epoch` attribute (#176)
- The existing `source_date_epoch` attribute for `pkg_rpm` is passed in as
- an `int`, and is then appended to a string. This, naturally, fails.
- The `int` needs to be stringified first.
- Additionally, since the [SOURCE_DATE_EPOCH] value can be any valid UNIX
- epoch value, account for the possibility of it being set to 0 in the
- Starlark code.
- [SOURCE_DATE_EPOCH]: https://reproducible-builds.org/specs/source-date-epoch/#idm55
-- commit ec802488edc1a0594b019fadf1794f13b434b365
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Fri Apr 10 10:33:50 2020 -0400
- Provide pkg_mklinks for creation of in-package symbolic links
- Symbolic links are often included within packages, referring to files and
- directories within and without.
- This commit provides a rule, `pkg_mklinks`, which allows for the creation of
- arbitrary symbolic links within a package, and support within the experimental
- `pkg_rpm` rule to emit them.
- `buildifier` was also opportunistically applied to files in this change.
-- commit b20c45f292be6c74d2f0d829ba02c83dbe271195
-
-# Release 0.2.6
-
-**New Features**
-
-- Author: aiuto <aiuto@google.com>
- Date: Mon Apr 27 15:47:20 2020 -0400
- Add support to generate stardoc. (#164)
- This is done in a manner so there is no new runtime dependency on bazel-skylib. The bzl_library needed as input to stardoc is only created within the distro directory, which is not part of the released package.
-- commit eea3f696ca3187897ddc3eb07d9955384809a84c
-
-- Merge: 0761c40 b4c4a91
- Author: Daniel Sullivan <danielalexandersullivan@gmail.com>
- Date: Fri Apr 24 11:02:10 2020 -0400
- Merge pull request #162 from aiuto/lic
- remove useless BUILD file. update readme
-- commit b4c4a91dc36a53bb5e9e1fc42c91f351d782a7ed
-
-- Author: Tony Aiuto <aiuto@google.com>
- Date: Thu Apr 23 23:53:56 2020 -0400
- remove useless BUILD file. update readme
-- commit 0761c40f7f1d265ebd814a11eaa03e327271ae5c
-
-- Author: Daniel Sullivan <danielalexandersullivan@gmail.com>
- Date: Mon Apr 20 21:15:27 2020 -0400
- Preserve mtimes from input tar files in TarFileWriter output tars (#155)
- * Preserve mtimes from input tar files in TarFileWriter output tars
- * Provide option for overriding input tar mtimes in TarFileWriter
- * Correctly set test fixture paths in archive test
-- commit 787f41777355ff2c0669e1a5a8771380d8752fa3
-
-- Author: Matt Mikitka <2027417+mmikitka@users.noreply.github.com>
- Date: Fri Apr 17 12:31:15 2020 -0400
- Changed the buildroot from BUILD to BUILDROOT (#108)
- * Changed the buildroot from BUILD to BUILDROOT
- * Install files in the RPM spec before the %files section
-- commit ce53425bc5449268ade670346bc39d8c52b1f822
-
-- Author: Andrew Psaltis <apsaltis@vmware.com>
- Date: Wed Apr 15 18:22:22 2020 -0400
- Add prototype pkgfilegroup-based RPM builder (#129)
- This change provides a prototype `pkgfilegroup`-based RPM builder in the form of
- the `gen_rpm` rule. See #128 for more details on `pkgfilegroup`.
- The RPM generator was derived from `make_rpm.py` in `pkg/` and supports a number
- of features over and above what's available in `pkg_rpm`. As written, it, given
- a template like the one provided, you can construct many full-fledged RPM
- packages entirely within Bazel. In most cases, the templates will only need to
- be customized with advanced logic and other macros that are not settable via
- bazel itself; `gen_rpm` will write much of the preamble, `%description` text,
- `%install` scriptlets, and `%files` based on rule-provided inputs.
- Documentation outside of the source files is not yet available. This was
- empirically tested on RPM packages internal to VMware with positive results;
- actual tests of the rules are not yet ready.
- This, naturally, is incomplete, and is missing capabilities such as:
- - Configurable compression
- - Configurable Provides/Requires
- - SRPM emission
- - Reproducibility
- - Configurable stripping
- - Configurable construction of "debug" packages
- Co-authored-by: mzeren-vmw <mzeren@vmware.com>
- Co-authored-by: klash <klash@vmware.com>
- Co-authored-by: mzeren-vmw <mzeren@vmware.com>
- Co-authored-by: klash <klash@vmware.com>
-- commit 79eafadca7b4fdb675b1cfa40b2ac20f23139271
-
-- Author: Matthias Frei <matthias.frei@inf.ethz.ch>
- Date: Tue Apr 7 03:27:05 2020 +0200
- make_deb: fix length computation for extrafiles (#144)
- * make_deb: fix length computation for extrafiles
- Analogous to the handling of the main control file.
- * Add test for genrule-preinst with non-ascii chars
- * Fix tests
-
-# Release 0.2.5
-
-**New Features**
-
-commit 48001d12e7037b04dc5b28fadfb1e10a8447e2fc
- Author: aiuto <aiuto@google.com>
- Date: Thu Mar 12 15:14:32 2020 -0400
-
- Depend on rules_python (#140)
-
- * load rules python
-
- * add workspace deps
-
- * add missing loads
-
-commit 2b375a08bfe36d2c35885a6f4e5b12d7898c9426
- Author: Ryan Beasley <39353016+beasleyr-vmw@users.noreply.github.com>
- Date: Wed Mar 11 14:49:21 2020 -0400
-
- Update test data in response to #121 (#137)
-
- PR #121 changed pkg_deb's behavior but didn't update test data to match.
-
- Reported in PR #132.
-
- Testing Done:
- - `bazelisk test ...`
-
-commit e5919f43791b2d4c5ab9e68786087cf889b9987e
- Author: Andrew Psaltis <ampsaltis@gmail.com>
- Date: Fri Feb 28 01:22:37 2020 -0500
-
- Add pkgfilegroup for package-independent destination mappings (#128)
-
- * Add pkgfilegroup for package-independent destination mappings
-
- This adds an experimental rule, `pkgfilegroup`, along with associated Providers,
- that gives rule developers and users a consistent mechanism for using the output
- of bazel targets in packaging rules.
-
- Inspired by #36.
-
- Other capabilities that are provided by this that were not mentioned in #36 are:
-
- - Creation of empty directories (`pkg_mkdirs`)
- - Exclusion of files from a `pkgfilegroup` (`excludes`)
- - Renames of files in a `pkgfilegroup` (`renames`)
-
- * Add analysis tests for pkgfilegroup and friends
-
- This provides some analysis tests for various features of `pkgfilegroup` and
- `pkg_mkdirs`. See #128.
-
- You can run them by invoking `bazel test experimental/...` from the `pkg`
- directory
-
- This implementation of pkgfilegroup was inspired by #36.
-
-commit 7a991dea418ab17c7e86f0a7b5e7d4a87ef4304b
- Author: Ryan Beasley <39353016+beasleyr-vmw@users.noreply.github.com>
- Date: Fri Feb 28 01:02:24 2020 -0500
-
- Improve handling of sources from external repositories (#132)
-
- Avoid use of [`File.short_path`][1] when mapping filenames, because when
- creating archives from files imported from external repositories we'll create
- archive members with leading `./../` prefixes. Instead, we'll stick to stripping
- to leading `File.root.path` (if present) from `File.path`, resulting in archive
- members like `external/repo/package/file.txt`.
-
- [1]: https://docs.bazel.build/versions/master/skylark/lib/File.html#short_path
-
- Resolves #131.
-
-commit 532f2857e712c5fcb71c662d680108685b242251
- Author: zoidbergwill <zoidbergwill@gmail.com>
- Date: Fri Feb 28 06:56:05 2020 +0100
-
- Update pkg.bzl (#125)
-
-commit 5877fa85b8598b5bb2186d3addca2408b1e61c5e
- Author: Matt Mikitka <2027417+mmikitka@users.noreply.github.com>
- Date: Fri Feb 28 05:49:40 2020 +0000
-
- Rpm source date epoch (#113)
-
- * Added --source_date_epoch
- * Support source_date_epoch_file since stamp variables are not accessible
- * Fixed _make_rpm label
- * Revert default make_rpm label
- * Default source_date_epoch to None and remove os.environ
-
-commit acc1ca9095e60bb9acd9858bc1812bfd805136df
- Author: Trevor Hickey <TrevorJamesHickey@gmail.com>
- Date: Mon Feb 24 09:53:55 2020 -0500
-
- update WORKSPACE example (#124)
-
-commit 2f5c9815a7bde4f18acfde268bd63fedd107d87c
- Author: andreas-0815-qwertz <57450822+andreas-0815-qwertz@users.noreply.github.com>
- Date: Wed Dec 4 22:32:01 2019 +0100
-
- Add "./" prefix to files in control.tar (#121)
-
- This improves compatibility to Debian packages created using dpkg.
-
- https://github.com/bazelbuild/rules_pkg/issues/116
-
-commit 2f09779667f0d6644c2ca5914d6113a82666ec63
- Author: Benjamin Peterson <benjamin@python.org>
- Date: Fri Nov 15 10:09:45 2019 -0800
-
- pkg_deb: Support Breaks and Replaces. (#117)
-
- https://www.debian.org/doc/debian-policy/ch-relationships.html#overwriting-files-and-replacing-packages-replaces
-
-commit 9192d3b3a0f6ccfdecdc66f08f0b2664fa0afc0f
- Author: Tony Aiuto <aiuto@google.com>
- Date: Fri Oct 4 16:33:47 2019 -0400
-
- Fix repo names with '-' in them.
-
- We can not use the form "@repo-name" in Bazel, so the common solution is
- to transform that to "@repo_name". We auto-correct the repo names to the
- required form when printing the WORKSPACE stanza.
diff --git a/CODEOWNERS b/CODEOWNERS
deleted file mode 100644
index 10e6cd3..0000000
--- a/CODEOWNERS
+++ /dev/null
@@ -1,14 +0,0 @@
-* @aiuto @alexeagle
-
-/deb_packages/ @aiuto
-/docs/ @aiuto @alexeagle @jylinv0 @gregestren
-/doc_build/ @aiuto @alexeagle @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
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
deleted file mode 100644
index 7c52059..0000000
--- a/CONTRIBUTING.md
+++ /dev/null
@@ -1,32 +0,0 @@
-Want to contribute? Great! First, read this page (including the small print at
-the end).
-
-### Before you contribute
-
-**Before we can use your code, you must sign the [Google Individual Contributor
-License
-Agreement](https://developers.google.com/open-source/cla/individual?csw=1)
-(CLA)**, which you can do online.
-
-The CLA is necessary mainly because you own the copyright to your changes, even
-after your contribution becomes part of our codebase, so we need your permission
-to use and distribute your code. We also need to be sure of various other things
-— for instance that you'll tell us if you know that your code infringes on other
-people's patents. You don't have to sign the CLA until after you've submitted
-your code for review and a member has approved it, but you must do it before we
-can put your code into our codebase.
-
-Before you start working on a larger contribution, you should get in touch with
-us first. Use the issue tracker to explain your idea so we can help and possibly
-guide you.
-
-### Code reviews and other contributions.
-
-**All submissions, including submissions by project members, require review.**
-Please follow the instructions in [the patching guide](/patching.md).
-
-### The small print
-
-Contributions made by corporations are covered by a different agreement than the
-one above, the [Software Grant and Corporate Contributor License
-Agreement](https://cla.developers.google.com/about/google-corporate).
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
deleted file mode 100644
index ebef3ac..0000000
--- a/CONTRIBUTORS
+++ /dev/null
@@ -1,12 +0,0 @@
-# People who have agreed to one of the CLAs and can contribute patches.
-# The AUTHORS file lists the copyright holders; this file
-# lists people. For example, Google employees are listed here
-# but not in AUTHORS, because Google holds the copyright.
-#
-# https://developers.google.com/open-source/cla/individual
-# https://developers.google.com/open-source/cla/corporate
-#
-# Names should be added to this file as:
-# Name <email address>
-Andrew Psaltis <apsaltis@vmware.com>
-Tony Aiuto <aiuto@google.com>
diff --git a/METADATA b/METADATA
deleted file mode 100644
index 2a6d666..0000000
--- a/METADATA
+++ /dev/null
@@ -1,17 +0,0 @@
-name: "rules_pkg"
-description:
- ""
-
-third_party {
- url {
- type: HOMEPAGE
- value: "https://github.com/bazelbuild/rules_pkg"
- }
- url {
- type: GIT
- value: "https://github.com/bazelbuild/rules_pkg.git"
- }
- version: "0.9.1"
- last_upgrade_date { year: 2024 month: 5 day: 2 }
-}
-
diff --git a/MODULE.bazel b/MODULE.bazel
deleted file mode 100644
index 7bb5bf9..0000000
--- a/MODULE.bazel
+++ /dev/null
@@ -1,15 +0,0 @@
-module(
- name = "rules_pkg",
- version = "0.10.0", # Must sync with version.bzl.
- repo_name = "rules_pkg",
- compatibility_level = 1,
-)
-
-# 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 = "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)
diff --git a/README.md b/README.md
index 175e5ec..8bb6fb8 100644
--- a/README.md
+++ b/README.md
@@ -1,34 +1,4 @@
-# Bazel package building
+# MOVED
-Bazel rules for building tar, zip, deb, and rpm for packages.
-
-For the latest version, see [Releases](https://github.com/bazelbuild/rules_pkg/releases) (with `WORKSPACE` setup) /
-[Documentation](https://bazelbuild.github.io/rules_pkg)
-
-Use rules-pkg-discuss@googlegroups.com for discussion.
-
-CI:
-[![Build status](https://badge.buildkite.com/e12f23186aa579f1e20fcb612a22cd799239c3134bc38e1aff.svg)](https://buildkite.com/bazel/rules-pkg)
-
-## Basic rules
-
-### Package building rules
-
-* [pkg](https://github.com/bazelbuild/rules_pkg/tree/main/pkg) - Rules for
- building packages of various types.
-* [examples](https://github.com/bazelbuild/rules_pkg/tree/main/examples) -
- Cookbook examples for using the rules.
-
-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.
-
-### For developers
-
-* [Contributor information](CONTRIBUTING.md) (including contributor license agreements)
-* [Patch process](patching.md)
-* [Coding guidelines](developers.md) and other developer information
-
-We hold an engineering status meeting on the first Monday of every month at 10am USA East coast time.
-[Add to calendar](https://calendar.google.com/event?action=TEMPLATE&tmeid=MDE2ODMzazlwZnRxbWtkZG5wa2hlYjllMGVfMjAyMTA1MDNUMTUwMDAwWiBjXzUzcHBwZzFudWthZXRmb3E5NzhxaXViNmxzQGc&tmsrc=c_53pppg1nukaetfoq978qiub6ls%40group.calendar.google.com&scp=ALL) /
-[meeting notes](https://docs.google.com/document/d/1wkY8ZIcrG8tlKCHzv4st-EltsdlpQENH58fguRnErWY/edit?usp=sharing)
+This repository is deprecated and moved to
+[platform/external/bazelbuild-rules_pkg](https://android.googlesource.com/platform/external/bazelbuild-rules_pkg).
diff --git a/WORKSPACE b/WORKSPACE
deleted file mode 100644
index cd5eca7..0000000
--- a/WORKSPACE
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rules_pkg")
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
-
-load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")
-
-bazel_skylib_workspace()
-
-### INTERNAL ONLY - lines after this are not included in the release packaging.
-#
-# Include dependencies which are only needed for development here.
-
-# Used to test invoking rules with targets in an external repo.
-local_repository(
- name = "mappings_test_external_repo",
- path = "tests/mappings/external_repo",
-)
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "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",
-)
-
-# Find rpmbuild if it exists.
-load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
-
-find_system_rpmbuild(
- name = "rules_pkg_rpmbuild",
- verbose = False,
-)
-
-# Needed for making our release notes
-load("@rules_pkg//toolchains/git:git_configure.bzl", "experimental_find_system_git")
-
-experimental_find_system_git(
- name = "rules_pkg_git",
- verbose = False,
-)
-
-http_archive(
- name = "bazel_stardoc",
- sha256 = "c9794dcc8026a30ff67cf7cf91ebe245ca294b20b071845d12c192afe243ad72",
- urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
- "https://github.com/bazelbuild/stardoc/releases/download/0.5.0/stardoc-0.5.0.tar.gz",
- ],
-)
-
-load("@bazel_stardoc//:setup.bzl", "stardoc_repositories")
-
-stardoc_repositories()
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
deleted file mode 100644
index e5300a3..0000000
--- a/WORKSPACE.bzlmod
+++ /dev/null
@@ -1,23 +0,0 @@
-# Include dependencies which are only needed for development here.
-
-local_repository(
- name = "mappings_test_external_repo",
- path = "tests/mappings/external_repo",
-)
-
-# TODO(aiuto): bzlmod chokes on @rules_pkg// in the toolchain labels.
-# Find rpmbuild if it exists.
-# load("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
-#
-#find_system_rpmbuild(
-# name = "rules_pkg_rpmbuild",
-# verbose = False,
-#)
-
-# 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,
-#)
diff --git a/deb_packages/README.md b/deb_packages/README.md
deleted file mode 100644
index d60633d..0000000
--- a/deb_packages/README.md
+++ /dev/null
@@ -1,5 +0,0 @@
-# This module is deprecated
-
-The work here has forked to two other places. Please look at both to see which is better maintained and meets your needs best.
-- https://github.com/mariusgrigoriu/rules_dpkg
-- https://github.com/aisbaa/deb_packages
diff --git a/deps.bzl b/deps.bzl
deleted file mode 100644
index 65bfe1e..0000000
--- a/deps.bzl
+++ /dev/null
@@ -1,25 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Workspace dependencies for rules_pkg/pkg.
-This is for backwards compatibility with existing usage. Please use
- load("//pkg:deps.bzl", "rules_pkg_dependencies")
-going forward.
-"""
-
-load("//pkg:deps.bzl", _rules_pkg_dependencies = "rules_pkg_dependencies")
-
-rules_pkg_dependencies = _rules_pkg_dependencies
-
-def rules_pkg_register_toolchains():
- pass
diff --git a/developers.md b/developers.md
deleted file mode 100644
index 611b1e0..0000000
--- a/developers.md
+++ /dev/null
@@ -1,108 +0,0 @@
-# rules_pkg - Information for Developers
-
-NOTE: This is perpetually a work in progress. We will revise it as we need.
-
-## PR guidelines
-
-Please discuss proposed major features and structural changes before sending a
-PR. The best way to do that is to do one or more of the following.
-
-1. Create an issue
-1. Discuss it in the issue or in rules-pkg-discuss@googlegroups.com
-1. Bring it up at the monthly engineering meeting. (See #325 for
- details)[https://github.com/bazelbuild/rules_pkg/issues/325].
-
-### A few small PRs are better than one big one.
-
-If you need to refactor a lot of code before you can add new behavior, please
-send a refactoring PR first (which should not add or change tests), then send a
-smaller change that implements the new behavior.
-
-## Functionality
-
-### General solutions are better than package specific ones.
-
-- Favor solutions that can be reused for all package formats. We will not
- accept contributions that add specific features to one package format when
- they could be incorporated into existing `pkg_files` and related rules such
- that they could be used by all formats.
-- We are moving towards aligning attribute names across rules. If we want
- backwards compatibility with older versions, do that in the macro wrapper.
-
-### Tests
-
-- All behavioral changes require tests. Even if you are fixing what is most
- likely a bug, please add a test that would have failed before the fix and
- passes after.
-- Aim for minimal tests. Favor unit tests over integration tests. It is better
- to have many small tests rather than one that checks many conditions.
-- Continuous testing is defined under `.bazel_ci`.
-
-### Portability
-
-- All of the code must work on Linux, macOS, and Windows. Other OSes are
- optional, but we do not have CI to ensure it. If you are making changes that
- require something specifically for portability, your change should include
- inline comments about why, so a future maintainer does not accidentally
- revert it.
-- Some features can not work on all platforms. Favor solutions that allow
- auto-skipping tests that are platform specific rather than requiring
- exclusion lists in CI.
-
-### Major features require commitment
-
-We would love to have features like an MSI builder or macOS application support.
-Before accepting a PR for something like that, we want to know that your
-organization will commit to maintaining that feature and responding to issues.
-
-## About the code
-
-### Repository structure: run time vs build time
-
-- pkg/... contains what is needed at run time. Everything else is not part of
- the packaged distribution releases.
-- docs/... is served as github pages. We mostly generate that rather than edit
- by hand.
-- distro/... contains the rules to create the distribution package.
-- examples/... contains runnable examples which serve as additional
- documentation. These are tested in CI.
-- tests/... contains unit and integration tests. It is a distinct folder so
- that it is not needed in the distribution runtime.
-- <root> contains shims for the .bzl files in pkg/*.bzl. They add backwards
- compatibility to to older releases.
-
-### Starlark style
-
-- We are moving towards fully generated docs. If you touch an attribute, you
- must update the docstring to explain it.
-- Add docstrings args defined in macros. We are targeting the future time when
- stardoc can build unified documentation for the rule and the wrapper.
-- Actions should not write quoted strings to command lines. If your rule must
- pass file paths to another program, write the paths to an intermediate file
- and pass that as an arg to the other program.
- [See #214](https://github.com/bazelbuild/rules_pkg/issues/214).
-- Run buildifier on you .bzl files before sending a PR.
-
-### Python style
-
-- We use Python 3. We are not trying to support Python 2 at all.
-- Always import with a full path from the root of the source tree.
-- Compatibility back to python 3.6 (for CentOS 7 and Ubuntu 18.04 LTS) is
- required.
-
-### Dependencies
-
-- No new dependencies on language toolchains. We take a dependency on Python
- because it is generally available on all OSes.
-- No new python package dependencies. Use only what is part of the core
- distribution.
-- Other new dependencies are strongly discouraged. The exception is that we
- may take dependencies on other modules maintained by the Bazel team.
-
-### Write for vendoring the source tree.
-
-We presume that some users will vendor this entire rule set into their source
-tree and want to test it from their WORKSPACE. Towards that end we try to
-minimize the places where we assume the path to any package is absolute
-from WORKSPACE. See tests/package_naming_aggregate_test.sh for an example
-of how we can write a sh_test that works after re-rooting the sources.
diff --git a/distro/BUILD b/distro/BUILD
deleted file mode 100644
index 0ffa34a..0000000
--- a/distro/BUILD
+++ /dev/null
@@ -1,109 +0,0 @@
-# Copyright 2019 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("//: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"],
- default_visibility = ["//visibility:private"],
-)
-
-alias(
- name = "distro",
- actual = "rules_pkg-%s" % version,
-)
-
-# Build the artifact to put on the github release page.
-pkg_tar(
- name = "rules_pkg-%s" % version,
- srcs = [
- ":small_workspace",
- "//:standard_package",
- "//pkg:standard_package",
- "//pkg/private:standard_package",
- "//pkg/private/deb:standard_package",
- "//pkg/private/tar:standard_package",
- "//pkg/private/zip:standard_package",
- "//pkg/releasing:standard_package",
- "//toolchains/git:standard_package",
- "//toolchains/rpm:standard_package",
- ],
- extension = "tar.gz",
- # It is all source code, so make it read-only.
- mode = "0444",
- # Make it owned by root so it does not have the uid of the CI robot.
- owner = "0.0",
- package_dir = ".",
- strip_prefix = ".",
-)
-
-genrule(
- name = "small_workspace",
- srcs = ["//:WORKSPACE"],
- outs = ["WORKSPACE"],
- cmd = "sed -e '/### INTERNAL ONLY/,$$d' $(location //:WORKSPACE) >$@",
-)
-
-print_rel_notes(
- name = "relnotes",
- outs = ["relnotes.txt"],
- changelog = ":changelog",
- deps_method = "rules_pkg_dependencies",
- mirror_host = "mirror.bazel.build",
- org = "bazelbuild",
- repo = "rules_pkg",
- version = version,
-)
-
-git_changelog(
- name = "changelog",
- out = "changelog.txt",
-)
-
-py_test(
- name = "packaging_test",
- size = "large",
- srcs = [
- "packaging_test.py",
- ":release_version.py",
- ],
- imports = [".."],
- data = [
- "testdata/BUILD.tpl",
- ":distro",
- "//:standard_package",
- ],
- local = True,
- python_version = "PY3",
- tags = [
- "no_windows",
- "noci",
- ],
- deps = [
- "//pkg/releasing:release_utils",
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-genrule(
- name = "version_as_py",
- outs = ["release_version.py"],
- cmd = "echo RELEASE_VERSION = \\'%s\\' >$@" % version,
-)
diff --git a/distro/__init__.py b/distro/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/distro/__init__.py
+++ /dev/null
diff --git a/distro/packaging_test.py b/distro/packaging_test.py
deleted file mode 100644
index 3e2a38c..0000000
--- a/distro/packaging_test.py
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2019 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.
-
-"""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 pkg.releasing import release_tools
-from distro import release_version
-
-_VERBOSE = True
-
-
-class PackagingTest(unittest.TestCase):
- """Test the distribution packaging."""
-
- def setUp(self):
- self.data_files = runfiles.Create()
- self.source_repo = 'rules_pkg'
- 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')
- if not os.path.exists(tempdir):
- os.makedirs(tempdir)
- with open(os.path.join(tempdir, 'WORKSPACE'), 'w') as workspace:
- file_name = release_tools.package_basename(self.source_repo, self.version)
- # The code looks wrong, but here is why it is correct.
- # - Rlocation requires '/' as path separators, not os.path.sep.
- # - When we read the file, the path must use os.path.sep
- local_path = self.data_files.Rlocation(
- 'rules_pkg/distro/' + file_name).replace('/', os.path.sep)
- sha256 = release_tools.get_package_sha256(local_path)
- workspace_content = '\n'.join((
- 'workspace(name = "test_rules_pkg_packaging")',
- release_tools.workspace_content(
- 'file://%s' % local_path, self.source_repo, sha256,
- rename_repo=self.dest_repo,
- deps_method='rules_pkg_dependencies'
- )
- ))
- workspace.write(workspace_content)
- if _VERBOSE:
- print('=== WORKSPACE ===')
- print(workspace_content)
-
- # We do a little dance of renaming *.tpl to *, mostly so that we do not
- # have a BUILD file in testdata, which would create a package boundary.
- def CopyTestFile(source_name, dest_name):
- source_path = self.data_files.Rlocation(
- 'rules_pkg/distro/testdata/' + source_name)
- with open(source_path) as inp:
- with open(os.path.join(tempdir, dest_name), 'w') as out:
- content = inp.read()
- out.write(content)
-
- CopyTestFile('BUILD.tpl', 'BUILD')
-
- os.chdir(tempdir)
- build_result = subprocess.check_output(['bazel', 'build', ':dummy_tar'])
- if _VERBOSE:
- print('=== Build Result ===')
- print(build_result)
-
- # TODO(aiuto): Find tar in a disciplined way
- content = subprocess.check_output(
- ['tar', 'tzf', 'bazel-bin/dummy_tar.tar.gz'])
- self.assertEqual(b'etc/\netc/BUILD\n', content)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/distro/testdata/BUILD.tpl b/distro/testdata/BUILD.tpl
deleted file mode 100644
index 7665384..0000000
--- a/distro/testdata/BUILD.tpl
+++ /dev/null
@@ -1,14 +0,0 @@
-load("@not_named_rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
- name = "dummy_tar",
- srcs = [
- ":BUILD",
- ],
- extension = "tar.gz",
- owner = "0.0",
- package_dir = "etc",
- tags = [
- "manual",
- ],
-)
diff --git a/doc_build/BUILD b/doc_build/BUILD
deleted file mode 100644
index 7e4b84b..0000000
--- a/doc_build/BUILD
+++ /dev/null
@@ -1,130 +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.
-"""Generate the reference documentation.
-
-How to:
- bazel build //doc_build:reference
- cp bazel-bin/doc_build/reference.md docs/latest.md
- git commit -m 'update docs' docs/latest.md
-"""
-
-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"])
-
-filegroup(
- name = "standard_package",
- srcs = [
- "BUILD",
- ] + glob([
- "*.bzl",
- "*.py",
- ]),
- visibility = ["//distro:__pkg__"],
-)
-
-exports_files(
- glob([
- "*.bzl",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//doc_build:__pkg__",
- ],
-)
-
-# pairs of rule name and the source file to get it from
-# buildifier: leave-alone, do not sort
-ORDER = [
- ("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),
-]
-
-genrule(
- name = "reference",
- srcs = ["%s.md" % rule for rule, _ in ORDER],
- outs = ["reference.md"],
- cmd = "$(location :merge) $(SRCS) >$@",
- tools = [":merge"],
-)
-
-[
- stardoc(
- name = "%s_gen" % rule,
- out = "%s.md" % rule,
- input = src,
- symbol_names = [
- rule,
- ],
- deps = [":rules_pkg_lib"],
- )
- for rule, src in ORDER
- if src
-]
-
-genrule(
- name = "toc",
- srcs = ["toc.md.tpl"],
- outs = ["toc.md"],
- cmd = "sed -e 's/{VERSION}/%s/' $(SRCS) >$@" % version,
-)
-
-# Generate separately or there will be a conflict with the other pkg_rpm.
-stardoc(
- name = "docs_legacy_rpm",
- out = "legacy_pkg_rpm.md",
- input = "//pkg/legacy:rpm.bzl",
- deps = [":rules_pkg_lib"],
-)
-
-# Mappings has a lot of pure rules, so it is mostly in a good order.
-stardoc(
- name = "mappings",
- out = "mappings.md",
- input = "//pkg:mappings.bzl",
- deps = [
- ":rules_pkg_lib",
- ],
-)
-
-# gather all rules that should be documented
-bzl_library(
- name = "rules_pkg_lib",
- srcs = [
- "//:version.bzl",
- "//pkg:bzl_srcs",
- "@bazel_skylib//lib:paths",
- ],
- visibility = ["//visibility:public"],
-)
-
-py_binary(
- name = "merge",
- srcs = ["merge.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- visibility = ["//visibility:private"],
-)
diff --git a/doc_build/common.md b/doc_build/common.md
deleted file mode 100644
index 7933de1..0000000
--- a/doc_build/common.md
+++ /dev/null
@@ -1,53 +0,0 @@
-<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.
-
-@since(0.8.0): File name substitution now supports the $(var) syntax.
-@since(0.8.0): 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`.
diff --git a/doc_build/merge.py b/doc_build/merge.py
deleted file mode 100755
index 02eb8f1..0000000
--- a/doc_build/merge.py
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/usr/bin/env python3
-# Copyright 2022 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.
-"""merge stardoc output into a single page.
-
-- concatenates files
-- corrects things that stardoc botches
-"""
-
-import re
-import sys
-import typing
-
-
-ID_RE = re.compile(r'<a id="#(.*)">')
-WRAPS_RE = re.compile(r'@wraps\((.*)\)')
-SINCE_RE = re.compile(r'@since\(([^)]*)\)')
-CENTER_RE = re.compile(r'<p align="center">([^<]*)</p>')
-
-
-def merge_file(file: str, out, wrapper_map:typing.Dict[str, str]) -> None:
- with open(file, 'r') as inp:
- content = inp.read()
- m = ID_RE.search(content)
- this_pkg = m.group(1) if m else None
- m = WRAPS_RE.search(content)
- if m:
- # I wrap something, so don't emit me.
- wrapper_map[m.group(1)] = this_pkg
- return
- # 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)
-
-
-def merge_text(text: str, out) -> None:
- """Merge a block of text into an output stream.
-
- Args:
- text: block of text produced by Starroc.
- out: an output file stream.
- """
- for line in text.split('\n'):
- line = SINCE_RE.sub(r'<div class="since"><i>Since \1</i></div>', line)
-
- if line.startswith('| :'):
- line = fix_stardoc_table_align(line)
- # Compensate for https://github.com/bazelbuild/stardoc/issues/118.
- # Convert escaped HTML <li> back to raw text
- line = line.replace('&lt;li&gt;', '<li>')
- line = CENTER_RE.sub(r'\1', line)
- _ = out.write(line)
- _ = out.write('\n')
-
-
-def fix_stardoc_table_align(line: str) -> str:
- """Change centered descriptions to left justified."""
- if line.startswith('| :-------------: | :-------------: '):
- return '| :------------ | :--------------- | :---------: | :---------: | :----------- |'
- return line
-
-
-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__':
- main(sys.argv)
diff --git a/doc_build/toc.md.tpl b/doc_build/toc.md.tpl
deleted file mode 100644
index 224f363..0000000
--- a/doc_build/toc.md.tpl
+++ /dev/null
@@ -1,28 +0,0 @@
-# rules_pkg - {VERSION}
-
-<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>
diff --git a/docs/0.4.0/reference.md b/docs/0.4.0/reference.md
deleted file mode 100644
index 22be482..0000000
--- a/docs/0.4.0/reference.md
+++ /dev/null
@@ -1,676 +0,0 @@
-<meta name="robots" content="noindex,nofollow">
-# rules_pkg - 0.4.0
-
-<div class="toc">
- <h2>Rules</h2>
- <ul>
- <li><a href="#pkg_tar">pkg_tar</a></li>
- <li><a href="#pkg_zip">pkg_zip</a></li>
- <li><a href="#pkg_deb">pkg_deb</a></li>
- <li><a href="#pkg_rpm">pkg_rpm</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 form `{var}`. The values for substitution are specified through `package_variables`. | 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.
-
-<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`.
-
-There are currently no other well-known attributes.
-
----
-
-<a name="pkg_tar"></a>
-## pkg_tar
-
-```python
-pkg_tar(name, extension, strip_prefix, package_dir, srcs,
- mode, modes, deps, symlinks, package_file_name, package_variables)
-```
-
-Creates a tar file from a list of inputs.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>extension</code></td>
- <td>
- <code>String, default to 'tar'</code>
- <p>
- The extension for the resulting tarball. The output
- file will be '<i>name</i>.<i>extension</i>'. This extension
- also decide on the compression: if set to <code>tar.gz</code>
- or <code>tgz</code> then gzip compression will be used and
- if set to <code>tar.bz2</code> or <code>tar.bzip2</code> then
- bzip2 compression will be used.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>strip_prefix</code></td>
- <td>
- <code>String, optional</code>
- <p>Root path of the files.</p>
- <p>
- The directory structure from the files is preserved inside the
- tarball but a prefix path determined by <code>strip_prefix</code>
- is removed from the directory structure. This path can
- be absolute from the workspace root if starting with a <code>/</code> or
- relative to the rule's directory. A relative path may start with "./"
- (or be ".") but cannot use ".." to go up level(s). By default, the
- <code>strip_prefix</code> attribute is unused and all files are supposed to have no
- prefix. A <code>strip_prefix</code> of "" (the empty string) means the
- same as the default.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_dir</code></td>
- <td>
- <code>String, optional</code>
- <p>Target directory.</p>
- <p>
- The directory in which to expand the specified files, defaulting to '/'.
- Only makes sense accompanying files.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>srcs</code></td>
- <td>
- <code>List of files, optional</code>
- <p>File to add to the layer.</p>
- <p>
- A list of files that should be included in the archive.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>mode</code></td>
- <td>
- <code>String, default to 0555</code>
- <p>
- Set the mode of files added by the <code>srcs</code> attribute.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>mtime</code></td>
- <td>
- <code>int, seconds since Jan 1, 1970, default to -1 (ignored)</code>
- <p>
- Set the modification time of files added by the <code>srcs</code> attribute.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>portable_mtime</code></td>
- <td>
- <code>bool, default True</code>
- <p>
- Set the modification time of files added by the <code>srcs</code> attribute
- to a 2000-01-01.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>modes</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default mode of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the octal permission of to apply to the file.
- </p>
- <p>
- <code>
- modes = {
- "tools/py/2to3.sh": "0755",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>owner</code></td>
- <td>
- <code>String, default to '0.0'</code>
- <p>
- <code>UID.GID</code> to set the default numeric owner for all files
- provided in <code>srcs</code>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>owners</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default owner of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the <code>UID.GID</code> numeric string for the owner of the
- file. When determining owner ids, this attribute is looked first then
- <code>owner</code>.
- </p>
- <p>
- <code>
- owners = {
- "tools/py/2to3.sh": "42.24",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>ownername</code></td>
- <td>
- <code>String, optional</code>
- <p>
- <code>username.groupname</code> to set the default owner for all files
- provided in <code>srcs</code> (by default there is no owner names).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>ownernames</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default owner of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the <code>username.groupname</code> string for the owner of the
- file. When determining ownernames, this attribute is looked first then
- <code>ownername</code>.
- </p>
- <p>
- <code>
- owners = {
- "tools/py/2to3.sh": "leeroy.jenkins",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>deps</code></td>
- <td>
- <code>List of labels, optional</code>
- <p>Tar files to extract and include in this tar package.</p>
- <p>
- A list of tarball labels to merge into the output tarball.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>symlinks</code></td>
- <td>
- <code>Dictionary, optional</code>
- <p>Symlinks to create in the output tarball.</p>
- <p>
- <code>
- symlinks = {
- "/path/to/link": "/path/to/target",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>remap_paths</code></td>
- <td>
- <code>Dictionary, optional</code>
- <p>Source path prefixes to remap in the tarfile.</p>
- <p>
- <code>
- remap_paths = {
- "original/path/prefix": "replaced/path",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_zip"></a>
-## pkg_zip
-
-```python
-pkg_zip(name, extension, package_dir, srcs, timestamp, package_file_name,
-package_variables)
-```
-
-Creates a zip file from a list of inputs.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>extension</code></td>
- <td>
- <code>String, default to 'zip'</code>
- <p>
- <b>Deprecated. Use <code>out</code> or <code>package_file_name</code> to specify the output file name.</b>
- The extension for the resulting zipfile. The output
- file will be '<i>name</i>.<i>extension</i>'.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_dir</code></td>
- <td>
- <code>String, default to '/'</code>
- <p>Target directory inside zip.</p>
- <p>
- The prefix of all paths in the zip.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>srcs</code></td>
- <td>
- <code>List of files, optional</code>
- <p>File to add to the layer.</p>
- <p>
- A list of files that should be included in the archive.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>timestamp</code></td>
- <td>
- <code>Integer, default to 315532800</code>
- <p>
- The time to use for every file in the zip, expressed as seconds since
- Unix Epoch, RFC 3339.
- </p>
- <p>
- 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.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_deb"></a>
-### pkg_deb
-
-```python
-pkg_deb(name, data, package, architecture, maintainer, preinst, postinst, prerm, postrm,
- version, version_file, description, description_file, built_using, built_using_file,
- priority, section, homepage, depends, suggests, enhances, breaks, conflicts,
- predepends, recommends, replaces, package_file_name, package_variables)
-```
-
-Create a debian package. See <a
-href="http://www.debian.org/doc/debian-policy/ch-controlfields.html">http://www.debian.org/doc/debian-policy/ch-controlfields.html</a>
-for more details on this.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <code>File, required</code>
- <p>
- A tar file that contains the data for the debian package (basically
- the list of files that will be installed by this package).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package</code></td>
- <td>
- <code>String, required</code>
- <p>The name of the package.</p>
- </td>
- </tr>
- <tr>
- <td><code>architecture</code></td>
- <td>
- <code>String, default to 'all'</code>
- <p>The architecture that this package target.</p>
- <p>
- See <a href="http://www.debian.org/ports/">http://www.debian.org/ports/</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>maintainer</code></td>
- <td>
- <code>String, required</code>
- <p>The maintainer of the package.</p>
- </td>
- </tr>
- <tr>
- <td><code>preinst</code>, <code>postinst</code>, <code>prerm</code> and <code>postrm</code></td>
- <td>
- <code>Files, optional</code>
- <p>
- Respectively, the pre-install, post-install, pre-remove and
- post-remove scripts for the package.
- </p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html">http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>config</code></td>
- <td>
- <code>File, optional</code>
- <p>
- config file used for debconf integration.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts">https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>templates</code></td>
- <td>
- <code>File, optional</code>
- <p>
- templates file used for debconf integration.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts">https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>triggers</code></td>
- <td>
- <code>File, optional</code>
- <p>
- triggers file for configuring installation events exchanged by packages.
- </p>
- <p>
- See <a href="https://wiki.debian.org/DpkgTriggers">https://wiki.debian.org/DpkgTriggers</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>conffiles</code>, <code>conffiles_file</code></td>
- <td>
- <code>String list or File, optional</code>
- <p>
- 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.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files">https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>version</code>, <code>version_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package version provided either inline (with <code>version</code>)
- or from a file (with <code>version_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>description</code>, <code>description_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package description provided either inline (with <code>description</code>)
- or from a file (with <code>description_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>built_using</code>, <code>built_using_file</code></td>
- <td>
- <code>String or File</code>
- <p>
- The tool that were used to build this package provided either inline
- (with <code>built_using</code>) or from a file (with <code>built_using_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>priority</code></td>
- <td>
- <code>String, default to 'optional'</code>
- <p>The priority of the package.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities">http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>section</code></td>
- <td>
- <code>String, default to 'contrib/devel'</code>
- <p>The section of the package.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>homepage</code></td>
- <td>
- <code>String, optional</code>
- <p>The homepage of the project.</p>
- </td>
- </tr>
- <tr>
- <td>
- <code>breaks</code>, <code>depends</code>, <code>suggests</code>,
- <code>enhances</code>, <code>conflicts</code>, <code>predepends</code>,
- <code>recommends</code>, <code>replaces</code> and <code>provides</code>.
- </td>
- <td>
- <code>String list, optional</code>
- <p>The list of dependencies in the project.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps">http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a>
- Default: "%{package}-%{version}-%{architecture}.deb"
- </td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_rpm"></a>
-### pkg_rpm
-
-```python
-pkg_rpm(name, spec_file, architecture, version, version_file, changelog, data)
-```
-
-Create an RPM package. See <a
-href="http://rpm.org/documentation.html">http://rpm.org/documentation.html</a>
-for more details on this.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule. Used to name the output package.</p>
- </td>
- </tr>
- <tr>
- <td><code>spec_file</code></td>
- <td>
- <code>File, required</code>
- <p>The RPM specification file used to generate the package.</p>
- <p>
- See <a href="http://ftp.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html">http://ftp.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>architecture</code></td>
- <td>
- <code>String, default to 'all'</code>
- <p>The architecture that this package target.</p>
- </td>
- </tr>
- <tr>
- <td><code>version</code>, <code>version_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package version provided either inline (with <code>version</code>)
- or from a file (with <code>version_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <code>Files, required</code>
- <p>
- Files to include in the generated package.
- </p>
- </td>
- </tr>
- </tbody>
-</table>
diff --git a/docs/0.5.0/reference.md b/docs/0.5.0/reference.md
deleted file mode 100644
index dd8897c..0000000
--- a/docs/0.5.0/reference.md
+++ /dev/null
@@ -1,722 +0,0 @@
-<meta name="robots" content="noindex,nofollow">
-# rules_pkg - 0.5.0
-
-<div class="toc">
- <h2>Rules</h2>
- <ul>
- <li><a href="#pkg_tar">pkg_tar</a></li>
- <li><a href="#pkg_zip">pkg_zip</a></li>
- <li><a href="#pkg_deb">pkg_deb</a></li>
- <li><a href="#pkg_rpm">pkg_rpm</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 form `{var}`. The values for substitution are specified through `package_variables`. | 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.
-
-<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`.
-
-There are currently no other well-known attributes.
-
----
-
-<a name="pkg_tar"></a>
-## pkg_tar
-
-```python
-pkg_tar(name, extension, strip_prefix, package_dir, srcs, compressor,
- compressor_args, mode, modes, deps, symlinks, package_file_name,
- package_variables)
-```
-
-Creates a tar file from a list of inputs.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>extension</code></td>
- <td>
- <code>String, default to 'tar'</code>
- <p>
- The extension for the resulting tarball. The output
- file will be '<i>name</i>.<i>extension</i>'. This extension
- also decide on the compression: if set to <code>tar.gz</code>
- or <code>tgz</code> then gzip compression will be used and
- if set to <code>tar.bz2</code> or <code>tar.bzip2</code> then
- bzip2 compression will be used.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>strip_prefix</code></td>
- <td>
- <code>String, optional</code>
- <p>Root path of the files.</p>
- <p>
- The directory structure from the files is preserved inside the
- tarball but a prefix path determined by <code>strip_prefix</code>
- is removed from the directory structure. This path can
- be absolute from the workspace root if starting with a <code>/</code> or
- relative to the rule's directory. A relative path may start with "./"
- (or be ".") but cannot use ".." to go up level(s). By default, the
- <code>strip_prefix</code> attribute is unused and all files are supposed to have no
- prefix. A <code>strip_prefix</code> of "" (the empty string) means the
- same as the default.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_dir</code></td>
- <td>
- <code>String, optional</code>
- <p>Target directory.</p>
- <p>
- The directory in which to expand the specified files, defaulting to '/'.
- Only makes sense accompanying files.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>srcs</code></td>
- <td>
- <code>List of files, optional</code>
- <p>File to add to the layer.</p>
- <p>
- A list of files that should be included in the archive.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>compressor</code></td>
- <td>
- <code>Label, optional</code>
- <p>
- Executable to be built and used as part of a custom compression filter.
- For example, to compress with <code>pigz -p 4</code>, use <code>"@pigz"</code> here
- (assuming a workspace rule named "pigz" exists).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>compressor_args</code></td>
- <td>
- <code>String, optional</code>
- <p>
- Arguments to be passed to <code>compressor</code>.
- For example, to compress with <code>pigz -p 4</code>, use <code>"-p 4"</code> here.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>mode</code></td>
- <td>
- <code>String, default to 0555</code>
- <p>
- Set the mode of files added by the <code>srcs</code> attribute.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>mtime</code></td>
- <td>
- <code>int, seconds since Jan 1, 1970, default to -1 (ignored)</code>
- <p>
- Set the modification time of files added by the <code>srcs</code> attribute.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>portable_mtime</code></td>
- <td>
- <code>bool, default True</code>
- <p>
- Set the modification time of files added by the <code>srcs</code> attribute
- to a 2000-01-01.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>modes</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default mode of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the octal permission of to apply to the file.
- </p>
- <p>
- <code>
- modes = {
- "tools/py/2to3.sh": "0755",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>owner</code></td>
- <td>
- <code>String, default to '0.0'</code>
- <p>
- <code>UID.GID</code> to set the default numeric owner for all files
- provided in <code>srcs</code>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>owners</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default owner of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the <code>UID.GID</code> numeric string for the owner of the
- file. When determining owner ids, this attribute is looked first then
- <code>owner</code>.
- </p>
- <p>
- <code>
- owners = {
- "tools/py/2to3.sh": "42.24",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>ownername</code></td>
- <td>
- <code>String, optional</code>
- <p>
- <code>username.groupname</code> to set the default owner for all files
- provided in <code>srcs</code> (by default there is no owner names).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>ownernames</code></td>
- <td>
- <code>Dictionary, default to '{}'</code>
- <p>
- A string dictionary to change default owner of specific files from
- <code>srcs</code>. Each key should be a path to a file before
- appending the prefix <code>package_dir</code> and the corresponding
- value the <code>username.groupname</code> string for the owner of the
- file. When determining ownernames, this attribute is looked first then
- <code>ownername</code>.
- </p>
- <p>
- <code>
- owners = {
- "tools/py/2to3.sh": "leeroy.jenkins",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>deps</code></td>
- <td>
- <code>List of labels, optional</code>
- <p>Tar files to extract and include in this tar package.</p>
- <p>
- A list of tarball labels to merge into the output tarball.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>stamp</code></td>
- <td>
- <code>Integer; optional; default is -1</code>
- <p>Enable file time stamping. Possible values:<ul>
- <li>stamp = 1: Use the time of the build as the modification time of each file in the archive.</li>
- <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching.</li>
- <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag.</li>
- </ul>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>symlinks</code></td>
- <td>
- <code>Dictionary, optional</code>
- <p>Symlinks to create in the output tarball.</p>
- <p>
- <code>
- symlinks = {
- "/path/to/link": "/path/to/target",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>remap_paths</code></td>
- <td>
- <code>Dictionary, optional</code>
- <p>Source path prefixes to remap in the tarfile.</p>
- <p>
- <code>
- remap_paths = {
- "original/path/prefix": "replaced/path",
- ...
- },
- </code>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_zip"></a>
-## pkg_zip
-
-```python
-pkg_zip(name, extension, package_dir, srcs, timestamp, package_file_name,
-package_variables)
-```
-
-Creates a zip file from a list of inputs.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>extension</code></td>
- <td>
- <code>String, default to 'zip'</code>
- <p>
- <b>Deprecated. Use <code>out</code> or <code>package_file_name</code> to specify the output file name.</b>
- The extension for the resulting zipfile. The output
- file will be '<i>name</i>.<i>extension</i>'.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_dir</code></td>
- <td>
- <code>String, default to '/'</code>
- <p>Target directory inside zip.</p>
- <p>
- The prefix of all paths in the zip.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>srcs</code></td>
- <td>
- <code>List of files, optional</code>
- <p>File to add to the layer.</p>
- <p>
- A list of files that should be included in the archive.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>stamp</code></td>
- <td>
- <code>Integer; optional; default is -1</code>
- <p>Enable file time stamping. Possible values:<ul>
- <li>stamp = 1: Use the time of the build as the modification time of each file in the archive.</li>
- <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching.</li>
- <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag.</li>
- </ul>
- </p>
- </td>
- </tr>
- <tr>
- <td><code>timestamp</code></td>
- <td>
- <code>Integer, default to 315532800</code>
- <p>
- The time to use for every file in the zip, expressed as seconds since
- Unix Epoch, RFC 3339.
- </p>
- <p>
- 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.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_deb"></a>
-### pkg_deb
-
-```python
-pkg_deb(name, data, package, architecture, maintainer, preinst, postinst, prerm, postrm,
- version, version_file, description, description_file, built_using, built_using_file,
- priority, section, homepage, depends, suggests, enhances, breaks, conflicts,
- predepends, recommends, replaces, package_file_name, package_variables)
-```
-
-Create a debian package. See <a
-href="http://www.debian.org/doc/debian-policy/ch-controlfields.html">http://www.debian.org/doc/debian-policy/ch-controlfields.html</a>
-for more details on this.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule.</p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <code>File, required</code>
- <p>
- A tar file that contains the data for the debian package (basically
- the list of files that will be installed by this package).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package</code></td>
- <td>
- <code>String, required</code>
- <p>The name of the package.</p>
- </td>
- </tr>
- <tr>
- <td><code>architecture</code></td>
- <td>
- <code>String, default to 'all'</code>
- <p>The architecture that this package target.</p>
- <p>
- See <a href="http://www.debian.org/ports/">http://www.debian.org/ports/</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>maintainer</code></td>
- <td>
- <code>String, required</code>
- <p>The maintainer of the package.</p>
- </td>
- </tr>
- <tr>
- <td><code>preinst</code>, <code>postinst</code>, <code>prerm</code> and <code>postrm</code></td>
- <td>
- <code>Files, optional</code>
- <p>
- Respectively, the pre-install, post-install, pre-remove and
- post-remove scripts for the package.
- </p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html">http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>config</code></td>
- <td>
- <code>File, optional</code>
- <p>
- config file used for debconf integration.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts">https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>templates</code></td>
- <td>
- <code>File, optional</code>
- <p>
- templates file used for debconf integration.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts">https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>triggers</code></td>
- <td>
- <code>File, optional</code>
- <p>
- triggers file for configuring installation events exchanged by packages.
- </p>
- <p>
- See <a href="https://wiki.debian.org/DpkgTriggers">https://wiki.debian.org/DpkgTriggers</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>conffiles</code>, <code>conffiles_file</code></td>
- <td>
- <code>String list or File, optional</code>
- <p>
- 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.
- </p>
- <p>
- See <a href="https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files">https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>version</code>, <code>version_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package version provided either inline (with <code>version</code>)
- or from a file (with <code>version_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>description</code>, <code>description_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package description provided either inline (with <code>description</code>)
- or from a file (with <code>description_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>built_using</code>, <code>built_using_file</code></td>
- <td>
- <code>String or File</code>
- <p>
- The tool that were used to build this package provided either inline
- (with <code>built_using</code>) or from a file (with <code>built_using_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>priority</code></td>
- <td>
- <code>String, default to 'optional'</code>
- <p>The priority of the package.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities">http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>section</code></td>
- <td>
- <code>String, default to 'contrib/devel'</code>
- <p>The section of the package.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>homepage</code></td>
- <td>
- <code>String, optional</code>
- <p>The homepage of the project.</p>
- </td>
- </tr>
- <tr>
- <td>
- <code>breaks</code>, <code>depends</code>, <code>suggests</code>,
- <code>enhances</code>, <code>conflicts</code>, <code>predepends</code>,
- <code>recommends</code>, <code>replaces</code> and <code>provides</code>.
- </td>
- <td>
- <code>String list, optional</code>
- <p>The list of dependencies in the project.</p>
- <p>
- See <a href="http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps">http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>package_file_name</code></td>
- <td>See <a href="#common">Common Attributes</a>
- Default: "%{package}-%{version}-%{architecture}.deb"
- </td>
- </tr>
- <tr>
- <td><code>package_variables</code></td>
- <td>See <a href="#common">Common Attributes</a></td>
- </tr>
- </tbody>
-</table>
-
-<a name="pkg_rpm"></a>
-### pkg_rpm
-
-```python
-pkg_rpm(name, spec_file, architecture, version, version_file, changelog, data)
-```
-
-Create an RPM package. See <a
-href="http://rpm.org/documentation.html">http://rpm.org/documentation.html</a>
-for more details on this.
-
-<table class="table table-condensed table-bordered table-params">
- <colgroup>
- <col class="col-param" />
- <col class="param-description" />
- </colgroup>
- <thead>
- <tr>
- <th colspan="2">Attributes</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>name</code></td>
- <td>
- <code>Name, required</code>
- <p>A unique name for this rule. Used to name the output package.</p>
- </td>
- </tr>
- <tr>
- <td><code>spec_file</code></td>
- <td>
- <code>File, required</code>
- <p>The RPM specification file used to generate the package.</p>
- <p>
- See <a href="http://ftp.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html">http://ftp.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html</a>.
- </p>
- </td>
- </tr>
- <tr>
- <td><code>architecture</code></td>
- <td>
- <code>String, default to 'all'</code>
- <p>The architecture that this package target.</p>
- </td>
- </tr>
- <tr>
- <td><code>version</code>, <code>version_file</code></td>
- <td>
- <code>String or File, required</code>
- <p>
- The package version provided either inline (with <code>version</code>)
- or from a file (with <code>version_file</code>).
- </p>
- </td>
- </tr>
- <tr>
- <td><code>data</code></td>
- <td>
- <code>Files, required</code>
- <p>
- Files to include in the generated package.
- </p>
- </td>
- </tr>
- </tbody>
-</table>
diff --git a/docs/0.6.0/reference.md b/docs/0.6.0/reference.md
deleted file mode 100755
index 8a8b5f9..0000000
--- a/docs/0.6.0/reference.md
+++ /dev/null
@@ -1,750 +0,0 @@
-# rules_pkg - 0.6.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:pkg.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 form `{var}`. The values for substitution are specified through `package_variables`. | 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.
-
-<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-archive_name">archive_name</a>, <a href="#pkg_deb-kwargs">kwargs</a>)
-</pre>
-
-Creates a deb file. See pkg_deb_impl.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :------------- | :------------- | :------------- |
-| <a id="pkg_deb-name"></a>name | <p align="center"> - </p> | none |
-| <a id="pkg_deb-archive_name"></a>archive_name | <p align="center"> - </p> | <code>None</code> |
-| <a id="pkg_deb-kwargs"></a>kwargs | <p align="center"> - </p> | none |
-
-
-<!-- Generated with Stardoc: http://skydoc.bazel.build -->
-
-Rule for creating Debian packages.
-
-<a id="#pkg_deb_impl"></a>
-
-## pkg_deb_impl
-
-<pre>
-pkg_deb_impl(<a href="#pkg_deb_impl-name">name</a>, <a href="#pkg_deb_impl-architecture">architecture</a>, <a href="#pkg_deb_impl-architecture_file">architecture_file</a>, <a href="#pkg_deb_impl-breaks">breaks</a>, <a href="#pkg_deb_impl-built_using">built_using</a>, <a href="#pkg_deb_impl-built_using_file">built_using_file</a>,
- <a href="#pkg_deb_impl-conffiles">conffiles</a>, <a href="#pkg_deb_impl-conffiles_file">conffiles_file</a>, <a href="#pkg_deb_impl-config">config</a>, <a href="#pkg_deb_impl-conflicts">conflicts</a>, <a href="#pkg_deb_impl-data">data</a>, <a href="#pkg_deb_impl-depends">depends</a>, <a href="#pkg_deb_impl-depends_file">depends_file</a>, <a href="#pkg_deb_impl-description">description</a>,
- <a href="#pkg_deb_impl-description_file">description_file</a>, <a href="#pkg_deb_impl-distribution">distribution</a>, <a href="#pkg_deb_impl-enhances">enhances</a>, <a href="#pkg_deb_impl-homepage">homepage</a>, <a href="#pkg_deb_impl-maintainer">maintainer</a>, <a href="#pkg_deb_impl-out">out</a>, <a href="#pkg_deb_impl-package">package</a>,
- <a href="#pkg_deb_impl-package_file_name">package_file_name</a>, <a href="#pkg_deb_impl-package_variables">package_variables</a>, <a href="#pkg_deb_impl-postinst">postinst</a>, <a href="#pkg_deb_impl-postrm">postrm</a>, <a href="#pkg_deb_impl-predepends">predepends</a>, <a href="#pkg_deb_impl-preinst">preinst</a>, <a href="#pkg_deb_impl-prerm">prerm</a>,
- <a href="#pkg_deb_impl-priority">priority</a>, <a href="#pkg_deb_impl-provides">provides</a>, <a href="#pkg_deb_impl-recommends">recommends</a>, <a href="#pkg_deb_impl-replaces">replaces</a>, <a href="#pkg_deb_impl-section">section</a>, <a href="#pkg_deb_impl-suggests">suggests</a>, <a href="#pkg_deb_impl-templates">templates</a>, <a href="#pkg_deb_impl-triggers">triggers</a>,
- <a href="#pkg_deb_impl-urgency">urgency</a>, <a href="#pkg_deb_impl-version">version</a>, <a href="#pkg_deb_impl-version_file">version_file</a>)
-</pre>
-
-
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_deb_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_deb_impl-architecture"></a>architecture | Package architecture. Must not be used with architecture_file. | String | optional | "all" |
-| <a id="pkg_deb_impl-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_impl-breaks"></a>breaks | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-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_impl-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_impl-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_impl-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_impl-conflicts"></a>conflicts | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-depends"></a>depends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-description"></a>description | The package description. Must not be used with <code>description_file</code>. | String | optional | "" |
-| <a id="pkg_deb_impl-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_impl-distribution"></a>distribution | "distribution: See http://www.debian.org/doc/debian-policy. | String | optional | "unstable" |
-| <a id="pkg_deb_impl-enhances"></a>enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-homepage"></a>homepage | The homepage of the project. | String | optional | "" |
-| <a id="pkg_deb_impl-maintainer"></a>maintainer | The maintainer of the package. | String | required | |
-| <a id="pkg_deb_impl-out"></a>out | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_deb_impl-package"></a>package | The name of the package | String | required | |
-| <a id="pkg_deb_impl-package_file_name"></a>package_file_name | See Common Attributes. Default: "{package}-{version}-{architecture}.deb | String | optional | "" |
-| <a id="pkg_deb_impl-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_impl-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_impl-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_impl-predepends"></a>predepends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-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_impl-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_impl-provides"></a>provides | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-recommends"></a>recommends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-replaces"></a>replaces | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-suggests"></a>suggests | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| <a id="pkg_deb_impl-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_impl-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_impl-urgency"></a>urgency | "urgency: See http://www.debian.org/doc/debian-policy. | String | optional | "medium" |
-| <a id="pkg_deb_impl-version"></a>version | Package version. Must not be used with <code>version_file</code>. | String | optional | "" |
-| <a id="pkg_deb_impl-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: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 manipulation of various packaging.
-
-<a id="#pkg_tar"></a>
-
-## pkg_tar
-
-<pre>
-pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-kwargs">kwargs</a>)
-</pre>
-
-Creates a .tar file. See pkg_tar_impl.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :------------- | :------------- | :------------- |
-| <a id="pkg_tar-name"></a>name | <p align="center"> - </p> | none |
-| <a id="pkg_tar-kwargs"></a>kwargs | <p align="center"> - </p> | none |
-
-
-<!-- Generated with Stardoc: http://skydoc.bazel.build -->
-
-Rules for manipulation of various packaging.
-
-<a id="#pkg_tar_impl"></a>
-
-## pkg_tar_impl
-
-<pre>
-pkg_tar_impl(<a href="#pkg_tar_impl-name">name</a>, <a href="#pkg_tar_impl-build_tar">build_tar</a>, <a href="#pkg_tar_impl-compressor">compressor</a>, <a href="#pkg_tar_impl-compressor_args">compressor_args</a>, <a href="#pkg_tar_impl-deps">deps</a>, <a href="#pkg_tar_impl-empty_dirs">empty_dirs</a>, <a href="#pkg_tar_impl-empty_files">empty_files</a>, <a href="#pkg_tar_impl-extension">extension</a>,
- <a href="#pkg_tar_impl-files">files</a>, <a href="#pkg_tar_impl-include_runfiles">include_runfiles</a>, <a href="#pkg_tar_impl-mode">mode</a>, <a href="#pkg_tar_impl-modes">modes</a>, <a href="#pkg_tar_impl-mtime">mtime</a>, <a href="#pkg_tar_impl-out">out</a>, <a href="#pkg_tar_impl-owner">owner</a>, <a href="#pkg_tar_impl-ownername">ownername</a>, <a href="#pkg_tar_impl-ownernames">ownernames</a>, <a href="#pkg_tar_impl-owners">owners</a>,
- <a href="#pkg_tar_impl-package_base">package_base</a>, <a href="#pkg_tar_impl-package_dir">package_dir</a>, <a href="#pkg_tar_impl-package_dir_file">package_dir_file</a>, <a href="#pkg_tar_impl-package_file_name">package_file_name</a>, <a href="#pkg_tar_impl-package_variables">package_variables</a>,
- <a href="#pkg_tar_impl-portable_mtime">portable_mtime</a>, <a href="#pkg_tar_impl-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar_impl-remap_paths">remap_paths</a>, <a href="#pkg_tar_impl-srcs">srcs</a>, <a href="#pkg_tar_impl-stamp">stamp</a>, <a href="#pkg_tar_impl-strip_prefix">strip_prefix</a>, <a href="#pkg_tar_impl-symlinks">symlinks</a>)
-</pre>
-
-
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_tar_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_tar_impl-build_tar"></a>build_tar | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/private:build_tar |
-| <a id="pkg_tar_impl-compressor"></a>compressor | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar_impl-compressor_args"></a>compressor_args | - | String | optional | "" |
-| <a id="pkg_tar_impl-deps"></a>deps | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
-| <a id="pkg_tar_impl-empty_dirs"></a>empty_dirs | - | List of strings | optional | [] |
-| <a id="pkg_tar_impl-empty_files"></a>empty_files | - | List of strings | optional | [] |
-| <a id="pkg_tar_impl-extension"></a>extension | - | String | optional | "tar" |
-| <a id="pkg_tar_impl-files"></a>files | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
-| <a id="pkg_tar_impl-include_runfiles"></a>include_runfiles | - | Boolean | optional | False |
-| <a id="pkg_tar_impl-mode"></a>mode | - | String | optional | "0555" |
-| <a id="pkg_tar_impl-modes"></a>modes | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar_impl-mtime"></a>mtime | - | Integer | optional | -1 |
-| <a id="pkg_tar_impl-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_tar_impl-owner"></a>owner | - | String | optional | "0.0" |
-| <a id="pkg_tar_impl-ownername"></a>ownername | - | String | optional | "." |
-| <a id="pkg_tar_impl-ownernames"></a>ownernames | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar_impl-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar_impl-package_base"></a>package_base | - | String | optional | "./" |
-| <a id="pkg_tar_impl-package_dir"></a>package_dir | - | String | optional | "" |
-| <a id="pkg_tar_impl-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_impl-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
-| <a id="pkg_tar_impl-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_impl-portable_mtime"></a>portable_mtime | - | Boolean | optional | True |
-| <a id="pkg_tar_impl-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
-| <a id="pkg_tar_impl-remap_paths"></a>remap_paths | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar_impl-srcs"></a>srcs | - | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
-| <a id="pkg_tar_impl-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_tar_impl-strip_prefix"></a>strip_prefix | - | String | optional | "" |
-| <a id="pkg_tar_impl-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 -->
-
-Rules for manipulation of various packaging.
-
-<a id="#pkg_zip"></a>
-
-## pkg_zip
-
-<pre>
-pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-kwargs">kwargs</a>)
-</pre>
-
-Creates a .zip file. See pkg_zip_impl.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :------------- | :------------- | :------------- |
-| <a id="pkg_zip-name"></a>name | <p align="center"> - </p> | none |
-| <a id="pkg_zip-kwargs"></a>kwargs | <p align="center"> - </p> | none |
-
-
-<!-- Generated with Stardoc: http://skydoc.bazel.build -->
-
-Rules for manipulation of various packaging.
-
-<a id="#pkg_zip_impl"></a>
-
-## pkg_zip_impl
-
-<pre>
-pkg_zip_impl(<a href="#pkg_zip_impl-name">name</a>, <a href="#pkg_zip_impl-mode">mode</a>, <a href="#pkg_zip_impl-out">out</a>, <a href="#pkg_zip_impl-package_dir">package_dir</a>, <a href="#pkg_zip_impl-package_file_name">package_file_name</a>, <a href="#pkg_zip_impl-package_variables">package_variables</a>,
- <a href="#pkg_zip_impl-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip_impl-srcs">srcs</a>, <a href="#pkg_zip_impl-stamp">stamp</a>, <a href="#pkg_zip_impl-strip_prefix">strip_prefix</a>, <a href="#pkg_zip_impl-timestamp">timestamp</a>)
-</pre>
-
-
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_zip_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_zip_impl-mode"></a>mode | The default mode for all files in the archive. | String | optional | "0555" |
-| <a id="pkg_zip_impl-out"></a>out | - | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| <a id="pkg_zip_impl-package_dir"></a>package_dir | The prefix to add to all all paths in the archive. | String | optional | "/" |
-| <a id="pkg_zip_impl-package_file_name"></a>package_file_name | See Common Attributes | String | optional | "" |
-| <a id="pkg_zip_impl-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_impl-private_stamp_detect"></a>private_stamp_detect | - | Boolean | optional | False |
-| <a id="pkg_zip_impl-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_impl-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_impl-strip_prefix"></a>strip_prefix | - | String | optional | "" |
-| <a id="pkg_zip_impl-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`.
-
- Labels associated with these rules are not passed directly to packaging
- rules, instead, they should be passed to an associated `pkg_filegroup` rule,
- which in turn should be passed to packaging rules.
-
- 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 | <p align="center"> - </p> | <code>None</code> |
-| <a id="pkg_mklink-kwargs"></a>kwargs | <p align="center"> - </p> | 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 | <p align="center"> - </p> | <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 | <p align="center"> - </p> | <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: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.7.0/reference.md b/docs/0.7.0/reference.md
deleted file mode 100755
index bc67345..0000000
--- a/docs/0.7.0/reference.md
+++ /dev/null
@@ -1,686 +0,0 @@
-# rules_pkg - 0.7.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 |
-| :------------- | :------------- | :-------------: | :-------------: | :------------- |
-| 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 form `{var}`. The values for substitution are specified through `package_variables`. | 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.
-
-<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-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-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. | 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 -->
-
-Rules for manipulation of various packaging.
-
-<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`.
-
- Labels associated with these rules are not passed directly to packaging
- rules, instead, they should be passed to an associated `pkg_filegroup` rule,
- which in turn should be passed to packaging rules.
-
- 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/0.8.0/reference.md b/docs/0.8.0/reference.md
deleted file mode 100755
index 4ba55cc..0000000
--- a/docs/0.8.0/reference.md
+++ /dev/null
@@ -1,690 +0,0 @@
-# rules_pkg - 0.8.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 |
-| :------------- | :------------- | :-------------: | :-------------: | :------------- |
-| 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-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-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 | (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 -->
-
-Rules for manipulation of various packaging.
-
-<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`.
-
- Labels associated with these rules are not passed directly to packaging
- rules, instead, they should be passed to an associated `pkg_filegroup` rule,
- which in turn should be passed to packaging rules.
-
- 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/0.9.1/reference.md b/docs/0.9.1/reference.md
deleted file mode 100755
index 52293be..0000000
--- a/docs/0.9.1/reference.md
+++ /dev/null
@@ -1,689 +0,0 @@
-# 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/_config.yml b/docs/_config.yml
deleted file mode 100644
index c419263..0000000
--- a/docs/_config.yml
+++ /dev/null
@@ -1 +0,0 @@
-theme: jekyll-theme-cayman \ No newline at end of file
diff --git a/docs/_includes/head-custom.html b/docs/_includes/head-custom.html
deleted file mode 100644
index b8e0a55..0000000
--- a/docs/_includes/head-custom.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!-- _includes/head-custom.html -->
-<meta charset="utf-8">
-<link rel="shortcut icon" type="image/x-icon" href="/rules_pkg/favicon.ico">
-<!-- Setup Google Analytics below -->
-
-<!-- end custom head snippets -->
diff --git a/docs/_includes/head.html b/docs/_includes/head.html
deleted file mode 100644
index 1b2b8fe..0000000
--- a/docs/_includes/head.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<!-- _inclues/head.html -->
-<meta charset="utf-8">
-<meta name="robots" content="noindex,nofollow">
diff --git a/docs/favicon.ico b/docs/favicon.ico
deleted file mode 100755
index 507f14f..0000000
--- a/docs/favicon.ico
+++ /dev/null
Binary files differ
diff --git a/docs/index.md b/docs/index.md
deleted file mode 100644
index dc50996..0000000
--- a/docs/index.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# bazelbuild/rules_pkg
-
-Bazel rules for building tar, zip, deb, and rpm packages.
-
-Use rules-pkg-discuss@googlegroups.com for discussion.
-
-* [Examples](https://github.com/bazelbuild/rules_pkg/tree/main/examples) -
- Cookbook examples for using the rules.
-
-## Reference
-
-We are in the process of migrating from hand-written docs to generated ones.
-Some rules are fully documented in their definitions, and will have complete
-documentation in the Latest or versioned snapshots. Some rules still have
-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.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)
-* [Version 0.5.0](0.5.0/reference.md)
-* [Version 0.4.0](0.4.0/reference.md)
-* [Legacy](https://github.com/bazelbuild/rules_pkg/blob/main/pkg/docs/reference.md)
diff --git a/docs/latest.md b/docs/latest.md
deleted file mode 100755
index acd0959..0000000
--- a/docs/latest.md
+++ /dev/null
@@ -1,697 +0,0 @@
-# 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>
-
-
-
-**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-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-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-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 | - | 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_attribures. | String | optional | "0.0" |
-| <a id="pkg_tar-ownername"></a>ownername | - | String | optional | "." |
-| <a id="pkg_tar-ownernames"></a>ownernames | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-owners"></a>owners | - | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-package_dir"></a>package_dir | Prefix to be prepend to all paths written.<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-compression_level">compression_level</a>, <a href="#pkg_zip-compression_type">compression_type</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-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-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/pkg_deb.md b/docs/pkg_deb.md
deleted file mode 100755
index 6e7faa1..0000000
--- a/docs/pkg_deb.md
+++ /dev/null
@@ -1,83 +0,0 @@
-<!-- Generated with Stardoc: http://skydoc.bazel.build -->
-
-<a name="#pkg_deb_impl"></a>
-
-## pkg_deb_impl
-
-<pre>
-pkg_deb_impl(<a href="#pkg_deb_impl-name">name</a>, <a href="#pkg_deb_impl-architecture">architecture</a>, <a href="#pkg_deb_impl-architecture_file">architecture_file</a>, <a href="#pkg_deb_impl-breaks">breaks</a>, <a href="#pkg_deb_impl-built_using">built_using</a>, <a href="#pkg_deb_impl-built_using_file">built_using_file</a>,
- <a href="#pkg_deb_impl-conffiles">conffiles</a>, <a href="#pkg_deb_impl-conffiles_file">conffiles_file</a>, <a href="#pkg_deb_impl-config">config</a>, <a href="#pkg_deb_impl-conflicts">conflicts</a>, <a href="#pkg_deb_impl-data">data</a>, <a href="#pkg_deb_impl-depends">depends</a>, <a href="#pkg_deb_impl-depends_file">depends_file</a>, <a href="#pkg_deb_impl-description">description</a>,
- <a href="#pkg_deb_impl-description_file">description_file</a>, <a href="#pkg_deb_impl-distribution">distribution</a>, <a href="#pkg_deb_impl-enhances">enhances</a>, <a href="#pkg_deb_impl-homepage">homepage</a>, <a href="#pkg_deb_impl-maintainer">maintainer</a>, <a href="#pkg_deb_impl-out">out</a>, <a href="#pkg_deb_impl-package">package</a>,
- <a href="#pkg_deb_impl-package_file_name">package_file_name</a>, <a href="#pkg_deb_impl-package_variables">package_variables</a>, <a href="#pkg_deb_impl-postinst">postinst</a>, <a href="#pkg_deb_impl-postrm">postrm</a>, <a href="#pkg_deb_impl-predepends">predepends</a>, <a href="#pkg_deb_impl-preinst">preinst</a>, <a href="#pkg_deb_impl-prerm">prerm</a>,
- <a href="#pkg_deb_impl-priority">priority</a>, <a href="#pkg_deb_impl-provides">provides</a>, <a href="#pkg_deb_impl-recommends">recommends</a>, <a href="#pkg_deb_impl-replaces">replaces</a>, <a href="#pkg_deb_impl-section">section</a>, <a href="#pkg_deb_impl-suggests">suggests</a>, <a href="#pkg_deb_impl-templates">templates</a>, <a href="#pkg_deb_impl-triggers">triggers</a>,
- <a href="#pkg_deb_impl-urgency">urgency</a>, <a href="#pkg_deb_impl-version">version</a>, <a href="#pkg_deb_impl-version_file">version_file</a>)
-</pre>
-
-
-
-**ATTRIBUTES**
-
-
-| Name | Description | Type | Mandatory | Default |
-| :-------------: | :-------------: | :-------------: | :-------------: | :-------------: |
-| name | A unique name for this target. | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required | |
-| architecture | Package architecture. Must not be used with architecture_file. | String | optional | "all" |
-| 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 |
-| breaks | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| 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 | "" |
-| 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 |
-| 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 | [] |
-| 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 |
-| 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 |
-| conflicts | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| 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 | |
-| depends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| 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 |
-| description | The package description. Must not be used with <code>description_file</code>. | String | optional | "" |
-| 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 |
-| distribution | TBD | String | optional | "unstable" |
-| enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| homepage | The homepage of the project. | String | optional | "" |
-| maintainer | The maintainer of the package. | String | required | |
-| out | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required | |
-| package | The name of the package | String | required | |
-| package_file_name | See Common Attributes. Default: "%{package}-%{version}-%{architecture}.deb | String | optional | "" |
-| package_variables | See Common Attributes | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| 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 |
-| 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 |
-| predepends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| 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 |
-| 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 |
-| priority | The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities. | String | optional | "" |
-| provides | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| recommends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| replaces | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| section | The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections. | String | optional | "" |
-| suggests | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
-| 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 |
-| 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 |
-| urgency | TBD | String | optional | "medium" |
-| version | Package version. Must not be used with <code>version_file</code>. | String | optional | "" |
-| 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 |
-
-
-<a name="#pkg_deb"></a>
-
-## pkg_deb
-
-<pre>
-pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-archive_name">archive_name</a>, <a href="#pkg_deb-kwargs">kwargs</a>)
-</pre>
-
-Creates a deb file. See pkg_deb_impl.
-
-**PARAMETERS**
-
-
-| Name | Description | Default Value |
-| :-------------: | :-------------: | :-------------: |
-| name | <p align="center"> - </p> | none |
-| archive_name | <p align="center"> - </p> | <code>None</code> |
-| kwargs | <p align="center"> - </p> | none |
-
-
diff --git a/docs/robots.txt b/docs/robots.txt
deleted file mode 100644
index 5fb851d..0000000
--- a/docs/robots.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-User-agent: *
-Disallow: /0.4.0/
-Disallow: /0.5.0/
diff --git a/examples/BUILD b/examples/BUILD
deleted file mode 100644
index fdffa2a..0000000
--- a/examples/BUILD
+++ /dev/null
@@ -1 +0,0 @@
-# placeholder
diff --git a/examples/naming_package_files/BUILD b/examples/naming_package_files/BUILD
deleted file mode 100644
index 2230c19..0000000
--- a/examples/naming_package_files/BUILD
+++ /dev/null
@@ -1,168 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -*- 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")
-
-config_setting(
- name = "special_build",
- values = {"define": "SPECIAL=1"},
-)
-
-VERSION = "1"
-
-REVISION = "2"
-
-# Exposes the value of the compilation mode to the package naming.
-basic_naming(
- name = "my_naming_vars",
-
- # We make the product name a variable rather than put it in every rule.
- # This technique can be useful if you need to create packages in many
- # different formats but have not decided on the final naming yet. You
- # can use a placeholder and change it on one location.
- product_name = "RulesPkgExamples",
- revision = REVISION,
-
- # Use a config_setting flag to specify part of the package name.
- # In this example, we define the config_setting based on a command line
- # flag. Example
- # bazel build :example1
- # bazel build :example1 --define=SPECIAL=1
- special_build = select({
- ":special_build": "-IsSpecial",
- "//conditions:default": "",
- }),
-
- # Explicit values to use in all package names
- version = VERSION,
-)
-
-# Try building with various flag combinations to explore.
-# bazel build :example1
-# bazel build :example1 -c dbg
-# bazel build :example1 -define=SPECIAL=1
-# bazel build :example1 -c dbg --define=SPECIAL=1
-pkg_tar(
- name = "example1",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "example1-{product_name}-{target_cpu}-{compilation_mode}{special_build}.tar",
- package_variables = ":my_naming_vars",
-)
-
-# This example shows that in the same way as package_file_name, the inner folder structure of the archive
-# specified with package_dir attribute also can be controlled by the package_variables attribute.
-pkg_tar(
- name = "example2",
- srcs = [
- ":BUILD",
- ],
- package_dir = "example1/{product_name}/{target_cpu}/{compilation_mode}{special_build}",
- package_file_name = "example2-{product_name}-{target_cpu}-{compilation_mode}{special_build}.tar",
- package_variables = ":my_naming_vars",
-)
-
-#
-# names_from_toolchains() extracts variables from the CC toolchain, like `compiler`.
-#
-names_from_toolchains(
- name = "toolchain_vars",
-)
-
-pkg_tar(
- name = "using_toolchain_elements",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "example-{cc_cpu}-{compiler}-{compilation_mode}.tar",
- package_variables = ":toolchain_vars",
-)
-
-#
-#
-#
-pkg_tar(
- name = "using_variable_from_ctx_var",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "using_variable_from_ctx_var-{TARGET_CPU}-{COMPILATION_MODE}.tar",
-)
-
-#
-# We can also use the familiar $(var) syntax.
-#
-pkg_tar(
- name = "using_make_variable_syntax",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "using_make_variable_syntax-$(TARGET_CPU)-$(COMPILATION_MODE).tar",
-)
-
-#
-# Demonstrate how the .changes file defaults based on package_file_name.
-#
-pkg_deb(
- name = "a_deb_package",
- data = ":example1",
- description = "what it does",
- maintainer = "someone@somewhere.com",
- package = "foo-tools",
- # Note: We could not know target_cpu at the time I write this rule.
- package_file_name = "foo-tools_{version}-{revision}_{target_cpu}.deb",
- package_variables = ":my_naming_vars",
- version = VERSION,
-)
-
-# This does not actually build anything. It writes a skelaton of a script that
-# could upload the .deb and .changes pair. You should see something like
-# $ cat bazel-bin/upload.sh
-# # Uploading foo_tools-1-k8
-# gsutil cp bazel-out/k8-fastbuild/bin/foo_tools-1-k8.deb gs://my_mirror/foo_tools-1-k8.deb
-# gsutil cp bazel-out/k8-fastbuild/bin/foo_tools-1-k8.changes gs://my_mirror/foo_tools-1-k8.changes
-debian_upload(
- name = "upload",
- out = "upload.sh",
- host = "my_mirror",
- # Refer to the target label, without having to know the final file name.
- package = ":a_deb_package",
-)
-
-#
-# Demonstrate how we can use a value from the command line in a package name.
-#
-# bazel build --//:name_part_from_command_line=bar :tarball_that_needs_a_name
-# ls bazel-bin/foo-bar.tar
-name_part_from_command_line(
- name = "name_part_from_command_line",
- # We use a harmless default value so that the build succeeds all the time.
- build_setting_default = "@set_me@",
-)
-
-pkg_tar(
- name = "tarball_that_needs_a_name",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "foo-{name_part}.tar",
- package_variables = ":name_part_from_command_line",
-)
diff --git a/examples/naming_package_files/MODULE.bazel b/examples/naming_package_files/MODULE.bazel
deleted file mode 100644
index 705b549..0000000
--- a/examples/naming_package_files/MODULE.bazel
+++ /dev/null
@@ -1,11 +0,0 @@
-module(
- name = "rules_pkg_examples",
- version = "0.0.1",
-)
-
-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
deleted file mode 100644
index be5819a..0000000
--- a/examples/naming_package_files/WORKSPACE
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rules_pkg_examples")
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-local_repository(
- name = "rules_pkg",
- path = "../..",
-)
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
-
-http_archive(
- name = "rules_cc",
- url = "https://github.com/bazelbuild/rules_cc/archive/b1c40e1de81913a3c40e5948f78719c28152486d.zip",
- sha256 = "d0c573b94a6ef20ef6ff20154a23d0efcb409fb0e1ff0979cec318dfe42f0cdd",
- strip_prefix = "rules_cc-b1c40e1de81913a3c40e5948f78719c28152486d",
-)
diff --git a/examples/naming_package_files/my_package_name.bzl b/examples/naming_package_files/my_package_name.bzl
deleted file mode 100644
index e4f6d37..0000000
--- a/examples/naming_package_files/my_package_name.bzl
+++ /dev/null
@@ -1,112 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""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")
-
-def _basic_naming_impl(ctx):
- values = {}
-
- # Copy attributes from the rule to the provider
- values["product_name"] = ctx.attr.product_name
- values["version"] = ctx.attr.version
- values["revision"] = ctx.attr.revision
- values["special_build"] = ctx.attr.special_build
-
- # Add some well known variables from the rule context.
- values["target_cpu"] = ctx.var.get("TARGET_CPU")
- values["compilation_mode"] = ctx.var.get("COMPILATION_MODE")
-
- return PackageVariablesInfo(values = values)
-
-#
-# A rule to inject variables from the build file into package names.
-#
-basic_naming = rule(
- implementation = _basic_naming_impl,
- attrs = {
- "product_name": attr.string(
- doc = "Placeholder for our final product name.",
- ),
- "revision": attr.string(
- doc = "Placeholder for our release revision.",
- ),
- "version": attr.string(
- doc = "Placeholder for our release version.",
- ),
- "special_build": attr.string(
- doc = "Indicates that we have built with a 'special' option.",
- ),
- },
-)
-
-def _names_from_toolchains_impl(ctx):
- values = {}
-
- # TODO(https://github.com/bazelbuild/bazel/issues/7260): Switch from
- # calling find_cc_toolchain to direct lookup via the name.
- # cc_toolchain = ctx.toolchains["@rules_cc//cc:toolchain_type"]
- cc_toolchain = find_cc_toolchain(ctx)
-
- # compiler is uninformative. Use the name of the executable
- values["compiler"] = cc_toolchain.compiler_executable.split("/")[-1]
- values["cc_cpu"] = cc_toolchain.cpu
- values["libc"] = cc_toolchain.libc
-
- values["compilation_mode"] = ctx.var.get("COMPILATION_MODE")
-
- return PackageVariablesInfo(values = values)
-
-#
-# 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 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
- # _cc_toolchain attribute.
- attrs = {
- "_cc_toolchain": attr.label(
- default = Label(
- "@rules_cc//cc:current_cc_toolchain",
- ),
- ),
- },
- toolchains = ["@rules_cc//cc:toolchain_type"],
- incompatible_use_toolchain_transition = True,
-)
-
-#
-# Using a command line build setting to name a package.
-#
-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
- return PackageVariablesInfo(values = values)
-
-#
-# Creating this build_setting defines a flag the user can set.
-#
-name_part_from_command_line = rule(
- implementation = _name_part_from_command_line_naming_impl,
- # Note that the default value comes from the rule instantiation.
- build_setting = config.string(flag = True),
-)
diff --git a/examples/naming_package_files/package_upload.bzl b/examples/naming_package_files/package_upload.bzl
deleted file mode 100644
index a28dafa..0000000
--- a/examples/naming_package_files/package_upload.bzl
+++ /dev/null
@@ -1,50 +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.
-"""Example of how we can use OutputGroupInfo to find an output name."""
-
-def _debian_upload_impl(ctx):
- # Find out the basename of the deb file we created.
- ogi = ctx.attr.package[OutputGroupInfo]
- deb = ogi.deb.to_list()[0]
- changes = ogi.changes.to_list()[0]
- package_basename = deb.basename.split(".")[0]
- content = ["# Uploading %s" % package_basename]
- for f in [deb, changes]:
- if f.basename.startswith(package_basename):
- content.append("gsutil cp %s gs://%s/%s" % (
- f.path,
- ctx.attr.host,
- f.basename,
- ))
- ctx.actions.write(ctx.outputs.out, "\n".join(content))
-
-debian_upload = rule(
- implementation = _debian_upload_impl,
- doc = """A demonstraion of consuming OutputGroupInfo to get a file name.""",
- attrs = {
- "package": attr.label(
- doc = "Package to upload",
- mandatory = True,
- providers = [OutputGroupInfo],
- ),
- "host": attr.string(
- doc = "Host to upload to",
- mandatory = True,
- ),
- "out": attr.output(
- doc = "Script file to create.",
- mandatory = True,
- ),
- },
-)
diff --git a/examples/naming_package_files/readme.md b/examples/naming_package_files/readme.md
deleted file mode 100644
index 14b3234..0000000
--- a/examples/naming_package_files/readme.md
+++ /dev/null
@@ -1,107 +0,0 @@
-# Examples of how to name packages using build time configuration.
-
-## Examples
-
-The examples below only show snippets of the relevant technique.
-See the BUILD file for the complete source.
-
-### Using command line flags to modify a package name
-
-We can use a `config_setting` to capture the command line flag and then
-`select()` on that to drop a part into into the name.
-
-```python
-config_setting(
- name = "special_build",
- values = {"define": "SPECIAL=1"},
-)
-
-my_package_naming(
- name = "my_naming_vars",
- special_build = select({
- ":special_build": "-IsSpecial",
- "//conditions:default": "",
- }),
-)
-```
-
-```shell
-bazel build :example1
-ls -l bazel-bin/example1.tar bazel-bin/RulesPkgExamples-k8-fastbuild.tar
-```
-
-```shell
-bazel build :example1 --define=SPECIAL=1
-ls -l bazel-bin/example1*.tar
-```
-
-### Using values from a toolchain in a package name.
-
-The rule providing the naming can depend on toolchains just like a `*_library`
-or `*_binary` rule
-
-```python
-def _names_from_toolchains_impl(ctx):
- values = {}
- cc_toolchain = find_cc_toolchain(ctx)
- values['cc_cpu'] = cc_toolchain.cpu
- return PackageVariablesInfo(values = values)
-
-names_from_toolchains = rule(
- implementation = _names_from_toolchains_impl,
- attrs = {
- "_cc_toolchain": attr.label(
- default = Label(
- "@rules_cc//cc:current_cc_toolchain",
- ),
- ),
- },
- toolchains = ["@rules_cc//cc:toolchain_type"],
-)
-```
-
-```shell
-bazel build :example2
-ls -l bazel-bin/example2*.tar
-```
-
-### Debian package names
-
-Debian package names are of the form `<package>_<version>-<revision>_<arch>.deb`.
-
-One way you might do that is shown in this snipped from the `BUILD` file.
-
-```python
-VERSION = "1"
-REVISION = "2"
-
-basic_naming(
- name = "my_naming_vars",
-
- version = VERSION,
- revision = REVISION,
- ...
-)
-
-pkg_deb(
- name = "a_deb_package",
- package = "foo-tools",
- ...
- # Note: target_cpu comes from the --cpu on the command line, and dows not
- # have to be stated in the BUILD file.
- package_file_name = "foo-tools_{version}-{revision}_{target_cpu}.deb",
- package_variables = ":my_naming_vars",
- version = VERSION,
-)
-```
-
-Try building `bazel build :a_deb_package` then examine the results. Note that
-the .deb out file has the correctly formed name, while the target itself is
-a symlink to that file.
-
-```console
-$ ls -l bazel-bin/a_deb_package.deb bazel-bin/foo-tools_1-2_k8.deb
-lrwxrwxrwx 1 user primarygroup 163 Jul 26 12:56 bazel-bin/a_deb_package.deb -> /home/user/.cache/bazel/_bazel_user/.../execroot/rules_pkg_examples/bazel-out/k8-fastbuild/bin/foo-tools_1-2_k8.deb
--r-xr-xr-x 1 user primarygroup 10662 Jul 26 12:56 bazel-bin/foo-tools_1-2_k8.deb
-```
-
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/prebuilt_rpmbuild/BUILD
deleted file mode 100644
index 5b8f762..0000000
--- a/examples/prebuilt_rpmbuild/BUILD
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -*- coding: utf-8 -*-
-
-load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")
-
-pkg_rpm(
- name = "test-rpm",
- data = [
- "BUILD",
- "WORKSPACE",
- "readme.md",
- "test_rpm.spec",
- ],
- release = "0",
- spec_file = "test_rpm.spec",
- version = "1",
-)
-
-# If you have rpmbuild, you probably have rpm2cpio too.
-# Feature idea: Add rpm2cpio and cpio to the rpmbuild toolchain
-genrule(
- name = "inspect_content",
- srcs = [":test-rpm"],
- outs = ["content.txt"],
- cmd = "rpm2cpio $(locations :test-rpm) | cpio -ivt >$@",
-)
diff --git a/examples/prebuilt_rpmbuild/WORKSPACE b/examples/prebuilt_rpmbuild/WORKSPACE
deleted file mode 100644
index 4fc8a59..0000000
--- a/examples/prebuilt_rpmbuild/WORKSPACE
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rules_pkg_example_prebuilt_rpmbuild")
-
-local_repository(
- name = "rules_pkg",
- path = "../..",
-)
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
-
-load("//local:rpmbuild.bzl", "register_my_rpmbuild_toolchain")
-
-register_my_rpmbuild_toolchain()
diff --git a/examples/prebuilt_rpmbuild/local/BUILD b/examples/prebuilt_rpmbuild/local/BUILD
deleted file mode 100644
index 7c273bf..0000000
--- a/examples/prebuilt_rpmbuild/local/BUILD
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@rules_pkg//toolchains/rpm:rpmbuild.bzl", "rpmbuild_toolchain")
-
-rpmbuild_toolchain(
- name = "prebuilt_rpmbuild",
- # You could also point to a target that builds rpmbuild from source.
- label = ":rpmbuild_binary",
-)
-
-toolchain(
- name = "local_rpmbuild",
- toolchain = ":prebuilt_rpmbuild",
- toolchain_type = "@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type",
-)
diff --git a/examples/prebuilt_rpmbuild/local/rpmbuild.bzl b/examples/prebuilt_rpmbuild/local/rpmbuild.bzl
deleted file mode 100644
index cb34178..0000000
--- a/examples/prebuilt_rpmbuild/local/rpmbuild.bzl
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Register a prebuilt rpmbuild."""
-
-# buildifier: disable=unnamed-macro
-def register_my_rpmbuild_toolchain():
- """Register a prebuilt rpmbuild."""
- native.register_toolchains("//local:local_rpmbuild")
diff --git a/examples/prebuilt_rpmbuild/local/rpmbuild_binary b/examples/prebuilt_rpmbuild/local/rpmbuild_binary
deleted file mode 100755
index 8015e88..0000000
--- a/examples/prebuilt_rpmbuild/local/rpmbuild_binary
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-
-echo Replace me with a real rpmbuild
diff --git a/examples/prebuilt_rpmbuild/readme.md b/examples/prebuilt_rpmbuild/readme.md
deleted file mode 100644
index 0f1c347..0000000
--- a/examples/prebuilt_rpmbuild/readme.md
+++ /dev/null
@@ -1,10 +0,0 @@
-# Using a prebuilt rpmbuild instead of the system one.
-
-## To use
-
-```
-cp /usr/bin/rpmbuild local/rpmbuild_binary
-bazel build :*
-rpm2cpio bazel-bin/test-rpm.rpm | cpio -ivt
-cat bazel-bin/content.txt
-```
diff --git a/examples/prebuilt_rpmbuild/test_rpm.spec b/examples/prebuilt_rpmbuild/test_rpm.spec
deleted file mode 100644
index c52dc24..0000000
--- a/examples/prebuilt_rpmbuild/test_rpm.spec
+++ /dev/null
@@ -1,24 +0,0 @@
-Name: example
-Version: 0
-Release: 1
-Summary: Example .spec file
-License: Apache License, v2.0
-
-# Do not try to use magic to determine file types
-%define __spec_install_post %{nil}
-# Do not die because we give it more input files than are in the files section
-%define _unpackaged_files_terminate_build 0
-
-%description
-This is a package description.
-
-%build
-
-%install
-cp WORKSPACE BUILD readme.md test_rpm.spec %{buildroot}/
-
-%files
-/WORKSPACE
-/BUILD
-/readme.md
-/test_rpm.spec
diff --git a/examples/readme.md b/examples/readme.md
deleted file mode 100644
index baa5dad..0000000
--- a/examples/readme.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# rules_pkg - Examples
-
-## TBD
diff --git a/examples/rich_structure/BUILD b/examples/rich_structure/BUILD
deleted file mode 100644
index 6bff0f6..0000000
--- a/examples/rich_structure/BUILD
+++ /dev/null
@@ -1,69 +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("@rules_pkg//pkg:mappings.bzl", "pkg_attributes", "pkg_filegroup", "pkg_files", "pkg_mkdirs", "strip_prefix")
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-load("@rules_pkg//pkg:zip.bzl", "pkg_zip")
-
-# This is the top level BUILD for a hypothetical project Foo. It has a client,
-# a server, docs, and runtime directories needed by the server.
-# We want to ship it for Linux, macOS, and Windows.
-#
-# This example shows various techniques for specifying how your source tree
-# transforms into the installation tree. As such, it favors using a lot of
-# distict features, at the expense of uniformity.
-
-pkg_files(
- name = "share_doc",
- srcs = [
- "//docs",
- ],
- # Where it should be in the final package
- prefix = "usr/share/doc/foo",
- # Required, but why?: see #354
- strip_prefix = strip_prefix.from_pkg(),
-)
-
-pkg_filegroup(
- name = "manpages",
- srcs = [
- "//src/client:manpages",
- "//src/server:manpages",
- ],
- prefix = "/usr/share",
-)
-
-pkg_tar(
- name = "foo_tar",
- srcs = [
- "README.txt",
- ":manpages",
- ":share_doc",
- "//resources/l10n:all",
- "//src/client:arch",
- "//src/server:arch",
- ],
-)
-
-pkg_zip(
- name = "foo_zip",
- srcs = [
- "README.txt",
- ":manpages",
- ":share_doc",
- "//resources/l10n:all",
- "//src/client:arch",
- "//src/server:arch",
- ],
-)
diff --git a/examples/rich_structure/README.md b/examples/rich_structure/README.md
deleted file mode 100644
index ed800a0..0000000
--- a/examples/rich_structure/README.md
+++ /dev/null
@@ -1,50 +0,0 @@
-# Example of how pkg_* rules can compose to create a rich package structure.
-
-## Use case
-
-Our use case is building a distribution package that represents a typical \*nix tool.
-That would include elements such as:
-
-- A main program that requires runtime support files
-- Associated documentation
-- A service associated with the main binary
-- Associate configuration files
-
-where each elements must be installed in a specific place in the file system.
-The final package might look like this for Linux:
-
-```
-etc/foo.rc
-etc/food.conf
-sbin/food
-usr/bin/foo # symlink to ../share/foo/bin/foo
-usr/bin/fooctl # symlink to ../share/foo/bin/fooctl
-usr/bin/foocheck
-usr/lib/foo/runtime.so
-usr/lib/foo/runtime.so
-usr/share/doc/foo/copyright
-usr/share/doc/foo/README.txt
-usr/share/doc/foo/foo.html
-usr/share/man/man1/foo.1.gz
-usr/share/man/man1/fooctl.1.gz
-usr/share/man/man8/food.8.gz
-usr/share/foo/bin/foo
-usr/share/foo/bin/fooctl
-usr/share/foo/bar.rules
-usr/share/foo/baz.rules
-usr/share/foo/locale/foo/en/msgs.cat
-usr/share/foo/locale/foo/it/msgs.cat
-usr/share/foo/locale/fooctl/en/msgs.cat
-usr/share/foo/locale/fooctl/it/msgs.cat
-usr/share/foo/locale/food/en/msgs.cat
-usr/share/foo/locale/food/it/msgs.cat
-var/tmp/foo
-var/tmp/foo/queue
-```
-
-For macOS, it would be mostly the same, but files under `usr/share/foo` would
-move to `Library/Foo`.
-
-To emulate reality better, the source tree is organized in a way that is
-convenient for the developers. This example illustrates techniques create
-the desired final structure.
diff --git a/examples/rich_structure/README.txt b/examples/rich_structure/README.txt
deleted file mode 100644
index 527b227..0000000
--- a/examples/rich_structure/README.txt
+++ /dev/null
@@ -1 +0,0 @@
-This is the Foo system. It does not do anything.
diff --git a/examples/rich_structure/WORKSPACE b/examples/rich_structure/WORKSPACE
deleted file mode 100644
index e2cdda3..0000000
--- a/examples/rich_structure/WORKSPACE
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rich_structure")
-
-local_repository(
- name = "rules_pkg",
- path = "../..",
-)
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
diff --git a/examples/rich_structure/copyright b/examples/rich_structure/copyright
deleted file mode 100644
index 05cf96c..0000000
--- a/examples/rich_structure/copyright
+++ /dev/null
@@ -1,13 +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.
diff --git a/examples/rich_structure/docs/BUILD b/examples/rich_structure/docs/BUILD
deleted file mode 100644
index a0868d3..0000000
--- a/examples/rich_structure/docs/BUILD
+++ /dev/null
@@ -1,7 +0,0 @@
-# Some docs
-
-filegroup(
- name = "docs",
- srcs = glob(["**/*"], exclude=["BUILD"]),
- visibility = ["//visibility:public"],
-)
diff --git a/examples/rich_structure/docs/index.md b/examples/rich_structure/docs/index.md
deleted file mode 100644
index 29e7b82..0000000
--- a/examples/rich_structure/docs/index.md
+++ /dev/null
@@ -1,4 +0,0 @@
-# The foo system
-
-Some text
-
diff --git a/examples/rich_structure/docs/reference/index.md b/examples/rich_structure/docs/reference/index.md
deleted file mode 100644
index 040a47d..0000000
--- a/examples/rich_structure/docs/reference/index.md
+++ /dev/null
@@ -1 +0,0 @@
-# A reference manual
diff --git a/examples/rich_structure/docs/user_guide.md b/examples/rich_structure/docs/user_guide.md
deleted file mode 100644
index 9e1e43a..0000000
--- a/examples/rich_structure/docs/user_guide.md
+++ /dev/null
@@ -1 +0,0 @@
-# More docs
diff --git a/examples/rich_structure/foo_defs.bzl b/examples/rich_structure/foo_defs.bzl
deleted file mode 100644
index 4dbacbb..0000000
--- a/examples/rich_structure/foo_defs.bzl
+++ /dev/null
@@ -1,21 +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.
-"""Shared bzl constants and methods for building the Foo product."""
-
-shared_object_path_selector = {
- "@platforms//os:linux": "/usr/share/foo",
- "@platforms//os:macos": "/Library/Foo",
- "@platforms//os:windows": "/Program Files/Foo",
- "//conditions:default": "/usr/local/share/foo",
-}
diff --git a/examples/rich_structure/resources/l10n/BUILD b/examples/rich_structure/resources/l10n/BUILD
deleted file mode 100644
index 823cab8..0000000
--- a/examples/rich_structure/resources/l10n/BUILD
+++ /dev/null
@@ -1,74 +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("@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.
-
-# Typically, you would have a lot of these and drop them in, so using a glob
-# to gather them is appropriate.
-pkg_files(
- name = "messages",
- srcs = glob(["**/msg.cat"]),
- attributes = pkg_attributes(
- # We know they should be read only. We don't know who should own them.
- mode = "0444",
- ),
- strip_prefix = strip_prefix.from_pkg(),
-)
-
-# Use the English catalog again under a different name.
-# This is a trick for reusing a single source file or files in multiple places
-# in the output tree. Here we place foo/en/msg.cat under foo/en_GB/msg.cat.
-# This is more efficient than having a rule copy the files to a new location.
-# The final package builder is passed just the information that the original
-# srcs should be placed in the output archive under this other name.
-pkg_files(
- name = "extra_messages",
- srcs = ["foo/en/msg.cat"],
- attributes = pkg_attributes(
- mode = "0444",
- ),
- prefix = "foo/en_GB",
- strip_prefix = strip_prefix.from_pkg(),
-)
-
-# This gathers together all our message catalogs, and adds a prefix based
-# on the target OS
-pkg_filegroup(
- name = "all",
- srcs = [
- ":extra_messages",
- ":messages",
- ],
- prefix = select(shared_object_path_selector) + "/locale",
- visibility = ["//visibility:public"],
-)
-
-pkg_files(
- name = "mraw",
- srcs = glob(["**/msg.cat"]),
- attributes = pkg_attributes(
- mode = "0444",
- ),
- strip_prefix = strip_prefix.from_root("resources"),
-)
-
-pkg_tar(
- name = "raw",
- srcs = [":mraw"],
-)
diff --git a/examples/rich_structure/resources/l10n/foo/en/msg.cat b/examples/rich_structure/resources/l10n/foo/en/msg.cat
deleted file mode 100644
index d8341c4..0000000
--- a/examples/rich_structure/resources/l10n/foo/en/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 hello
diff --git a/examples/rich_structure/resources/l10n/foo/it/msg.cat b/examples/rich_structure/resources/l10n/foo/it/msg.cat
deleted file mode 100644
index d1f51b7..0000000
--- a/examples/rich_structure/resources/l10n/foo/it/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 ciao
diff --git a/examples/rich_structure/resources/l10n/fooctl/en/msg.cat b/examples/rich_structure/resources/l10n/fooctl/en/msg.cat
deleted file mode 100644
index 6048081..0000000
--- a/examples/rich_structure/resources/l10n/fooctl/en/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 forty-two
diff --git a/examples/rich_structure/resources/l10n/fooctl/it/msg.cat b/examples/rich_structure/resources/l10n/fooctl/it/msg.cat
deleted file mode 100644
index 17b018e..0000000
--- a/examples/rich_structure/resources/l10n/fooctl/it/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 quarantadue
diff --git a/examples/rich_structure/resources/l10n/food/en/msg.cat b/examples/rich_structure/resources/l10n/food/en/msg.cat
deleted file mode 100644
index 2543997..0000000
--- a/examples/rich_structure/resources/l10n/food/en/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 help!
diff --git a/examples/rich_structure/resources/l10n/food/it/msg.cat b/examples/rich_structure/resources/l10n/food/it/msg.cat
deleted file mode 100644
index 286045c..0000000
--- a/examples/rich_structure/resources/l10n/food/it/msg.cat
+++ /dev/null
@@ -1 +0,0 @@
-100 aiuto!
diff --git a/examples/rich_structure/src/client/BUILD b/examples/rich_structure/src/client/BUILD
deleted file mode 100644
index 28a84d5..0000000
--- a/examples/rich_structure/src/client/BUILD
+++ /dev/null
@@ -1,109 +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("@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")
-
-cc_library(
- name = "foolib",
- srcs = [
- "foocore.cc",
- ],
- hdrs = [
- "foo.h",
- ],
-)
-
-cc_binary(
- name = "foo",
- srcs = [
- "foo.cc",
- ],
- # TODO(aiuto): How to we get the data to be in /usr/share/foo?
- # See #153 as a starting point for runfiles discussions.
- data = [
- "bar.rules",
- "baz.rules",
- ],
- deps = [
- ":foolib",
- ],
-)
-
-cc_binary(
- name = "fooctl",
- srcs = [
- "fooctl.cc",
- ],
-)
-
-pkg_files(
- name = "binary",
- srcs = [
- ":foo",
- ":fooctl",
- ],
- # Where it should be in the final package
- prefix = select(shared_object_path_selector) + "/bin",
- # Should this work?
- # runfiles_prefix = select(shared_object_path_selector) + "/bin/runfiles",
-)
-
-pkg_files(
- name = "runtime",
- srcs = [
- ":foolib",
- ],
- prefix = "usr/lib/foo",
-)
-
-pkg_tar(
- name = "man",
- srcs = [
- "foo.1",
- ],
- out = "foo.1.gz",
- extension = ".gz",
-)
-
-pkg_files(
- name = "manpages",
- srcs = [
- ":man",
- ],
- attributes = pkg_attributes(
- group = "man",
- mode = "0444",
- owner = "man",
- ),
- prefix = "man/man1",
- visibility = ["//visibility:public"],
-)
-
-pkg_mklink(
- name = "usr_bin",
- link_name = "usr/bin/foo",
- target = select(shared_object_path_selector) + "/bin/foo",
-)
-
-pkg_filegroup(
- name = "arch",
- srcs = [
- ":binary",
- ":runtime",
- ":usr_bin",
- ],
- visibility = ["//visibility:public"],
-)
diff --git a/examples/rich_structure/src/client/bar.rules b/examples/rich_structure/src/client/bar.rules
deleted file mode 100644
index 5716ca5..0000000
--- a/examples/rich_structure/src/client/bar.rules
+++ /dev/null
@@ -1 +0,0 @@
-bar
diff --git a/examples/rich_structure/src/client/baz.rules b/examples/rich_structure/src/client/baz.rules
deleted file mode 100644
index 7601807..0000000
--- a/examples/rich_structure/src/client/baz.rules
+++ /dev/null
@@ -1 +0,0 @@
-baz
diff --git a/examples/rich_structure/src/client/foo.1 b/examples/rich_structure/src/client/foo.1
deleted file mode 100644
index 5390a5e..0000000
--- a/examples/rich_structure/src/client/foo.1
+++ /dev/null
@@ -1,13 +0,0 @@
-.TH FOO 1 local
-.SH NAME
-foo \- create and manipulate foos
-.SH SYNOPSIS
-.ll +8
-.B foo
-[
-.I "name \&..."
-]
-.ll -8
-.SH DESCRIPTION
-.I Foo
-does nothing.
diff --git a/examples/rich_structure/src/client/foo.cc b/examples/rich_structure/src/client/foo.cc
deleted file mode 100644
index e3c023c..0000000
--- a/examples/rich_structure/src/client/foo.cc
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "foo.h"
-
-int main(int argc, char* argv[]) {
- return foo_core(42);
-}
diff --git a/examples/rich_structure/src/client/foo.h b/examples/rich_structure/src/client/foo.h
deleted file mode 100644
index f1944b5..0000000
--- a/examples/rich_structure/src/client/foo.h
+++ /dev/null
@@ -1 +0,0 @@
-int foo_core(int);
diff --git a/examples/rich_structure/src/client/foocore.cc b/examples/rich_structure/src/client/foocore.cc
deleted file mode 100644
index 1deb5c4..0000000
--- a/examples/rich_structure/src/client/foocore.cc
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "foo.h"
-
-int foo_core(int) {
- return 0;
-}
diff --git a/examples/rich_structure/src/client/fooctl.cc b/examples/rich_structure/src/client/fooctl.cc
deleted file mode 100644
index 5822685..0000000
--- a/examples/rich_structure/src/client/fooctl.cc
+++ /dev/null
@@ -1,6 +0,0 @@
-
-#include <iostream>
-
-int main(int argc, char* argv[]) {
- std::cout << "fooctl does nothing" << std::endl;
-}
diff --git a/examples/rich_structure/src/server/BUILD b/examples/rich_structure/src/server/BUILD
deleted file mode 100644
index aaf9383..0000000
--- a/examples/rich_structure/src/server/BUILD
+++ /dev/null
@@ -1,95 +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("@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",
- srcs = [
- "foocore.cc",
- ],
- hdrs = [
- "foo.h",
- ],
-)
-
-cc_binary(
- name = "food",
- srcs = [
- "food.cc",
- ],
- data = [
- ":foolib",
- ],
-)
-
-pkg_files(
- name = "binary",
- srcs = [
- ":food",
- ],
- attributes = pkg_attributes(
- group = "root",
- mode = "0551",
- owner = "root",
- ),
- prefix = "/usr/sbin",
-)
-
-pkg_tar(
- name = "mansrc",
- srcs = [
- "food.8",
- ],
- out = "food.8.gz",
- extension = ".gz",
-)
-
-pkg_files(
- name = "manpages",
- srcs = [
- ":mansrc",
- ],
- attributes = pkg_attributes(
- group = "man",
- mode = "0444",
- owner = "man",
- ),
- prefix = "man/man8",
- visibility = ["//visibility:public"],
-)
-
-pkg_mkdirs(
- name = "runtime",
- attributes = pkg_attributes(
- group = "bin",
- mode = "0771",
- owner = "foo",
- ),
- dirs = [
- "/var/tmp/foo",
- "/var/tmp/foo/queue",
- ],
-)
-
-pkg_filegroup(
- name = "arch",
- srcs = [
- ":binary",
- ":runtime",
- ],
- visibility = ["//visibility:public"],
-)
diff --git a/examples/rich_structure/src/server/foo.h b/examples/rich_structure/src/server/foo.h
deleted file mode 100644
index d1c445d..0000000
--- a/examples/rich_structure/src/server/foo.h
+++ /dev/null
@@ -1 +0,0 @@
-/* foo.h */
diff --git a/examples/rich_structure/src/server/foocore.cc b/examples/rich_structure/src/server/foocore.cc
deleted file mode 100644
index 68b7879..0000000
--- a/examples/rich_structure/src/server/foocore.cc
+++ /dev/null
@@ -1 +0,0 @@
-int foocore = 1;
diff --git a/examples/rich_structure/src/server/food.8 b/examples/rich_structure/src/server/food.8
deleted file mode 100644
index cb4c838..0000000
--- a/examples/rich_structure/src/server/food.8
+++ /dev/null
@@ -1,10 +0,0 @@
-.TH FOOD 1 local
-.SH NAME
-food \- the foo daemon
-.SH SYNOPSIS
-.ll +8
-.B food
-.ll -8
-.SH DESCRIPTION
-.I Food
-serves the foo system.
diff --git a/examples/rich_structure/src/server/food.cc b/examples/rich_structure/src/server/food.cc
deleted file mode 100644
index 6559531..0000000
--- a/examples/rich_structure/src/server/food.cc
+++ /dev/null
@@ -1,5 +0,0 @@
-#include <iostream>
-
-int main(int argc, char* argv[]) {
- std::cout << "food does nothing" << std::endl;
-}
diff --git a/examples/time_stamping/BUILD b/examples/time_stamping/BUILD
deleted file mode 100644
index 91d0121..0000000
--- a/examples/time_stamping/BUILD
+++ /dev/null
@@ -1,41 +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.
-# -*- coding: utf-8 -*-
-
-licenses(["notice"])
-
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-pkg_tar(
- name = "never_stamped",
- srcs = [
- ":BUILD",
- ],
-)
-
-pkg_tar(
- name = "always_stamped",
- srcs = [
- ":BUILD",
- ],
- stamp = 1,
-)
-
-pkg_tar(
- name = "controlled_by_stamp_option",
- srcs = [
- ":BUILD",
- ],
- stamp = -1,
-)
diff --git a/examples/time_stamping/WORKSPACE b/examples/time_stamping/WORKSPACE
deleted file mode 100644
index d170970..0000000
--- a/examples/time_stamping/WORKSPACE
+++ /dev/null
@@ -1,24 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rules_pkg_examples")
-
-local_repository(
- name = "rules_pkg",
- path = "../..",
-)
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
diff --git a/examples/time_stamping/readme.md b/examples/time_stamping/readme.md
deleted file mode 100644
index 39d2edf..0000000
--- a/examples/time_stamping/readme.md
+++ /dev/null
@@ -1,46 +0,0 @@
-# Examples of how time stamping works.
-
-## How it works
-
-Target declarations may use the `stamp` attribute to control
-the time stamping of files in an archive. The behavior follows
-the pattern of the cc_binary rule:
-
-https://docs.bazel.build/versions/main/be/c-cpp.html#cc_binary
-
-Read the BUILD file for more details.
-
-## Try this
-
-```
-bazel build :*
-for tarball in bazel-bin/*.tar ; do
- echo ==== $tarball
- tar tvf $tarball
-done
-
-bazel build :* --stamp=1
-for tarball in bazel-bin/*.tar ; do
- echo ==== $tarball
- tar tvf $tarball
-done
-```
-
-You should see something like:
-```
-INFO: Build completed successfully, 3 total actions
-==== bazel-bin/always_stamped.tar
--r-xr-xr-x 0 0 0 968 May 3 17:34 BUILD
-==== bazel-bin/controlled_by_stamp_option.tar
--r-xr-xr-x 0 0 0 968 Dec 31 1999 BUILD
-==== bazel-bin/never_stamped.tar
--r-xr-xr-x 0 0 0 968 Dec 31 1999 BUILD
-INFO: Build option --stamp has changed, discarding analysis cache.
-INFO: Build completed successfully, 3 total actions
-==== bazel-bin/always_stamped.tar
--r-xr-xr-x 0 0 0 968 May 3 17:34 BUILD
-==== bazel-bin/controlled_by_stamp_option.ta
--r-xr-xr-x 0 0 0 968 May 6 17:42 BUILD
-==== bazel-bin/never_stamped.tar
--r-xr-xr-x 0 0 0 968 Dec 31 1999 BUILD
-```
diff --git a/examples/where_is_my_output/BUILD b/examples/where_is_my_output/BUILD
deleted file mode 100644
index 62f28fc..0000000
--- a/examples/where_is_my_output/BUILD
+++ /dev/null
@@ -1,56 +0,0 @@
-# -*- coding: utf-8 -*-
-# 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.
-# Build a trivial .deb package to show how to find the output files.
-
-load("@rules_pkg//pkg:deb.bzl", "pkg_deb")
-load("@rules_pkg//pkg:tar.bzl", "pkg_tar")
-
-genrule(
- name = "generate_files",
- outs = [
- "etc/example.conf",
- "usr/bin/a_binary",
- ],
- cmd = "for i in $(OUTS); do echo 1 >$$i; done",
-)
-
-pkg_tar(
- name = "content",
- srcs = [":generate_files"],
-)
-
-pkg_deb(
- name = "deb",
- data = ":content",
- description = "My wonderful product",
- maintainer = "someone@somewhere.com",
- package = "mwp",
- version = "3.14",
-)
-
-# We can also depend just on the .changes file
-
-filegroup(
- name = "the_changes_file",
- srcs = [":deb"],
- output_group = "changes",
-)
-
-genrule(
- name = "use_changes_file",
- srcs = [":the_changes_file"],
- outs = ["copy_of_changes.txt"],
- cmd = "cp $(location :the_changes_file) $@",
-)
diff --git a/examples/where_is_my_output/README.md b/examples/where_is_my_output/README.md
deleted file mode 100644
index c977ec8..0000000
--- a/examples/where_is_my_output/README.md
+++ /dev/null
@@ -1,101 +0,0 @@
-# Where are my files?
-
-## Finding the exact path to the files created by a target.
-
-Most of the time, Bazel users do not need to know the path to the artifacts
-created for any given target. A notable exception is for users of packaging
-rules. You typically create an RPM or Debian packaged file for the explicit
-purpose of taking it from your machine and giving it to someone else.
-
-Users often create scripts to push `bazel build` outputs to other places and
-need to know the path to those outputs. This can be a challenge for rules which
-may create the file name by combining a base part with a version number,
-and maybe a CPU architecture. We don't do find them with shell wildcards
-like `bazel-bin/my-pkg/pkg-*.deb`. That is brittle. Fortunately, Bazel
-provide all the tools we need to get the precise path of an output.
-
-## Using cquery to find the exact path to the outputs created for a target.
-
-We can use Bazel's cquery command to find information about a target.
-
-In Bazel 5.3.0 or later, there is a [`--output=files` flag](https://bazel.build/query/cquery#files-output) that provides this info directly. ([PR](https://github.com/bazelbuild/bazel/pull/15552))
-
-Older versions of Bazel require a small Starlark program to be supplied.
-Specifically we use
-[cquery's Starlark output](https://docs.bazel.build/versions/main/cquery.html#cquery-starlark-dialect)
-to inspect a target and print exactly what we need. Let's try it:
-
-```shell
-bazel build :deb
-bazel cquery :deb --output=starlark --starlark:file=show_all_outputs.bzl 2>/dev/null
-```
-
-That should produce something like
-
-```python
-deb: bazel-out/k8-fastbuild/bin/mwp_3.14_all.deb
-changes: bazel-out/k8-fastbuild/bin/mwp_3.changes
-```
-
-### How it works
-
-show_all_outputs.bzl is a Starlark script that must contain a function with the
-name `format`, that takes a single argument. The argument is typically named
-target, and is a configured Bazel target, as you might have access to while
-writing a custom rule. We can inspect its providers and print them in a useful
-way.
-
-For pkg_deb, there are two files, the .deb file and the .changes, and both are
-passed along in the rule's OutputGroupInfo provider. This snippet below (from
-show_all_outputs.bzl) prints them.
-
-```python
-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):
- if attr.startswith("_"):
- continue
- attr_value = getattr(output_group_info, attr)
- if type(attr_value) == "depset":
- for file in attr_value.to_list():
- ret.append("%s: %s" % (attr, file.path))
- return "\n".join(ret)
-```
-
-A full explanation of why this works is beyond the scope of this example. It
-requires some knowledge of how to write custom Bazel rules. See the Bazel
-documentation for more information.
-
-## Using an implicit output as input to another rule.
-
-Sometimes a rule will create an implicit output that the user does not
-explicitly specify as an attribute of the target. The .changes file from
-pkg_deb is an example. If we want another rule to depend on an implicitly
-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 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.
-
-```python
-
-pkg_deb(name = "deb", ...)
-
-filegroup(
- name = "the_changes_file",
- srcs = [":deb"],
- output_group = "changes",
-)
-
-genrule(
- name = "use_changes_file",
- srcs = [":the_changes_file"],
- outs = ["copy_of_changes.txt"],
- cmd = "cp $(location :the_changes_file) $@",
-)
-```
diff --git a/examples/where_is_my_output/WORKSPACE b/examples/where_is_my_output/WORKSPACE
deleted file mode 100644
index 50f3c24..0000000
--- a/examples/where_is_my_output/WORKSPACE
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "rich_structure")
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
-
-local_repository(
- name = "rules_pkg",
- path = "../..",
-)
-
-load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
-
-rules_pkg_dependencies()
diff --git a/examples/where_is_my_output/show_all_outputs.bzl b/examples/where_is_my_output/show_all_outputs.bzl
deleted file mode 100644
index 12d658d..0000000
--- a/examples/where_is_my_output/show_all_outputs.bzl
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- coding: utf-8 -*-
-# 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.
-
-# Extract the paths to the various outputs of pkg_deb
-#
-# Usage:
-# bazel cquery //pkg:deb --output=starlark --starlark:file=show_all_outputs.bzl
-#
-
-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):
- if attr.startswith("_"):
- continue
- attr_value = getattr(output_group_info, attr)
- if type(attr_value) == "depset":
- for file in attr_value.to_list():
- ret.append("%s: %s" % (attr, file.path))
- return "\n".join(ret)
diff --git a/patching.md b/patching.md
deleted file mode 100644
index 0c616c3..0000000
--- a/patching.md
+++ /dev/null
@@ -1,43 +0,0 @@
-# Patch Acceptance Process
-
-- PRs that change or add behavior are not accepted without being tied to an
- issue. Most fixes, even if you think they are obvious, require an issue
- too. Almost every change breaks someone who has depended on the behavior,
- even broken behavior.
-- Significant changes need a design document. Please create an issue describing
- the proposed change, and post a link to it to rules-pkg-discuss@googlegroups.com.
- Wait for discussion to come to agreement before proceeding.
-- Features and bug fixes should be as portable as possible.
- - do not not disable tests on Windows because it is convenient for you
- - if a feature is only available on specific platforms, it must be optional. That
- is, it requires a distinct bzlmod MODULE
-- All fixes and features must have tests.
-- Ensure you've signed a [Contributor License
- Agreement](https://cla.developers.google.com).
-- Send us a pull request on
- [GitHub](https://github.com/bazelbuild/rules_pkg/pulls). If you're new to GitHub,
- read [about pull
- requests](https://help.github.com/articles/about-pull-requests/). Note that
- we restrict permissions to create branches on the main repository, so
- you will need to push your commit to [your own fork of the
- 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 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.
-
-Tips
-- Large PRs are harder to review. If you have to refactor code to implement a feature
- please split that into at least 2 PRs. The first to refactor without changing behavior
- and the second to implemtn the new behavior. Of course, as above, any PR that large
- should be discussed in an issue first
-- Please do not send PRs that update dependencies (WORKSPACE or MODULE.bzl) just to
- stay at head. We try to maintain backwards compatibility to LTS releases as long as
- possible, so we only update to new versions of dependencies when it is required.
-
-For further information about working with Bazel and rules in general:
-- Read the [Bazel governance plan](https://www.bazel.build/governance.html).
-- Read the [contributing to Bazel](https://www.bazel.build/contributing.html) guide.
diff --git a/pkg/.bazelignore b/pkg/.bazelignore
deleted file mode 100644
index b856cd9..0000000
--- a/pkg/.bazelignore
+++ /dev/null
@@ -1 +0,0 @@
-tests/external_project \ No newline at end of file
diff --git a/pkg/BUILD b/pkg/BUILD
deleted file mode 100644
index 1c33b2f..0000000
--- a/pkg/BUILD
+++ /dev/null
@@ -1,107 +0,0 @@
-# Copyright 2019 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# -*- coding: utf-8 -*-
-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"])
-
-exports_files(
- glob([
- "*.bzl",
- ]),
- visibility = ["//visibility:public"],
-)
-
-constraint_setting(name = "not_compatible_setting")
-
-constraint_value(
- name = "not_compatible",
- constraint_setting = ":not_compatible_setting",
- visibility = ["//visibility:public"],
-)
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*.bzl",
- "*.py",
- "*.tpl",
- ]) + [
- "BUILD",
- "//pkg/legacy:standard_package",
- "//pkg/rpm:standard_package",
- ],
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-starlark_library(
- name = "bzl_srcs",
- srcs = [
- ":standard_package",
- "//pkg:pkg.bzl",
- "//pkg/private:standard_package",
- "//pkg/private/deb:standard_package",
- "//pkg/private/tar:standard_package",
- "//pkg/private/zip:standard_package",
- "//pkg/releasing:standard_package",
- ],
- visibility = ["//visibility:public"],
-)
-
-# Used by pkg_rpm in rpm.bzl.
-py_binary(
- name = "make_rpm",
- srcs = ["make_rpm.py"],
- imports = [".."],
- python_version = "PY3",
- srcs_version = "PY3",
- target_compatible_with = select({
- "//toolchains/rpm:have_rpmbuild": [],
- "//conditions:default": [":not_compatible"],
- }),
- visibility = ["//visibility:public"],
- deps = [
- "//pkg:make_rpm_lib",
- "//pkg/private:archive",
- ],
-)
-
-py_library(
- name = "make_rpm_lib",
- srcs = ["make_rpm.py"],
- imports = [".."],
- srcs_version = "PY3",
- visibility = [
- "//experimental:__subpackages__",
- "//tests:__subpackages__",
- ],
- deps = [
- "//pkg/private:archive",
- "//pkg/private:helpers",
- ],
-)
-
-py_binary(
- name = "filter_directory",
- srcs = ["filter_directory.py"],
- python_version = "PY3",
- visibility = ["//visibility:public"],
-)
-
-exports_files(["verify_archive_test_main.py.tpl"])
diff --git a/pkg/__init__.py b/pkg/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/pkg/__init__.py
+++ /dev/null
diff --git a/pkg/deb.bzl b/pkg/deb.bzl
deleted file mode 100644
index 159ebae..0000000
--- a/pkg/deb.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.
-"""Forwarder for pkg_deb."""
-
-load("//pkg/private/deb:deb.bzl", _pkg_deb = "pkg_deb")
-
-pkg_deb = _pkg_deb
diff --git a/pkg/deps.bzl b/pkg/deps.bzl
deleted file mode 100644
index 1fecfbf..0000000
--- a/pkg/deps.bzl
+++ /dev/null
@@ -1,59 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""WORKSPACE dependencies for rules_pkg/pkg."""
-
-load("@bazel_tools//tools/build_defs/repo:http.bzl", _http_archive = "http_archive")
-load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
-
-def http_archive(**kwargs):
- maybe(_http_archive, **kwargs)
-
-def rules_pkg_dependencies():
- http_archive(
- name = "bazel_skylib",
- sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa",
- urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
- "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz",
- ],
- )
-
- 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",
- 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",
- )
-
- http_archive(
- name = "rules_license",
- urls = [
- "https://mirror.bazel.build/github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
- "https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
- ],
- sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
- )
-
-def rules_pkg_register_toolchains():
- pass
diff --git a/pkg/filter_directory.py b/pkg/filter_directory.py
deleted file mode 100644
index 8342424..0000000
--- a/pkg/filter_directory.py
+++ /dev/null
@@ -1,285 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-"""Generic directory filter
-
-This program provides a command-line interface that allows for copying contents
-from one directory to another, in support of basic manipulation of
-TreeArtifacts (directory outputs).
-
-For more information on TreeArtifacts, see
-https://docs.bazel.build/versions/master/glossary.html#artifact
-
-"""
-
-import argparse
-import os
-import pathlib
-import shutil
-import sys
-import textwrap
-
-
-def main(argv):
- parser = argparse.ArgumentParser(fromfile_prefix_chars='@')
-
- parser.add_argument("--strip_prefix", type=pathlib.Path, default=None,
- help="directory prefix to strip from all incoming paths")
- parser.add_argument("--prefix", type=pathlib.Path, default=None,
- help="prefix to add to all output paths")
- parser.add_argument("--rename", type=str, action='append', default=[],
- help="DESTINATION=SOURCE mappings. Only supports files. "
- "DESTINATION=SOURCE must be one-to-one.")
- parser.add_argument("--exclude", type=pathlib.Path, action='append',
- default=[],
- help="Input files to exclude from the output directory")
-
- parser.add_argument("input_dir", type=pathlib.Path,
- help="input directory")
- parser.add_argument("output_dir", type=pathlib.Path,
- help="output directory")
-
- args = parser.parse_args(argv)
-
- ###########################################################################
- # Argument consistency checking.
- ###########################################################################
-
- dir_in = args.input_dir
- dir_out = args.output_dir
- dir_out_abs = pathlib.Path.cwd() / dir_out
-
- excludes_used_map = {e: False for e in args.exclude}
-
- # src -> dest
- renames_map = {}
- # dest -> src, used for diagnostics
- renames_map_reversed = {}
-
- for r in args.rename:
- dest, src = (pathlib.Path(p) for p in r.split('=', maxsplit=1))
- if src in renames_map:
- sys.exit(textwrap.dedent("""In --renames, sources used multiple times:
- {s1} -> {d1}
- {s2} -> {d2}
-
- Each --rename DESTINATION=SOURCE pair must be one-to-one.
- """.format(
- s1=src, d1=dest,
- s2=src, d2=renames_map[src],
- )))
-
- if dest in renames_map_reversed:
- sys.exit(textwrap.dedent("""--renames destination collision:
- {d1} <- {s1}
- {d2} <- {s2}
-
- Each --rename DESTINATION=SOURCE pair must be one-to-one.
- """.format(
- d1=dest, s1=src,
- d2=dest, s2=renames_map_reversed[dest],
- )))
- renames_map[src] = dest
- renames_map_reversed[dest] = src
-
- ###########################################################################
- # Assemble src -> dest map (file_mappings)
- ###########################################################################
- renames_used_map = {src: False for src in renames_map.keys()}
- invalid_strip_prefix_dirs = []
-
- files_installed_outside_destdir = []
-
- file_mappings = {}
-
- # NOTE: We need to stringify `dir_in` to support Python 3.5 (Ubuntu 16.04).
- # Otherwise we could just pass it directly. This is supported as of
- # Python 3.6.
- for root, dirs, files in os.walk(str(dir_in)):
- root_path = pathlib.Path(root)
-
- rel_root = root_path.relative_to(dir_in)
-
- # Prepend the prefix
- if args.prefix:
- dest_dir = dir_out / args.prefix
- else:
- dest_dir = dir_out
-
- # strip_prefix must apply to everything to reduce overall surprise. If
- # this root contains files and is not under strip_prefix, record it and
- # fail after this preprocessing stage.
- #
- # This can be refined somewhat -- for example, if we descend into a
- # child directory, we don't need to mention it again.
- #
- # TODO(nacl): this does not make an attempt to tell if everything was
- # rename'd out of the directory we're currently inspecting. We could
- # theoretically check if this was actually used, and if it was, then add
- # it in.
- dest_rel_root = rel_root
- if len(files) != 0 and args.strip_prefix is not None:
- try:
- dest_rel_root = rel_root.relative_to(args.strip_prefix)
- except ValueError:
- # Cannot proceed -- strip_prefix does not apply here. Store
- # "invalid" directories in an output list, and then continue.
- invalid_strip_prefix_dirs.append(rel_root)
-
- # This is the base output directory that will be used when there are no
- # --rename's.
- dest_dir /= dest_rel_root
-
- for f in files:
- rel_src_path = rel_root / f
-
- # Handle exclusions
- if rel_src_path in excludes_used_map:
- excludes_used_map[rel_src_path] = True
- # Skip it
- continue
-
- if rel_src_path in renames_map:
- # Calculate a new path based on the individual renames. Renames
- # override "strip_prefix". Include the prefix too.
- dest = dir_out
- if args.prefix:
- dest /= args.prefix
- dest /= renames_map[rel_src_path]
- renames_used_map[rel_src_path] = True
- else:
- # Use the paths we already calculated.
- dest = dest_dir / f
-
- # Verify that files are not going to be installed outside the output
- # directory, and include them in error lists if this is the case.
-
- # NOTE: We can't use pathlib here since non-strict checks are only
- # available as of Python 3.6 (Ubuntu 16.04 still uses 3.5).
- common_pfx = os.path.commonprefix([
- os.path.abspath(str(dest)),
- str(dir_out_abs)
- ])
- if common_pfx != str(dir_out_abs):
- files_installed_outside_destdir.append(rel_root / f)
-
- file_mappings[root_path / f] = dest
-
- ###########################################################################
- # Check for early failure
- ###########################################################################
-
- # Figure out if anything is being installed to multiple places in case we
- # missed something above. Interactions between strip_prefix and renames
- # come to mind, as well as renames to outputs already in the tarball.
- #
- # These are converted to strings here because they aren't used again
- # afterward.
- dest_src_str_map = {}
- duplicate_mappings = {}
- for src, dest in file_mappings.items():
- rel_srcs_str = str(src.relative_to(dir_in))
- try:
- rel_dest_str = str(dest.relative_to(dir_out))
- except ValueError:
- # This can fail if dest is absolute for some reason. Log something
- # in case there is a code problem here.
- #
- # This probably will also fail due to files being outside of the
- # package.
- print("Ignoring invalid src/dest pair {} -> {}".format(
- src, dest
- ),
- file=sys.stderr,
- )
- continue
-
- if rel_dest_str in dest_src_str_map:
- dest_src_str_map[rel_dest_str].append(rel_srcs_str)
- else:
- dest_src_str_map[rel_dest_str] = [rel_srcs_str]
-
- duplicate_mappings = {
- dest: srcs
- for dest, srcs in dest_src_str_map.items()
- if len(srcs) > 1
- }
-
- # And now, figure out if any of our exclusions/renames were left unused
- def value_unused(value_tuple):
- _, used = value_tuple
- return not used
-
- unused_exclusions = dict(filter(value_unused, excludes_used_map.items()))
- unused_renames = dict(filter(value_unused, renames_used_map.items()))
-
- # If any of these iterables have items in them, there's an inconsistency.
- # We should fail before proceeding
- #
- # Empty iterables below are "falsy", so this works well enough.
- fail_early = any([
- invalid_strip_prefix_dirs,
- unused_exclusions,
- unused_renames,
- files_installed_outside_destdir,
- duplicate_mappings,
- ])
-
- if fail_early:
- print("Refusing to continue due to:")
- if invalid_strip_prefix_dirs:
- print(" strip_prefix not applying to directories")
- for d in invalid_strip_prefix_dirs:
- print(" {}".format(d))
- if unused_exclusions:
- print(" unused exclusions:")
- for p in unused_exclusions.keys():
- print(" {}".format(p))
- if unused_renames:
- print(" unused renames:")
- for src in unused_renames.keys():
- # TODO: this could be formatted more prettily, specifically,
- # aligned
- print(" {} -> {}".format(src, renames_map[src]))
- if files_installed_outside_destdir:
- print(" files copied outside DESTDIR:")
- for src in files_installed_outside_destdir:
- print(" {}".format(src))
- if duplicate_mappings:
- print(" duplicate destination mappings:")
- for dest, srcs in duplicate_mappings.items():
- print(" {} <- {}".format(dest, ', '.join(srcs)))
- print("")
- print("Sources are relative to {}".format(dir_in))
- print("Destinations are relative to {}".format(dir_out))
-
- sys.exit(1)
-
- ###########################################################################
- # Do the thing
- ###########################################################################
-
- for src, dest in file_mappings.items():
- dest.parent.mkdir(exist_ok=True, parents=True)
- shutil.copy(
- # NOTE: Stringifying for Python 3.5
- str(src),
- str(dest),
- )
-
-
-if __name__ == "__main__":
- exit(main(sys.argv[1:]))
diff --git a/pkg/install.bzl b/pkg/install.bzl
deleted file mode 100644
index 262554b..0000000
--- a/pkg/install.bzl
+++ /dev/null
@@ -1,185 +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.
-"""Rules for creating install scripts from pkg_filegroups and friends.
-
-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")
-
-def _pkg_install_script_impl(ctx):
- script_file = ctx.actions.declare_file(ctx.attr.name + ".py")
-
- fragments = []
- files_to_run = []
- content_map = {}
- for src in ctx.attr.srcs:
- process_src(
- ctx,
- content_map,
- files_to_run,
- src = src,
- origin = src.label,
- default_mode = "0644",
- default_user = None,
- default_group = None,
- default_uid = None,
- default_gid = None,
- )
-
- manifest_file = ctx.actions.declare_file(ctx.attr.name + "-install-manifest.json")
-
- # Write out the manifest in terms of "short" paths, which are those expected
- # when you make `bazel run`nable binaries).
- #
- # 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)
-
- # 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")]
-
- ctx.actions.expand_template(
- template = ctx.file._script_template,
- output = script_file,
- substitutions = {
- "{MANIFEST_INCLUSION}": manifest_file.short_path,
- # This is used to extend the manifest paths when the script is run
- # inside a build.
- "{WORKSPACE_NAME}": ctx.workspace_name,
- # Used to annotate --help with "bazel run //path/to/your:installer"
- "{TARGET_LABEL}": label_str,
- },
- is_executable = True,
- )
-
- my_runfiles = ctx.runfiles(
- files = [manifest_file],
- transitive_files = depset(transitive = files_to_run),
- )
-
- return [
- DefaultInfo(
- files = depset([script_file]),
- runfiles = my_runfiles,
- executable = script_file,
- ),
- ]
-
-_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 necessary to run the script are
- included as runfiles.
- """,
- implementation = _pkg_install_script_impl,
- attrs = {
- "srcs": attr.label_list(
- mandatory = True,
- providers = [
- [PackageFilegroupInfo],
- [PackageFilesInfo],
- [PackageDirsInfo],
- [PackageSymlinkInfo],
- ],
- doc = "Source mapping/grouping targets",
- ),
- # This is private for now -- one could perhaps imagine making this
- # public, but that would require more documentation of the underlying
- # scripts and expected interfaces.
- "_script_template": attr.label(
- allow_single_file = True,
- default = "//pkg/private:install.py.tpl",
- ),
- },
- executable = True,
-)
-
-def pkg_install(name, srcs, **kwargs):
- """Create an installer script from pkg_filegroups and friends.
-
- This macro allows users to create `bazel run`nable installation scripts
- using the pkg_filegroup framework.
-
- For example:
-
- ```python
- pkg_install(
- name = "install",
- srcs = [
- # mapping/grouping targets here
- ],
- )
- ```
-
- Installation can be done by invoking:
-
- ```
- bazel run -- //path/to:install
- ```
-
- Additional features can be accessed by invoking the script with the --help
- option:
-
- ```
- 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
- occur. Not doing so can lead the outputs going to an unexpected location,
- or in some cases, failing. Run the script command with `--help`, as
- mentioned above, for more details.
-
- One such use would be to run the script created by `pkg_install` to produce
- a directory output in the build root. This may not function as expected or
- may suffer from poorly tested edge cases. A purpose-written rule that would
- allow for creation of such directories is discussed in
- https://github.com/bazelbuild/rules_pkg/issues/388.
-
- Args:
- name: rule name
- srcs: pkg_filegroup framework mapping or grouping targets
- **kwargs: common rule attributes
-
- """
-
- _pkg_install_script(
- name = name + "_install_script",
- srcs = srcs,
- **kwargs
- )
-
- py_binary(
- name = name,
- srcs = [":" + name + "_install_script"],
- main = name + "_install_script.py",
- deps = [Label("//pkg/private:manifest")],
- srcs_version = "PY3",
- python_version = "PY3",
- **kwargs
- )
diff --git a/pkg/legacy/BUILD b/pkg/legacy/BUILD
deleted file mode 100644
index eab0ec9..0000000
--- a/pkg/legacy/BUILD
+++ /dev/null
@@ -1,27 +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.
-
-package(default_applicable_licenses = ["//:license"])
-
-exports_files(["rpm.bzl"])
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*.bzl",
- ]) + [
- "BUILD",
- ],
- visibility = ["//pkg:__pkg__"],
-)
diff --git a/pkg/legacy/rpm.bzl b/pkg/legacy/rpm.bzl
deleted file mode 100644
index 3211bbd..0000000
--- a/pkg/legacy/rpm.bzl
+++ /dev/null
@@ -1,246 +0,0 @@
-# Copyright 2017 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.
-"""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")
-"""
-
-rpm_filetype = [".rpm"]
-
-spec_filetype = [".spec"]
-
-def _pkg_rpm_impl(ctx):
- """Implements to pkg_rpm rule."""
-
- files = []
- tools = []
- args = ["--name=" + ctx.label.name]
- if ctx.attr.debug:
- args += ["--debug"]
-
- if ctx.attr.rpmbuild_path:
- args += ["--rpmbuild=" + ctx.attr.rpmbuild_path]
-
- # buildifier: disable=print
- print("rpmbuild_path is deprecated. See the README for instructions on how" +
- " to migrate to toolchains")
- else:
- toolchain = ctx.toolchains["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"].rpmbuild
- if not toolchain.valid:
- fail("The rpmbuild_toolchain is not properly configured: " +
- toolchain.name)
- if toolchain.path:
- args += ["--rpmbuild=" + toolchain.path]
- else:
- executable_files = toolchain.label[DefaultInfo].files_to_run
- tools.append(executable_files)
- args.append("--rpmbuild=%s" % executable_files.executable.path)
-
- # Version can be specified by a file or inlined.
- 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]
- elif ctx.attr.version:
- args += ["--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]
- elif ctx.attr.release:
- args += ["--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]
- elif ctx.attr.source_date_epoch != None:
- args += ["--source_date_epoch=" + str(ctx.attr.source_date_epoch)]
-
- if ctx.attr.architecture:
- args += ["--arch=" + ctx.attr.architecture]
-
- if not ctx.attr.spec_file:
- fail("spec_file was not specified")
-
- # Expand the spec file template.
- spec_file = ctx.actions.declare_file("%s.spec" % ctx.label.name)
-
- # Create the default substitutions based on the data files.
- substitutions = {}
- for data_file in ctx.files.data:
- key = "{%s}" % data_file.basename
- substitutions[key] = data_file.path
- ctx.actions.expand_template(
- template = ctx.file.spec_file,
- output = spec_file,
- substitutions = substitutions,
- )
- args += ["--spec_file=" + spec_file.path]
- files += [spec_file]
-
- args += ["--out_file=" + ctx.outputs.rpm.path]
-
- # Add data files.
- if ctx.file.changelog:
- files += [ctx.file.changelog]
- args += [ctx.file.changelog.path]
- files += ctx.files.data
-
- for f in ctx.files.data:
- args += [f.path]
-
- # Call the generator script.
- ctx.actions.run(
- mnemonic = "MakeRpm",
- executable = ctx.executable._make_rpm,
- use_default_shell_env = True,
- arguments = args,
- inputs = files,
- outputs = [ctx.outputs.rpm],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- tools = tools,
- )
-
- # Link the RPM to the expected output name.
- ctx.actions.symlink(
- output = ctx.outputs.out,
- target_file = ctx.outputs.rpm,
- )
-
- # Link the RPM to the RPM-recommended output name if possible.
- if "rpm_nvra" in dir(ctx.outputs):
- ctx.actions.symlink(
- output = ctx.outputs.rpm_nvra,
- target_file = ctx.outputs.rpm,
- )
-
-def _pkg_rpm_outputs(version, release):
- outputs = {
- "out": "%{name}.rpm",
- "rpm": "%{name}-%{architecture}.rpm",
- }
-
- # The "rpm_nvra" output follows the recommended package naming convention of
- # Name-Version-Release.Arch.rpm
- # See http://ftp.rpm.org/max-rpm/ch-rpm-file-format.html
- if version and release:
- outputs["rpm_nvra"] = "%{name}-%{version}-%{release}.%{architecture}.rpm"
-
- return outputs
-
-# Define the rule.
-pkg_rpm = rule(
- doc = "Legacy version",
- attrs = {
- "spec_file": attr.label(
- mandatory = True,
- allow_single_file = spec_filetype,
- ),
- "architecture": attr.string(default = "all"),
- "version_file": attr.label(
- allow_single_file = True,
- ),
- "version": attr.string(),
- "changelog": attr.label(
- allow_single_file = True,
- ),
- "data": attr.label_list(
- mandatory = True,
- allow_files = True,
- ),
- "release_file": attr.label(allow_single_file = True),
- "release": attr.string(),
- "source_date_epoch_file": attr.label(allow_single_file = True),
- "source_date_epoch": attr.int(),
- "debug": attr.bool(default = False),
-
- # Implicit dependencies.
- "rpmbuild_path": attr.string(), # deprecated
- "_make_rpm": attr.label(
- default = Label("//pkg:make_rpm"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
- executable = False,
- outputs = _pkg_rpm_outputs,
- implementation = _pkg_rpm_impl,
- toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
-)
-
-# buildifier: disable=no-effect
-"""Creates an RPM format package from the data files.
-
-This runs rpmbuild (and requires it to be installed beforehand) to generate
-an RPM package based on the spec_file and data attributes.
-
-Two outputs are guaranteed to be produced: "%{name}.rpm", and
-"%{name}-%{architecture}.rpm". If the "version" and "release" arguments are
-non-empty, a third output will be produced, following the RPM-recommended
-N-V-R.A format (Name-Version-Release.Architecture.rpm). Note that due to
-the fact that rule implementations cannot access the contents of files,
-the "version_file" and "release_file" arguments will not create an output
-using N-V-R.A format.
-
-Args:
- spec_file: The RPM spec file to use. If the version or version_file
- attributes are provided, the Version in the spec will be overwritten,
- and likewise behaviour with release and release_file. Any Sources listed
- in the spec file must be provided as data dependencies.
- The base names of data dependencies can be replaced with the actual location
- using "{basename}" syntax.
- version: The version of the package to generate. This will overwrite any
- Version provided in the spec file. Only specify one of version and
- version_file.
- version_file: A file containing the version of the package to generate. This
- will overwrite any Version provided in the spec file. Only specify one of
- version and version_file.
- release: The release of the package to generate. This will overwrite any
- release provided in the spec file. Only specify one of release and
- release_file.
- release_file: A file containing the release of the package to generate. This
- will overwrite any release provided in the spec file. Only specify one of
- release and release_file.
- changelog: A changelog file to include. This will not be written to the spec
- file, which should only list changes to the packaging, not the software itself.
- source_date_epoch: Value to export as SOURCE_DATE_EPOCH to facilitate reproducible
- timestamps. Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the
- subordinate call to `rpmbuild` to facilitate more consistent in-RPM file
- timestamps.
- source_date_epoch_file: File containing the SOURCE_DATE_EPOCH value. Sets
- `%clamp_mtime_to_source_date_epoch` like with "source_date_epoch".
- data: List all files to be included in the package here.
-"""
diff --git a/pkg/legacy/tests/rpm/BUILD b/pkg/legacy/tests/rpm/BUILD
deleted file mode 100644
index 13d74e3..0000000
--- a/pkg/legacy/tests/rpm/BUILD
+++ /dev/null
@@ -1,30 +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.
-# -*- coding: utf-8 -*-
-
-load("//pkg:rpm.bzl", "pkg_rpm")
-
-package(default_applicable_licenses = ["//:license"])
-
-pkg_rpm(
- name = "test-rpm",
- data = [
- "BUILD",
- "//pkg/legacy:rpm.bzl",
- ],
- debug = 1,
- release = "0",
- spec_file = "test_rpm.spec",
- version = "1",
-)
diff --git a/pkg/legacy/tests/rpm/test_rpm.spec b/pkg/legacy/tests/rpm/test_rpm.spec
deleted file mode 100644
index efaeb6f..0000000
--- a/pkg/legacy/tests/rpm/test_rpm.spec
+++ /dev/null
@@ -1,25 +0,0 @@
-Name: rules_pkg
-Version: 0
-Release: 1
-Summary: Test data
-URL: https://github.com/bazelbuild/rules_pkg
-License: Apache License, v2.0
-
-# Do not try to use magic to determine file types
-%define __spec_install_post %{nil}
-# Do not die because we give it more input files than are in the files section
-%define _unpackaged_files_terminate_build 0
-
-%description
-This is a package description.
-
-%prep
-
-%build
-
-%install
-cp -r ./pkg/legacy %{buildroot}/
-
-%files
-/legacy/rpm.bzl
-/legacy/tests/rpm/BUILD
diff --git a/pkg/make_rpm.py b/pkg/make_rpm.py
deleted file mode 100644
index 2b5ce4c..0000000
--- a/pkg/make_rpm.py
+++ /dev/null
@@ -1,538 +0,0 @@
-# Copyright 2017 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.
-"""A simple cross-platform helper to create an RPM package."""
-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-import argparse
-import contextlib
-import fileinput
-import os
-import pprint
-import re
-import shutil
-import subprocess
-import sys
-import tempfile
-from string import Template
-
-from pkg.private import helpers
-
-
-# Setup to safely create a temporary directory and clean it up when done.
-@contextlib.contextmanager
-def Cd(newdir, cleanup=lambda: True):
- """Change the current working directory.
-
- This will run the provided cleanup function when the context exits and the
- previous working directory is restored.
-
- Args:
- newdir: The directory to change to. This must already exist.
- cleanup: An optional cleanup function to be executed when the context exits.
-
- Yields:
- Nothing.
- """
-
- prevdir = os.getcwd()
- os.chdir(os.path.expanduser(newdir))
- try:
- yield
- finally:
- os.chdir(prevdir)
- cleanup()
-
-
-@contextlib.contextmanager
-def Tempdir():
- """Create a new temporary directory and change to it.
-
- The temporary directory will be removed when the context exits.
-
- Yields:
- The full path of the temporary directory.
- """
-
- dirpath = tempfile.mkdtemp()
-
- def Cleanup():
- shutil.rmtree(dirpath)
-
- with Cd(dirpath, Cleanup):
- yield dirpath
-
-
-WROTE_FILE_RE = re.compile(r'Wrote: (?P<rpm_path>.+)', re.MULTILINE)
-
-
-def FindOutputFile(log):
- """Find the written file from the log information."""
-
- m = WROTE_FILE_RE.search(log)
- if m:
- return m.group('rpm_path')
- return None
-
-def SlurpFile(input_path):
- with open(input_path, 'r') as input:
- return input.read()
-
-def CopyAndRewrite(input_file, output_file, replacements=None, template_replacements=None):
- """Copies the given file and optionally rewrites with replacements.
-
- Args:
- input_file: The file to copy.
-
- output_file: The file to write to.
-
- replacements: A dictionary of replacements.
- Keys are prefixes scan for, values are the replacements to write after
- the prefix.
-
- template_replacements: A dictionary of in-place replacements.
- Keys are variable names, values are replacements. Used with
- string.Template.
- """
-
- with open(output_file, 'w') as output:
- for line in fileinput.input(input_file):
- if replacements:
- for prefix, text in replacements.items():
- if line.startswith(prefix):
- line = prefix + ' ' + text + '\n'
- break
- if template_replacements:
- template = Template(line)
- line = template.safe_substitute(template_replacements)
- output.write(line)
-
-
-def IsExe(fpath):
- return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
-
-
-def Which(program):
- """Search for the given program in the PATH.
-
- Args:
- program: The program to search for.
-
- Returns:
- The full path to the program.
- """
-
- for path in os.environ['PATH'].split(os.pathsep):
- filename = os.path.join(path, program)
- if IsExe(filename):
- return filename
-
- return None
-
-
-class NoRpmbuildFoundError(Exception):
- pass
-
-
-class InvalidRpmbuildError(Exception):
- pass
-
-
-def FindRpmbuild(rpmbuild_path):
- """Finds absolute path to rpmbuild.
-
- Args:
- rpmbuild_path: path to the rpmbuild_binary. If None, find 'rpmbuild' by
- walking $PATH.
- """
- if rpmbuild_path:
- if not rpmbuild_path.startswith(os.path.sep):
- return os.path.join(os.getcwd(), rpmbuild_path)
- return rpmbuild_path
- path = Which('rpmbuild')
- if path:
- return path
- raise NoRpmbuildFoundError()
-
-
-class RpmBuilder(object):
- """A helper class to manage building the RPM file."""
-
- SOURCE_DIR = 'SOURCES'
- BUILD_DIR = 'BUILD'
- BUILDROOT_DIR = 'BUILDROOT'
- TEMP_DIR = 'TMP'
- RPMS_DIR = 'RPMS'
- DIRS = [SOURCE_DIR, BUILD_DIR, RPMS_DIR, TEMP_DIR]
-
- def __init__(self, name, version, release, arch, rpmbuild_path,
- source_date_epoch=None,
- debug=False):
- self.name = name
- self.version = helpers.GetFlagValue(version)
- self.release = helpers.GetFlagValue(release)
- self.arch = arch
- self.files = []
- self.rpmbuild_path = FindRpmbuild(rpmbuild_path)
- self.rpm_path = None
- self.source_date_epoch = helpers.GetFlagValue(source_date_epoch)
- self.debug = debug
-
- # The below are initialized in SetupWorkdir()
- self.spec_file = None
-
- self.preamble_file = None
- 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
- self.preun_scriptlet = None
- self.postun_scriptlet = None
-
- def AddFiles(self, paths, root=''):
- """Add a set of files to the current RPM.
-
- If an item in paths is a directory, its files are recursively added.
-
- Args:
- paths: The files to add.
- root: The root of the filesystem to search for files. Defaults to ''.
- """
- for path in paths:
- full_path = os.path.join(root, path)
- if os.path.isdir(full_path):
- self.AddFiles(os.listdir(full_path), full_path)
- else:
- self.files.append(full_path)
-
- def SetupWorkdir(self,
- spec_file,
- original_dir,
- preamble_file=None,
- description_file=None,
- install_script_file=None,
- pre_scriptlet_path=None,
- post_scriptlet_path=None,
- preun_scriptlet_path=None,
- postun_scriptlet_path=None,
- changelog_file=None,
- file_list_path=None):
- """Create the needed structure in the workdir."""
-
- # Create the rpmbuild-expected directory structure.
- for name in RpmBuilder.DIRS:
- if not os.path.exists(name):
- os.makedirs(name, 0o777)
-
- # Copy the to-be-packaged files into the BUILD directory
- for f in self.files:
- dst_dir = os.path.join(RpmBuilder.BUILD_DIR, os.path.dirname(f))
- if not os.path.exists(dst_dir):
- os.makedirs(dst_dir, 0o777)
- shutil.copy(os.path.join(original_dir, f), dst_dir)
-
- # The code below is related to assembling the RPM spec template and
- # everything else it needs to produce a valid RPM package.
- #
- # There two different types of substitution going on here: textual, directly
- # into the spec file, and macro; done when we call rpmbuild(8).
- #
- # Plans to clean this up are tracked in #209.
-
- # Slurp in the scriptlets...
- self.pre_scriptlet = \
- SlurpFile(os.path.join(original_dir, pre_scriptlet_path)) if pre_scriptlet_path is not None else ''
- self.post_scriptlet = \
- SlurpFile(os.path.join(original_dir, post_scriptlet_path)) if post_scriptlet_path is not None else ''
- self.preun_scriptlet = \
- 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 ''
-
- # 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,
- '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"
- # `pkg_rpm`.
- #
- # The "tpl_replacements" are used for direct text substitution of scriptlets
- # into the spec file, typically only for the "experimental" `pkg_rpm`.
- spec_origin = os.path.join(original_dir, spec_file)
- self.spec_file = os.path.basename(spec_file)
- replacements = {}
- if self.version:
- replacements['Version:'] = self.version
- if self.release:
- replacements['Release:'] = self.release
- CopyAndRewrite(spec_origin, self.spec_file,
- replacements=replacements,
- template_replacements=tpl_replacements)
-
- # "Preamble" template substitutions. Currently only support values for the
- # "Version" and "Release" tags.
- #
- # This is only the case for `pkg_rpm` in experimental/rpm.bzl.
- #
- # This is substituted by rpmbuild(8) via macro expansion.
- if preamble_file:
- # Copy in the various other files needed to build the RPM
- self.preamble_file = os.path.basename(preamble_file)
- tpl_replacements = {}
- if self.version:
- tpl_replacements['VERSION_FROM_FILE'] = self.version
- if self.release:
- tpl_replacements['RELEASE_FROM_FILE'] = self.release
- CopyAndRewrite(os.path.join(original_dir, preamble_file),
- self.preamble_file,
- template_replacements=tpl_replacements)
-
- # The below are all copied into place within the RPM spec root. It may be
- # possible to directly some, if not all, of these out of the Bazel build
- # root instead. "file_list_path" may be the problematic one here,
- # as it must be there.
- #
- # These are substituted by rpmbuild(8) via macro expansion.
-
- # Used in %description
- if description_file:
- shutil.copy(os.path.join(original_dir, description_file), os.getcwd())
- self.description_file = os.path.basename(description_file)
-
- # Used in %install
- if install_script_file:
- shutil.copy(os.path.join(original_dir, install_script_file), os.getcwd())
- self.install_script_file = os.path.basename(install_script_file)
-
- # Used in %files -f
- if file_list_path:
- shutil.copy(os.path.join(original_dir, file_list_path), RpmBuilder.BUILD_DIR)
- self.file_list_path = os.path.join(RpmBuilder.BUILD_DIR, os.path.basename(file_list_path))
-
- def CallRpmBuild(self, dirname, rpmbuild_args):
- """Call rpmbuild with the correct arguments."""
-
- buildroot = os.path.join(dirname, RpmBuilder.BUILDROOT_DIR)
- # For reference, E121 is a hanging indent flake8 issue. It really wants
- # four space indents, but properly fixing that will require re-indenting the
- # entire file.
-
- # Further, the use of disabling yapf and friends is to allow argument names
- # to be associated with their values neatly.
- args = [
- self.rpmbuild_path, # noqa: E121
- ]
- if self.debug:
- args.append('-vv')
-
- # Common options
- args += [
- '--define', '_topdir %s' % dirname,
- '--define', '_tmppath %s/TMP' % dirname,
- '--bb',
- '--buildroot=%s' % buildroot,
- ] # yapf: disable
-
- # Macro-based RPM parameter substitution, if necessary inputs provided.
- if self.preamble_file:
- args += ['--define', 'build_rpm_options %s' % self.preamble_file]
- if self.description_file:
- args += ['--define', 'build_rpm_description %s' % self.description_file]
- if self.install_script_file:
- args += ['--define', 'build_rpm_install %s' % self.install_script_file]
- if self.file_list_path:
- # %files -f is taken relative to the package root
- args += ['--define', 'build_rpm_files %s' % os.path.basename(self.file_list_path)]
-
- args.extend(rpmbuild_args)
-
- args.append(self.spec_file)
-
- env = {
- 'LANG': 'C',
- 'RPM_BUILD_ROOT': buildroot,
- }
-
- if self.source_date_epoch is not None:
- env['SOURCE_DATE_EPOCH'] = self.source_date_epoch
- args += ["--define", "clamp_mtime_to_source_date_epoch 1"]
- args += ["--define", "use_source_date_epoch_as_buildtime 1"]
-
- if self.debug:
- print('Running rpmbuild as:', ' '.join(["'" + a + "'" for a in args]))
- print('With environment:')
- pprint.pprint(env)
-
- p = subprocess.Popen(
- args,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- env=env)
- output = p.communicate()[0].decode()
-
- if p.returncode == 0:
- # Find the created file.
- self.rpm_path = FindOutputFile(output)
-
- if p.returncode != 0 or not self.rpm_path:
- print('Error calling rpmbuild:')
- print(output)
- elif self.debug:
- print(output)
-
- # Return the status.
- return p.returncode
-
- def SaveResult(self, out_file):
- """Save the result RPM out of the temporary working directory."""
-
- if self.rpm_path:
- shutil.copy(self.rpm_path, out_file)
- if self.debug:
- print('Saved RPM file to %s' % out_file)
- else:
- print('No RPM file created.')
-
- def Build(self, spec_file, out_file,
- preamble_file=None,
- description_file=None,
- install_script_file=None,
- pre_scriptlet_path=None,
- post_scriptlet_path=None,
- preun_scriptlet_path=None,
- postun_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"""
-
- if self.debug:
- print('Building RPM for %s at %s' % (self.name, out_file))
-
- original_dir = os.getcwd()
- spec_file = os.path.join(original_dir, spec_file)
- out_file = os.path.join(original_dir, out_file)
- with Tempdir() as dirname:
- self.SetupWorkdir(spec_file,
- original_dir,
- preamble_file=preamble_file,
- description_file=description_file,
- install_script_file=install_script_file,
- file_list_path=file_list_path,
- pre_scriptlet_path=pre_scriptlet_path,
- post_scriptlet_path=post_scriptlet_path,
- preun_scriptlet_path=preun_scriptlet_path,
- postun_scriptlet_path=postun_scriptlet_path,
- changelog_file=changelog_file)
- status = self.CallRpmBuild(dirname, rpmbuild_args or [])
- self.SaveResult(out_file)
-
- return status
-
-
-def main(argv):
- parser = argparse.ArgumentParser(
- description='Helper for building rpm packages',
- fromfile_prefix_chars='@')
-
- parser.add_argument('--name',
- help='The name of the software being packaged.')
- parser.add_argument('--version',
- help='The version of the software being packaged.')
- parser.add_argument('--release',
- help='The release of the software being packaged.')
- parser.add_argument(
- '--arch',
- help='The CPU architecture of the software being packaged.')
- parser.add_argument('--spec_file', required=True,
- help='The file containing the RPM specification.')
- parser.add_argument('--out_file', required=True,
- help='The destination to save the resulting RPM file to.')
- parser.add_argument('--rpmbuild', help='Path to rpmbuild executable.')
- parser.add_argument('--source_date_epoch',
- help='Value for the SOURCE_DATE_EPOCH rpmbuild '
- 'environment variable')
- parser.add_argument('--debug', action='store_true', default=False,
- help='Print debug messages.')
-
- # Options currently used experimental/rpm.bzl:
- parser.add_argument('--install_script',
- help='Installer script')
- parser.add_argument('--file_list',
- help='File containing a list of files to include with rpm spec %files -f')
- parser.add_argument('--preamble',
- help='File containing the RPM Preamble')
- parser.add_argument('--description',
- help='File containing the RPM %description text')
- parser.add_argument('--pre_scriptlet',
- help='File containing the RPM %pre scriptlet, if to be substituted')
- parser.add_argument('--post_scriptlet',
- help='File containing the RPM %post scriptlet, if to be substituted')
- parser.add_argument('--preun_scriptlet',
- 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('--changelog',
- help='File containing the RPM changelog text')
-
- parser.add_argument('--rpmbuild_arg', dest='rpmbuild_args', action='append',
- help='Any additional arguments to pass to rpmbuild')
- parser.add_argument('files', nargs='*')
-
- options = parser.parse_args(argv or ())
-
- try:
- builder = RpmBuilder(options.name,
- options.version, options.release,
- options.arch, options.rpmbuild,
- source_date_epoch=options.source_date_epoch,
- debug=options.debug)
- builder.AddFiles(options.files)
- return builder.Build(options.spec_file, options.out_file,
- preamble_file=options.preamble,
- description_file=options.description,
- install_script_file=options.install_script,
- file_list_path=options.file_list,
- pre_scriptlet_path=options.pre_scriptlet,
- post_scriptlet_path=options.post_scriptlet,
- preun_scriptlet_path=options.preun_scriptlet,
- postun_scriptlet_path=options.postun_scriptlet,
- changelog_file=options.changelog,
- rpmbuild_args=options.rpmbuild_args)
- except NoRpmbuildFoundError:
- print('ERROR: rpmbuild is required but is not present in PATH')
- return 1
-
-
-if __name__ == '__main__':
- main(sys.argv[1:])
-
-# vim: ts=2:sw=2:
diff --git a/pkg/mappings.bzl b/pkg/mappings.bzl
deleted file mode 100644
index 3c5bff5..0000000
--- a/pkg/mappings.bzl
+++ /dev/null
@@ -1,878 +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.
-
-"""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.
-"""
-
-load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
-load("@bazel_skylib//lib:paths.bzl", "paths")
-
-# TODO(#333): strip_prefix module functions should produce unique outputs. In
-# particular, this one and `_sp_from_pkg` can overlap.
-_PKGFILEGROUP_STRIP_ALL = "."
-
-REMOVE_BASE_DIRECTORY = "\0"
-
-def _sp_files_only():
- return _PKGFILEGROUP_STRIP_ALL
-
-def _sp_from_pkg(path = ""):
- if path.startswith("/"):
- return path[1:]
- else:
- return path
-
-def _sp_from_root(path = ""):
- if path.startswith("/"):
- return path
- else:
- return "/" + path
-
-strip_prefix = struct(
- _doc = """pkg_files `strip_prefix` helper. Instructs `pkg_files` what to do with directory prefixes of files.
-
- Each member is a function that equates to:
-
- - `files_only()`: strip all directory components from all paths
-
- - `from_pkg(path)`: strip all directory components up to the current
- package, plus what's in `path`, if provided.
-
- - `from_root(path)`: strip beginning from the file's WORKSPACE root (even if
- it is in an external workspace) plus what's in `path`, if provided.
-
- Prefix stripping is applied to each `src` in a `pkg_files` rule
- independently.
- """,
- files_only = _sp_files_only,
- from_pkg = _sp_from_pkg,
- from_root = _sp_from_root,
-)
-
-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", "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`).
-
- Args:
- mode: string: UNIXy octal permissions, as a string.
- 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:
- A value usable in the "attributes" attribute in package mapping rules.
-
- """
- ret = kwargs
- if mode:
- ret["mode"] = mode
- if user:
- 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)
-
-####
-# Internal helpers
-####
-
-def _do_strip_prefix(path, to_strip, src_file):
- if to_strip == "":
- # We were asked to strip nothing, which is valid. Just return the
- # original path.
- return path
-
- path_norm = paths.normalize(path)
- to_strip_norm = paths.normalize(to_strip) + "/"
-
- 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 ""
- else:
- # Avoid user surprise by failing if prefix stripping doesn't work as
- # expected.
- #
- # We already leave enough breadcrumbs, so if File.owner() returns None,
- # this won't be a problem.
- failmsg = "Could not strip prefix '{}' from file {} ({})".format(to_strip, str(src_file), str(src_file.owner))
- if src_file.is_directory:
- failmsg += """\n\nNOTE: prefix stripping does not operate within TreeArtifacts (directory outputs)
-
-To strip the directory named by the TreeArtifact itself, see documentation for the `renames` attribute.
-"""
- fail(failmsg)
-
-# The below routines make use of some path checking magic that may difficult to
-# understand out of the box. This following table may be helpful to demonstrate
-# how some of these members may look like in real-world usage:
-#
-# Note: "F" is "File", "FO": is "File.owner".
-
-# | File type | Repo | `F.path` | `F.root.path` | `F.short_path` | `FO.workspace_name` | `FO.workspace_root` |
-# |-----------|----------|----------------------------------------------------------|------------------------------|-------------------------|---------------------|---------------------|
-# | Source | Local | `dirA/fooA` | | `dirA/fooA` | | |
-# | Generated | Local | `bazel-out/k8-fastbuild/bin/dirA/gen.out` | `bazel-out/k8-fastbuild/bin` | `dirA/gen.out` | | |
-# | Source | External | `external/repo2/dirA/fooA` | | `../repo2/dirA/fooA` | `repo2` | `external/repo2` |
-# | Generated | External | `bazel-out/k8-fastbuild/bin/external/repo2/dirA/gen.out` | `bazel-out/k8-fastbuild/bin` | `../repo2/dirA/gen.out` | `repo2` | `external/repo2` |
-
-def _owner(file):
- # File.owner allows us to find a label associated with a file. While highly
- # convenient, it may return None in certain circumstances, which seem to be
- # primarily when bazel doesn't know about the files in question.
- #
- # Given that a sizeable amount of the code we have here relies on it, we
- # should fail() when we encounter this if only to make the rare error more
- # clear.
- #
- # File.owner returns a Label structure
- if file.owner == None:
- fail("File {} ({}) has no owner attribute; cannot continue".format(file, file.path))
- else:
- return file.owner
-
-def _relative_workspace_root(label):
- # Helper function that returns the workspace root relative to the bazel File
- # "short_path", so we can exclude external workspace names in the common
- # path stripping logic.
- #
- # This currently is "../$LABEL_WORKSPACE_ROOT" if the label has a specific
- # workspace name specified, else it's just an empty string.
- #
- # TODO(nacl): Make this not a hack
- return paths.join("..", label.workspace_name) if label.workspace_name else ""
-
-def _path_relative_to_package(file):
- # Helper function that returns a path to a file relative to its package.
- owner = _owner(file)
- return paths.relativize(
- file.short_path,
- paths.join(_relative_workspace_root(owner), owner.package),
- )
-
-def _path_relative_to_repo_root(file):
- # Helper function that returns a path to a file relative to its workspace root.
- return paths.relativize(
- file.short_path,
- _relative_workspace_root(_owner(file)),
- )
-
-def _pkg_files_impl(ctx):
- # The input sources are already known. Let's calculate the destinations...
-
- # Exclude 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}
- elif ctx.attr.strip_prefix.startswith("/"):
- # Relative to workspace/repository root
- src_dest_paths_map = {src: paths.join(
- ctx.attr.prefix,
- _do_strip_prefix(
- _path_relative_to_repo_root(src),
- ctx.attr.strip_prefix[1:],
- src,
- ),
- ) for src in srcs}
- else:
- # Relative to package
- src_dest_paths_map = {src: paths.join(
- ctx.attr.prefix,
- _do_strip_prefix(
- _path_relative_to_package(src),
- ctx.attr.strip_prefix,
- src,
- ),
- ) for src in srcs}
-
- out_attributes = json.decode(ctx.attr.attributes)
-
- # The least surprising default mode is that of a normal file (0644)
- out_attributes.setdefault("mode", "0644")
-
- # Do file renaming
- for rename_src, rename_dest in ctx.attr.renames.items():
- # rename_src.files is a depset
- rename_src_files = rename_src.files.to_list()
-
- # Need to do a length check before proceeding. We cannot rename
- # multiple files simultaneously.
- if len(rename_src_files) != 1:
- fail(
- "Target {} expands to multiple files, should only refer to one".format(rename_src),
- "renames",
- )
-
- src_file = rename_src_files[0]
- if src_file not in src_dest_paths_map:
- fail(
- "File remapping from {0} to {1} is invalid: {0} is not provided to this rule or was excluded".format(rename_src, rename_dest),
- "renames",
- )
-
- if rename_dest == REMOVE_BASE_DIRECTORY:
- if not src_file.is_directory:
- fail(
- "REMOVE_BASE_DIRECTORY as a renaming target for non-directories is disallowed.",
- "renames",
- )
-
- # REMOVE_BASE_DIRECTORY results in the contents being dropped into
- # place directly in the prefix path.
- src_dest_paths_map[src_file] = ctx.attr.prefix
-
- 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
- # check for duplicated destinations.
- dest_src_map = {}
- for src, dest in src_dest_paths_map.items():
- if dest in dest_src_map:
- fail("After renames, multiple sources (at least {0}, {1}) map to the same destination. Consider adjusting strip_prefix and/or renames".format(dest_src_map[dest].path, src.path))
- dest_src_map[dest] = src
-
- return [
- PackageFilesInfo(
- dest_src_map = dest_src_map,
- attributes = out_attributes,
- ),
- DefaultInfo(
- # Simple passthrough
- files = depset(dest_src_map.values()),
- ),
- ]
-
-pkg_files = rule(
- doc = """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.
- """,
- implementation = _pkg_files_impl,
- # @unsorted-dict-items
- attrs = {
- "srcs": attr.label_list(
- doc = """Files/Labels to include in the outputs of these rules""",
- mandatory = True,
- allow_files = True,
- ),
- "attributes": attr.string(
- doc = """Attributes to set on packaged files.
-
- Always use `pkg_attributes()` to set this rule attribute.
-
- If not otherwise overridden, the file's mode will be set to UNIX
- "0644", or the target platform's equivalent.
-
- Consult the "Mapping Attributes" documentation in the rules_pkg
- reference for more details.
- """,
- default = "{}", # Empty JSON
- ),
- "prefix": attr.string(
- doc = """Installation prefix.
-
- This may be an arbitrary string, but it should be understandable by
- the packaging system you are using to have the desired outcome. For
- example, RPM macros like `%{_libdir}` may work correctly in paths
- for RPM packages, not, say, Debian packages.
-
- If any part of the directory structure of the computed destination
- of a file provided to `pkg_filegroup` or any similar rule does not
- already exist within a package, the package builder will create it
- for you with a reasonable set of default permissions (typically
- `0755 root.root`).
-
- It is possible to establish directory structures with arbitrary
- permissions using `pkg_mkdirs`.
- """,
- default = "",
- ),
- "strip_prefix": attr.string(
- doc = """What prefix of a file's path to discard prior to installation.
-
- This specifies what prefix of an incoming file's path should not be
- included in the output package at after being appended to the
- install prefix (the `prefix` attribute). Note that this is only
- applied to full directory names, see `strip_prefix` for more
- details.
-
- Use the `strip_prefix` struct to define this attribute. If this
- attribute is not specified, all directories will be stripped from
- all files prior to being included in packages
- (`strip_prefix.files_only()`).
-
- If prefix stripping fails on any file provided in `srcs`, the build
- will fail.
-
- 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.
- """,
- default = strip_prefix.files_only(),
- ),
- "excludes": attr.label_list(
- doc = """List of files or labels to exclude from the inputs to this rule.
-
- Mostly useful for removing files from generated outputs or
- preexisting `filegroup`s.
- """,
- default = [],
- allow_files = True,
- ),
- "renames": attr.label_keyed_string_dict(
- doc = """Destination override map.
-
- This attribute allows the user to override destinations of files in
- `pkg_file`s relative to the `prefix` attribute. Keys to the
- dict are source files/labels, values are destinations relative to
- the `prefix`, ignoring whatever value was provided for
- `strip_prefix`.
-
- If the key refers to a TreeArtifact (directory output), you may
- specify the constant `REMOVE_BASE_DIRECTORY` as the value, which
- will result in all containing files and directories being installed
- relative to the otherwise specified install prefix (via the `prefix`
- and `strip_prefix` attributes), not the directory name.
-
- The following keys are rejected:
-
- - Any label that expands to more than one file (mappings must be
- one-to-one).
-
- - Any label or file that was either not provided or explicitly
- `exclude`d.
-
- The following values result in undefined behavior:
-
- - "" (the empty string)
-
- - "."
-
- - Anything containing ".."
-
- """,
- 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],
-)
-
-def _pkg_mkdirs_impl(ctx):
- out_attributes = json.decode(ctx.attr.attributes)
-
- # The least surprising default mode is that of a normal directory (0755)
- out_attributes.setdefault("mode", "0755")
- return [
- PackageDirsInfo(
- dirs = ctx.attr.dirs,
- attributes = out_attributes,
- ),
- ]
-
-pkg_mkdirs = rule(
- doc = """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.
- """,
- implementation = _pkg_mkdirs_impl,
- # @unsorted-dict-items
- attrs = {
- "dirs": attr.string_list(
- doc = """Directory names to make within the package
-
- If any part of the requested directory structure does not already
- exist within a package, the package builder will create it for you
- with a reasonable set of default permissions (typically `0755
- root.root`).
-
- """,
- mandatory = True,
- ),
- "attributes": attr.string(
- doc = """Attributes to set on packaged directories.
-
- Always use `pkg_attributes()` to set this rule attribute.
-
- If not otherwise overridden, the directory's mode will be set to
- UNIX "0755", or the target platform's equivalent.
-
- Consult the "Mapping Attributes" documentation in the rules_pkg
- reference for more details.
- """,
- default = "{}", # Empty JSON
- ),
- },
- provides = [PackageDirsInfo],
-)
-
-def _pkg_mklink_impl(ctx):
- out_attributes = json.decode(ctx.attr.attributes)
-
- # The least surprising default mode is that of a symbolic link (0777).
- # Permissions on symlinks typically don't matter, as the operation is
- # typically moved to where the link is pointing.
- out_attributes.setdefault("mode", "0777")
- return [
- PackageSymlinkInfo(
- destination = ctx.attr.link_name,
- target = ctx.attr.target,
- attributes = out_attributes,
- ),
- ]
-
-pkg_mklink_impl = rule(
- doc = """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.
-
- """,
- implementation = _pkg_mklink_impl,
- # @unsorted-dict-items
- attrs = {
- "target": attr.string(
- doc = """Link "target", a path on the filesystem.
-
- This is what the link "points" to, and may point to an arbitrary
- filesystem path, even relative paths.
-
- """,
- mandatory = True,
- ),
- "link_name": attr.string(
- doc = """Link "destination", a path within the package.
-
- This is the actual created symbolic link.
-
- If the directory structure provided by this attribute is not
- otherwise created when exist within the package when it is built, it
- will be created implicitly, much like with `pkg_files`.
-
- This path may be prefixed or rooted by grouping or packaging rules.
-
- """,
- mandatory = True,
- ),
- "attributes": attr.string(
- doc = """Attributes to set on packaged symbolic links.
-
- Always use `pkg_attributes()` to set this rule attribute.
-
- Symlink permissions may have different meanings depending on your
- host operating system; consult its documentation for more details.
-
- If not otherwise overridden, the link's mode will be set to UNIX
- "0777", or the target platform's equivalent.
-
- Consult the "Mapping Attributes" documentation in the rules_pkg
- reference for more details.
- """,
- default = "{}", # Empty JSON
- ),
- },
- provides = [PackageSymlinkInfo],
-)
-
-#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 = []
- dirs = []
- links = []
- mapped_files_depsets = []
-
- if ctx.attr.prefix:
- # If "prefix" is provided, we need to manipulate the incoming providers.
- for s in ctx.attr.srcs:
- if PackageFilegroupInfo in s:
- old_pfgi, old_di = s[PackageFilegroupInfo], s[DefaultInfo]
-
- files += [
- (
- PackageFilesInfo(
- dest_src_map = {
- paths.join(ctx.attr.prefix, dest): src
- for dest, src in pfi.dest_src_map.items()
- },
- attributes = pfi.attributes,
- ),
- origin,
- )
- for (pfi, origin) in old_pfgi.pkg_files
- ]
- dirs += [
- (
- PackageDirsInfo(
- dirs = [paths.join(ctx.attr.prefix, d) for d in pdi.dirs],
- attributes = pdi.attributes,
- ),
- origin,
- )
- for (pdi, origin) in old_pfgi.pkg_dirs
- ]
- links += [
- (
- PackageSymlinkInfo(
- target = psi.target,
- destination = paths.join(ctx.attr.prefix, psi.destination),
- attributes = psi.attributes,
- ),
- origin,
- )
- for (psi, origin) in old_pfgi.pkg_symlinks
- ]
-
- mapped_files_depsets.append(old_di.files)
-
- if PackageFilesInfo in s:
- new_pfi = PackageFilesInfo(
- dest_src_map = {
- paths.join(ctx.attr.prefix, dest): src
- for dest, src in s[PackageFilesInfo].dest_src_map.items()
- },
- attributes = s[PackageFilesInfo].attributes,
- )
- files.append((new_pfi, s.label))
-
- # dict.values() returns a list, not an iterator like in python3
- mapped_files_depsets.append(s[DefaultInfo].files)
-
- if PackageDirsInfo in s:
- new_pdi = PackageDirsInfo(
- dirs = [paths.join(ctx.attr.prefix, d) for d in s[PackageDirsInfo].dirs],
- attributes = s[PackageDirsInfo].attributes,
- )
- dirs.append((new_pdi, s.label))
-
- if PackageSymlinkInfo in s:
- new_psi = PackageSymlinkInfo(
- target = s[PackageSymlinkInfo].target,
- destination = paths.join(ctx.attr.prefix, s[PackageSymlinkInfo].destination),
- attributes = s[PackageSymlinkInfo].attributes,
- )
- links.append((new_psi, s.label))
- else:
- # Otherwise, everything is pretty much direct copies
- for s in ctx.attr.srcs:
- if PackageFilegroupInfo in s:
- files += s[PackageFilegroupInfo].pkg_files
- mapped_files_depsets.append(s[DefaultInfo].files)
- dirs += s[PackageFilegroupInfo].pkg_dirs
- links += s[PackageFilegroupInfo].pkg_symlinks
-
- if PackageFilesInfo in s:
- files.append((s[PackageFilesInfo], s.label))
-
- # dict.values() returns a list, not an iterator like in python3
- mapped_files_depsets.append(s[DefaultInfo].files)
- if PackageDirsInfo in s:
- dirs.append((s[PackageDirsInfo], s.label))
- if PackageSymlinkInfo in s:
- links.append((s[PackageSymlinkInfo], s.label))
-
- return [
- PackageFilegroupInfo(
- pkg_files = files,
- pkg_dirs = dirs,
- pkg_symlinks = links,
- ),
- # Necessary to ensure that dependent rules have access to files being
- # mapped in.
- DefaultInfo(
- files = depset(transitive = mapped_files_depsets),
- ),
- ]
-
-pkg_filegroup = rule(
- doc = """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.
- """,
- implementation = _pkg_filegroup_impl,
- # @unsorted-dict-items
- attrs = {
- "srcs": attr.label_list(
- doc = """A list of packaging specifications to be grouped together.""",
- mandatory = True,
- providers = [
- [PackageFilegroupInfo, DefaultInfo],
- [PackageFilesInfo, DefaultInfo],
- [PackageDirsInfo],
- [PackageSymlinkInfo],
- ],
- ),
- "prefix": attr.string(
- doc = """A prefix to prepend to provided paths, applied like so:
-
- - For files and directories, this is simply prepended to the destination
- - For symbolic links, this is prepended to the "destination" part.
-
- """,
- ),
- },
- provides = [PackageFilegroupInfo],
-)
-
-def _filter_directory_argify_pair(pair):
- return "{}={}".format(*pair)
-
-def _filter_directory_impl(ctx):
- out_dir = ctx.actions.declare_directory(ctx.attr.outdir_name or ctx.attr.name)
-
- if not ctx.file.src.is_directory:
- fail("Must be a directory (TreeArtifact)", "src")
-
- args = ctx.actions.args()
-
- # Flags
- args.add_all(ctx.attr.excludes, before_each = "--exclude")
- args.add_all(ctx.attr.renames.items(), before_each = "--rename", map_each = _filter_directory_argify_pair)
-
- args.add("--prefix", ctx.attr.prefix)
- args.add("--strip_prefix", ctx.attr.strip_prefix)
-
- # Adding the directories directly here requires manually specifying the
- # path. Bazel will reject simply passing in the File object.
- args.add(ctx.file.src.path)
- args.add(out_dir.path)
-
- ctx.actions.run(
- executable = ctx.executable._filterer,
- use_default_shell_env = True,
- arguments = [args],
- inputs = [ctx.file.src],
- outputs = [out_dir],
- )
-
- return [DefaultInfo(files = depset([out_dir]))]
-
-filter_directory = rule(
- doc = """Transform directories (TreeArtifacts) using pkg_filegroup-like semantics.
-
- Effective order of operations:
-
- 1) Files are `exclude`d
- 2) `renames` _or_ `strip_prefix` is applied.
- 3) `prefix` is applied
-
- 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.
- """,
- implementation = _filter_directory_impl,
- # @unsorted-dict-items
- attrs = {
- "src": attr.label(
- doc = """Directory (TreeArtifact) to process.""",
- allow_single_file = True,
- mandatory = True,
- ),
- "outdir_name": attr.string(
- doc = """Name of output directory (otherwise defaults to the rule's name)""",
- ),
- "strip_prefix": attr.string(
- doc = """Prefix to remove from all paths in the output directory.
-
- Must apply to all paths in the directory, even those rename'd.
- """,
- ),
- "prefix": attr.string(
- doc = """Prefix to add to all paths in the output directory.
-
- This does not include the output directory name, which will be added
- regardless.
- """,
- ),
- "renames": attr.string_dict(
- doc = """Files to rename in the output directory.
-
- Keys are destinations, values are sources prior to any path
- modifications (e.g. via `prefix` or `strip_prefix`). Files that are
- `exclude`d must not be renamed.
-
- This currently only operates on individual files. `strip_prefix`
- does not apply to them.
-
- All renames must be used.
- """,
- ),
- "excludes": attr.string_list(
- doc = """Files to exclude from the output directory.
-
- Each element must refer to an individual file in `src`.
-
- All exclusions must be used.
- """,
- ),
- "_filterer": attr.label(
- default = "//pkg:filter_directory",
- executable = True,
- cfg = "exec",
- ),
- },
-)
diff --git a/pkg/package_variables.bzl b/pkg/package_variables.bzl
deleted file mode 100644
index 865fefd..0000000
--- a/pkg/package_variables.bzl
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Utility methods to populate PackageVariablesInfo instances."""
-
-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")
- return values
diff --git a/pkg/path.bzl b/pkg/path.bzl
deleted file mode 100644
index c933ccd..0000000
--- a/pkg/path.bzl
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2016 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.
-"""Helper functions that don't depend on Skylark, so can be unit tested."""
-
-def safe_short_path(file_):
- """Like `File.short_path` but safe for use with files from external repositories.
- """
- # Note: "F" is "File", "FO": is "File.owner". (Lifted from genpkg.bzl.)
- # | File type | Repo | `F.path` | `F.root.path` | `F.short_path` | `FO.workspace_name` | `FO.workspace_root` |
- # |-----------|----------|----------------------------------------------------------|------------------------------|-------------------------|---------------------|---------------------|
- # | Source | Local | `dirA/fooA` | | `dirA/fooA` | | |
- # | Generated | Local | `bazel-out/k8-fastbuild/bin/dirA/gen.out` | `bazel-out/k8-fastbuild/bin` | `dirA/gen.out` | | |
- # | Source | External | `external/repo2/dirA/fooA` | | `../repo2/dirA/fooA` | `repo2` | `external/repo2` |
- # | Generated | External | `bazel-out/k8-fastbuild/bin/external/repo2/dirA/gen.out` | `bazel-out/k8-fastbuild/bin` | `../repo2/dirA/gen.out` | `repo2` | `external/repo2` |
-
- # 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:]
- return working_path
-
-def _short_path_dirname(path):
- """Returns the directory's name of the short path of an artifact."""
- sp = safe_short_path(path)
- last_pkg = sp.rfind("/")
- if last_pkg == -1:
- # Top-level BUILD file.
- return ""
- return sp[:last_pkg]
-
-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)
- if strip_prefix == None:
- # If no strip_prefix was specified, use the package of the
- # given input as the strip_prefix.
- strip_prefix = _short_path_dirname(f)
- if not strip_prefix:
- return f_short_path
- if f_short_path.startswith(strip_prefix):
- # Check that the last directory in strip_prefix is a complete
- # directory (so that we don't strip part of a dir name)
- prefix_last_dir_index = strip_prefix.rfind("/")
- prefix_last_dir = strip_prefix[prefix_last_dir_index + 1:]
-
- # Avoid stripping prefix if final directory is incomplete
- if prefix_last_dir not in f_short_path.split("/"):
- strip_prefix = data_path_without_prefix
-
- return f_short_path[len(strip_prefix):]
- return f_short_path
-
-def compute_data_path(ctx, 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.
- """
- 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
- # 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
- elif data_path[0] == "/": # Absolute path
- return data_path[1:]
- else: # Relative to a sub-directory
- tmp_short_path_dirname = build_dir
- if tmp_short_path_dirname:
- return tmp_short_path_dirname + "/" + data_path
- return data_path
- else:
- return None
diff --git a/pkg/pkg.bzl b/pkg/pkg.bzl
deleted file mode 100644
index 1f4ba20..0000000
--- a/pkg/pkg.bzl
+++ /dev/null
@@ -1,22 +0,0 @@
-# Copyright 2015 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.
-"""Rules for manipulation of various packaging."""
-
-load("//pkg/private/deb:deb.bzl", _pkg_deb = "pkg_deb")
-load("//pkg/private/tar:tar.bzl", _pkg_tar = "pkg_tar")
-load("//pkg/private/zip:zip.bzl", _pkg_zip = "pkg_zip")
-
-pkg_deb = _pkg_deb
-pkg_tar = _pkg_tar
-pkg_zip = _pkg_zip
diff --git a/pkg/private/BUILD b/pkg/private/BUILD
deleted file mode 100644
index 8f3ca4c..0000000
--- a/pkg/private/BUILD
+++ /dev/null
@@ -1,110 +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.
-"""rules_pkg internal code.
-
-All interfaces are subject to change at any time.
-"""
-
-load("@rules_python//python:defs.bzl", "py_library")
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = [
- "BUILD",
- "install.py.tpl",
- ] + glob([
- "*.bzl",
- "*.py",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-exports_files(
- glob([
- "*.bzl",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//doc_build:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-# pkg_install's template script file
-exports_files(
- ["install.py.tpl"],
- visibility = ["//visibility:public"],
-)
-
-config_setting(
- name = "private_stamp_detect",
- values = {"stamp": "1"},
- # When --incompatible_config_setting_private_default_visibility is set, this fails unless this is public.
- # TODO: refactor to clear up confusion that this is a "private" target with public access.
- visibility = ["//visibility:public"],
-)
-
-py_library(
- name = "build_info",
- srcs = [
- "build_info.py",
- ],
- imports = ["../.."],
- srcs_version = "PY3",
- visibility = [
- "//:__subpackages__",
- "//tests:__pkg__",
- ],
-)
-
-py_library(
- name = "archive",
- srcs = [
- "__init__.py",
- "archive.py",
- ],
- imports = ["../.."],
- srcs_version = "PY3",
- visibility = [
- "//:__subpackages__",
- "//tests:__subpackages__",
- ],
-)
-
-py_library(
- name = "helpers",
- srcs = [
- "__init__.py",
- "helpers.py",
- ],
- imports = ["../.."],
- srcs_version = "PY3",
- visibility = [
- "//:__subpackages__",
- "//tests:__pkg__",
- ],
-)
-
-py_library(
- name = "manifest",
- srcs = ["manifest.py"],
- imports = ["../.."],
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
-)
diff --git a/pkg/private/__init__.py b/pkg/private/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/pkg/private/__init__.py
+++ /dev/null
diff --git a/pkg/private/archive.py b/pkg/private/archive.py
deleted file mode 100644
index f88db97..0000000
--- a/pkg/private/archive.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2015 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.
-"""Archive reader library for the .deb file testing."""
-
-import io
-import os
-
-class SimpleArReader(object):
- """A simple AR file reader.
-
- This enable to read AR file (System V variant) as described
- in https://en.wikipedia.org/wiki/Ar_(Unix).
-
- The standard usage of this class is:
-
- with SimpleArReader(filename) as ar:
- nextFile = ar.next()
- while nextFile:
- print('This archive contains', nextFile.filename)
- nextFile = ar.next()
-
- Upon error, this class will raise a ArError exception.
- """
-
- class ArError(Exception):
- pass
-
- class SimpleArFileEntry(object):
- """Represent one entry in a AR archive.
-
- Attributes:
- filename: the filename of the entry, as described in the archive.
- timestamp: the timestamp of the file entry.
- owner_id: numeric id of the user and group owning the file.
- group_id: numeric id of the user and group owning the file.
- mode: unix permission mode of the file
- size: size of the file
- data: the content of the file.
- """
-
- def __init__(self, f):
- self.filename = f.read(16).decode('utf-8').strip()
- if self.filename.endswith('/'): # SysV variant
- self.filename = self.filename[:-1]
- self.timestamp = int(f.read(12).strip())
- self.owner_id = int(f.read(6).strip())
- self.group_id = int(f.read(6).strip())
- self.mode = int(f.read(8).strip(), 8)
- self.size = int(f.read(10).strip())
- pad = f.read(2)
- if pad != b'\x60\x0a':
- raise SimpleArReader.ArError('Invalid AR file header')
- self.data = f.read(self.size)
-
- MAGIC_STRING = b'!<arch>\n'
-
- def __init__(self, filename):
- self.filename = filename
-
- def __enter__(self):
- self.f = open(self.filename, 'rb')
- if self.f.read(len(self.MAGIC_STRING)) != self.MAGIC_STRING:
- raise self.ArError('Not a ar file: ' + self.filename)
- return self
-
- def __exit__(self, t, v, traceback):
- self.f.close()
-
- def next(self):
- """Read the next file. Returns None when reaching the end of file."""
- # AR sections are two bit aligned using new lines.
- if self.f.tell() % 2 != 0:
- self.f.read(1)
- # An AR sections is at least 60 bytes. Some file might contains garbage
- # bytes at the end of the archive, ignore them.
- if self.f.tell() > os.fstat(self.f.fileno()).st_size - 60:
- return None
- return self.SimpleArFileEntry(self.f)
diff --git a/pkg/private/build_info.py b/pkg/private/build_info.py
deleted file mode 100644
index 6780623..0000000
--- a/pkg/private/build_info.py
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Get BUILD_TIMESTAMP."""
-
-
-def get_timestamp(volatile_status_file):
- """Get BUILD_TIMESTAMP as an integer.
-
- Reads a file of "name<space>value" pairs and returns the value
- of the BUILD_TIMESTAMP. The file should be in the workspace status
- format: https://docs.bazel.build/versions/master/user-manual.html#workspace_status
-
- Args:
- volatile_status_file: path to input file. Typically ctx.version_file.path.
- Returns:
- int: value of BUILD_TIMESTAMP
- Exceptions:
- Exception: Raised if there is no BUILD_TIMESTAMP or if it is not a number.
- """
- with open(volatile_status_file, 'r') as status_f:
- for line in status_f:
- parts = line.strip().split(' ')
- if len(parts) > 1 and parts[0] == 'BUILD_TIMESTAMP':
- return int(parts[1])
- raise Exception(
- "Invalid status file <%s>. Expected to find BUILD_TIMESTAMP" % volatile_status_file)
diff --git a/pkg/private/deb/BUILD b/pkg/private/deb/BUILD
deleted file mode 100644
index 646877b..0000000
--- a/pkg/private/deb/BUILD
+++ /dev/null
@@ -1,68 +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.
-"""rules_pkg internal code.
-
-All interfaces are subject to change at any time.
-"""
-
-load("@rules_python//python:defs.bzl", "py_binary", "py_library")
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = [
- "BUILD",
- ] + glob([
- "*.bzl",
- "*.py",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-exports_files(
- glob([
- "*.bzl",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//doc_build:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-py_binary(
- name = "make_deb",
- srcs = ["make_deb.py"],
- imports = ["../../.."],
- python_version = "PY3",
- visibility = ["//visibility:public"],
- deps = [
- "//pkg/private:helpers",
- ],
-)
-
-py_library(
- name = "make_deb_lib",
- srcs = ["make_deb.py"],
- imports = ["../../.."],
- srcs_version = "PY3",
- visibility = ["//tests/deb:__pkg__"],
- deps = [
- "//pkg/private:helpers",
- ],
-)
diff --git a/pkg/private/deb/deb.bzl b/pkg/private/deb/deb.bzl
deleted file mode 100644
index 5facdd7..0000000
--- a/pkg/private/deb/deb.bzl
+++ /dev/null
@@ -1,381 +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.
-"""Rule for creating Debian packages."""
-
-load("//pkg:providers.bzl", "PackageVariablesInfo")
-load("//pkg/private:util.bzl", "setup_output_files")
-
-_tar_filetype = [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz", "tar.zst"]
-
-def _pkg_deb_impl(ctx):
- """The implementation for the pkg_deb rule."""
-
- package_file_name = ctx.attr.package_file_name
- if not package_file_name:
- package_file_name = "%s_%s_%s.deb" % (
- ctx.attr.package,
- ctx.attr.version,
- ctx.attr.architecture,
- )
-
- outputs, output_file, output_name = setup_output_files(
- ctx,
- package_file_name = package_file_name,
- )
-
- changes_file = ctx.actions.declare_file(output_name.rsplit(".", 1)[0] + ".changes")
- outputs.append(changes_file)
-
- files = [ctx.file.data]
- args = [
- "--output=" + output_file.path,
- "--changes=" + changes_file.path,
- "--data=" + ctx.file.data.path,
- "--package=" + ctx.attr.package,
- "--maintainer=" + ctx.attr.maintainer,
- ]
-
- # Version and description can be specified by a file or inlined
- 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]
- else:
- args += ["--architecture=" + ctx.attr.architecture]
-
- if ctx.attr.preinst:
- args += ["--preinst=@" + ctx.file.preinst.path]
- files += [ctx.file.preinst]
- if ctx.attr.postinst:
- args += ["--postinst=@" + ctx.file.postinst.path]
- files += [ctx.file.postinst]
- if ctx.attr.prerm:
- args += ["--prerm=@" + ctx.file.prerm.path]
- files += [ctx.file.prerm]
- if ctx.attr.postrm:
- args += ["--postrm=@" + ctx.file.postrm.path]
- files += [ctx.file.postrm]
- if ctx.attr.config:
- args += ["--config=@" + ctx.file.config.path]
- files += [ctx.file.config]
- if ctx.attr.templates:
- args += ["--templates=@" + ctx.file.templates.path]
- files += [ctx.file.templates]
- if ctx.attr.triggers:
- args += ["--triggers=@" + ctx.file.triggers.path]
- files += [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]
- elif ctx.attr.conffiles:
- args += ["--conffile=%s" % cf for cf in ctx.attr.conffiles]
-
- # Version and description can be specified by a file or inlined
- 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]
- elif ctx.attr.version:
- args += ["--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]
- elif ctx.attr.description:
- args += ["--description=" + ctx.attr.description]
- else:
- fail("Neither description_file nor description attribute was specified")
-
- if ctx.attr.changelog:
- args += ["--changelog=@" + ctx.file.changelog.path]
- files += [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]
- elif ctx.attr.built_using:
- args += ["--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]
- elif ctx.attr.depends:
- args += ["--depends=" + d for d in ctx.attr.depends]
-
- if ctx.attr.priority:
- args += ["--priority=" + ctx.attr.priority]
- if ctx.attr.section:
- args += ["--section=" + ctx.attr.section]
- if ctx.attr.homepage:
- args += ["--homepage=" + ctx.attr.homepage]
- if ctx.attr.license:
- args += ["--license=" + ctx.attr.license]
-
- args += ["--distribution=" + ctx.attr.distribution]
- args += ["--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]
- args += ["--breaks=" + d for d in ctx.attr.breaks]
- args += ["--pre_depends=" + d for d in ctx.attr.predepends]
- args += ["--recommends=" + d for d in ctx.attr.recommends]
- args += ["--replaces=" + d for d in ctx.attr.replaces]
- args += ["--provides=" + d for d in ctx.attr.provides]
-
- ctx.actions.run(
- mnemonic = "MakeDeb",
- executable = ctx.executable._make_deb,
- arguments = args,
- inputs = files,
- outputs = [output_file, changes_file],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- )
- output_groups = {
- "out": [ctx.outputs.out],
- "deb": [output_file],
- "changes": [changes_file],
- }
- return [
- OutputGroupInfo(**output_groups),
- DefaultInfo(
- files = depset([output_file]),
- runfiles = ctx.runfiles(files = outputs),
- ),
- ]
-
-# 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 specificially 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(
- doc = """A tar file that contains the data for the debian package.""",
- mandatory = True,
- allow_single_file = _tar_filetype,
- ),
- "package": attr.string(
- doc = "The name of the package",
- mandatory = True,
- ),
- "architecture": attr.string(
- default = "all",
- doc = """Package architecture. Must not be used with architecture_file.""",
- ),
- "architecture_file": attr.label(
- doc = """File that contains the package architecture.
- Must not be used with architecture.""",
- allow_single_file = True,
- ),
- "maintainer": attr.string(
- doc = "The maintainer of the package.",
- mandatory = True,
- ),
- "version": attr.string(
- doc = """Package version. Must not be used with `version_file`.""",
- ),
- "version_file": attr.label(
- doc = """File that contains the package version.
- Must not be used with `version`.""",
- allow_single_file = True,
- ),
- "config": attr.label(
- doc = """config file used for debconf integration.
- 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
- ),
- "distribution": attr.string(
- doc = """"distribution: See http://www.debian.org/doc/debian-policy.""",
- default = "unstable",
- ),
- "urgency": attr.string(
- doc = """"urgency: See http://www.debian.org/doc/debian-policy.""",
- default = "medium",
- ),
- "preinst": attr.label(
- doc = """"The pre-install script for the package.
- See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
- allow_single_file = True,
- ),
- "postinst": attr.label(
- doc = """The post-install script for the package.
- See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
- allow_single_file = True,
- ),
- "prerm": attr.label(
- doc = """The pre-remove script for the package.
- See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
- allow_single_file = True,
- ),
- "postrm": attr.label(
- doc = """The post-remove script for the package.
- See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.""",
- allow_single_file = True,
- ),
- "templates": attr.label(
- doc = """templates file used for debconf integration.
- See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.""",
- allow_single_file = True,
- ),
- "triggers": attr.label(
- doc = """triggers file for configuring installation events exchanged by packages.
- See https://wiki.debian.org/DpkgTriggers.""",
- 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)."""
- ),
- "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
- ),
- "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.
-See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
- default = [],
- ),
- "conffiles_file": attr.label(
- 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.
-See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.""",
- allow_single_file = True,
- ),
- "priority": attr.string(
- doc = """The priority of the package.
- See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities.""",
- ),
- "section": attr.string(
- doc = """The section of the package.
- See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections.""",
- ),
- "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 = [],
- ),
- "conflicts": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "depends": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "depends_file": attr.label(
- doc = """File that contains a list of package dependencies. Must not be used with `depends`.
- See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- allow_single_file = True,
- ),
- "enhances": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "provides": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "predepends": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "recommends": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "replaces": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
- "suggests": attr.string_list(
- doc = """See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.""",
- default = [],
- ),
-
- # Common attributes
- "out": attr.output(
- doc = """See [Common Attributes](#out)""",
- mandatory = True
- ),
- "package_file_name": attr.string(
- doc = """See [Common Attributes](#package_file_name).
- Default: "{package}-{version}-{architecture}.deb""",
- ),
- "package_variables": attr.label(
- doc = """See [Common Attributes](#package_variables)""",
- providers = [PackageVariablesInfo],
- ),
-
- # Implicit dependencies.
- "_make_deb": attr.label(
- default = Label("//pkg/private/deb:make_deb"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
-)
-
-def pkg_deb(name, out = None, **kwargs):
- """@wraps(pkg_deb_impl)."""
- if not out:
- out = name + ".deb"
- pkg_deb_impl(
- name = name,
- out = out,
- **kwargs
- )
diff --git a/pkg/private/deb/make_deb.py b/pkg/private/deb/make_deb.py
deleted file mode 100644
index 9d10c4b..0000000
--- a/pkg/private/deb/make_deb.py
+++ /dev/null
@@ -1,422 +0,0 @@
-# Copyright 2015 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.
-"""A simple cross-platform helper to create a debian package."""
-
-import argparse
-from enum import Enum
-import gzip
-import hashlib
-import io
-import os
-import sys
-import tarfile
-import textwrap
-import time
-
-if sys.version_info < (3, 7):
- from collections import OrderedDict
-else:
- OrderedDict = dict
-
-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
-
-DEBIAN_FIELDS = [
- ('Package', True, False),
- ('Version', True, False),
- ('Section', False, False, 'contrib/devel'),
- ('Priority', False, False, 'optional'),
- ('Architecture', False, False, 'all'),
- ('Depends', False, False, []),
- ('Recommends', False, False, []),
- ('Replaces', False, False, []),
- ('Suggests', False, False, []),
- ('Enhances', False, False, []),
- ('Conflicts', False, False, []),
- ('Breaks', False, False, []),
- ('Pre-Depends', False, False, []),
- ('Provides', False, False, []),
- ('Installed-Size', False, False),
- ('Maintainer', True, False),
- ('Description', True, True),
- ('Homepage', False, False),
- ('License', False, False),
- ('Built-Using', False, False, None),
- ('Distribution', False, False, 'unstable'),
- ('Urgency', False, False, 'medium'),
-]
-
-# size of chunks for copying package content to final .deb file
-# This is a wild guess, but I am not convinced of the value of doing much work
-# to tune it.
-_COPY_CHUNK_SIZE = 1024 * 32
-
-
-def AddControlFlags(parser):
- """Creates a flag for each of the control file fields."""
- for field in DEBIAN_FIELDS:
- flag_name = '--' + field[0].replace('-', '_').lower()
- msg = 'The value for the %s content header entry.' % field[0]
- required = field[1]
- if len(field) > 3:
- default = field[3]
- if isinstance(field[3], list):
- parser.add_argument(flag_name, action='append', default=default,
- required=required, help=msg)
- else:
- parser.add_argument(flag_name, default=default, required=required,
- help=msg)
- else:
- parser.add_argument(flag_name, required=required, help=msg)
-
-
-def ConvertToFileLike(content, content_len, converter):
- if content_len < 0:
- content_len = len(content)
- content = converter(content)
- return content_len, content
-
-
-def AddArFileEntry(fileobj, filename,
- content='', content_len=-1, timestamp=0,
- owner_id=0, group_id=0, mode=0o644):
- """Add a AR file entry to fileobj."""
- # If we got the content as a string, turn it into a file like thing.
- if isinstance(content, (str, bytes)):
- content_len, content = ConvertToFileLike(content, content_len, io.BytesIO)
- inputs = [
- (filename + '/').ljust(16), # filename (SysV)
- str(timestamp).ljust(12), # timestamp
- str(owner_id).ljust(6), # owner id
- str(group_id).ljust(6), # group id
- str(oct(mode)).replace('0o', '0').ljust(8), # mode
- str(content_len).ljust(10), # size
- '\x60\x0a', # end of file entry
- ]
- for i in inputs:
- fileobj.write(i.encode('ascii'))
- size = 0
- while True:
- data = content.read(_COPY_CHUNK_SIZE)
- if not data:
- break
- size += len(data)
- fileobj.write(data)
- if size % 2 != 0:
- fileobj.write(b'\n') # 2-byte alignment padding
-
-
-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
-
- Args:
- name: Control field name
- value: Value for that
- """
- if isinstance(value, bytes):
- value = value.decode('utf-8')
- if isinstance(value, list):
- value = u', '.join(value)
- value = value.rstrip()
- 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')
- 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
- result += '\n'
- return result
-
-
-def CreateDebControl(extrafiles=None, **kwargs):
- """Create the control.tar.gz file."""
- # create the control file
- controlfile = u''
- for values in DEBIAN_FIELDS:
- fieldname = values[0]
- mandatory = values[1]
- 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], multiline)
- # Create the control.tar file
- tar = io.BytesIO()
- with gzip.GzipFile('control.tar.gz', mode='w', fileobj=tar, mtime=0) as gz:
- with tarfile.open('control.tar.gz', mode='w', fileobj=gz,
- format=tarfile.GNU_FORMAT) as f:
- tarinfo = tarfile.TarInfo('./control')
- control_file_data = controlfile.encode('utf-8')
- tarinfo.size = len(control_file_data)
- f.addfile(tarinfo, fileobj=io.BytesIO(control_file_data))
- if extrafiles:
- for name, (data, mode) in extrafiles.items():
- tarinfo = tarfile.TarInfo('./' + name)
- data_encoded = data.encode('utf-8')
- tarinfo.size = len(data_encoded)
- tarinfo.mode = mode
- f.addfile(tarinfo, fileobj=io.BytesIO(data_encoded))
- control = tar.getvalue()
- tar.close()
- return control
-
-
-def CreateDeb(output,
- data,
- preinst=None,
- postinst=None,
- prerm=None,
- postrm=None,
- config=None,
- templates=None,
- triggers=None,
- conffiles=None,
- changelog=None,
- **kwargs):
- """Create a full debian package."""
- extrafiles = OrderedDict()
- if preinst:
- extrafiles['preinst'] = (preinst, 0o755)
- if postinst:
- extrafiles['postinst'] = (postinst, 0o755)
- if prerm:
- extrafiles['prerm'] = (prerm, 0o755)
- if postrm:
- extrafiles['postrm'] = (postrm, 0o755)
- if config:
- extrafiles['config'] = (config, 0o755)
- if templates:
- extrafiles['templates'] = (templates, 0o644)
- if triggers:
- 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)
- with open(output, 'wb') as f:
- f.write(b'!<arch>\n') # Magic AR header
- AddArFileEntry(f, 'debian-binary', b'2.0\n')
- AddArFileEntry(f, 'control.tar.gz', control)
- # Tries to preserve the extension name
- ext = os.path.basename(data).split('.')[-2:]
- if len(ext) < 2:
- ext = 'tar'
- elif ext[1] == 'tgz':
- ext = 'tar.gz'
- elif ext[1] == 'tar.bzip2':
- ext = 'tar.bz2'
- else:
- ext = '.'.join(ext)
- 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:
- AddArFileEntry(f, 'data.' + ext, datafile, content_len=data_size)
-
-
-def GetChecksumsFromFile(filename, hash_fns=None):
- """Computes MD5 and/or other checksums of a file.
-
- Args:
- filename: Name of the file.
- hash_fns: Mapping of hash functions.
- Default is {'md5': hashlib.md5}
-
- Returns:
- Mapping of hash names to hexdigest strings.
- { <hashname>: <hexdigest>, ... }
- """
- hash_fns = hash_fns or {'md5': hashlib.md5}
- checksums = {k: fn() for (k, fn) in hash_fns.items()}
-
- with open(filename, 'rb') as file_handle:
- while True:
- buf = file_handle.read(1048576) # 1 MiB
- if not buf:
- break
- for hashfn in checksums.values():
- hashfn.update(buf)
-
- return {k: fn.hexdigest() for (k, fn) in checksums.items()}
-
-
-def CreateChanges(output,
- deb_file,
- architecture,
- description,
- maintainer,
- package,
- version,
- section,
- priority,
- distribution,
- urgency,
- timestamp=0):
- """Create the changes file."""
- checksums = GetChecksumsFromFile(deb_file, {'md5': hashlib.md5,
- 'sha1': hashlib.sha1,
- 'sha256': hashlib.sha256})
- debsize = str(os.path.getsize(deb_file))
- deb_basename = os.path.basename(deb_file)
-
- changesdata = u''.join([
- MakeDebianControlField('Format', '1.8'),
- MakeDebianControlField('Date', time.asctime(time.gmtime(timestamp))),
- MakeDebianControlField('Source', package),
- MakeDebianControlField('Binary', package),
- MakeDebianControlField('Architecture', architecture),
- MakeDebianControlField('Version', version),
- MakeDebianControlField('Distribution', distribution),
- MakeDebianControlField('Urgency', urgency),
- MakeDebianControlField('Maintainer', maintainer),
- MakeDebianControlField('Changed-By', maintainer),
- # The description in the changes file is strange
- MakeDebianControlField('Description', (
- '%s - %s\n') % (
- package, description.split('\n')[0]),
- multiline=Multiline.YES_ADD_NEWLINE),
- MakeDebianControlField('Changes', (
- '%s (%s) %s; urgency=%s'
- '\n Changes are tracked in revision control.') % (
- package, version, distribution, urgency),
- multiline=Multiline.YES_ADD_NEWLINE),
- MakeDebianControlField(
- 'Files', ' '.join(
- [checksums['md5'], debsize, section, priority, deb_basename]),
- multiline=Multiline.YES_ADD_NEWLINE),
- MakeDebianControlField(
- 'Checksums-Sha1',
- ' '.join([checksums['sha1'], debsize, deb_basename]),
- multiline=Multiline.YES_ADD_NEWLINE),
- MakeDebianControlField(
- 'Checksums-Sha256',
- ' '.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'))
-
-
-def GetFlagValues(flagvalues):
- if flagvalues:
- return [helpers.GetFlagValue(f, False) for f in flagvalues]
- else:
- return None
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Helper for building deb packages')
-
- parser.add_argument('--output', required=True,
- help='The output file, mandatory')
- parser.add_argument('--changes', required=True,
- help='The changes output file, mandatory.')
- parser.add_argument('--data', required=True,
- help='Path to the data tarball, mandatory')
- parser.add_argument(
- '--preinst',
- help='The preinst script (prefix with @ to provide a path).')
- parser.add_argument(
- '--postinst',
- help='The postinst script (prefix with @ to provide a path).')
- parser.add_argument(
- '--prerm',
- help='The prerm script (prefix with @ to provide a path).')
- parser.add_argument(
- '--postrm',
- help='The postrm script (prefix with @ to provide a path).')
- parser.add_argument(
- '--config',
- help='The config script (prefix with @ to provide a path).')
- parser.add_argument(
- '--templates',
- help='The templates file (prefix with @ to provide a path).')
- parser.add_argument(
- '--triggers',
- help='The triggers file (prefix with @ to provide a path).')
- # see
- # https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-conffile
- 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()
-
- CreateDeb(
- options.output,
- options.data,
- preinst=helpers.GetFlagValue(options.preinst, False),
- postinst=helpers.GetFlagValue(options.postinst, False),
- prerm=helpers.GetFlagValue(options.prerm, False),
- postrm=helpers.GetFlagValue(options.postrm, False),
- config=helpers.GetFlagValue(options.config, False),
- 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),
- maintainer=helpers.GetFlagValue(options.maintainer),
- section=options.section,
- architecture=helpers.GetFlagValue(options.architecture),
- depends=GetFlagValues(options.depends),
- suggests=options.suggests,
- enhances=options.enhances,
- preDepends=options.pre_depends,
- recommends=options.recommends,
- replaces=options.replaces,
- provides=options.provides,
- homepage=helpers.GetFlagValue(options.homepage),
- license=helpers.GetFlagValue(options.license),
- builtUsing=helpers.GetFlagValue(options.built_using),
- priority=options.priority,
- conflicts=options.conflicts,
- breaks=options.breaks,
- installedSize=helpers.GetFlagValue(options.installed_size))
- CreateChanges(
- output=options.changes,
- deb_file=options.output,
- architecture=options.architecture,
- description=helpers.GetFlagValue(options.description),
- maintainer=helpers.GetFlagValue(options.maintainer), package=options.package,
- version=helpers.GetFlagValue(options.version), section=options.section,
- priority=options.priority, distribution=options.distribution,
- urgency=options.urgency)
-
-if __name__ == '__main__':
- main()
diff --git a/pkg/private/helpers.py b/pkg/private/helpers.py
deleted file mode 100644
index 5147cc2..0000000
--- a/pkg/private/helpers.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright 2019 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.
-import os
-import sys
-
-def SplitNameValuePairAtSeparator(arg, sep):
- """Split a string at the first unquoted occurrence of a character.
-
- Split the string arg at the first unquoted occurrence of the character c.
- Here, in the first part of arg, the backslash is considered the
- quoting character indicating that the next character is to be
- added literally to the first part, even if it is the split character.
-
- Args:
- arg: the string to be split
- sep: the character at which to split
-
- Returns:
- The unquoted string before the separator and the string after the
- separator.
- """
- head = ''
- i = 0
- while i < len(arg):
- if arg[i] == sep:
- return (head, arg[i + 1:])
- elif arg[i] == '\\':
- i += 1
- if i == len(arg):
- # dangling quotation symbol
- return (head, '')
- else:
- head += arg[i]
- else:
- head += arg[i]
- i += 1
- # if we leave the loop, the character sep was not found unquoted
- return (head, '')
-
-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 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.
- https://docs.python.org/3/library/sys.html#sys.argv
- https://docs.python.org/3/library/os.html#os.fsencode
- https://www.python.org/dev/peps/pep-0383/
-
- Args:
- flagvalue: (str) raw flag value
- strip: (bool) Strip white space.
-
- Returns:
- Python2: unicode
- Python3: str
- """
- if flagvalue:
- if sys.version_info[0] < 3:
- # python2 gives us raw bytes in argv.
- flagvalue = flagvalue.decode('utf-8')
- # assertion: py2: flagvalue is unicode
- # assertion: py3: flagvalue is str, but in weird format
- if flagvalue[0] == '@':
- # Subtle: We do not want to re-encode the value here, because it
- # is encoded in the right format for file open operations.
- with open(flagvalue[1:], 'rb') as f:
- flagvalue = f.read().decode('utf-8')
- else:
- # convert fs specific encoding back to proper unicode.
- if sys.version_info[0] > 2:
- flagvalue = os.fsencode(flagvalue).decode('utf-8')
-
- if strip:
- return flagvalue.strip()
- return flagvalue
diff --git a/pkg/private/install.py.tpl b/pkg/private/install.py.tpl
deleted file mode 100644
index b0517f4..0000000
--- a/pkg/private/install.py.tpl
+++ /dev/null
@@ -1,203 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-# This template is completed by `pkg_install` to create installation scripts,
-# and will not function on its own. See pkg/install.bzl for more details.
-
-import argparse
-import logging
-import os
-import shutil
-import sys
-
-from pkg.private import manifest
-
-# Globals used for runfile path manipulation.
-#
-# These are necessary because runfiles are different when used as a part of
-# `bazel build` and `bazel run`. # See also
-# https://docs.bazel.build/versions/4.1.0/skylark/rules.html#tools-with-runfiles
-
-# Bazel's documentation claims these are set when calling `bazel run`, but not other
-# modes, like in `build` or `test`. We'll see.
-CALLED_FROM_BAZEL_RUN = bool(os.getenv("BUILD_WORKSPACE_DIRECTORY") and
- os.getenv("BUILD_WORKING_DIRECTORY"))
-
-WORKSPACE_NAME = "{WORKSPACE_NAME}"
-# This seems to be set when running in `bazel build` or `bazel test`
-# TODO(#382): This may not be the case in Windows.
-RUNFILE_PREFIX = os.path.join(os.getenv("RUNFILES_DIR"), WORKSPACE_NAME) if os.getenv("RUNFILES_DIR") else None
-
-
-# This is named "NativeInstaller" because it makes use of "native" python
-# functionality for installing files that should be cross-platform.
-#
-# A variant on this might be an installer at least partially based on coreutils.
-# Most notably, some filesystems on Linux (and maybe others) support
-# copy-on-write functionality that are known to tools like cp(1) and install(1)
-# but may not be in the available python runtime.
-#
-# See also https://bugs.python.org/issue37157.
-class NativeInstaller(object):
- def __init__(self, default_user=None, default_group=None, destdir=None):
- self.default_user = default_user
- self.default_group = default_group
- self.destdir = destdir
- self.entries = []
-
- # Logger helper method, may not be necessary or desired
- def _subst_destdir(path, self):
- return path.replace(self.destdir, "$DESTDIR")
-
- def _chown_chmod(self, dest, mode, user, group):
- if mode:
- logging.info("CHMOD %s %s", mode, dest)
- os.chmod(dest, int(mode, 8))
- if user or group:
- # Ownership can only be changed by sufficiently
- # privileged users.
- # TODO(nacl): This does not support windows
- if hasattr(os, "getuid") and os.getuid() == 0:
- logging.info("CHOWN %s:%s %s", user, group, dest)
- shutil.chown(dest, user, group)
-
- def _do_file_copy(self, src, dest, mode, user, group):
- logging.info("COPY %s <- %s", dest, src)
- shutil.copyfile(src, dest)
-
- def _do_mkdir(self, dirname, mode, user, group):
- logging.info("MKDIR %s %s", mode, dirname)
- os.makedirs(dirname, int(mode, 8), exist_ok=True)
-
- def _do_symlink(self, target, link_name, mode, user, group):
- raise NotImplementedError("symlinking not yet supported")
-
- def _maybe_make_unowned_dir(self, path):
- logging.info("MKDIR (unowned) %s", path)
- # TODO(nacl): consider default permissions here
- # TODO(nacl): consider default ownership here
- os.makedirs(path, 0o755, exist_ok=True)
-
- def _install_file(self, entry):
- self._maybe_make_unowned_dir(os.path.dirname(entry.dest))
- self._do_file_copy(entry.src, entry.dest, entry.mode, entry.user, entry.group)
- self._chown_chmod(entry.dest, entry.mode, entry.user, entry.group)
-
- def _install_directory(self, entry):
- self._maybe_make_unowned_dir(os.path.dirname(entry.dest))
- self._do_mkdir(entry.dest, entry.mode, entry.user, entry.group)
- self._chown_chmod(entry.dest, entry.mode, entry.user, entry.group)
-
- def _install_treeartifact(self, entry):
- logging.info("COPYTREE %s <- %s/**", entry.dest, entry.src)
- raise NotImplementedError("treeartifact installation not yet supported")
- for root, dirs, files in os.walk(entry.src):
- relative_installdir = os.path.join(entry.dest, root)
- for d in dirs:
- self._maybe_make_unowned_dir(os.path.join(relative_installdir, d))
-
- logging.info("COPY_FROM_TREE %s <- %s", entry.dest, entry.src)
- logging.info("CHMOD %s %s", entry.mode, entry.dest)
- logging.info("CHOWN %s:%s %s", entry.user, entry.group, entry.dest)
-
- def _install_symlink(self, entry):
- raise NotImplementedError("symlinking not yet supported")
- logging.info("SYMLINK %s <- %s", entry.dest, entry.link_to)
- logging.info("CHMOD %s %s", entry.dest, entry.mode)
- logging.info("CHOWN %s.%s %s", entry.dest, entry.user, entry.group)
-
- def include_manifest_path(self, path):
- with open(path, 'r') as fh:
- self.include_manifest(fh)
-
- def include_manifest(self, manifest_fh):
- manifest_entries = manifest.read_entries_from(manifest_fh)
-
- for entry in manifest_entries:
- # Swap out the source with the actual "runfile" location if we're
- # called as a part of the build rather than "bazel run"
- if not CALLED_FROM_BAZEL_RUN and entry.src is not None:
- entry.src = os.path.join(RUNFILE_PREFIX, entry.src)
- # Prepend the destdir path to all installation paths, if one is
- # specified.
- if self.destdir is not None:
- entry.dest = os.path.join(self.destdir, entry.dest)
- self.entries.append(entry)
-
- def do_the_thing(self):
- for entry in self.entries:
- if entry.type == manifest.ENTRY_IS_FILE:
- self._install_file(entry)
- elif entry.type == manifest.ENTRY_IS_LINK:
- self._install_symlink(entry)
- elif entry.type == manifest.ENTRY_IS_DIR:
- self._install_directory(entry)
- elif entry.type == manifest.ENTRY_IS_TREE:
- self._install_treeartifact(entry)
- else:
- raise ValueError("Unrecognized entry type '{}'".format(entry.type))
-
-
-def main(args):
- parser = argparse.ArgumentParser(
- prog="bazel run -- {TARGET_LABEL}",
- description='Installer for bazel target {TARGET_LABEL}',
- fromfile_prefix_chars='@',
- )
- parser.add_argument('-v', '--verbose', action='count', default=0,
- help="Be verbose. Specify multiple times to increase verbosity further")
- parser.add_argument('-q', '--quiet', action='store_true', default=False,
- help="Be silent, except for errors")
- # TODO(nacl): consider supporting DESTDIR=/whatever syntax, like "make
- # install".
- #
- # TODO(nacl): consider removing absolute path restriction, perhaps using
- # BUILD_WORKING_DIRECTORY.
- parser.add_argument('--destdir', action='store', default=os.getenv("DESTDIR"),
- help="Installation root directory (defaults to DESTDIR "
- "environment variable). Must be an absolute path.")
-
- args = parser.parse_args()
-
- loudness = args.verbose - args.quiet
-
- if args.quiet:
- logging.getLogger().setLevel(logging.ERROR)
- elif loudness == 0:
- logging.getLogger().setLevel(logging.WARNING)
- elif loudness == 1:
- logging.getLogger().setLevel(logging.INFO)
- else: # loudness >= 2:
- logging.getLogger().setLevel(logging.DEBUG)
-
- 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 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
-
- for f in ["{MANIFEST_INCLUSION}"]:
- if CALLED_FROM_BAZEL_RUN:
- installer.include_manifest_path(f)
- else:
- installer.include_manifest_path(os.path.join(RUNFILE_PREFIX, f))
-
- installer.do_the_thing()
-
-
-if __name__ == "__main__":
- exit(main(sys.argv))
diff --git a/pkg/private/make_starlark_library.bzl b/pkg/private/make_starlark_library.bzl
deleted file mode 100644
index c6b0dee..0000000
--- a/pkg/private/make_starlark_library.bzl
+++ /dev/null
@@ -1,35 +0,0 @@
-"""Turn a label_list of mixed sources and bzl_library's into a bzl_library.
-
-The sources can be anything. Only the ones that end in ".bzl" will be added.
-"""
-
-load("@bazel_skylib//:bzl_library.bzl", "StarlarkLibraryInfo")
-
-def _make_starlark_library(ctx):
- direct = []
- transitive = []
- for src in ctx.attr.srcs:
- if StarlarkLibraryInfo in src:
- transitive.append(src[StarlarkLibraryInfo])
- else:
- for file in src[DefaultInfo].files.to_list():
- if file.path.endswith(".bzl"):
- # print(file.path)
- direct.append(file)
- all_files = depset(direct, transitive = transitive)
- return [
- DefaultInfo(files = all_files, runfiles = ctx.runfiles(transitive_files = all_files)),
- StarlarkLibraryInfo(srcs = direct, transitive_srcs = all_files),
- ]
-
-starlark_library = rule(
- implementation = _make_starlark_library,
- attrs = {
- "srcs": attr.label_list(
- doc = "Any mix of source files. Only .bzl files will be used.",
- allow_files = True,
- cfg = "exec",
- mandatory = True,
- ),
- },
-)
diff --git a/pkg/private/manifest.py b/pkg/private/manifest.py
deleted file mode 100644
index 6bfd387..0000000
--- a/pkg/private/manifest.py
+++ /dev/null
@@ -1,79 +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.
-
-"""Common package builder manifest helpers
-"""
-
-import json
-
-
-# These must be kept in sync with the declarations in private/pkg_files.bzl
-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_EMPTY_FILE = "empty-file" # Entry is a an empty file
-
-class ManifestEntry(object):
- """Structured wrapper around rules_pkg-produced manifest entries"""
- type: str
- dest: str
- src: str
- mode: str
- user: str
- group: str
- uid: int
- gid: int
- origin: str = 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):
- return "ManifestEntry<{}>".format(vars(self))
-
-def read_entries_from(fh):
- """Return a list of ManifestEntry's from `fh`"""
- # Subtle: decode the content with read() rather than in json.load() because
- # the load in older python releases (< 3.7?) does not know how to decode.
- raw_entries = json.loads(fh.read())
- return [ManifestEntry(**entry) for entry in raw_entries]
-
-def read_entries_from_file(manifest_path):
- """Return a list of ManifestEntry's from the manifest file at `path`"""
- with open(manifest_path, 'r', encoding='utf-8') as fh:
- return read_entries_from(fh)
-
-def entry_type_to_string(et):
- """Entry type stringifier"""
- if et == ENTRY_IS_FILE:
- return "file"
- elif et == ENTRY_IS_LINK:
- return "symlink",
- elif et == ENTRY_IS_DIR:
- return "directory"
- elif et == ENTRY_IS_TREE:
- return "tree"
- elif et == ENTRY_IS_EMPTY_FILE:
- return "empty_file"
- else:
- raise ValueError("Invalid entry id {}".format(et))
diff --git a/pkg/private/pkg_files.bzl b/pkg/private/pkg_files.bzl
deleted file mode 100644
index 86a438b..0000000
--- a/pkg/private/pkg_files.bzl
+++ /dev/null
@@ -1,610 +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.
-"""Internal functions for processing pkg_file* instances.
-
-Concepts and terms:
-
- DestFile: A provider holding the source path, attributes and other
- information about a file that should appear in the package.
- When attributes are empty in DestFile, we let the package
- tool decide their values.
-
- content map: The map of destination paths to DestFile instances. Note that
- several distinct destinations make share the same source path.
- Attempting to insert a duplicate entry in the content map is
- an error, because it means you are collapsing files together.
- We may want to relax this in the future if their DestFiles
- are equal.
-
- manifest: The file which represents the content map. This is generated
- by rule implementations and passed to the build_*.py helpers.
-"""
-
-load("//pkg:path.bzl", "compute_data_path", "dest_path")
-load(
- "//pkg:providers.bzl",
- "PackageDirsInfo",
- "PackageFilegroupInfo",
- "PackageFilesInfo",
- "PackageSymlinkInfo",
-)
-
-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_EMPTY_FILE = "empty-file" # Entry is a an empty file
-
-_DestFile = provider(
- doc = """Information about each destination in the final package.""",
- fields = {
- "src": "source file",
- "mode": "mode, or empty",
- "user": "user, or empty",
- "group": "group, or empty",
- "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(ctx, content_map, dest, src, origin):
- old_entry = content_map.get(dest)
- if not old_entry:
- return
- if old_entry.src == src or old_entry.origin == origin:
- return
-
- # TODO(#385): This is insufficient but good enough for now. We should
- # compare over all the attributes too. That will detect problems where
- # 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:
- msg = "Duplicate output path: <%s>, declared in %s and %s\n SRC: %s" % (
- dest,
- origin,
- content_map[dest].origin,
- src,
- )
- if ctx.attr.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, 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
-
- 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 _process_pkg_dirs(ctx, content_map, pkg_dirs_info, origin, default_mode, default_user, default_group, default_uid, default_gid):
- attrs = _merge_attributes(pkg_dirs_info, default_mode, default_user, default_group, default_uid, default_gid)
- for dir in pkg_dirs_info.dirs:
- dest = dir.strip("/")
- _check_dest(ctx, content_map, dest, None, origin)
- 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(ctx, content_map, pkg_files_info, origin, default_mode, default_user, default_group, default_uid, default_gid):
- attrs = _merge_attributes(pkg_files_info, default_mode, default_user, default_group, default_uid, default_gid)
- for filename, src in pkg_files_info.dest_src_map.items():
- dest = filename.strip("/")
- _check_dest(ctx, content_map, dest, src, origin)
- 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(ctx, content_map, pkg_symlink_info, origin, default_mode, default_user, default_group, default_uid, default_gid):
- dest = pkg_symlink_info.destination.strip("/")
- attrs = _merge_attributes(pkg_symlink_info, default_mode, default_user, default_group, default_uid, default_gid)
- _check_dest(ctx, content_map, dest, None, origin)
- 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(ctx, content_map, pkg_filegroup_info, origin, default_mode, default_user, default_group, default_uid, default_gid):
- if hasattr(pkg_filegroup_info, "pkg_dirs"):
- for d in pkg_filegroup_info.pkg_dirs:
- _process_pkg_dirs(ctx, content_map, d[0], d[1], default_mode, default_user, default_group, default_uid, default_gid)
- if hasattr(pkg_filegroup_info, "pkg_files"):
- for pf in pkg_filegroup_info.pkg_files:
- _process_pkg_files(ctx, content_map, pf[0], pf[1], default_mode, default_user, default_group, default_uid, default_gid)
- if hasattr(pkg_filegroup_info, "pkg_symlinks"):
- for psl in pkg_filegroup_info.pkg_symlinks:
- _process_pkg_symlink(ctx, content_map, psl[0], psl[1], default_mode, default_user, default_group, default_uid, default_gid)
-
-def process_src(
- ctx,
- content_map,
- files,
- src,
- origin,
- default_mode,
- default_user,
- default_group,
- default_uid = None,
- default_gid = None):
- """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
- 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
- default_uid: fallback uid to use for Package*Info elements without uid
- default_gid: fallback gid to use for Package*Info elements without gid
-
- Returns:
- True if src was a Package*Info and added to content_map.
- """
-
- # 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)
- found_info = False
- if PackageFilesInfo in src:
- _process_pkg_files(
- ctx,
- content_map,
- src[PackageFilesInfo],
- origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- )
- found_info = True
- if PackageFilegroupInfo in src:
- _process_pkg_filegroup(
- ctx,
- content_map,
- src[PackageFilegroupInfo],
- origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- )
- found_info = True
- if PackageSymlinkInfo in src:
- _process_pkg_symlink(
- ctx,
- content_map,
- src[PackageSymlinkInfo],
- origin,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- )
- found_info = True
- if PackageDirsInfo in src:
- _process_pkg_dirs(
- ctx,
- content_map,
- src[PackageDirsInfo],
- origin,
- default_mode = "0555",
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- )
- found_info = True
- return found_info
-
-def add_directory(content_map, 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
- 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
- """
- content_map[dir_path.strip("/")] = _DestFile(
- src = None,
- entry_type = ENTRY_IS_DIR,
- origin = origin,
- mode = mode,
- user = user,
- group = group,
- uid = uid,
- gid = gid,
- )
-
-def add_empty_file(ctx, content_map, dest_path, origin, mode = None, user = None, group = None, uid = None, gid = None):
- """Add a single file to the content map.
-
- Args:
- ctx: rule context.
- content_map: The content map
- 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
- """
- dest = dest_path.strip("/")
- _check_dest(ctx, content_map, dest, None, origin)
- content_map[dest] = _DestFile(
- src = None,
- entry_type = ENTRY_IS_EMPTY_FILE,
- origin = origin,
- mode = mode,
- user = user,
- group = group,
- uid = uid,
- gid = gid,
- )
-
-def add_label_list(
- ctx,
- content_map,
- file_deps,
- srcs,
- default_mode = None,
- default_user = None,
- default_group = None,
- default_uid = None,
- default_gid = None):
- """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
- default_uid: fallback uid to use for Package*Info elements without uid
- default_gid: fallback gid to use for Package*Info elements without guid
- """
-
- 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 "",
- )
- data_path_without_prefix = compute_data_path(ctx, ".")
-
- for src in srcs:
- if not process_src(
- ctx,
- content_map,
- file_deps,
- src = src,
- origin = src.label,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- ):
- # Add in the files of srcs which are not pkg_* types
- add_from_default_info(
- ctx,
- content_map,
- file_deps,
- src,
- data_path,
- data_path_without_prefix,
- default_mode = default_mode,
- default_user = default_user,
- default_group = default_group,
- default_uid = default_uid,
- default_gid = default_gid,
- include_runfiles = include_runfiles,
- )
-
-def add_from_default_info(
- ctx,
- content_map,
- file_deps,
- src,
- data_path,
- data_path_without_prefix,
- default_mode = None,
- default_user = None,
- default_group = None,
- default_uid = None,
- default_gid = None,
- include_runfiles = False):
- """Helper method to add the DefaultInfo of a target 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.
- 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:
- return
-
- # Auto-detect the executable so we can set its mode.
- 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)
- if f.is_directory:
- add_tree_artifact(
- content_map,
- d_path,
- f,
- origin = src.label,
- mode = default_mode,
- user = default_user,
- group = default_group,
- )
- else:
- fmode = "0755" if f == the_executable else default_mode
- add_single_file(
- ctx,
- content_map,
- dest_path = d_path,
- src = f,
- origin = src.label,
- mode = fmode,
- user = default_user,
- group = default_group,
- )
- if include_runfiles:
- runfiles = src[DefaultInfo].default_runfiles
- if runfiles:
- base_path = d_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(ctx, content_map, d_path, rf, src.label)
- content_map[d_path] = _DestFile(
- src = rf,
- entry_type = ENTRY_IS_FILE,
- origin = src.label,
- mode = fmode,
- user = default_user,
- group = default_group,
- uid = default_uid,
- gid = default_gid,
- )
-
-def get_my_executable(src):
- """If a target represents an executable, return its file handle.
-
- The roundabout hackery here is because there is no good way to see if
- DefaultInfo was created with an executable in it.
- See: https://github.com/bazelbuild/bazel/issues/14811
-
- Args:
- src: A label.
- Returns:
- File or None.
- """
- if not DefaultInfo in src:
- return None
- di = src[DefaultInfo]
- if not hasattr(di, "files_to_run"):
- return None
- ftr = di.files_to_run
-
- # The docs lead you to believe that you could look at
- # files_to_run.executable, but that is filled out even for source
- # files.
- if not hasattr(ftr, "runfiles_manifest"):
- return None
- if ftr.runfiles_manifest:
- # DEBUG print("Got an manifest executable", ftr.executable)
- return ftr.executable
- return None
-
-
-def add_single_file(ctx, content_map, dest_path, src, origin, mode = None, user = None, group = None, uid = None, gid = None):
- """Add an single file to the content map.
-
- Args:
- ctx: rule context.
- content_map: The content map
- 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
- """
- dest = dest_path.strip("/")
- _check_dest(ctx, content_map, dest, src, origin)
- content_map[dest] = _DestFile(
- src = src,
- entry_type = ENTRY_IS_FILE,
- origin = origin,
- mode = mode,
- user = user,
- group = group,
- uid = uid,
- gid = gid,
- )
-
-def add_symlink(ctx, content_map, dest_path, src, origin, mode = None, user = None, group = None, uid = None, gid = None):
-
- """Add a symlink to the content map.
-
- Args:
- ctx: rule context.
- content_map: The content map
- 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(ctx, content_map, dest, None, origin)
- content_map[dest] = _DestFile(
- src = None,
- link_to = src,
- entry_type = ENTRY_IS_LINK,
- origin = origin,
- mode = mode,
- user = user,
- group = group,
- uid = uid,
- gid = gid,
- )
-
-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:
- content_map: The content map
- 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
- """
- content_map[dest_path] = _DestFile(
- src = src,
- origin = origin,
- entry_type = ENTRY_IS_TREE,
- 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):
- """Write a content map to a manifest file.
-
- The format of this file is currently undocumented, as it is a private
- contract between the rule implementation and the package writers. It will
- become a published interface in a future release.
-
- For reproducibility, the manifest file must be ordered consistently.
-
- Args:
- ctx: rule context
- 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`.
- """
- ctx.actions.write(
- manifest_file,
- "[\n" + ",\n".join(
- [
- _encode_manifest_entry(dst, content_map[dst], use_short_path, pretty_print)
- for dst in sorted(content_map.keys())
- ]
- ) + "\n]\n"
- )
-
-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
- # entry_type is left as-is
-
- elif hasattr(df, "link_to"):
- src = df.link_to
- entry_type = ENTRY_IS_LINK
- else:
- src = None
-
- # Bazel 6 has a new flag "--incompatible_unambiguous_label_stringification"
- # (https://github.com/bazelbuild/bazel/issues/15916) that causes labels in
- # the repository in which Bazel was run to be stringified with a preceding
- # "@". In older versions, this flag did not exist.
- #
- # 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
-
- data = {
- "type": df.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,
- }
-
- if pretty_print:
- return json.encode_indent(data)
- else:
- return json.encode(data)
diff --git a/pkg/private/tar/BUILD b/pkg/private/tar/BUILD
deleted file mode 100644
index 6bfeb1e..0000000
--- a/pkg/private/tar/BUILD
+++ /dev/null
@@ -1,71 +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.
-"""rules_pkg internal code.
-
-All interfaces are subject to change at any time.
-"""
-
-load("@rules_python//python:defs.bzl", "py_binary", "py_library")
-
-licenses(["notice"])
-
-filegroup(
- name = "standard_package",
- srcs = [
- "BUILD",
- ] + glob([
- "*.bzl",
- "*.py",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-exports_files(
- glob(["*.bzl"]),
- visibility = [
- "//distro:__pkg__",
- "//doc_build:__pkg__",
- ],
-)
-
-py_binary(
- name = "build_tar",
- srcs = ["build_tar.py"],
- imports = ["../../.."],
- python_version = "PY3",
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
- deps = [
- ":tar_writer",
- "//pkg/private:archive",
- "//pkg/private:build_info",
- "//pkg/private:helpers",
- "//pkg/private:manifest",
- ],
-)
-
-py_library(
- name = "tar_writer",
- 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
deleted file mode 100644
index 08a3a06..0000000
--- a/pkg/private/tar/build_tar.py
+++ /dev/null
@@ -1,459 +0,0 @@
-# Copyright 2015 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.
-"""This tool build tar files from a list of inputs."""
-
-import argparse
-import os
-import tarfile
-import tempfile
-
-from pkg.private import archive
-from pkg.private import helpers
-from pkg.private import build_info
-from pkg.private import manifest
-from pkg.private.tar import tar_writer
-
-
-def normpath(path):
- """Normalize a path to the format we need it.
-
- os.path.normpath changes / to \ on windows, but tarfile needs / style paths.
-
- Args:
- path: (str) path to normalize.
- """
- return os.path.normpath(path).replace(os.path.sep, '/')
-
-
-class TarFile(object):
- """A class to generates a TAR file."""
-
- class DebError(Exception):
- pass
-
- def __init__(self, output, directory, compression, compressor, default_mtime):
- # Directory prefix on all output paths
- d = directory.strip('/')
- self.directory = (d + '/') if d else None
- self.output = output
- self.compression = compression
- self.compressor = compressor
- self.default_mtime = default_mtime
-
- def __enter__(self):
- self.tarfile = tar_writer.TarFileWriter(
- self.output,
- self.compression,
- self.compressor,
- default_mtime=self.default_mtime)
- return self
-
- def __exit__(self, t, v, traceback):
- self.tarfile.close()
-
- def normalize_path(self, path: str) -> str:
- dest = normpath(path)
- # paths should not have a leading ./
- if dest.startswith('./'):
- dest = dest[2:]
- # No path should ever come in with slashs on either end, but protect
- # against that anyway.
- dest = dest.strip('/')
- # 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
-
- def add_file(self, f, destfile, mode=None, ids=None, names=None):
- """Add a file to the tar file.
-
- Args:
- f: the file to add to the layer
- destfile: the name of the file in the layer
- mode: (int) force to set the specified mode, by default the value from the
- source is taken.
- ids: (uid, gid) for the file to set ownership
- names: (username, groupname) for the file to set ownership. `f` will be
- copied to `self.directory/destfile` in the layer.
- """
- dest = self.normalize_path(destfile)
- # If mode is unspecified, derive the mode from the file's mode.
- if mode is None:
- mode = 0o755 if os.access(f, os.X_OK) else 0o644
- if ids is None:
- ids = (0, 0)
- if names is None:
- names = ('', '')
- self.tarfile.add_file(
- dest,
- file_content=f,
- mode=mode,
- uid=ids[0],
- gid=ids[1],
- uname=names[0],
- gname=names[1])
-
- def add_empty_file(self,
- destfile,
- mode=None,
- ids=None,
- names=None,
- kind=tarfile.REGTYPE):
- """Add a file to the tar file.
-
- Args:
- destfile: the name of the file in the layer
- mode: force to set the specified mode, defaults to 644
- ids: (uid, gid) for the file to set ownership
- names: (username, groupname) for the file to set ownership.
- kind: type of the file. tarfile.DIRTYPE for directory. An empty file
- will be created as `destfile` in the layer.
- """
- dest = destfile.lstrip('/') # Remove leading slashes
- # If mode is unspecified, assume read only
- if mode is None:
- mode = 0o644
- if ids is None:
- ids = (0, 0)
- if names is None:
- names = ('', '')
- dest = normpath(dest)
- self.tarfile.add_file(
- dest,
- content='' if kind == tarfile.REGTYPE else None,
- kind=kind,
- mode=mode,
- uid=ids[0],
- gid=ids[1],
- uname=names[0],
- gname=names[1])
-
- def add_empty_dir(self, destpath, mode=None, ids=None, names=None):
- """Add a directory to the tar file.
-
- Args:
- destpath: the name of the directory in the layer
- mode: force to set the specified mode, defaults to 644
- ids: (uid, gid) for the file to set ownership
- names: (username, groupname) for the file to set ownership. An empty
- file will be created as `destfile` in the layer.
- """
- self.add_empty_file(
- destpath, mode=mode, ids=ids, names=names, kind=tarfile.DIRTYPE)
-
- def add_tar(self, tar):
- """Merge a tar file into the destination tar file.
-
- All files presents in that tar will be added to the output file
- under self.directory/path. No user name nor group name will be
- added to the output.
-
- Args:
- tar: the tar file to add
- """
- self.tarfile.add_tar(tar, numeric=True, prefix=self.directory)
-
- def add_link(self, symlink, destination, mode=None, ids=None, names=None):
- """Add a symbolic link pointing to `destination`.
-
- Args:
- symlink: the name of the symbolic link to add.
- destination: where the symbolic link point to.
- mode: (int) force to set the specified posix mode (e.g. 0o755). The
- default is derived from the source
- ids: (uid, gid) for the file to set ownership
- names: (username, groupname) for the file to set ownership. An empty
- file will be created as `destfile` in the layer.
- """
- dest = self.normalize_path(symlink)
- self.tarfile.add_file(
- dest,
- tarfile.SYMTYPE,
- link=destination,
- mode = mode,
- uid=ids[0],
- gid=ids[1],
- uname=names[0],
- gname=names[1])
-
- def add_deb(self, deb):
- """Extract a debian package in the output tar.
-
- All files presents in that debian package will be added to the
- output tar under the same paths. No user name nor group names will
- be added to the output.
-
- Args:
- deb: the tar file to add
-
- Raises:
- DebError: if the format of the deb archive is incorrect.
- """
- with archive.SimpleArReader(deb) as arfile:
- current = next(arfile)
- while current and not current.filename.startswith('data.'):
- current = next(arfile)
- if not current:
- raise self.DebError(deb + ' does not contains a data file!')
- tmpfile = tempfile.mkstemp(suffix=os.path.splitext(current.filename)[-1])
- with open(tmpfile[1], 'wb') as f:
- f.write(current.data)
- self.add_tar(tmpfile[1])
- os.remove(tmpfile[1])
-
- def add_tree(self, tree_top, destpath, mode=None, ids=None, names=None):
- """Add a tree artifact to the tar file.
-
- Args:
- tree_top: the top of the tree to add
- destpath: the path under which to place the files
- mode: (int) force to set the specified posix mode (e.g. 0o755). The
- default is derived from the source
- ids: (uid, gid) for the file to set ownership
- names: (username, groupname) for the file to set ownership. `f` will be
- copied to `self.directory/destfile` in the layer.
- """
- # We expect /-style paths.
- tree_top = normpath(tree_top)
-
- dest = destpath.strip('/') # redundant, dests should never have / here
- if self.directory and self.directory != '/':
- dest = self.directory.lstrip('/') + '/' + dest
-
- # Again, we expect /-style paths.
- dest = normpath(dest)
- # normpath may be ".", and dest paths should not start with "./"
- dest = '' if dest == '.' else dest + '/'
-
- if ids is None:
- ids = (0, 0)
- if names is None:
- names = ('', '')
-
- to_write = {}
- for root, dirs, files in os.walk(tree_top):
- # While `tree_top` uses '/' as a path separator, results returned by
- # `os.walk` and `os.path.join` on Windows may not.
- root = normpath(root)
-
- dirs = sorted(dirs)
- rel_path_from_top = root[len(tree_top):].lstrip('/')
- if rel_path_from_top:
- dest_dir = dest + rel_path_from_top + '/'
- else:
- dest_dir = dest
- for dir in dirs:
- to_write[dest_dir + dir] = None
- for file in sorted(files):
- content_path = os.path.abspath(os.path.join(root, file))
- if os.name == "nt":
- # "To specify an extended-length path, use the `\\?\` prefix. For
- # example, `\\?\D:\very long path`."[1]
- #
- # [1]: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
- to_write[dest_dir + file] = "\\\\?\\" + content_path
- else:
- to_write[dest_dir + file] = content_path
-
- for path in sorted(to_write.keys()):
- content_path = to_write[path]
- if not content_path:
- # This is an intermediate directory. Bazel has no API to specify modes
- # for this, so the least surprising thing we can do is make it the
- # canonical rwxr-xr-x
- self.add_empty_file(
- path,
- mode=0o755,
- ids=ids,
- names=names,
- kind=tarfile.DIRTYPE)
- else:
- # If mode is unspecified, derive the mode from the file's mode.
- if mode is None:
- f_mode = 0o755 if os.access(content_path, os.X_OK) else 0o644
- else:
- f_mode = mode
- self.tarfile.add_file(
- path,
- file_content=content_path,
- mode=f_mode,
- uid=ids[0],
- gid=ids[1],
- uname=names[0],
- gname=names[1])
-
- def add_manifest_entry(self, entry, file_attributes):
- # 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)
- else:
- attrs = {}
- # But any attributes from the manifest have higher precedence
- if entry.mode is not None and entry.mode != '':
- attrs['mode'] = int(entry.mode, 8)
- if entry.user:
- if entry.group:
- attrs['names'] = (entry.user, entry.group)
- 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(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(self.normalize_path(entry.dest), **attrs)
- else:
- self.add_file(entry.src, entry.dest, **attrs)
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Helper for building tar packages',
- fromfile_prefix_chars='@')
- parser.add_argument('--output', required=True,
- help='The output file, mandatory.')
- parser.add_argument('--manifest',
- help='manifest of contents to add to the layer.')
- parser.add_argument('--mode',
- help='Force the mode on the added files (in octal).')
- parser.add_argument(
- '--mtime',
- help='Set mtime on tar file entries. May be an integer or the'
- ' value "portable", to get the value 2000-01-01, which is'
- ' is usable with non *nix OSes.')
- parser.add_argument('--tar', action='append',
- help='A tar file to add to the layer')
- parser.add_argument('--deb', action='append',
- help='A debian package to add to the layer')
- parser.add_argument(
- '--directory',
- help='Directory in which to store the file inside the layer')
-
- compression = parser.add_mutually_exclusive_group()
- compression.add_argument('--compression',
- help='Compression (`gz` or `bz2`), default is none.')
- compression.add_argument('--compressor',
- help='Compressor program and arguments, '
- 'e.g. `pigz -p 4`')
-
- parser.add_argument(
- '--modes', action='append',
- help='Specific mode to apply to specific file (from the file argument),'
- ' e.g., path/to/file=0455.')
- parser.add_argument(
- '--owners', action='append',
- help='Specify the numeric owners of individual files, '
- 'e.g. path/to/file=0.0.')
- parser.add_argument(
- '--owner', default='0.0',
- help='Specify the numeric default owner of all files,'
- ' e.g., 0.0')
- parser.add_argument(
- '--owner_name',
- help='Specify the owner name of all files, e.g. root.root.')
- parser.add_argument(
- '--owner_names', action='append',
- help='Specify the owner names of individual files, e.g. '
- 'path/to/file=root.root.')
- parser.add_argument('--stamp_from', default='',
- help='File to find BUILD_STAMP in')
- options = parser.parse_args()
-
- # Parse modes arguments
- default_mode = None
- if options.mode:
- # Convert from octal
- default_mode = int(options.mode, 8)
-
- mode_map = {}
- if options.modes:
- for filemode in options.modes:
- (f, mode) = helpers.SplitNameValuePairAtSeparator(filemode, '=')
- if f[0] == '/':
- f = f[1:]
- mode_map[f] = int(mode, 8)
-
- default_ownername = ('', '')
- if options.owner_name:
- default_ownername = options.owner_name.split('.', 1)
- names_map = {}
- if options.owner_names:
- for file_owner in options.owner_names:
- (f, owner) = helpers.SplitNameValuePairAtSeparator(file_owner, '=')
- (user, group) = owner.split('.', 1)
- if f[0] == '/':
- f = f[1:]
- names_map[f] = (user, group)
-
- default_ids = options.owner.split('.', 1)
- default_ids = (int(default_ids[0]), int(default_ids[1]))
- ids_map = {}
- if options.owners:
- for file_owner in options.owners:
- (f, owner) = helpers.SplitNameValuePairAtSeparator(file_owner, '=')
- (user, group) = owner.split('.', 1)
- if f[0] == '/':
- f = f[1:]
- ids_map[f] = (int(user), int(group))
-
- default_mtime = options.mtime
- if options.stamp_from:
- default_mtime = build_info.get_timestamp(options.stamp_from)
-
- # Add objects to the tar file
- with TarFile(
- options.output,
- directory = helpers.GetFlagValue(options.directory),
- compression = options.compression,
- compressor = options.compressor,
- default_mtime=default_mtime) as output:
-
- def file_attributes(filename):
- if filename.startswith('/'):
- filename = filename[1:]
- return {
- 'mode': mode_map.get(filename, default_mode),
- 'ids': ids_map.get(filename, default_ids),
- 'names': names_map.get(filename, default_ownername),
- }
-
- if options.manifest:
- with open(options.manifest, 'r') as manifest_fp:
- manifest_entries = manifest.read_entries_from(manifest_fp)
- for entry in manifest_entries:
- output.add_manifest_entry(entry, file_attributes)
-
- for tar in options.tar or []:
- output.add_tar(tar)
- for deb in options.deb or []:
- output.add_deb(deb)
-
-
-if __name__ == '__main__':
- main()
diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl
deleted file mode 100644
index 3a4d1a6..0000000
--- a/pkg/private/tar/tar.bzl
+++ /dev/null
@@ -1,372 +0,0 @@
-# Copyright 2015 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.
-"""Rules for making .tar files."""
-
-load("//pkg:path.bzl", "compute_data_path", "dest_path")
-load("//pkg:providers.bzl", "PackageVariablesInfo")
-load(
- "//pkg/private:pkg_files.bzl",
- "add_directory",
- "add_empty_file",
- "add_label_list",
- "add_single_file",
- "add_symlink",
- "add_tree_artifact",
- "process_src",
- "write_manifest",
-)
-load("//pkg/private:util.bzl", "setup_output_files", "substitute_package_variables")
-
-# TODO(aiuto): Figure out how to get this from the python toolchain.
-# See check for lzma in archive.py for a hint at a method.
-HAS_XZ_SUPPORT = True
-
-# Filetype to restrict inputs
-tar_filetype = (
- [".tar", ".tar.gz", ".tgz", ".tar.bz2", "tar.xz", ".txz"] if HAS_XZ_SUPPORT else [".tar", ".tar.gz", ".tgz", ".tar.bz2"]
-)
-SUPPORTED_TAR_COMPRESSIONS = (
- ["", "gz", "bz2", "xz"] if HAS_XZ_SUPPORT else ["", "gz", "bz2"]
-)
-_DEFAULT_MTIME = -1
-_stamp_condition = Label("//pkg/private:private_stamp_detect")
-
-def _remap(remap_paths, path):
- """If path starts with a key in remap_paths, rewrite it."""
- for prefix, replacement in remap_paths.items():
- if path.startswith(prefix):
- return replacement + path[len(prefix):]
- return path
-
-def _quote(filename, protect = "="):
- """Quote the filename, by escaping = by \\= and \\ by \\\\"""
- return filename.replace("\\", "\\\\").replace(protect, "\\" + protect)
-
-def _pkg_tar_impl(ctx):
- """Implementation of the pkg_tar rule."""
-
- # 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
-
- # Start building the arguments.
- args = ctx.actions.args()
- args.add("--output", output_file.path)
- args.add("--mode", ctx.attr.mode)
- args.add("--owner", ctx.attr.owner)
- args.add("--owner_name", ctx.attr.ownername)
-
- # Package dir can be specified by a file or inlined.
- if ctx.attr.package_dir_file:
- if ctx.attr.package_dir:
- fail("Both package_dir and package_dir_file attributes were specified")
- args.add("--directory", "@" + ctx.file.package_dir_file.path)
- files.append(ctx.file.package_dir_file)
- else:
- package_dir_expanded = substitute_package_variables(ctx, ctx.attr.package_dir)
- args.add("--directory", package_dir_expanded or "/")
-
- if ctx.executable.compressor:
- args.add("--compressor", "%s %s" % (ctx.executable.compressor.path, ctx.attr.compressor_args))
- else:
- extension = ctx.attr.extension
- if extension and extension != "tar":
- compression = None
- dot_pos = ctx.attr.extension.rfind(".")
- if dot_pos >= 0:
- compression = ctx.attr.extension[dot_pos + 1:]
- else:
- compression = ctx.attr.extension
- if compression == "tgz":
- compression = "gz"
- if compression == "txz":
- compression = "xz"
- if compression:
- if compression in SUPPORTED_TAR_COMPRESSIONS:
- args.add("--compression", compression)
- else:
- fail("Unsupported compression: '%s'" % compression)
-
- if ctx.attr.mtime != _DEFAULT_MTIME:
- if ctx.attr.portable_mtime:
- fail("You may not set both mtime and portable_mtime")
- args.add("--mtime", "%d" % ctx.attr.mtime)
- if ctx.attr.portable_mtime:
- args.add("--mtime", "portable")
-
- # Now we begin processing the files.
- file_deps = [] # inputs we depend on
- content_map = {} # content handled in the manifest
-
- # Start with all the pkg_* inputs
- for src in ctx.attr.srcs:
- if not process_src(
- ctx,
- content_map,
- file_deps,
- src = src,
- origin = src.label,
- default_mode = None,
- default_user = None,
- default_group = None,
- default_uid = None,
- default_gid = 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)
-
- # 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)
- if f.is_directory:
- add_tree_artifact(content_map, dest, 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(ctx, content_map, dest, f, src.label)
-
- # 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)
-
- # The files attribute is a map of labels to destinations. We can add them
- # directly to the content map.
- for target, f_dest_path in ctx.attr.files.items():
- 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]]))
- add_single_file(
- ctx,
- content_map,
- 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(ctx, content_map, empty_file, ctx.label)
- for empty_dir in ctx.attr.empty_dirs or []:
- add_directory(content_map, empty_dir, ctx.label)
- for f in ctx.files.deps:
- args.add("--tar", f.path)
- for link in ctx.attr.symlinks:
- add_symlink(
- ctx,
- content_map,
- link,
- ctx.attr.symlinks[link],
- ctx.label,
- )
- if ctx.attr.stamp == 1 or (ctx.attr.stamp == -1 and
- ctx.attr.private_stamp_detect):
- args.add("--stamp_from", ctx.version_file.path)
- files.append(ctx.version_file)
-
- manifest_file = ctx.actions.declare_file(ctx.label.name + ".manifest")
- files.append(manifest_file)
- write_manifest(ctx, manifest_file, 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)
-
- 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,
- arguments = [args],
- outputs = [output_file],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- use_default_shell_env = True,
- )
- return [
- DefaultInfo(
- files = depset([output_file]),
- runfiles = ctx.runfiles(files = outputs),
- ),
- # NB: this is not a committed public API.
- # The format of this file is subject to change without notice,
- # or this OutputGroup might be totally removed.
- # Depend on it at your own risk!
- OutputGroupInfo(
- manifest = [manifest_file],
- ),
- ]
-
-# A rule for creating a tar file, see README.md
-pkg_tar_impl = rule(
- implementation = _pkg_tar_impl,
- attrs = {
- "strip_prefix": attr.string(
- doc = """(note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)""",
- ),
- "package_dir": attr.string(
- 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(
- 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(
- doc = """Default numeric owner.group to apply to files when not set via pkg_attribures.""",
- default = "0.0",
- ),
- "ownername": attr.string(default = "."),
- "owners": attr.string_dict(),
- "ownernames": attr.string_dict(),
- "extension": attr.string(default = "tar"),
- "symlinks": attr.string_dict(),
- "empty_files": attr.string_list(),
- "include_runfiles": attr.bool(),
- "empty_dirs": attr.string_list(),
- "remap_paths": attr.string_dict(),
- "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)"),
- "package_variables": attr.label(
- 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.
-<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.
-@since(0.5.0)
-""",
- default = 0,
- ),
- # 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),
-
- # Implicit dependencies.
- "_build_tar": attr.label(
- default = Label("//pkg/private/tar:build_tar"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
-)
-
-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:
- if "files" in kwargs:
- if not hasattr(kwargs["files"], "items"):
- label = "%s//%s:%s" % (native.repository_name(), native.package_name(), name)
-
- # buildifier: disable=print
- print("%s: you provided a non dictionary to the pkg_tar `files` attribute. " % (label,) +
- "This attribute was renamed to `srcs`. " +
- "Consider renaming it in your BUILD file.")
- kwargs["srcs"] = kwargs.pop("files")
- extension = kwargs.get("extension") or "tar"
- if extension[0] == ".":
- extension = extension[1:]
- pkg_tar_impl(
- name = name,
- out = kwargs.pop("out", None) or (name + "." + extension),
- private_stamp_detect = select({
- _stamp_condition: True,
- "//conditions:default": False,
- }),
- **kwargs
- )
diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py
deleted file mode 100644
index 325db76..0000000
--- a/pkg/private/tar/tar_writer.py
+++ /dev/null
@@ -1,338 +0,0 @@
-# Copyright 2022 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.
-"""Tar writing helper."""
-
-import gzip
-import io
-import os
-import subprocess
-import tarfile
-
-try:
- import lzma # pylint: disable=g-import-not-at-top, unused-import
- HAS_LZMA = True
-except ImportError:
- HAS_LZMA = False
-
-# This is slightly a lie. We do support xz fallback through the xz tool, but
-# that is fragile. Users should stick to the expectations provided here.
-COMPRESSIONS = ('', 'gz', 'bz2', 'xz') if HAS_LZMA else ('', 'gz', 'bz2')
-
-# Use a deterministic mtime that doesn't confuse other programs.
-# See: https://github.com/bazelbuild/bazel/issues/1299
-PORTABLE_MTIME = 946684800 # 2000-01-01 00:00:00.000 UTC
-
-_DEBUG_VERBOSITY = 0
-
-
-class TarFileWriter(object):
- """A wrapper to write tar files."""
-
- class Error(Exception):
- pass
-
- def __init__(self,
- name,
- compression='',
- compressor='',
- default_mtime=None,
- preserve_tar_mtimes=True):
- """TarFileWriter wraps tarfile.open().
-
- Args:
- name: the tar file name.
- compression: compression type: bzip2, bz2, gz, tgz, xz, lzma.
- compressor: custom command to do the compression.
- default_mtime: default mtime to use for elements in the archive.
- May be an integer or the value 'portable' to use the date
- 2000-01-01, which is compatible with non *nix OSes'.
- preserve_tar_mtimes: if true, keep file mtimes from input tar file.
- """
- self.preserve_mtime = preserve_tar_mtimes
- if default_mtime is None:
- self.default_mtime = 0
- elif default_mtime == 'portable':
- self.default_mtime = PORTABLE_MTIME
- else:
- self.default_mtime = int(default_mtime)
-
- self.fileobj = None
- self.compressor_cmd = (compressor or '').strip()
- if self.compressor_cmd:
- # Some custom command has been specified: no need for further
- # configuration, we're just going to use it.
- pass
- # Support xz compression through xz... until we can use Py3
- elif compression in ['xz', 'lzma']:
- if HAS_LZMA:
- mode = 'w:xz'
- else:
- self.compressor_cmd = 'xz -F {} -'.format(compression)
- elif compression in ['bzip2', 'bz2']:
- mode = 'w:bz2'
- else:
- mode = 'w:'
- if compression in ['tgz', 'gz']:
- # 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=6, mtime=self.default_mtime)
- self.compressor_proc = None
- if self.compressor_cmd:
- mode = 'w|'
- self.compressor_proc = subprocess.Popen(self.compressor_cmd.split(),
- stdin=subprocess.PIPE,
- stdout=open(name, 'wb'))
- self.fileobj = self.compressor_proc.stdin
- self.name = name
-
- self.tar = tarfile.open(name=name, mode=mode, fileobj=self.fileobj,
- format=tarfile.GNU_FORMAT)
- self.members = set()
- self.directories = set()
- # Preseed the added directory list with things we should not add. If we
- # some day need to allow '.' or '/' as an explicit member of the archive,
- # we can adjust that here based on the setting of root_dirctory.
- self.directories.add('/')
- self.directories.add('./')
-
- def __enter__(self):
- return self
-
- def __exit__(self, t, v, traceback):
- self.close()
-
- def _have_added(self, path):
- """Have we added this file before."""
- return (path in self.members) or (path in self.directories)
-
- def _addfile(self, info, fileobj=None):
- """Add a file in the tar file if there is no conflict."""
- if info.type == tarfile.DIRTYPE:
- # Enforce the ending / for directories so we correctly deduplicate.
- if not info.name.endswith('/'):
- info.name += '/'
- if not self._have_added(info.name):
- self.tar.addfile(info, fileobj)
- self.members.add(info.name)
- if info.type == tarfile.DIRTYPE:
- self.directories.add(info.name)
- elif info.type != tarfile.DIRTYPE:
- print('Duplicate file in archive: %s, '
- 'picking first occurrence' % info.name)
-
- def add_directory_path(self,
- path,
- uid=0,
- gid=0,
- uname='',
- gname='',
- mtime=None,
- mode=0o755):
- """Add a directory to the current tar.
-
- Args:
- path: the ('/' delimited) path of the file to add.
- uid: owner user identifier.
- gid: owner group identifier.
- uname: owner user names.
- gname: owner group names.
- mtime: modification time to put in the archive.
- mode: unix permission mode of the file, default: 0755.
- """
- assert path[-1] == '/'
- if not path or self._have_added(path):
- return
- if _DEBUG_VERBOSITY > 1:
- print('DEBUG: adding directory', path)
- tarinfo = tarfile.TarInfo(path)
- tarinfo.type = tarfile.DIRTYPE
- tarinfo.mtime = mtime
- tarinfo.mode = mode
- tarinfo.uid = uid
- tarinfo.gid = gid
- tarinfo.uname = uname
- tarinfo.gname = gname
- self._addfile(tarinfo)
-
- def add_parents(self, path, uid=0, gid=0, uname='', gname='', mtime=0, mode=0o755):
- dirs = path.split('/')
- parent_path = ''
- for next_level in dirs[0:-1]:
- parent_path = parent_path + next_level + '/'
- self.add_directory_path(
- parent_path,
- uid=uid,
- gid=gid,
- uname=uname,
- gname=gname,
- mtime=mtime,
- mode=0o755)
-
- def add_file(self,
- name,
- kind=tarfile.REGTYPE,
- content=None,
- link=None,
- file_content=None,
- uid=0,
- gid=0,
- uname='',
- gname='',
- mtime=None,
- mode=None):
- """Add a file to the current tar.
-
- Args:
- name: the ('/' delimited) path of the file to add.
- kind: the type of the file to add, see tarfile.*TYPE.
- content: the content to put in the file.
- link: if the file is a link, the destination of the link.
- file_content: file to read the content from. Provide either this
- one or `content` to specifies a content for the file.
- uid: owner user identifier.
- gid: owner group identifier.
- uname: owner user names.
- gname: owner group names.
- mtime: modification time to put in the archive.
- mode: unix permission mode of the file, default 0644 (0755).
- """
- if not name:
- return
- if name == '.':
- return
- if name in self.members:
- return
-
- if mtime is None:
- mtime = self.default_mtime
-
- # Make directories up the file
- self.add_parents(name, mtime=mtime, mode=0o755, uid=uid, gid=gid, uname=uname, gname=gname)
-
- tarinfo = tarfile.TarInfo(name)
- tarinfo.mtime = mtime
- tarinfo.uid = uid
- tarinfo.gid = gid
- tarinfo.uname = uname
- tarinfo.gname = gname
- tarinfo.type = kind
- if mode is None:
- tarinfo.mode = 0o644 if kind == tarfile.REGTYPE else 0o755
- else:
- tarinfo.mode = mode
- if link:
- tarinfo.linkname = link
- if content:
- content_bytes = content.encode('utf-8')
- tarinfo.size = len(content_bytes)
- self._addfile(tarinfo, io.BytesIO(content_bytes))
- elif file_content:
- with open(file_content, 'rb') as f:
- tarinfo.size = os.fstat(f.fileno()).st_size
- self._addfile(tarinfo, f)
- else:
- self._addfile(tarinfo)
-
- def add_tar(self,
- tar,
- rootuid=None,
- rootgid=None,
- numeric=False,
- name_filter=None,
- prefix=None):
- """Merge a tar content into the current tar, stripping timestamp.
-
- Args:
- tar: the name of tar to extract and put content into the current tar.
- rootuid: user id that we will pretend is root (replaced by uid 0).
- rootgid: group id that we will pretend is root (replaced by gid 0).
- numeric: set to true to strip out name of owners (and just use the
- numeric values).
- name_filter: filter out file by names. If not none, this method will be
- called for each file to add, given the name and should return true if
- the file is to be added to the final tar and false otherwise.
- prefix: prefix to add to all file paths.
-
- Raises:
- TarFileWriter.Error: if an error happens when uncompressing the tar file.
- """
- if prefix:
- prefix = prefix.strip('/') + '/'
- if _DEBUG_VERBOSITY > 1:
- print('========================== prefix is', prefix)
- intar = tarfile.open(name=tar, mode='r:*')
- for tarinfo in intar:
- if name_filter is None or name_filter(tarinfo.name):
- if not self.preserve_mtime:
- tarinfo.mtime = self.default_mtime
- if rootuid is not None and tarinfo.uid == rootuid:
- tarinfo.uid = 0
- tarinfo.uname = 'root'
- if rootgid is not None and tarinfo.gid == rootgid:
- tarinfo.gid = 0
- tarinfo.gname = 'root'
- if numeric:
- tarinfo.uname = ''
- tarinfo.gname = ''
-
- in_name = tarinfo.name
- if prefix:
- in_name = os.path.normpath(prefix + in_name).replace(os.path.sep, '/')
- tarinfo.name = in_name
- self.add_parents(
- path=tarinfo.name,
- mtime=tarinfo.mtime,
- mode=0o755,
- uid=tarinfo.uid,
- gid=tarinfo.gid,
- uname=tarinfo.uname,
- gname=tarinfo.gname)
-
- if prefix is not None:
- # Relocate internal hardlinks as well to avoid breaking them.
- link = tarinfo.linkname
- if link.startswith('.') and tarinfo.type == tarfile.LNKTYPE:
- tarinfo.linkname = '.' + prefix + link.lstrip('.')
-
- # Remove path pax header to ensure that the proposed name is going
- # to be used. Without this, files with long names will not be
- # properly written to its new path.
- if 'path' in tarinfo.pax_headers:
- del tarinfo.pax_headers['path']
-
- if tarinfo.isfile():
- # use extractfile(tarinfo) instead of tarinfo.name to preserve
- # seek position in intar
- self._addfile(tarinfo, intar.extractfile(tarinfo))
- else:
- self._addfile(tarinfo)
- intar.close()
-
- def close(self):
- """Close the output tar file.
-
- This class should not be used anymore after calling that method.
-
- Raises:
- TarFileWriter.Error: if an error happens when compressing the output file.
- """
- self.tar.close()
- # Close the file object if necessary.
- if self.fileobj:
- self.fileobj.close()
- if self.compressor_proc and self.compressor_proc.wait() != 0:
- raise self.Error('Custom compression command '
- '"{}" failed'.format(self.compressor_cmd))
-
diff --git a/pkg/private/util.bzl b/pkg/private/util.bzl
deleted file mode 100644
index 7d36cf8..0000000
--- a/pkg/private/util.bzl
+++ /dev/null
@@ -1,86 +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.
-"""Internal utilities for rules_pkg."""
-
-load("//pkg:providers.bzl", "PackageVariablesInfo")
-
-def setup_output_files(ctx, package_file_name = None, default_output_file = None):
- """Provide output file metadata for common packaging rules
-
- By default, this will instruct rules to write directly to the File specified
- by the `default_output_file` argument or `ctx.outputs.out` otherwise.
-
- If `package_file_name` is given, or is available in `ctx`, we will write to
- that name instead, do substitution via `ctx.attr.package_variables`, and the
- default output (either by `default_output_file` or `ctx.outputs.out`) will
- be a symlink to it.
-
- Callers should:
- - write to `output_file`
- - add `outputs` to their returned `DefaultInfo(files)` provider
- - Possibly add a distinguishing element to OutputGroups
-
- Args:
- ctx: rule context
- package_file_name: computed value for package_file_name
- default_output_file: File identifying the rule's default output, otherwise `ctx.outputs.out` will be used instead.
-
- Returns:
- outputs: list(output handles)
- output_file: file handle to write to
- output_name: name of output file
-
- """
- default_output = default_output_file or ctx.outputs.out
-
- outputs = [default_output]
- if not package_file_name:
- package_file_name = ctx.attr.package_file_name
- if package_file_name:
- output_name = substitute_package_variables(ctx, package_file_name)
- output_file = ctx.actions.declare_file(output_name)
- outputs.append(output_file)
- ctx.actions.symlink(
- output = default_output,
- target_file = output_file,
- )
- else:
- output_file = default_output
- output_name = output_file.basename
- return outputs, output_file, output_name
-
-def substitute_package_variables(ctx, attribute_value):
- """Substitute package_variables in the attribute with the given name.
-
- Args:
- ctx: context
- attribute_value: the name of the attribute to perform package_variables substitution for
-
- Returns:
- expanded_attribute_value: new value of the attribute after package_variables substitution
- """
- if not attribute_value:
- return attribute_value
-
- if type(attribute_value) != "string":
- fail("attempt to substitute package_variables in the attribute value %s which is not a string" % attribute_value)
- vars = dict(ctx.var)
- if ctx.attr.package_variables:
- package_variables = ctx.attr.package_variables[PackageVariablesInfo]
- vars.update(package_variables.values)
-
- # 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)
diff --git a/pkg/private/zip/BUILD b/pkg/private/zip/BUILD
deleted file mode 100644
index 4823e90..0000000
--- a/pkg/private/zip/BUILD
+++ /dev/null
@@ -1,60 +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.
-"""rules_pkg internal code.
-
-All interfaces are subject to change at any time.
-"""
-
-load("@rules_python//python:defs.bzl", "py_binary")
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = [
- "BUILD",
- ] + glob([
- "*.bzl",
- "*.py",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-exports_files(
- glob([
- "*.bzl",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//doc_build:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-py_binary(
- name = "build_zip",
- srcs = ["build_zip.py"],
- imports = ["../../.."],
- python_version = "PY3",
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
- deps = [
- "//pkg/private:build_info",
- "//pkg/private:helpers",
- "//pkg/private:manifest",
- ],
-)
diff --git a/pkg/private/zip/__init__.py b/pkg/private/zip/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/pkg/private/zip/__init__.py
+++ /dev/null
diff --git a/pkg/private/zip/build_zip.py b/pkg/private/zip/build_zip.py
deleted file mode 100644
index ca48a08..0000000
--- a/pkg/private/zip/build_zip.py
+++ /dev/null
@@ -1,305 +0,0 @@
-# Copyright 2015 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.
-"""This tool builds zip files from a list of inputs."""
-
-import argparse
-import datetime
-import logging
-import os
-import sys
-import zipfile
-
-from pkg.private import build_info
-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_SYMLINK_BIT = 0o120000
-
-def _create_argument_parser():
- """Creates the command line arg parser."""
- parser = argparse.ArgumentParser(description='create a zip file',
- fromfile_prefix_chars='@')
- parser.add_argument('-o', '--output', type=str,
- help='The output zip file path.')
- parser.add_argument(
- '-d', '--directory', type=str, default='/',
- help='An absolute path to use as a prefix for all files in the zip.')
- parser.add_argument(
- '-t', '--timestamp', type=int, default=ZIP_EPOCH,
- help='The unix time to use for files added into the zip. values prior to'
- ' Jan 1, 1980 are ignored.')
- parser.add_argument('--stamp_from', default='',
- help='File to find BUILD_STAMP in')
- 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)
- parser.add_argument(
- 'files', type=str, nargs='*',
- help='Files to be added to the zip, in the form of {srcpath}={dstpath}.')
- return parser
-
-
-def _combine_paths(left, right):
- result = left.rstrip('/') + '/' + right.lstrip('/')
-
- # important: remove leading /'s: the zip format spec says paths should never
- # have a leading slash, but Python will happily do this. The built-in zip
- # tool in Windows will complain that such a zip file is invalid.
- return result.lstrip('/')
-
-
-def parse_date(ts):
- ts = datetime.datetime.utcfromtimestamp(ts)
- return (ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second)
-
-
-class ZipWriter(object):
-
- 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.
-
- Args:
- output_path: path to write to
- time_stamp: time stamp to add to files
- default_mode: file mode to use if not specified in the entry.
- """
- self.output_path = output_path
- self.time_stamp = time_stamp
- self.default_mode = default_mode
- 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
-
- def __exit__(self, t, v, traceback):
- self.close()
-
- def close(self):
- 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.
-
- Args:
- path: file path
- mode: file mode
- """
- entry_info = zipfile.ZipInfo(filename=path, date_time=self.time_stamp)
- # See http://www.pkware.com/documents/casestudies/APPNOTE.TXT
- # denotes UTF-8 encoded file name.
- entry_info.flag_bits |= 0x800
-
- # See: https://trac.edgewall.org/attachment/ticket/8919/ZipDownload.patch
- # external_attr is 4 bytes in size. The high order two bytes represent UNIX
- # permission and file type bits, while the low order two contain MS-DOS FAT
- # file attributes.
- if mode:
- f_mode = int(mode, 8)
- else:
- f_mode = self.default_mode
- entry_info.external_attr = f_mode << 16
- return entry_info
-
- def add_manifest_entry(self, entry):
- """Add an entry to the zip file.
-
- Args:
- zip_file: ZipFile to write to
- entry: manifest entry
- """
-
- entry_type = entry.type
- dest = entry.dest
- src = entry.src
- mode = entry.mode
- user = entry.user
- group = entry.group
-
- # 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 = self.compression_type
- # Using utf-8 for the file names is for python <3.7 compatibility.
- with open(src.encode('utf-8'), 'rb') as src_content:
- 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
- entry_info.external_attr |= (UNIX_DIR_BIT << 16) | MSDOS_DIR_BIT
- self.zip_file.writestr(entry_info, '')
- elif entry_type == manifest.ENTRY_IS_LINK:
- entry_info.compress_type = zipfile.ZIP_STORED
- # Set directory bits
- entry_info.external_attr |= (UNIX_SYMLINK_BIT << 16)
- self.zip_file.writestr(entry_info, src.encode('utf-8'))
- 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_STORED
- self.zip_file.writestr(entry_info, '')
- else:
- raise Exception('Unknown type for manifest entry:', entry)
-
- def add_tree(self, tree_top: str, destpath: str, mode: int):
- """Add a tree artifact to the zip file.
-
- Args:
- tree_top: the top of the tree to add
- destpath: the path under which to place the files
- mode: if not None, file mode to apply to all files
- """
-
- # We expect /-style paths.
- tree_top = os.path.normpath(tree_top).replace(os.path.sep, '/')
-
- # Again, we expect /-style paths.
- dest = destpath.strip('/') # redundant, dests should never have / here
- dest = os.path.normpath(dest).replace(os.path.sep, '/')
- # paths should not have a leading ./
- dest = '' if dest == '.' else dest + '/'
-
- to_write = {}
- for root, dirs, files in os.walk(tree_top):
- # While `tree_top` uses '/' as a path separator, results returned by
- # `os.walk` and `os.path.join` on Windows may not.
- root = os.path.normpath(root).replace(os.path.sep, '/')
-
- rel_path_from_top = root[len(tree_top):].lstrip('/')
- if rel_path_from_top:
- dest_dir = dest + rel_path_from_top + '/'
- else:
- dest_dir = dest
- to_write[dest_dir] = None
- for file in files:
- content_path = os.path.abspath(os.path.join(root, file))
- if os.name == "nt":
- # "To specify an extended-length path, use the `\\?\` prefix. For
- # example, `\\?\D:\very long path`."[1]
- #
- # [1]: https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation
- to_write[dest_dir + file] = "\\\\?\\" + content_path
- else:
- to_write[dest_dir + file] = content_path
-
- for path in sorted(to_write.keys()):
- content_path = to_write[path]
- if content_path:
- # If mode is unspecified, derive the mode from the file's mode.
- if mode is None:
- f_mode = "0o755" if os.access(content_path, os.X_OK) else self.default_mode
- else:
- f_mode = mode
- entry_info = self.make_zipinfo(path=path, mode=f_mode)
- entry_info.compress_type = self.compression_type
- with open(content_path, 'rb') as src:
- self.writestr(entry_info, src.read(), compresslevel=self.compression_level)
- else:
- # Implicitly created directory
- dir_path = path
- if not dir_path.endswith('/'):
- dir_path += '/'
- entry_info = self.make_zipinfo(path=dir_path, mode="0o755")
- entry_info.compress_type = zipfile.ZIP_STORED
- # Set directory bits
- entry_info.external_attr |= (UNIX_DIR_BIT << 16) | MSDOS_DIR_BIT
- self.zip_file.writestr(entry_info, '')
-
-def _load_manifest(prefix, manifest_path):
- manifest_map = {}
-
- for entry in manifest.read_entries_from_file(manifest_path):
- entry.dest = _combine_paths(prefix, entry.dest)
- manifest_map[entry.dest] = entry
-
- # We modify the dictionary as we're iterating over it, so we need to listify
- # the keys here.
- manifest_keys = list(manifest_map.keys())
- # Add all parent directories of entries that have not been added explicitly.
- for dest in manifest_keys:
- parent = dest
- # TODO: use pathlib instead of string manipulation?
- for _ in range(dest.count("/")):
- parent, _, _ = parent.rpartition("/")
- if parent and parent not in manifest_map:
- manifest_map[parent] = manifest.ManifestEntry(
- type = manifest.ENTRY_IS_DIR,
- dest = parent,
- src = "",
- mode = "0o755",
- user = None,
- group = None,
- uid = None,
- gid = None,
- origin = "parent directory of {}".format(manifest_map[dest].origin),
- )
-
- return sorted(manifest_map.values(), key = lambda x: x.dest)
-
-def main(args):
- unix_ts = max(ZIP_EPOCH, args.timestamp)
- if args.stamp_from:
- unix_ts = build_info.get_timestamp(args.stamp_from)
- ts = parse_date(unix_ts)
- 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, compression_type=args.compression_type, compression_level=compression_level) as zip_out:
- for entry in manifest:
- zip_out.add_manifest_entry(entry)
-
-
-if __name__ == '__main__':
- arg_parser = _create_argument_parser()
- main(arg_parser.parse_args())
diff --git a/pkg/private/zip/zip.bzl b/pkg/private/zip/zip.bzl
deleted file mode 100644
index e038b48..0000000
--- a/pkg/private/zip/zip.bzl
+++ /dev/null
@@ -1,185 +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.
-"""Zip archive creation rule and associated logic."""
-
-load("//pkg:path.bzl", "compute_data_path", "dest_path")
-load(
- "//pkg:providers.bzl",
- "PackageVariablesInfo",
-)
-load(
- "//pkg/private:util.bzl",
- "setup_output_files",
- "substitute_package_variables",
-)
-load(
- "//pkg/private:pkg_files.bzl",
- "add_label_list",
- "write_manifest",
-)
-
-_stamp_condition = Label("//pkg/private:private_stamp_detect")
-
-def _pkg_zip_impl(ctx):
- outputs, output_file, output_name = 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)
-
- manifest_file = ctx.actions.declare_file(ctx.label.name + ".manifest")
- inputs.append(manifest_file)
- write_manifest(ctx, manifest_file, 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)
-
- ctx.actions.run(
- mnemonic = "PackageZip",
- inputs = all_inputs,
- executable = ctx.executable._build_zip,
- arguments = [args],
- outputs = [output_file],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- use_default_shell_env = True,
- )
- return [
- DefaultInfo(
- files = depset([output_file]),
- runfiles = ctx.runfiles(files = outputs),
- ),
- ]
-
-pkg_zip_impl = rule(
- implementation = _pkg_zip_impl,
- # @unsorted-dict-items
- attrs = {
- "srcs": attr.label_list(
- doc = """List of files that should be included in the archive.""",
- allow_files = True,
- ),
- "mode": attr.string(
- doc = """The default mode for all files in the archive.""",
- default = "0555",
- ),
- "package_dir": attr.string(
- doc = """Prefix to be prepend to all paths written.
-The name may contain variables, same as [package_file_name](#package_file_name)""",
- default = "/",
- ),
- "strip_prefix": attr.string(),
- "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,
-1980, 00:00 UTC.
-
-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.""",
- 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)"),
- "package_variables": attr.label(
- doc = "See [Common Attributes](#package_variables)",
- providers = [PackageVariablesInfo],
- ),
- "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.
-<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.
-""",
- 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),
-
- # Implicit dependencies.
- "_build_zip": attr.label(
- default = Label("//pkg/private/zip:build_zip"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
-)
-
-def pkg_zip(name, out = None, **kwargs):
- """Creates a .zip file.
-
- @wraps(pkg_zip_impl)
-
- Args:
- out: output file name. Default: name + ".zip".
- """
- if not out:
- out = name + ".zip"
- pkg_zip_impl(
- name = name,
- out = out,
- private_stamp_detect = select({
- _stamp_condition: True,
- "//conditions:default": False,
- }),
- **kwargs
- )
diff --git a/pkg/providers.bzl b/pkg/providers.bzl
deleted file mode 100644
index 6d5fc27..0000000
--- a/pkg/providers.bzl
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Packaging related providers."""
-
-PackageArtifactInfo = provider(
- doc = """Metadata about a package artifact.""",
- fields = {
- "file": "File object for said artifact",
- "file_name": "DEPRECATED (use fields of file instead): The file name of the artifact.",
- "label": "Label which produced it",
- },
-)
-
-PackageVariablesInfo = provider(
- doc = """Variables which may be substituted into package names and content.""",
- fields = {
- "values": "Dict of name/value pairs",
- },
-)
-
-PackageFilesInfo = provider(
- doc = """Provider representing the installation of one or more files to destination with attributes""",
- fields = {
- "attributes": """Attribute information, represented as a `dict`.
-
-Keys are strings representing attribute identifiers, values are
-arbitrary data structures that represent the associated data. These are
-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.
- """,
-
- # This is a mapping of destinations to sources to allow for the same
- # target to be installed to multiple locations within a package within a
- # single provider.
- "dest_src_map": """Map of file destinations to sources.
-
- Sources are represented by bazel `File` structures.""",
- },
-)
-
-PackageDirsInfo = provider(
- doc = """Provider representing the creation of one or more directories in a package""",
- fields = {
- "attributes": """See `attributes` in PackageFilesInfo.""",
- "dirs": """string list: installed directory names""",
- },
-)
-
-PackageSymlinkInfo = provider(
- doc = """Provider representing the creation of a single symbolic link in a package""",
- fields = {
- "attributes": """See `attributes` in PackageFilesInfo.""",
- "destination": """string: Filesystem link 'name'""",
- "target": """string or Label: Filesystem link 'target'.
-
- TODO(nacl): Label sources not yet supported.
- """,
- },
-)
-
-# Grouping provider: the only one that needs to be consumed by packaging (or
-# other) rules that materialize paths.
-PackageFilegroupInfo = provider(
- doc = """Provider representing a collection of related packaging providers,
-
- In the "fields" documentation, "origin" refers to the label identifying the
- where the provider was originally defined. This can be used by packaging
- rules to provide better diagnostics related to where packaging rules were
- created.
-
- """,
- fields = {
- "pkg_files": "list of tuples of (PackageFilesInfo, origin)",
- "pkg_dirs": "list of tuples of (PackageDirsInfo, origin)",
- "pkg_symlinks": "list of tuples of (PackageSymlinkInfo, origin)",
- },
-)
diff --git a/pkg/releasing/BUILD b/pkg/releasing/BUILD
deleted file mode 100644
index 31d3f61..0000000
--- a/pkg/releasing/BUILD
+++ /dev/null
@@ -1,73 +0,0 @@
-load("@rules_python//python:defs.bzl", "py_binary", "py_library", "py_test")
-load("git.bzl", "git_changelog")
-
-package(
- default_applicable_licenses = ["//:license"],
- default_visibility = ["//visibility:public"],
-)
-
-# WARNING: 2021-06-28. This is experimental and subject to change.
-
-# Sample usage:
-# load("@rules_pkg//releasing:defs.bzl", "print_rel_notes")
-# print_rel_notes(
-# name = "relnotes",
-# repo = "rules_pkg",
-# version = "2.1",
-# outs = ["relnotes.txt"],
-# )
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "BUILD",
- "*.bzl",
- "*.py",
- ]),
- visibility = [
- "//distro:__pkg__",
- "//pkg:__pkg__",
- ],
-)
-
-py_library(
- name = "release_utils",
- srcs = [
- "__init__.py",
- "release_tools.py",
- ],
- imports = ["../.."],
- srcs_version = "PY3",
-)
-
-py_binary(
- name = "print_rel_notes",
- srcs = [
- "print_rel_notes.py",
- ],
- imports = ["../.."],
- python_version = "PY3",
- deps = [
- ":release_utils",
- ],
-)
-
-py_test(
- name = "release_tools_test",
- srcs = ["release_tools_test.py"],
- python_version = "PY3",
- deps = [
- ":release_utils",
- ],
-)
-
-# This is an internal tool. Use at your own risk.
-py_binary(
- name = "git_changelog_private",
- srcs = [
- "git_changelog_private.py",
- ],
- srcs_version = "PY3",
- # TODO(https://github.com/bazelbuild/bazel/issues/7377): Make this private.
- visibility = ["//visibility:public"],
-)
diff --git a/pkg/releasing/__init__.py b/pkg/releasing/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/pkg/releasing/__init__.py
+++ /dev/null
diff --git a/pkg/releasing/defs.bzl b/pkg/releasing/defs.bzl
deleted file mode 100644
index 3f62602..0000000
--- a/pkg/releasing/defs.bzl
+++ /dev/null
@@ -1,53 +0,0 @@
-"""Implementation for print_rel_notes."""
-
-def print_rel_notes(
- name,
- repo,
- version,
- artifact_name = None,
- outs = None,
- setup_file = "",
- deps_method = "",
- toolchains_method = "",
- org = "bazelbuild",
- changelog = None,
- 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")
- tools = [print_rel_notes_helper]
- cmd = [
- "LC_ALL=C.UTF-8 $(location %s)" % str(print_rel_notes_helper),
- "--org=%s" % org,
- "--repo=%s" % repo,
- "--version=%s" % version,
- "--tarball=$(location %s)" % artifact_name,
- ]
- if setup_file:
- cmd.append("--setup_file=%s" % setup_file)
- if deps_method:
- cmd.append("--deps_method=%s" % deps_method)
- if toolchains_method:
- 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
- # system. That only makes sense locally on the host, because the
- # revision history is never exported to a remote build system.
- tools.append(changelog)
- if mirror_host:
- cmd.append("--mirror_host=%s" % mirror_host)
- cmd.append(">$@")
- native.genrule(
- name = name,
- srcs = [
- artifact_name,
- ],
- outs = outs or [name + ".txt"],
- cmd = " ".join(cmd),
- tools = tools,
- )
diff --git a/pkg/releasing/git.bzl b/pkg/releasing/git.bzl
deleted file mode 100644
index 2952e6c..0000000
--- a/pkg/releasing/git.bzl
+++ /dev/null
@@ -1,97 +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.
-"""A rule to extract the git changelog."""
-
-def _git_changelog_impl(ctx):
- """Implements to git_changelog rule."""
-
- args = ctx.actions.args()
- tools = []
-
- toolchain = ctx.toolchains["@rules_pkg//toolchains/git:git_toolchain_type"].git
- if not toolchain.valid:
- fail("The git_toolchain is not properly configured: " +
- toolchain.name)
- if toolchain.path:
- args.add("--git_path", toolchain.path)
- else:
- executable = toolchain.label.files_to_run.executable
- tools.append(executable)
- tools.append(toolchain.label.default_runfiles.files.to_list())
- args.add("--git_path", executable.path)
- args.add("--git_root", toolchain.client_top)
- args.add("--from_ref", ctx.attr.from_ref)
- args.add("--to_ref", ctx.attr.to_ref)
- args.add("--out", ctx.outputs.out.path)
- if ctx.attr.verbose:
- args.add("--verbose")
-
- ctx.actions.run(
- mnemonic = "GitChangelog",
- executable = ctx.executable._git_changelog,
- use_default_shell_env = True,
- arguments = [args],
- outputs = [ctx.outputs.out],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- execution_requirements = {
- "local": "1",
- },
- tools = tools,
- )
-
-# Define the rule.
-_git_changelog = rule(
- doc = "Extracts the git changelog between two refs.",
- attrs = {
- "from_ref": attr.string(
- doc = "lower commit ref. The default is to use the latest tag",
- default = "_LATEST_TAG_",
- ),
- "to_ref": attr.string(
- doc = "upper commit ref. The default is HEAD",
- default = "HEAD",
- ),
- "out": attr.output(mandatory = True),
- "verbose": attr.bool(
- doc = "Be verbose",
- default = False,
- ),
- "_git_changelog": attr.label(
- default = Label("//pkg/releasing:git_changelog_private"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
- implementation = _git_changelog_impl,
- toolchains = ["@rules_pkg//toolchains/git:git_toolchain_type"],
-)
-
-
-def git_changelog(name, **kwargs):
- _git_changelog(
- name = name,
- # This requires bazel 4.x
- target_compatible_with = select({
- # Force label resolution to be rules_pkg, instead of my repo.
- str(Label("//toolchains/git:have_git")): [],
- "//conditions:default": ["//:not_compatible"],
- }),
- **kwargs,
- )
diff --git a/pkg/releasing/git_changelog_private.py b/pkg/releasing/git_changelog_private.py
deleted file mode 100644
index 8344cef..0000000
--- a/pkg/releasing/git_changelog_private.py
+++ /dev/null
@@ -1,72 +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.
-"""Utilities to extract git commit descriptions in useful ways."""
-
-import argparse
-import os
-import subprocess
-import sys
-
-
-def guess_previous_release_tag(git_path, pattern=None):
- assert git_path
- most_recent = None
- cmd = [git_path, 'tag']
- if pattern:
- cmd.extend(['--list', pattern])
- # We are doing something dumb here for now. Grab the list of tags, and pick
- # the last one.
- with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
- most_recent = proc.stdout.read().decode('utf-8')
- most_recent = most_recent.strip().replace('\n\n', '\n').split('\n')[-1]
- return most_recent
-
-
-def git_changelog(from_ref, to_ref='HEAD', git_path=None):
- assert from_ref
- assert to_ref
- assert git_path
- cmd = [git_path, 'log', '%s..%s' % (from_ref, to_ref)]
- with subprocess.Popen(cmd, stdout=subprocess.PIPE) as proc:
- return proc.stdout.read().decode('utf-8')
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Helper for extracting git changelog',
- fromfile_prefix_chars='@')
- parser.add_argument('--git_path', required=True, help='path to git binary')
- parser.add_argument('--git_root', required=True, help='path to git client')
- parser.add_argument('--out', required=True, help='output path')
- parser.add_argument('--from_ref', help='from REF')
- parser.add_argument('--to_ref', help='to REF')
- parser.add_argument('--verbose', action='store_true')
-
- options = parser.parse_args()
-
- with open(options.out, 'w', encoding='utf-8') as out:
- os.chdir(options.git_root)
- from_ref = options.from_ref
- if not from_ref or from_ref == '_LATEST_TAG_':
- from_ref = guess_previous_release_tag(options.git_path)
- to_ref = options.to_ref or 'HEAD'
- if options.verbose:
- print('Getting changelog from %s to %s' % (from_ref, to_ref))
- changelog = git_changelog(
- from_ref=from_ref, to_ref=to_ref, git_path=options.git_path)
- out.write(changelog)
- return 0
-
-if __name__ == '__main__':
- main()
diff --git a/pkg/releasing/print_rel_notes.py b/pkg/releasing/print_rel_notes.py
deleted file mode 100644
index 379d0c0..0000000
--- a/pkg/releasing/print_rel_notes.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# Copyright 2019 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.
-"""Print release notes for a package.
-
-"""
-
-import argparse
-import os
-import string
-import textwrap
-
-from pkg.releasing import release_tools
-
-
-def print_notes(org, repo, version, tarball_path, mirror_host=None,
- deps_method=None, setup_file=None, toolchains_method=None,
- changelog=''):
- file_name = os.path.basename(tarball_path)
- sha256 = release_tools.get_package_sha256(tarball_path)
-
- url = 'https://github.com/%s/%s/releases/download/%s/%s' % (
- org, repo, version, file_name)
- mirror_url = 'https://%s/github.com/%s/%s/releases/download/%s/%s' % (
- mirror_host, org, repo, version, file_name) if mirror_host else None
- workspace_stanza = release_tools.workspace_content(
- url, repo, sha256, mirror_url=mirror_url, setup_file=setup_file,
- deps_method=deps_method, toolchains_method=toolchains_method)
- relnotes_template = string.Template(textwrap.dedent(
- """
- ------------------------ snip ----------------------------
- **New Features**
-
- **Incompatible Changes**
-
- **Change Log**
- ${changelog}
-
- **MODULE.bazel setup**
-
- ```
- bazel_dep(name = "${repo}", version = "${version}")
- ```
-
- **WORKSPACE setup**
-
- ```
- ${workspace_stanza}
- ```
-
- **Using the rules**
-
- See [the source](https://github.com/${org}/${repo}/tree/${version}).
- ------------------------ snip ----------------------------
-
- """).strip())
- print(relnotes_template.substitute({
- 'changelog': changelog,
- 'org': org,
- 'repo': repo,
- 'version': version,
- 'workspace_stanza': workspace_stanza,
- }))
- if mirror_url:
- file = os.path.basename(tarball_path)
- path = 'github.com/{org}/{repo}/releases/download/{version}/{file}'.format(
- org=org,
- repo=repo,
- version=version,
- file=file
- )
- mirroring_template = string.Template(textwrap.dedent(
- """
-
- !!!: Make sure to copy the file to the release notes.
- If you are using Google Cloud Storage, you might use a command like
- gsutil cp bazel-bin/distro/${file} gs://bazel-mirror/${path}
- gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/${path}"
- """).strip())
- print(mirroring_template.substitute({
- 'org': org,
- 'repo': repo,
- 'version': version,
- 'file': file,
- 'path': path,
- }))
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Print release notes for a package')
-
- parser.add_argument(
- '--org', default='bazelbuild', help='Github org name')
- parser.add_argument(
- '--repo', default=None, required=True, help='Repo name')
- parser.add_argument(
- '--version', default=None, required=True, help='Release version')
- parser.add_argument(
- '--tarball_path', default=None,
- required=True, help='path to release tarball')
- parser.add_argument(
- '--mirror_host', default=None,
- help='If provider, the hostname of a mirror for the download url')
- parser.add_argument(
- '--setup_file', default=None,
- help='Alternate name for setup file. Default: deps.bzl')
- parser.add_argument(
- '--deps_method', default=None,
- help='Alternate name for dependencies method. Default: {repo}_dependencies')
- parser.add_argument(
- '--toolchains_method', default=None,
- help='Alternate name for toolchains method. Default: {repo}_toolchains')
- parser.add_argument(
- '--changelog', default=None,
- help='Pre-fill release notes with changes from this file')
-
- options = parser.parse_args()
- if options.changelog:
- with open(options.changelog, 'r', encoding='utf-8') as f:
- changelog = f.read()
- else:
- changelog = 'TBD'
-
- print_notes(options.org, options.repo, options.version, options.tarball_path,
- deps_method=options.deps_method,
- changelog=changelog,
- mirror_host=options.mirror_host,
- setup_file=options.setup_file,
- toolchains_method=options.toolchains_method)
-
-
-if __name__ == '__main__':
- main()
diff --git a/pkg/releasing/release_tools.py b/pkg/releasing/release_tools.py
deleted file mode 100644
index 52440de..0000000
--- a/pkg/releasing/release_tools.py
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright 2019 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.
-"""Utilities to help create a rule set release."""
-
-import hashlib
-import string
-import sys
-import textwrap
-
-
-WORKSPACE_STANZA_TEMPLATE = string.Template(textwrap.dedent(
- """
- load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
- http_archive(
- name = "${repo}",
- urls = [
- ${urls},
- ],
- sha256 = "${sha256}",
- )
- """).strip())
-
-
-DEPS_STANZA_TEMPLATE = string.Template(textwrap.dedent(
- """
- load("@${repo}//${setup_file}", ${to_load})
- """).strip())
-
-
-def package_basename(repo, version):
- return '%s-%s.tar.gz' % (repo, version)
-
-
-def get_package_sha256(tarball_path):
- with open(tarball_path, 'rb') as pkg_content:
- tar_sha256 = hashlib.sha256(pkg_content.read()).hexdigest()
- return tar_sha256
-
-
-def workspace_content(
- url,
- repo,
- sha256,
- deps_method=None,
- mirror_url=None,
- rename_repo=None,
- setup_file=None,
- toolchains_method=None):
- # Create the WORKSPACE stanza needed for this rule set.
- if setup_file and not (deps_method or toolchains_method):
- print(
- 'setup_file can only be set if at least one of (deps_method, toolchains_method) is set.',
- flush=True,
- file=sys.stderr,
- )
- sys.exit(1)
-
- methods = []
- if deps_method:
- methods.append(deps_method)
- if toolchains_method:
- methods.append(toolchains_method)
-
- # If the github repo has a '-' in the name, that breaks bazel unless we remove
- # it or change it to an '_'
- repo = rename_repo or repo
- repo = repo.replace('-', '_')
- # Correct the common mistake of not putting a ':' in your setup file name
- if setup_file and ':' not in setup_file:
- setup_file = ':' + setup_file
- if mirror_url:
- # this could be more elegant
- urls = '"%s",\n "%s"' % (mirror_url, url)
- else:
- urls = '"%s"' % url
- ret = WORKSPACE_STANZA_TEMPLATE.substitute({
- 'urls': urls,
- 'sha256': sha256,
- 'repo': repo,
- })
- if methods:
- deps = DEPS_STANZA_TEMPLATE.substitute({
- 'repo': repo,
- 'setup_file': setup_file or ':deps.bzl',
- 'to_load': ', '.join('"%s"' % m for m in methods),
- })
- ret += '\n%s\n' % deps
-
- for m in methods:
- ret += '%s()\n' % m
-
- return ret
diff --git a/pkg/releasing/release_tools_test.py b/pkg/releasing/release_tools_test.py
deleted file mode 100644
index 7ca80d1..0000000
--- a/pkg/releasing/release_tools_test.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# Copyright 2019 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.
-
-import unittest
-
-import release_tools
-
-
-class ReleaseToolsTest(unittest.TestCase):
-
- def test_workspace_content_full(self):
- content = release_tools.workspace_content(
- url='http://github.com',
- repo='foo-bar',
- sha256='@computed@',
- setup_file='my_setup.bzl',
- deps_method='my_deps',
- toolchains_method='my_tools')
- self.assertGreater(content.find(' name = "foo_bar",'), 0, content)
- self.assertGreater(content.find(
- '\nload("@foo_bar//:my_setup.bzl", "my_deps", "my_tools")\n'), 0,
- content)
- self.assertGreater(content.find('\nmy_deps()\n'), 0)
- self.assertGreater(content.find('\nmy_tools()\n'), 0, content)
-
- def test_workspace_content_notools(self):
- content = release_tools.workspace_content(
- url='http://github.com',
- repo='foo-bar',
- sha256='@computed@',
- setup_file='my_setup.bzl',
- deps_method='my_deps')
- self.assertGreater(content.find(
- '\nload("@foo_bar//:my_setup.bzl", "my_deps")\n'), 0, content)
- self.assertGreater(content.find('\nmy_deps()\n'), 0)
- self.assertLess(content.find('\nmy_tools()\n'), 0)
-
- def test_workspace_content_nodeps(self):
- content = release_tools.workspace_content(
- url='http://github.com',
- repo='foo-bar',
- sha256='@computed@',
- setup_file='my_setup.bzl',
- toolchains_method='my_tools')
- self.assertGreater(content.find(
- '\nload("@foo_bar//:my_setup.bzl", "my_tools")\n'), 0, content)
- self.assertLess(content.find('\nmy_deps()\n'), 0)
- self.assertGreater(content.find('\nmy_tools()\n'), 0)
-
- def test_workspace_content_minimal(self):
- content = release_tools.workspace_content(
- url='http://github.com',
- repo='foo-bar',
- sha256='@computed@')
- self.assertLess(content.find('\nload("@foo_bar'), 0)
-
- def test_workspace_content_mirror(self):
- content = release_tools.workspace_content(
- url='http://github.com/foo/bar',
- mirror_url='http://mirror/github.com/foo/bar',
- repo='foo-bar',
- sha256='@computed@')
- url_pos = content.find('http://github.com/foo/bar')
- mirror_pos = content.find('http://mirror/github.com/foo/bar')
- self.assertGreater(url_pos, 0)
- self.assertGreater(mirror_pos, 0)
- self.assertLess(mirror_pos, url_pos)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/pkg/rpm.bzl b/pkg/rpm.bzl
deleted file mode 100644
index 6115eaa..0000000
--- a/pkg/rpm.bzl
+++ /dev/null
@@ -1,74 +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.
-
-"""RPM packaging interfaces
-
-This module provides a wrapper macro "pkg_rpm" that allows users to select
-between the two variants of `pkg_rpm`:
-
-- `pkg_rpm_pfg`, which arranges contents via the `pkg_filegroup`
- framework defined in `:mappings.bzl`.
-
-- `pkg_rpm_legacy`, which arranges contents via a spec file template.
-
-`pkg_rpm_legacy` is deprecated and will be removed in a future release of
-rules_pkg.
-
-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")
-
-def pkg_rpm(name, srcs = None, spec_file = None, **kwargs):
- """pkg_rpm wrapper
-
- This rule selects between the two implementations of pkg_rpm as described in
- the module docstring. In particular:
-
- If `srcs` is provided, this macro will choose `pkg_rpm_pfg`. If
- `spec_file` is provided, it will choose `pkg_rpm_legacy`.
-
- If neither or both are provided, this will fail.
-
- Args:
- name: rule name
- srcs: pkg_rpm_pfg `srcs` attribute
- spec_file: pkg_rpm_legacy `spec_file` attribute
- **kwargs: arguments to either `pkg_rpm_pfg` or `pkg_rpm_legacy`,
- depending on mode
-
- """
- if srcs and spec_file:
- fail("Cannot determine which pkg_rpm rule to use. `srcs` and `spec_file` are mutually exclusive")
-
- if not srcs and not spec_file:
- fail("Either `srcs` or `spec_file` must be provided.")
-
- if srcs:
- pkg_rpm_pfg(
- name = name,
- srcs = srcs,
- **kwargs
- )
- elif spec_file:
- pkg_rpm_legacy(
- name = name,
- spec_file = spec_file,
- **kwargs
- )
-
- else:
- fail("This should be unreachable; kindly file a bug against rules_pkg.")
diff --git a/pkg/rpm/BUILD b/pkg/rpm/BUILD
deleted file mode 100644
index f7564b2..0000000
--- a/pkg/rpm/BUILD
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-load("@rules_python//python:defs.bzl", "py_binary")
-
-package(default_applicable_licenses = ["//:license"])
-
-exports_files(
- glob([
- "*.bzl",
- "*.tpl",
- ]),
- visibility = ["//visibility:public"],
-)
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*.bzl",
- "*.py",
- "*.tpl",
- ]) + [
- "BUILD",
- ],
- visibility = ["//pkg:__pkg__"],
-)
-
-# Helper script used to augment the %install scriptlet and %files list with
-# those found in TreeArtifacts (directory outputs) See also #292.
-py_binary(
- name = "augment_rpm_files_install",
- srcs = ["augment_rpm_files_install.py"],
- visibility = ["//visibility:public"],
-)
diff --git a/pkg/rpm/augment_rpm_files_install.py b/pkg/rpm/augment_rpm_files_install.py
deleted file mode 100644
index 6f0762b..0000000
--- a/pkg/rpm/augment_rpm_files_install.py
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-# This script takes a pair of Bazel-generated RPM %install scriptlet and %files
-# list, and combined with JSON description of TreeArtifacts, emits copies
-# augmented with the files detected in the materialized TreeArtifacts.
-
-import os
-import sys
-import json
-
-# 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}'
-""".strip()
-
-_FILE_MODE_STANZA_FMT = """
-{0} "{1}"
-""".strip()
-
-# Cheapo arg parsing. Currently this script is single-purpose.
-
-# JSON file containing the TreeArtifact manifest info.
-#
-# This is expected to be an array of objects with the following fields:
-#
-# - src: Source file/directory location.
-# - dest: Install prefix
-# - tags: Tags for the %files manifest
-dir_data_path = sys.argv[1]
-
-# Existing files
-existing_install_script_path = sys.argv[2]
-existing_files_path = sys.argv[3]
-
-# Output files
-new_install_script_path = sys.argv[4]
-new_files_path = sys.argv[5]
-
-# Computed outputs to be combined with the originals
-dir_install_script_segments = []
-dir_files_segments = []
-
-with open(dir_data_path, 'r') as fh:
- dir_data = json.load(fh)
-
- for d in dir_data:
- # d is a dict, d["src"] is the TreeArtifact directory to walk.
- for root, dirs, files in os.walk(d["src"]):
- # "root" is the current directory we're walking through. This
- # computes the path the source location (the TreeArtifact root) --
- # the desired install location relative to the user-provided install
- # destination.
- path_relative_to_install_dest = os.path.relpath(root, start=d["src"])
-
- for f in files:
- full_dest = os.path.join(d["dest"], path_relative_to_install_dest, f)
- dir_install_script_segments.append(_INSTALL_FILE_STANZA_FMT.format(
- os.path.join(root, f),
- 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()
-
-with open(existing_files_path, 'r') as fh:
- existing_files = fh.read()
-
-# Write the outputs
-with open(new_install_script_path, 'w') as fh:
- fh.write(existing_install_script)
- fh.write("\n")
- fh.write("\n".join(dir_install_script_segments))
-
-with open(new_files_path, 'w') as fh:
- fh.write(existing_files)
- fh.write("\n")
- fh.write("\n".join(dir_files_segments))
diff --git a/pkg/rpm/template.spec.tpl b/pkg/rpm/template.spec.tpl
deleted file mode 100644
index 36bd5dc..0000000
--- a/pkg/rpm/template.spec.tpl
+++ /dev/null
@@ -1,22 +0,0 @@
-# -*- rpm-spec -*-
-
-# This comprises the entirety of the preamble
-%include %build_rpm_options
-
-%description
-%include %build_rpm_description
-
-%install
-%include %build_rpm_install
-
-%files -f %build_rpm_files
-
-${PRE_SCRIPTLET}
-
-${POST_SCRIPTLET}
-
-${PREUN_SCRIPTLET}
-
-${POSTUN_SCRIPTLET}
-
-${CHANGELOG} \ No newline at end of file
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl
deleted file mode 100644
index 28c5b2d..0000000
--- a/pkg/rpm_pfg.bzl
+++ /dev/null
@@ -1,1028 +0,0 @@
-# Copyright 2019 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.
-
-"""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")
-```
-"""
-
-load(
- "//pkg:providers.bzl",
- "PackageDirsInfo",
- "PackageFilegroupInfo",
- "PackageFilesInfo",
- "PackageSymlinkInfo",
- "PackageVariablesInfo",
-)
-load("//pkg/private:util.bzl", "setup_output_files")
-
-rpm_filetype = [".rpm"]
-
-spec_filetype = [".spec", ".spec.in", ".spec.tpl"]
-
-# TODO(nacl): __install, __cp
-# {0} is the source, {1} is the dest
-#
-# 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}'
-""".strip()
-
-# TODO(nacl): __install
-# {0} is the directory name
-#
-# 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}'
-""".strip()
-
-# {0} is the name of the link, {1} is the target, {2} is the desired symlink "mode".
-#
-# In particular, {2} exists because umasks on symlinks apply on macOS, unlike
-# Linux. You can't even change symlink permissions in Linux; all permissions
-# apply to the target instead.
-#
-# This is not the case in BSDs and macOS. This comes up because rpmbuild(8)
-# does not know about the BSD "lchmod" call, which would otherwise be used to
-# set permissions.
-#
-# This is primarily to ensure that tests pass. Actually attempting to build
-# functional RPMs on macOS in rules_pkg has not yet been attempted at any scale.
-#
-# 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}'
-%if "%_host_os" != "linux"
- %{{__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"""
- return struct(
- origin = origin_label if origin_label else "<UNKNOWN>",
- group = grouping_label,
- )
-
-def _conflicting_contents_error(destination, from1, from2, attr_name = "srcs"):
- real_from1_origin = "<UNKNOWN>" if not from1.origin else from1.origin
- real_from1_group = "directly" if not from1.group else "from group {}".format(from1.group)
- real_from2_origin = "<UNKNOWN>" if not from2.origin else from2.origin
- real_from2_group = "directly" if not from2.group else "from group {}".format(from2.group)
-
- message = """Destination {destination} is provided by both (1) {from1_origin} and (2) {from2_origin}; please ensure that each destination is provided by exactly one input.
-
- (1) {from1_origin} is provided {from1_group}
- (2) {from2_origin} is provided {from2_group}
- """.format(
- destination = destination,
- from1_origin = real_from1_origin,
- from1_group = real_from1_group,
- from2_origin = real_from2_origin,
- from2_group = real_from2_group,
- )
-
- fail(message, attr_name)
-
-def _make_filetags(attributes, default_filetag = None):
- """Helper function for rendering RPM spec file tags, like
-
- ```
- %attr(0755, root, root) %dir
- ```
- """
- template = "%attr({mode}, {user}, {group}) {supplied_filetag}"
-
- mode = attributes.get("mode", "-")
- user = attributes.get("user", "-")
- group = attributes.get("group", "-")
-
- supplied_filetag = attributes.get("rpm_filetag", default_filetag)
-
- return template.format(
- mode = mode,
- user = user,
- group = group,
- supplied_filetag = supplied_filetag or "",
- )
-
-def _make_absolute_if_not_already_or_is_macro(path):
- # Make a destination path absolute if it isn't already or if it starts with
- # a macro (assumed to be a value that starts with "%").
- #
- # If the user has provided a macro as the installation destination, assume
- # they know what they're doing. Specifically, the macro needs to resolve to
- # an absolute path.
-
- # This may not be the fastest way to do this, but if it becomes a problem
- # this can be inlined easily.
- return path if path.startswith(("/", "%")) else "/" + path
-
-#### 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
-# there, but as of writing, it's not quite ready.
-def _process_files(pfi, origin_label, grouping_label, file_base, dest_check_map, packaged_directories, rpm_files_list, install_script_pieces):
- for dest, src in pfi.dest_src_map.items():
- metadata = _package_contents_metadata(origin_label, grouping_label)
- if dest in dest_check_map:
- _conflicting_contents_error(dest, metadata, dest_check_map[dest])
- else:
- dest_check_map[dest] = metadata
-
- abs_dest = _make_absolute_if_not_already_or_is_macro(dest)
- if src.is_directory:
- # Set aside TreeArtifact information for external processing
- #
- # @unsorted-dict-items
- packaged_directories.append({
- "src": src,
- "dest": abs_dest,
- # This doesn't exactly make it extensible, but it saves
- # us from having to having to maintain tag processing
- # code in multiple places.
- "tags": file_base,
- })
- else:
- # Files are well-known. Take care of them right here.
- 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):
- for dest in pdi.dirs:
- metadata = _package_contents_metadata(origin_label, grouping_label)
- if dest in dest_check_map:
- _conflicting_contents_error(dest, metadata, dest_check_map[dest])
- else:
- dest_check_map[dest] = metadata
-
- abs_dirname = _make_absolute_if_not_already_or_is_macro(dest)
- 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):
- 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])
- else:
- dest_check_map[psi.destination] = metadata
-
- abs_dest = _make_absolute_if_not_already_or_is_macro(psi.destination)
- 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,
- psi.attributes["mode"],
- ))
-
-#### Rule implementation
-
-def _pkg_rpm_impl(ctx):
- """Implements the pkg_rpm rule."""
-
- files = []
- tools = []
- args = ["--name=" + ctx.label.name]
-
- if ctx.attr.debug:
- args.append("--debug")
-
- if 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" +
- " to migrate to toolchains")
- else:
- toolchain = ctx.toolchains["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"].rpmbuild
- if not toolchain.valid:
- fail("The rpmbuild_toolchain is not properly configured: " +
- toolchain.name)
- if toolchain.path:
- args.append("--rpmbuild=" + toolchain.path)
- else:
- executable_files = toolchain.label[DefaultInfo].files_to_run
- tools.append(executable_files)
- args.append("--rpmbuild=%s" % executable_files.executable.path)
-
- #### Calculate output file name
- # rpm_name takes precedence over name if provided
- if ctx.attr.package_name:
- rpm_name = ctx.attr.package_name
- else:
- rpm_name = ctx.attr.name
-
- default_file = ctx.actions.declare_file("{}.rpm".format(rpm_name))
-
- package_file_name = ctx.attr.package_file_name
- if not package_file_name:
- package_file_name = "%s-%s-%s.%s.rpm" % (
- rpm_name,
- ctx.attr.version,
- ctx.attr.release,
- ctx.attr.architecture,
- )
-
- outputs, output_file, output_name = setup_output_files(
- ctx,
- package_file_name = package_file_name,
- default_output_file = default_file,
- )
-
- #### rpm spec "preamble"
- preamble_pieces = []
-
- preamble_pieces.append("Name: " + rpm_name)
-
- # Version can be specified by a file or inlined.
- if ctx.attr.version_file:
- if ctx.attr.version:
- fail("Both version and version_file attributes were specified")
-
- 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:
- preamble_pieces.append("Version: " + ctx.attr.version)
- else:
- fail("None of the version or version_file attributes were specified")
-
- # 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")
-
- 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:
- preamble_pieces.append("Release: " + ctx.attr.release)
- else:
- fail("None of the release or release_file attributes were specified")
-
- # source_date_epoch is an integer, and Bazel (as of 4.2.2) does not allow
- # you to put "None" as the default for an "int" attribute. See also
- # https://github.com/bazelbuild/bazel/issues/14434.
- #
- # Since source_date_epoch cannot reasonably be negative, being zero or
- # positive treated the same as existing below.
- if ctx.attr.source_date_epoch_file:
- if ctx.attr.source_date_epoch >= 0:
- fail("Both source_date_epoch and source_date_epoch_file attributes were specified")
- 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 >= 0:
- args.append("--source_date_epoch=" + str(ctx.attr.source_date_epoch))
-
- if ctx.attr.summary:
- preamble_pieces.append("Summary: " + ctx.attr.summary)
- if ctx.attr.url:
- preamble_pieces.append("URL: " + ctx.attr.url)
- if ctx.attr.license:
- preamble_pieces.append("License: " + ctx.attr.license)
- if ctx.attr.group:
- preamble_pieces.append("Group: " + ctx.attr.group)
- if ctx.attr.provides:
- 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.requires:
- preamble_pieces.extend(["Requires: " + r for r in ctx.attr.requires])
- if ctx.attr.requires_contextual:
- preamble_pieces.extend(
- [
- "Requires({}): {}".format(scriptlet, capability)
- for scriptlet in ctx.attr.requires_contextual.keys()
- for capability in ctx.attr.requires_contextual[scriptlet]
- ],
- )
-
- # TODO: BuildArch is usually not hardcoded in spec files, unless the package
- # is indeed restricted to a particular CPU architecture, or is actually
- # "noarch". This will become more of a concern when we start providing
- # source RPMs.
- #
- # In the meantime, this will allow the "architecture" attribute to take
- # effect.
- if ctx.attr.architecture:
- preamble_pieces.append("BuildArch: " + ctx.attr.architecture)
-
- preamble_file = ctx.actions.declare_file(
- "{}.spec.preamble".format(rpm_name),
- )
- ctx.actions.write(
- output = preamble_file,
- content = "\n".join(preamble_pieces),
- )
- files.append(preamble_file)
- args.append("--preamble=" + preamble_file.path)
-
- #### %description
-
- if ctx.attr.description_file:
- if ctx.attr.description:
- fail("Both description and description_file attributes were specified")
- description_file = ctx.file.description_file
- elif ctx.attr.description:
- description_file = ctx.actions.declare_file(
- "{}.spec.description".format(rpm_name),
- )
- ctx.actions.write(
- output = description_file,
- content = ctx.attr.description,
- )
- else:
- fail("None of the description or description_file attributes were specified")
-
- 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 = {}
- if ctx.attr.pre_scriptlet_file:
- if ctx.attr.pre_scriptlet:
- fail("Both pre_scriptlet and pre_scriptlet_file attributes were specified")
- pre_scriptlet_file = ctx.file.pre_scriptlet_file
- files.append(pre_scriptlet_file)
- args.append("--pre_scriptlet=" + pre_scriptlet_file.path)
- elif ctx.attr.pre_scriptlet:
- scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".pre_scriptlet")
- files.append(scriptlet_file)
- ctx.actions.write(scriptlet_file, ctx.attr.pre_scriptlet)
- args.append("--pre_scriptlet=" + scriptlet_file.path)
-
- if ctx.attr.post_scriptlet_file:
- if ctx.attr.post_scriptlet:
- fail("Both post_scriptlet and post_scriptlet_file attributes were specified")
- post_scriptlet_file = ctx.file.post_scriptlet_file
- files.append(post_scriptlet_file)
- args.append("--post_scriptlet=" + post_scriptlet_file.path)
- elif ctx.attr.post_scriptlet:
- scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".post_scriptlet")
- files.append(scriptlet_file)
- ctx.actions.write(scriptlet_file, ctx.attr.post_scriptlet)
- args.append("--post_scriptlet=" + scriptlet_file.path)
-
- if ctx.attr.preun_scriptlet_file:
- if ctx.attr.preun_scriptlet:
- fail("Both preun_scriptlet and preun_scriptlet_file attributes were specified")
- preun_scriptlet_file = ctx.file.preun_scriptlet_file
- files.append(preun_scriptlet_file)
- args.append("--preun_scriptlet=" + preun_scriptlet_file.path)
- elif ctx.attr.preun_scriptlet:
- scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".preun_scriptlet")
- files.append(scriptlet_file)
- ctx.actions.write(scriptlet_file, ctx.attr.preun_scriptlet)
- args.append("--preun_scriptlet=" + scriptlet_file.path)
-
- if ctx.attr.postun_scriptlet_file:
- if ctx.attr.postun_scriptlet:
- fail("Both postun_scriptlet and postun_scriptlet_file attributes were specified")
- postun_scriptlet_file = ctx.file.postun_scriptlet_file
- files.append(postun_scriptlet_file)
- args.append("--postun_scriptlet=" + postun_scriptlet_file.path)
- elif ctx.attr.postun_scriptlet:
- scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".postun_scriptlet")
- files.append(scriptlet_file)
- ctx.actions.write(scriptlet_file, ctx.attr.postun_scriptlet)
- args.append("--postun_scriptlet=" + scriptlet_file.path)
-
- #### Expand the spec file template; prepare data files
-
- spec_file = ctx.actions.declare_file("%s.spec" % rpm_name)
- ctx.actions.expand_template(
- template = ctx.file.spec_template,
- output = spec_file,
- substitutions = substitutions,
- )
- args.append("--spec_file=" + spec_file.path)
- files.append(spec_file)
-
- args.append("--out_file=" + output_file.path)
-
- # Add data files
- files += ctx.files.srcs
-
- #### Consistency checking; input processing
-
- # Ensure that no destinations collide. RPMs that fail this check may be
- # correct, but the output may also create hard-to-debug issues. Better to
- # err on the side of correctness here.
- dest_check_map = {}
-
- # The contents of the "%install" scriptlet
- install_script_pieces = []
- if ctx.attr.debug:
- install_script_pieces.append("set -x")
-
- # The list of entries in the "%files" list
- rpm_files_list = []
-
- # Directories (TreeArtifacts) are to be treated differently. Specifically,
- # since Bazel does not know their contents at analysis time, processing them
- # needs to be delegated to a helper script. This is done via the
- # _treeartifact_helper script used later on.
- packaged_directories = []
-
- # Iterate over all incoming data, checking for conflicts and creating
- # datasets as we go from the actual contents of the RPM.
- #
- # This is a naive approach to script creation is almost guaranteed to
- # produce an installation script that is longer than necessary. A better
- # implementation would track directories that are created and ensure that
- # they aren't unnecessarily recreated.
- for dep in ctx.attr.srcs:
- # NOTE: This does not detect cases where directories are not named
- # consistently. For example, all of these may collide in reality, but
- # won't be detected by the below:
- #
- # 1) usr/lib/libfoo.a
- # 2) /usr/lib/libfoo.a
- # 3) %{_libdir}/libfoo.a
- #
- # The most important thing, regardless of how these checks below are
- # done, is to be consistent with path naming conventions.
- #
- # There is also an unsolved question of determining how to handle
- # subdirectories of "PackageFilesInfo" targets that are actually
- # directories.
-
- # dep is a Target
- if PackageFilesInfo in dep:
- _process_files(
- dep[PackageFilesInfo],
- dep.label, # origin label
- None, # group label
- _make_filetags(dep[PackageFilesInfo].attributes), # file_base
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
-
- if PackageDirsInfo in dep:
- _process_dirs(
- dep[PackageDirsInfo],
- dep.label, # origin label
- None, # group label
- _make_filetags(dep[PackageDirsInfo].attributes, "%dir"), # file_base
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
-
- if PackageSymlinkInfo in dep:
- _process_symlink(
- dep[PackageSymlinkInfo],
- dep.label, # origin label
- None, # group label
- _make_filetags(dep[PackageSymlinkInfo].attributes), # file_base
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
-
- if PackageFilegroupInfo in dep:
- pfg_info = dep[PackageFilegroupInfo]
- for entry, origin in pfg_info.pkg_files:
- file_base = _make_filetags(entry.attributes)
- _process_files(
- entry,
- origin,
- dep.label,
- file_base,
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
- for entry, origin in pfg_info.pkg_dirs:
- file_base = _make_filetags(entry.attributes, "%dir")
- _process_dirs(
- entry,
- origin,
- dep.label,
- file_base,
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
-
- for entry, origin in pfg_info.pkg_symlinks:
- file_base = _make_filetags(entry.attributes)
- _process_symlink(
- entry,
- origin,
- dep.label,
- file_base,
- dest_check_map,
- packaged_directories,
- rpm_files_list,
- install_script_pieces,
- )
-
- #### Procedurally-generated scripts/lists (%install, %files)
-
- # We need to write these out regardless of whether we are using
- # TreeArtifacts. That stage will use these files as inputs.
- install_script = ctx.actions.declare_file("{}.spec.install".format(rpm_name))
- ctx.actions.write(
- install_script,
- "\n".join(install_script_pieces),
- )
-
- rpm_files_file = ctx.actions.declare_file(
- "{}.spec.files".format(rpm_name),
- )
- ctx.actions.write(
- rpm_files_file,
- "\n".join(rpm_files_list),
- )
-
- # TreeArtifact processing work
- if packaged_directories:
- packaged_directories_file = ctx.actions.declare_file("{}.spec.packaged_directories.json".format(rpm_name))
-
- packaged_directories_inputs = [d["src"] for d in packaged_directories]
-
- # This isn't the prettiest thing in the world, but it works. Bazel
- # needs the "File" data to pass to the command, but "File"s cannot be
- # JSONified.
- #
- # This data isn't used outside of this block, so it's probably fine.
- # Cleaner code would separate the JSONable values from the File type (in
- # a struct, probably).
- for d in packaged_directories:
- d["src"] = d["src"].path
-
- ctx.actions.write(packaged_directories_file, json.encode(packaged_directories))
-
- # Overwrite all following uses of the install script and files lists to
- # use the ones generated below.
- install_script_old = install_script
- install_script = ctx.actions.declare_file("{}.spec.install.with_dirs".format(rpm_name))
- rpm_files_file_old = rpm_files_file
- rpm_files_file = ctx.actions.declare_file("{}.spec.files.with_dirs".format(rpm_name))
-
- input_files = [packaged_directories_file, install_script_old, rpm_files_file_old]
- output_files = [install_script, rpm_files_file]
-
- helper_args = ctx.actions.args()
- helper_args.add_all(input_files)
- helper_args.add_all(output_files)
-
- ctx.actions.run(
- executable = ctx.executable._treeartifact_helper,
- use_default_shell_env = True,
- arguments = [helper_args],
- inputs = input_files + packaged_directories_inputs,
- outputs = output_files,
- progress_message = "Generating RPM TreeArtifact Data " + str(ctx.label),
- )
-
- # And then we're done. Yay!
-
- files.append(install_script)
- args.append("--install_script=" + install_script.path)
-
- files.append(rpm_files_file)
- args.append("--file_list=" + rpm_files_file.path)
-
- #### Remaining setup
-
- additional_rpmbuild_args = []
- if ctx.attr.binary_payload_compression:
- additional_rpmbuild_args.extend([
- "--define",
- "_binary_payload {}".format(ctx.attr.binary_payload_compression),
- ])
-
- args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args])
-
- for f in ctx.files.srcs:
- args.append(f.path)
-
- #### Call the generator script.
-
- ctx.actions.run(
- mnemonic = "MakeRpm",
- executable = ctx.executable._make_rpm,
- use_default_shell_env = True,
- arguments = args,
- inputs = files,
- outputs = [output_file],
- env = {
- "LANG": "en_US.UTF-8",
- "LC_CTYPE": "UTF-8",
- "PYTHONIOENCODING": "UTF-8",
- "PYTHONUTF8": "1",
- },
- tools = tools,
- )
-
- changes = []
- if ctx.attr.changelog:
- changes = [ctx.attr.changelog]
-
- output_groups = {
- "out": [default_file],
- "rpm": [output_file],
- "changes": changes
- }
- return [
- OutputGroupInfo(**output_groups),
- DefaultInfo(
- files = depset([output_file]),
- ),
- ]
-
-# Define the rule.
-pkg_rpm = rule(
- doc = """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 specificially 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 = {
- "package_name": attr.string(
- doc = """Optional; RPM name override.
-
- If not provided, the `name` attribute of this rule will be used
- instead.
-
- This influences values like the spec file name.
- """,
- ),
- "package_file_name": attr.string(
- doc = """See 'Common Attributes' in the rules_pkg reference.
-
- If this is not provided, the package file given a NVRA-style
- (name-version-release.arch) output, which is preferred by most RPM
- repositories.
- """,
- ),
- "package_variables": attr.label(
- doc = "See 'Common Attributes' in the rules_pkg reference",
- providers = [PackageVariablesInfo],
- ),
- "version": attr.string(
- doc = """RPM "Version" tag.
-
- Exactly one of `version` or `version_file` must be provided.
- """,
- ),
- "version_file": attr.label(
- doc = """File containing RPM "Version" tag.""",
- allow_single_file = True,
- ),
- "release": attr.string(
- doc = """RPM "Release" tag
-
- Exactly one of `release` or `release_file` must be provided.
- """,
- ),
- "release_file": attr.label(
- doc = """File containing RPM "Release" tag.""",
- allow_single_file = True,
- ),
- "group": attr.string(
- doc = """Optional; RPM "Group" tag.
-
- NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL
- > 5) have deprecated this tag. Other distributions may require it,
- but it is harmless in any case.
-
- """,
- ),
- "source_date_epoch": attr.int(
- doc = """Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds
-
- Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the
- subordinate call to `rpmbuild` to facilitate more consistent in-RPM
- file timestamps.
-
- Negative values (like the default) disable this feature.
- """,
- default = -1,
- ),
- "source_date_epoch_file": attr.label(
- doc = """File containing the SOURCE_DATE_EPOCH value.
-
- Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the
- subordinate call to `rpmbuild` to facilitate more consistent in-RPM
- file timestamps.
- """,
- allow_single_file = True,
- ),
- # TODO(nacl): this should be augmented to use bazel platforms, and
- # should not really set BuildArch.
- #
- # TODO(nacl): This, uh, is more required than it looks. It influences
- # the "A" part of the "NVRA" RPM file name, and RPMs file names look
- # funny if it's not provided. The contents of the RPM are believed to
- # be set as expected, though.
- "architecture": attr.string(
- doc = """Package architecture.
-
- This currently sets the `BuildArch` tag, which influences the output
- architecture of the package.
-
- Typically, `BuildArch` only needs to be set when the package is
- known to be cross-platform (e.g. written in an interpreted
- language), or, less common, when it is known that the application is
- only valid for specific architectures.
-
- When no attribute is provided, this will default to your host's
- architecture. This is usually what you want.
-
- """,
- ),
- "license": attr.string(
- doc = """RPM "License" tag.
-
- The software license for the code distributed in this package.
-
- 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".
-
- """,
- mandatory = True,
- ),
- "summary": attr.string(
- doc = """RPM "Summary" tag.
-
- One-line summary of this package. Must not contain newlines.
-
- """,
- mandatory = True,
- ),
- "url": attr.string(
- doc = """RPM "URL" tag; this project/vendor's home on the Internet.""",
- ),
- "description": attr.string(
- doc = """Multi-line description of this package, corresponds to RPM %description.
-
- Exactly one of `description` or `description_file` must be provided.
- """,
- ),
- "description_file": attr.label(
- doc = """File containing a multi-line description of this package, corresponds to RPM
- %description.""",
- allow_single_file = True,
- ),
- # TODO: this isn't consumed yet
- "changelog": attr.label(
- allow_single_file = True,
- ),
- "srcs": attr.label_list(
- doc = """Mapping groups to include in this RPM.
-
- These are typically brought into life as `pkg_filegroup`s.
- """,
- mandatory = True,
- providers = [
- [PackageDirsInfo],
- [PackageFilesInfo],
- [PackageFilegroupInfo],
- [PackageSymlinkInfo],
- ],
- ),
- "debug": attr.bool(
- doc = """Debug the RPM helper script and RPM generation""",
- default = False,
- ),
- "pre_scriptlet": attr.string(
- doc = """RPM `%pre` scriptlet. Currently only allowed to be a shell script.
-
- `pre_scriptlet` and `pre_scriptlet_file` are mutually exclusive.
- """,
- ),
- "pre_scriptlet_file": attr.label(
- doc = """File containing the RPM `%pre` scriptlet""",
- allow_single_file = True,
- ),
- "post_scriptlet": attr.string(
- doc = """RPM `%post` scriptlet. Currently only allowed to be a shell script.
-
- `post_scriptlet` and `post_scriptlet_file` are mutually exclusive.
- """,
- ),
- "post_scriptlet_file": attr.label(
- doc = """File containing the RPM `%post` scriptlet""",
- allow_single_file = True,
- ),
- "preun_scriptlet": attr.string(
- doc = """RPM `%preun` scriptlet. Currently only allowed to be a shell script.
-
- `preun_scriptlet` and `preun_scriptlet_file` are mutually exclusive.
- """,
- ),
- "preun_scriptlet_file": attr.label(
- doc = """File containing the RPM `%preun` scriptlet""",
- allow_single_file = True,
- ),
- "postun_scriptlet": attr.string(
- doc = """RPM `%postun` scriptlet. Currently only allowed to be a shell script.
-
- `postun_scriptlet` and `postun_scriptlet_file` are mutually exclusive.
- """,
- ),
- "postun_scriptlet_file": attr.label(
- doc = """File containing the RPM `%postun` 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
- """,
- ),
- "provides": attr.string_list(
- doc = """List of rpm capabilities that this package provides.
-
- Corresponds to the "Provides" preamble tag.
-
- See also: https://rpm.org/user_doc/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
- """,
- ),
- "requires_contextual": attr.string_list_dict(
- doc = """Contextualized requirement specifications
-
- This is a map of various properties (often scriptlet types) to
- capability name specifications, e.g.:
-
- ```python
- {"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}
- ```
-
- Which causes the below to be added to the spec file's preamble:
-
- ```
- Requires(pre): GConf2
- Requires(post): GConf2
- Requires(postun): GConf2
- ```
-
- 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:
-
- - `pre`
- - `post`
- - `preun`
- - `postun`
- - `pretrans`
- - `posttrans`
-
- 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
-
- NOTE: `pkg_rpm` does not check if the keys of this dictionary are
- acceptable to `rpm(8)`.
- """,
- ),
- "spec_template": attr.label(
- doc = """Spec file template.
-
- Use this if you need to add additional logic to your spec files that
- is not available by default.
-
- In most cases, you should not need to override this attribute.
- """,
- allow_single_file = spec_filetype,
- default = "//pkg/rpm:template.spec.tpl",
- ),
- "binary_payload_compression": attr.string(
- doc = """Compression mode used for this RPM
-
- Must be a form that `rpmbuild(8)` knows how to process, which will
- depend on the version of `rpmbuild` in use. The value corresponds
- to the `%_binary_payload` macro and is set on the `rpmbuild(8)`
- command line if provided.
-
- Some examples of valid values (which may not be supported on your
- system) can be found [here](https://git.io/JU9Wg). On CentOS
- systems (also likely Red Hat and Fedora), you can find some
- supported values by looking for `%_binary_payload` in
- `/usr/lib/rpm/macros`. Other systems have similar files and
- configurations.
-
- If not provided, the compression mode will be computed by `rpmbuild`
- itself. Defaults may vary per distribution or build of `rpm`;
- consult the relevant documentation for more details.
-
- WARNING: Bazel is currently not aware of action threading requirements
- for non-test actions. Using threaded compression may result in
- overcommitting your system.
- """,
- ),
- "rpmbuild_path": attr.string(
- doc = """Path to a `rpmbuild` binary. Deprecated in favor of the rpmbuild toolchain""",
- ),
- # Implicit dependencies.
- "_make_rpm": attr.label(
- default = Label("//pkg:make_rpm"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- "_treeartifact_helper": attr.label(
- default = Label("//pkg/rpm:augment_rpm_files_install"),
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- },
- executable = False,
- implementation = _pkg_rpm_impl,
- toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
-)
diff --git a/pkg/tar.bzl b/pkg/tar.bzl
deleted file mode 100644
index 697f95a..0000000
--- a/pkg/tar.bzl
+++ /dev/null
@@ -1,18 +0,0 @@
-# Copyright 2022 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.
-"""Forwarder for pkg_tar."""
-
-load("//pkg/private/tar:tar.bzl", _pkg_tar = "pkg_tar")
-
-pkg_tar = _pkg_tar
diff --git a/pkg/verify_archive.bzl b/pkg/verify_archive.bzl
deleted file mode 100644
index 07a9f0e..0000000
--- a/pkg/verify_archive.bzl
+++ /dev/null
@@ -1,135 +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.
-
-"""Rule to test that the content of an archive has particular properties.
-
-This is available for integration testing, when people want to verify that all
-the files they expect are in an archive. Or possibly, they want to verify that
-some files do not appear.
-
-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,
- output = ctx.outputs.out,
- # @unsorted-dict-items
- substitutions = {
- "${TEST_NAME}": ctx.attr.test_name,
- "${TARGET}": ctx.files.target[0].short_path,
- "${MUST_CONTAIN}": str(ctx.attr.must_contain),
- "${MUST_CONTAIN_REGEX}": str(ctx.attr.must_contain_regex),
- "${MUST_NOT_CONTAIN}": str(ctx.attr.must_not_contain),
- "${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 [
- DefaultInfo(files = depset([ctx.outputs.out])),
- ]
-
-_gen_verify_archive_test_main = rule(
- implementation = _gen_verify_archive_test_main_impl,
- # @unsorted-dict-items
- attrs = {
- "out": attr.output(mandatory = True),
- "test_name": attr.string(mandatory = True),
- "target": attr.label(
- doc = "Archive to test",
- allow_single_file = True,
- mandatory = True,
- ),
- "must_contain": attr.string_list(
- doc = "List of paths which all must appear in the archive.",
- ),
- "must_contain_regex": attr.string_list(
- doc = "List of regexes which all must appear in the archive.",
- ),
- "must_not_contain": attr.string_list(
- doc = """List of paths that must not be in the archive.""",
- ),
- "must_not_contain_regex": attr.string_list(
- doc = """List of regexes that must not be in the archive.""",
- ),
- "min_size": attr.int(
- doc = """Minimum number of entries in the archive.""",
- ),
- "max_size": attr.int(
- 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.
- "_template": attr.label(
- default = Label("//pkg:verify_archive_test_main.py.tpl"),
- allow_single_file = True,
- ),
- },
-)
-
-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.
-
- Args:
- target: A target archive.
- must_contain: A list of paths which must appear in the archive.
- must_contain_regex: A list of path regexes which must appear in the archive.
- must_not_contain: A list of paths which must not appear in the archive.
- 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"
- _gen_verify_archive_test_main(
- name = name + "_internal_main",
- target = target,
- test_name = name.replace("-", "_") + "Test",
- out = test_src,
- must_contain = must_contain,
- must_contain_regex = must_contain_regex,
- must_not_contain = must_not_contain,
- 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,
- srcs = [":" + test_src],
- main = test_src,
- data = [target],
- python_version = "PY3",
- )
diff --git a/pkg/verify_archive_test_main.py.tpl b/pkg/verify_archive_test_main.py.tpl
deleted file mode 100644
index 681bb0a..0000000
--- a/pkg/verify_archive_test_main.py.tpl
+++ /dev/null
@@ -1,146 +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.
-"""Tests for generated content manifest."""
-
-import re
-import tarfile
-import unittest
-
-class VerifyArchiveTest(unittest.TestCase):
- """Test harness to see if we wrote the content manifest correctly."""
-
-
- 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.
- """
- 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))
-
- 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()
- self.scan_target('${TARGET}')
-
- def test_min_size(self):
- self.assertMinSize(${MIN_SIZE})
-
- def test_max_size(self):
- self.assertMaxSize(${MAX_SIZE})
-
- def test_must_contain(self):
- self.check_must_contain(${MUST_CONTAIN})
-
- def test_must_not_contain(self):
- self.check_must_not_contain(${MUST_NOT_CONTAIN})
-
- def test_must_not_contain(self):
- self.check_must_contain_regex(${MUST_CONTAIN_REGEX})
-
- 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/pkg/zip.bzl b/pkg/zip.bzl
deleted file mode 100644
index e51410b..0000000
--- a/pkg/zip.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.
-"""Forwarder for pkg_zip."""
-
-load("//pkg/private/zip:zip.bzl", _pkg_zip = "pkg_zip")
-
-pkg_zip = _pkg_zip
diff --git a/tests/BUILD b/tests/BUILD
deleted file mode 100644
index 07b993a..0000000
--- a/tests/BUILD
+++ /dev/null
@@ -1,214 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -*- coding: utf-8 -*-
-
-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")
-
-package(
- default_applicable_licenses = ["//:license"],
- default_visibility = ["//tests:__subpackages__"],
-)
-
-licenses(["notice"])
-
-exports_files(glob(["testdata/**"]))
-
-filegroup(
- name = "loremipsum_txt",
- srcs = [
- "testdata/loremipsum.txt",
- ],
- visibility = ["//visibility:public"],
-)
-
-filegroup(
- name = "file_and_link",
- srcs = [
- "BUILD",
- "testdata/outer_BUILD",
- ],
- visibility = ["//visibility:public"],
-)
-
-filegroup(
- name = "glob_for_texts",
- srcs = glob(["**/*.txt"]),
-)
-
-#
-# Data source for Unicode handling tests
-#
-pkg_files(
- name = "utf8_files",
- srcs = [
- "//tests/testdata/utf8:files",
- ],
- # Note: This is temporary. We need to fix a latent bug where
- # we are using 555 as the default for many things. That was the
- # Google internal behavior.
- # See https://github.com/bazelbuild/rules_pkg/issues/302 for thoughts.
- attributes = pkg_attributes(mode = "0o555"),
- strip_prefix = strip_prefix.from_pkg(),
- visibility = ["//tests:__subpackages__"],
-)
-
-py_test(
- name = "archive_test",
- srcs = [
- "archive_test.py",
- ],
- imports = [".."],
- data = [
- "//tests:testdata/empty.ar",
- "//tests:testdata/a_ab.ar",
- "//tests:testdata/a.ar",
- "//tests:testdata/a_b_ab.ar",
- "//tests:testdata/a_b.ar",
- "//tests:testdata/ab.ar",
- "//tests:testdata/b.ar",
- ],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//pkg/private:archive",
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-py_test(
- name = "path_test",
- srcs = ["path_test.py"],
- data = ["//pkg:path.bzl"],
- python_version = "PY3",
- 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"],
- deps = [
- ":liba",
- ":libb",
- ],
-)
-
-py_test(
- name = "helpers_test",
- srcs = ["helpers_test.py"],
- imports = [".."],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//pkg/private:helpers",
- ],
-)
-
-#
-# Tests for package_file_name
-#
-my_package_naming(
- name = "my_package_variables",
- label = "some_value",
-)
-
-pkg_tar(
- name = "test_tar_naming",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "test_naming_{label}.tar",
- package_variables = ":my_package_variables",
-)
-
-pkg_deb(
- name = "test_deb_naming",
- data = ":test_tar_naming",
- description = "desc",
- maintainer = "someone@somewhere.com",
- package = "some_name",
- package_file_name = "test_naming_{label}.deb",
- package_variables = ":my_package_variables",
- version = "1",
-)
-
-pkg_zip(
- name = "test_zip_naming",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "test_naming_{label}.zip",
- package_variables = ":my_package_variables",
-)
-
-# This just proves that we would create the files via package_file_name rather
-# than the default out file.
-sh_test(
- name = "package_naming_aggregate_test",
- srcs = ["package_naming_aggregate_test.sh"],
- data = [
- ":test_deb_naming",
- ":test_tar_naming",
- ":test_zip_naming",
- ],
-)
-
-pkg_tar(
- name = "stamped_tar",
- srcs = ["BUILD"],
- stamp = 1,
-)
-
-pkg_zip(
- name = "stamped_zip",
- srcs = ["BUILD"],
- stamp = 1,
-)
-
-# Note that this only tests that stamping works. Other tests cover the case
-# of archive members having the default, epoch, time stamp.
-py_test(
- name = "stamp_test",
- srcs = [
- "stamp_test.py",
- ],
- data = [
- "stamped_tar.tar",
- "stamped_zip.zip",
- ],
- python_version = "PY3",
- deps = [
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-path_tests(name = "path_tests")
diff --git a/tests/a.cc b/tests/a.cc
deleted file mode 100644
index d46545e..0000000
--- a/tests/a.cc
+++ /dev/null
@@ -1 +0,0 @@
-int a = 1;
diff --git a/tests/archive_test.py b/tests/archive_test.py
deleted file mode 100644
index 21ddd5e..0000000
--- a/tests/archive_test.py
+++ /dev/null
@@ -1,98 +0,0 @@
-# Copyright 2015 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.
-"""Testing for archive."""
-
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-from pkg.private import archive
-
-
-class SimpleArReaderTest(unittest.TestCase):
- """Testing for SimpleArReader class."""
-
- def setUp(self):
- super(SimpleArReaderTest, self).setUp()
- self.data_files = runfiles.Create()
-
- def assertArFileContent(self, arfile, content):
- """Assert that arfile contains exactly the entry described by `content`.
-
- Args:
- arfile: the path to the AR file to test.
- content: an array describing the expected content of the AR file.
- Each entry in that list should be a dictionary where each field
- is a field to test in the corresponding SimpleArFileEntry. For
- testing the presence of a file "x", then the entry could simply
- be `{"filename": "x"}`, the missing field will be ignored.
- """
- print("READING: %s" % arfile)
- with archive.SimpleArReader(arfile) as f:
- current = f.next()
- i = 0
- while current:
- error_msg = "Extraneous file at end of archive %s: %s" % (
- arfile,
- current.filename
- )
- self.assertLess(i, len(content), error_msg)
- for k, v in content[i].items():
- value = getattr(current, k)
- error_msg = " ".join([
- "Value `%s` for key `%s` of file" % (value, k),
- "%s in archive %s does" % (current.filename, arfile),
- "not match expected value `%s`" % v
- ])
- self.assertEqual(value, v, error_msg)
- current = f.next()
- i += 1
- if i < len(content):
- self.fail("Missing file %s in archive %s" % (content[i], arfile))
-
- def testEmptyArFile(self):
- self.assertArFileContent(
- self.data_files.Rlocation("rules_pkg/tests/testdata/empty.ar"),
- [])
-
- def assertSimpleFileContent(self, names):
- datafile = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/" + "_".join(names) + ".ar")
- # pylint: disable=g-complex-comprehension
- content = [{"filename": n,
- "size": len(n.encode("utf-8")),
- "data": n.encode("utf-8")}
- for n in names]
- self.assertArFileContent(datafile, content)
-
- def testAFile(self):
- self.assertSimpleFileContent(["a"])
-
- def testBFile(self):
- self.assertSimpleFileContent(["b"])
-
- def testABFile(self):
- self.assertSimpleFileContent(["ab"])
-
- def testA_BFile(self):
- self.assertSimpleFileContent(["a", "b"])
-
- def testA_ABFile(self):
- self.assertSimpleFileContent(["a", "ab"])
-
- def testA_B_ABFile(self):
- self.assertSimpleFileContent(["a", "b", "ab"])
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/b.cc b/tests/b.cc
deleted file mode 100644
index b20302a..0000000
--- a/tests/b.cc
+++ /dev/null
@@ -1 +0,0 @@
-int b = 2;
diff --git a/tests/deb/BUILD b/tests/deb/BUILD
deleted file mode 100644
index 655b46b..0000000
--- a/tests/deb/BUILD
+++ /dev/null
@@ -1,150 +0,0 @@
-# -*- coding: utf-8 -*-
-# 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.
-
-# 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:tar.bzl", "pkg_tar")
-load("//tests:my_package_name.bzl", "my_package_naming")
-
-package(default_applicable_licenses = ["//:license"])
-
-genrule(
- name = "generate_files",
- outs = [
- "etc/nsswitch.conf",
- "usr/fizzbuzz",
- ],
- cmd = "for i in $(OUTS); do echo 1 >$$i; done",
-)
-
-my_package_naming(
- name = "my_package_variables",
- label = "some_value",
-)
-
-pkg_mklink(
- name = "java_link",
- link_name = "usr/bin/java",
- target = "/path/to/bin/java",
-)
-
-pkg_tar(
- name = "tar_input",
- srcs = [
- ":etc/nsswitch.conf",
- ":java_link",
- ":usr/fizzbuzz",
- ],
- extension = "tar.gz",
- mode = "0644",
- modes = {"usr/fizzbuzz": "0755"},
- owner = "42.24",
- ownername = "fizzbuzz.foobar",
- ownernames = {"etc/nsswitch.conf": "foobar.fizzbuzz"},
- owners = {"etc/nsswitch.conf": "24.42"},
- package_dir = "/",
- strip_prefix = ".",
-)
-
-pkg_deb(
- name = "test_deb",
- breaks = ["oldbrokenpkg"],
- built_using = "some_test_data (0.1.2)",
- conffiles = [
- "/etc/nsswitch.conf",
- "/etc/other",
- ],
- config = "config",
- data = ":tar_input",
- depends = [
- "dep1",
- "dep2",
- ],
- description = "toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\n more",
- distribution = "trusty",
- license = "Apache-2.0",
- maintainer = "soméone@somewhere.com",
- package = "fizzbuzz",
- preinst = "deb_preinst",
- provides = ["hello"],
- replaces = ["oldpkg"],
- templates = "templates",
- triggers = "deb_triggers",
- urgency = "low",
- version = "4.5.6",
-)
-
-py_test(
- name = "pkg_deb_test",
- size = "medium",
- srcs = [
- "pkg_deb_test.py",
- ],
- imports = ["../.."],
- data = [
- # The target includes both the .deb and .changes files in DefaultInfo
- ":test_deb",
- ],
- python_version = "PY3",
- deps = [
- "//pkg/private:archive",
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-package_naming_test(
- name = "naming_test",
- expected_name = "fizzbuzz_4.5.6_all.deb",
- target_under_test = ":test_deb",
-)
-
-py_test(
- name = "control_field_test",
- size = "small",
- srcs = [
- "control_field_test.py",
- ],
- imports = ["../.."],
- python_version = "PY3",
- deps = [
- "//pkg/private/deb:make_deb_lib",
- ],
-)
-
-# Test case for expanding $(var) constructions and for using ctx.var directly
-pkg_deb(
- name = "deb_using_ctxvar",
- config = "config",
- data = ":tar_input",
- description = "Compiled with $(COMPILATION_MODE)",
- #distribution = "trusty",
- maintainer = "soméone@somewhere.com",
- package = "fizzbuzz",
- version = "7",
- # This does not make sense for architecture, but for testing, compilation
- # mode is more stable than cpu.
- architecture = "$(COMPILATION_MODE)",
-)
-
-package_naming_test(
- name = "expand_from_ctx_var",
- # Heads up. If the default compilation mode ever changes this will break.
- expected_name = "fizzbuzz_7_fastbuild.deb",
- target_under_test = ":deb_using_ctxvar",
-)
diff --git a/tests/deb/config b/tests/deb/config
deleted file mode 100644
index d39edc7..0000000
--- a/tests/deb/config
+++ /dev/null
@@ -1 +0,0 @@
-# test config file
diff --git a/tests/deb/control_field_test.py b/tests/deb/control_field_test.py
deleted file mode 100644
index 5f4f5e9..0000000
--- a/tests/deb/control_field_test.py
+++ /dev/null
@@ -1,83 +0,0 @@
-# Copyright 2022 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# -*- coding: utf-8 -*-
-"""Testing for archive."""
-
-import codecs
-from io import BytesIO
-import os
-import sys
-import tarfile
-import unittest
-
-from pkg.private.deb import make_deb
-
-class MakeControlFieldTest(unittest.TestCase):
- """Tests for MakeControlField.
-
- https://www.debian.org/doc/debian-policy/ch-controlfields.html#syntax-of-control-files
- """
-
- def test_simple(self):
- self.assertEqual(
- 'Package: fizzbuzz\n',
- make_deb.MakeDebianControlField('Package', 'fizzbuzz'))
-
- def test_simple_strip(self):
- self.assertEqual(
- 'Package: fizzbuzz\n',
- make_deb.MakeDebianControlField('Package', ' fizzbuzz'))
- self.assertEqual(
- 'Package: fizzbuzz\n',
- make_deb.MakeDebianControlField('Package', ' fizzbuzz '))
-
- def test_simple_no_newline(self):
- with self.assertRaises(ValueError):
- make_deb.MakeDebianControlField('Package', ' fizz\nbuzz ')
-
-
- def test_multiline(self):
- self.assertEqual(
- 'Description: fizzbuzz\n',
- make_deb.MakeDebianControlField(
- 'Description', 'fizzbuzz', multiline=make_deb.Multiline.YES))
- self.assertEqual(
- 'Description: fizz\n buzz\n',
- make_deb.MakeDebianControlField(
- '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', 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', multiline=make_deb.Multiline.YES))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/deb/deb_preinst b/tests/deb/deb_preinst
deleted file mode 100644
index 9a88ab0..0000000
--- a/tests/deb/deb_preinst
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# tete ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é
-echo fnord
diff --git a/tests/deb/deb_tests.bzl b/tests/deb/deb_tests.bzl
deleted file mode 100644
index 0227d05..0000000
--- a/tests/deb/deb_tests.bzl
+++ /dev/null
@@ -1,51 +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.
-"""Helpers for pkg_deb tests."""
-
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-
-def _package_naming_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- ogi = target_under_test[OutputGroupInfo]
-
- deb_path = ogi.deb.to_list()[0].path
-
- # Test that the .changes file is computed correctly
- changes_path = ogi.changes.to_list()[0].path
- expected_changes_path = deb_path[0:-3] + "changes"
- asserts.equals(
- env,
- changes_path,
- expected_changes_path,
- "Changes file does not have the correct name",
- )
-
- # Is the generated file name what we expect
- if ctx.attr.expected_name:
- asserts.equals(
- env,
- deb_path.split("/")[-1], # basename(path)
- ctx.attr.expected_name,
- "Deb package file name is not correct",
- )
- return analysistest.end(env)
-
-package_naming_test = analysistest.make(
- _package_naming_test_impl,
- attrs = {
- "expected_name": attr.string(),
- },
-)
diff --git a/tests/deb/deb_triggers b/tests/deb/deb_triggers
deleted file mode 100644
index e7c1249..0000000
--- a/tests/deb/deb_triggers
+++ /dev/null
@@ -1,2 +0,0 @@
-# tutu ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é
-some-trigger
diff --git a/tests/deb/pkg_deb_test.py b/tests/deb/pkg_deb_test.py
deleted file mode 100644
index 285a965..0000000
--- a/tests/deb/pkg_deb_test.py
+++ /dev/null
@@ -1,280 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-# -*- coding: utf-8 -*-
-"""Testing for archive."""
-
-import codecs
-from io import BytesIO
-import os
-import sys
-import tarfile
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-from pkg.private import archive
-
-
-class DebInspect(object):
- """Class to open and unpack a .deb file so we can examine it."""
-
- def __init__(self, deb_file):
- self.deb_version = None
- self.data = None
- self.control = None
- with archive.SimpleArReader(deb_file) as f:
- info = f.next()
- while info:
- if info.filename == 'debian-binary':
- self.deb_version = info.data
- elif info.filename == 'control.tar.gz':
- self.control = info.data
- elif info.filename == 'data.tar.gz':
- self.data = info.data
- else:
- raise Exception('Unexpected file: %s' % info.filename)
- info = f.next()
-
- def get_deb_ctl_file(self, file_name):
- """Extract a control file."""
-
- with tarfile.open(mode='r:gz', fileobj=BytesIO(self.control)) as f:
- for info in f:
- if info.name == './' + file_name:
- return codecs.decode(f.extractfile(info).read(), 'utf-8')
- raise Exception('Could not find control file: %s' % file_name)
-
-
-class PkgDebTest(unittest.TestCase):
- """Testing for pkg_deb rule."""
-
- def setUp(self):
- super(PkgDebTest, self).setUp()
- self.runfiles = runfiles.Create()
- # Note: Rlocation requires forward slashes. os.path.join() will not work.
- self.deb_path = self.runfiles.Rlocation('rules_pkg/tests/deb/fizzbuzz_4.5.6_all.deb')
- self.deb_file = DebInspect(self.deb_path)
-
- def assert_control_content(self, expected, match_order=False):
- self.assert_tar_stream_content(
- BytesIO(self.deb_file.control),
- expected,
- match_order=match_order)
-
- def assert_data_content(self, expected, match_order=True):
- self.assert_tar_stream_content(
- BytesIO(self.deb_file.data),
- expected,
- match_order=match_order)
-
- def assert_tar_stream_content(self, data, expected, match_order=True):
- """Assert that tarfile contains exactly the entry described by `expected`.
-
- Args:
- data: the tar file stream to check.
- expected: an array describing the expected content of the TAR file.
- Each entry in that list should be a dictionary where each field
- is a field to test in the corresponding TarInfo. For
- testing the presence of a file "x", then the entry could simply
- be `{'name': 'x'}`, the missing field will be ignored. To match
- the content of a file entry, use the key 'data'.
- match_order: True if files must match in order as well as properties.
- """
- expected_by_name = {}
- for e in expected:
- expected_by_name[e['name']] = e
-
- with tarfile.open(mode='r:*', fileobj=data) as f:
- i = 0
- for info in f:
- error_msg = 'Extraneous file at end of archive: %s' % (
- info.name
- )
- self.assertLess(i, len(expected), error_msg)
- name_in_tar_file = getattr(info, 'name')
- if match_order:
- want = expected[i]
- else:
- want = expected_by_name[name_in_tar_file]
- for k, v in want.items():
- if k == 'data':
- value = f.extractfile(info).read()
- elif k == 'name':
- # 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':
- value = info.isdir()
- elif k == "name" and sys.platform == 'win32':
- value = getattr(current, k).replace("\\", "/")
- else:
- value = getattr(info, k)
- error_msg = ' '.join([
- 'Value `%s` for key `%s` of file' % (value, k),
- '%s in archive does' % info.name,
- 'not match expected value `%s`' % v
- ])
- self.assertEqual(value, v, error_msg)
- i += 1
- if i < len(expected):
- self.fail('Missing file %s' % expected[i])
-
- def test_expected_files(self):
- # Check the set of 'test-tar-basic-*' smoke test.
- expected = [
- {'name': 'etc', 'isdir': True,
- 'uid': 24, 'gid': 42, 'uname': 'foobar', 'gname': 'fizzbuzz'},
- {'name': 'etc/nsswitch.conf',
- 'mode': 0o644,
- 'uid': 24, 'gid': 42, 'uname': 'foobar', 'gname': 'fizzbuzz'
- },
- {'name': 'usr', 'isdir': True,
- 'uid': 42, 'gid': 24, 'uname': 'fizzbuzz', 'gname': 'foobar'},
- {'name': 'usr/bin', 'isdir': True},
- {'name': 'usr/bin/java', 'linkname': '/path/to/bin/java'},
- {'name': 'usr/fizzbuzz',
- 'mode': 0o755,
- 'uid': 42, 'gid': 24, 'uname': 'fizzbuzz', 'gname': 'foobar'},
- ]
- self.assert_data_content(expected)
-
- def test_description(self):
- control = self.deb_file.get_deb_ctl_file('control')
- fields = [
- 'Package: fizzbuzz',
- 'Depends: dep1, dep2',
- 'Built-Using: some_test_data',
- 'Replaces: oldpkg',
- 'Breaks: oldbrokenpkg',
- 'Provides: hello',
- 'License: Apache-2.0',
- ]
- # TODO(https://github.com/bazelbuild/rules_pkg/issues/214): This can not
- # pass on Windows Until we rewrite how description is passed
- if sys.platform != 'win32':
- fields.extend([
- 'Description: toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\n more\n',
- 'Maintainer: soméone@somewhere.com',
- ])
- for field in fields:
- if control.find(field) < 0:
- self.fail('Missing control field: <%s> in <%s>' % (field, control))
-
- def test_control_files(self):
- expected = [
- {'name': './conffiles', 'mode': 0o644},
- {'name': './config', 'mode': 0o755},
- {'name': './control', 'mode': 0o644},
- {'name': './preinst', 'mode': 0o755},
- {'name': './templates', 'mode': 0o644},
- {'name': './triggers', 'mode': 0o644},
- ]
- self.assert_control_content(expected, match_order=False)
-
- def test_conffiles(self):
- conffiles = self.deb_file.get_deb_ctl_file('conffiles')
- self.assertEqual(
- conffiles,
- '/etc/nsswitch.conf\n/etc/other\n')
-
- def test_config(self):
- config = self.deb_file.get_deb_ctl_file('config')
- self.assertEqual(config, '# test config file\n')
-
- def test_preinst(self):
- preinst = self.deb_file.get_deb_ctl_file('preinst')
- self.assertEqual(
- preinst,
- '#!/usr/bin/env bash\n'
- '# tete ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\n'
- 'echo fnord\n')
-
- def test_templates(self):
- templates = self.deb_file.get_deb_ctl_file('templates')
- for field in ('Template: deb/test', 'Type: string'):
- if templates.find(field) < 0:
- self.fail('Missing template field: <%s> in <%s>' % (field, templates))
-
- def test_triggers(self):
- triggers = self.deb_file.get_deb_ctl_file('triggers')
- self.assertEqual(
- triggers,
- '# tutu ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\n'
- 'some-trigger\n')
-
- def test_changes(self):
- changes_path = self.runfiles.Rlocation(
- 'rules_pkg/tests/deb/fizzbuzz_4.5.6_all.changes')
- with open(changes_path, 'r', encoding='utf-8') as f:
- content = f.read()
- for field in (
- 'Urgency: low',
- 'Distribution: trusty'):
- if content.find(field) < 0:
- self.fail('Missing template field: <%s> in <%s>' % (field, content))
-
- # TODO(https://github.com/bazelbuild/rules_pkg/issues/214): This can not
- # pass on Windows until we rewrite how description is passed.
- if sys.platform == 'win32':
- return
-
- # From the spec:
- # In a .changes file, the Description field contains a summary of the
- # descriptions for the packages being uploaded. For this case, the first
- # line of the field value (the part on the same line as Description:) is
- # always empty. It is a multiline field, with one line per package. Each
- # line is indented by one space and contains the name of a binary package,
- # a space, a hyphen (-), a space, and the short description line from that
- # package.
- d_expect = 'Description:\n fizzbuzz - toto ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é\n'
- d_start = content.find(d_expect)
- if d_start < 0:
- self.fail(
- 'Could not find expected description (%s) in\n=====%s=====' %
- (d_expect, content))
- # Check that the next line is the start of a new description, rather than
- # a continuation.
- self.assertTrue(
- 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/deb/templates b/tests/deb/templates
deleted file mode 100644
index 0576bc0..0000000
--- a/tests/deb/templates
+++ /dev/null
@@ -1,6 +0,0 @@
-Template: deb/test
-Type: string
-Default:
-Description: test question
- test question to check that templates are included into
- debian directory
diff --git a/tests/foo.cc b/tests/foo.cc
deleted file mode 100644
index 3274cf8..0000000
--- a/tests/foo.cc
+++ /dev/null
@@ -1,20 +0,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/helpers_test.py b/tests/helpers_test.py
deleted file mode 100644
index 0e6f005..0000000
--- a/tests/helpers_test.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# Copyright 2019 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.
-
-import os
-import tempfile
-import unittest
-
-from pkg.private import helpers
-
-
-class GetFlagValueTestCase(unittest.TestCase):
-
- def testNonStripped(self):
- self.assertEqual(helpers.GetFlagValue('value ', strip=False), 'value ')
-
- def testStripped(self):
- self.assertEqual(helpers.GetFlagValue('value ', strip=True), 'value')
-
- def testNonStripped_fromFile(self):
- with tempfile.TemporaryDirectory() as temp_d:
- argfile_path = os.path.join(temp_d, 'argfile')
- with open(argfile_path, 'wb') as f:
- f.write(b'value ')
- self.assertEqual(
- helpers.GetFlagValue('@'+argfile_path, strip=False), 'value ')
-
- def testStripped_fromFile(self):
- with tempfile.TemporaryDirectory() as temp_d:
- argfile_path = os.path.join(temp_d, 'argfile')
- with open(argfile_path, 'wb') as f:
- f.write(b'value ')
- self.assertEqual(
- helpers.GetFlagValue('@'+argfile_path, strip=True), 'value')
-
-
-class SplitNameValuePairAtSeparatorTestCase(unittest.TestCase):
-
- def testNoSep(self):
- key, val = helpers.SplitNameValuePairAtSeparator('abc', '=')
- self.assertEqual(key, 'abc')
- self.assertEqual(val, '')
-
- def testNoSepWithEscape(self):
- key, val = helpers.SplitNameValuePairAtSeparator('a\\=bc', '=')
- self.assertEqual(key, 'a=bc')
- self.assertEqual(val, '')
-
- def testNoSepWithDanglingEscape(self):
- key, val = helpers.SplitNameValuePairAtSeparator('abc\\', '=')
- self.assertEqual(key, 'abc')
- self.assertEqual(val, '')
-
- def testHappyCase(self):
- key, val = helpers.SplitNameValuePairAtSeparator('abc=xyz', '=')
- self.assertEqual(key, 'abc')
- self.assertEqual(val, 'xyz')
-
- def testHappyCaseWithEscapes(self):
- key, val = helpers.SplitNameValuePairAtSeparator('a\\=\\=b\\=c=xyz', '=')
- self.assertEqual(key, 'a==b=c')
- self.assertEqual(val, 'xyz')
-
- def testStopsAtFirstSep(self):
- key, val = helpers.SplitNameValuePairAtSeparator('a=b=c', '=')
- self.assertEqual(key, 'a')
- self.assertEqual(val, 'b=c')
-
- def testDoesntUnescapeVal(self):
- key, val = helpers.SplitNameValuePairAtSeparator('abc=x\\=yz\\', '=')
- self.assertEqual(key, 'abc')
- # the val doesn't get unescaped at all
- self.assertEqual(val, 'x\\=yz\\')
-
- def testUnescapesNonsepCharsToo(self):
- key, val = helpers.SplitNameValuePairAtSeparator('na\\xffme=value', '=')
- # this behaviour is surprising
- self.assertEqual(key, 'naxffme')
- self.assertEqual(val, 'value')
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/install/BUILD b/tests/install/BUILD
deleted file mode 100644
index df97dff..0000000
--- a/tests/install/BUILD
+++ /dev/null
@@ -1,77 +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("@rules_python//python:defs.bzl", "py_test")
-load("//pkg:install.bzl", "pkg_install")
-load("//pkg:mappings.bzl", "pkg_attributes", "pkg_files", "pkg_mkdirs")
-load("//tests/util:defs.bzl", "fake_artifact")
-
-package(default_applicable_licenses = ["//:license"])
-
-py_test(
- name = "install_test",
- srcs = ["test.py"],
- args = ["-v"],
- imports = ["../.."],
- data = [
- ":test_installer",
- ],
- main = "test.py",
- tags = [
- # TODO(nacl): investigate this. See also
- # https://buildkite.com/bazel/rules-pkg/builds/961#992dbe09-7e4b-4e34-91b6-491120476ed3
- "no-windows",
- # TODO(nacl): consider enabling this for testing on Linux.
- #"requires-fakeroot"
- ],
- deps = [
- "//pkg/private:manifest",
- "@rules_python//python/runfiles",
- ],
-)
-
-pkg_install(
- name = "test_installer",
- srcs = [
- ":artifact-in-owned-dir",
- ":artifact-in-unowned-dir",
- ":dirs",
- ],
-)
-
-fake_artifact(
- name = "artifact",
-)
-
-pkg_files(
- name = "artifact-in-owned-dir",
- srcs = ["artifact"],
- attributes = pkg_attributes(mode = "0700"),
- prefix = "owned-dir",
-)
-
-pkg_files(
- name = "artifact-in-unowned-dir",
- srcs = ["artifact"],
- attributes = pkg_attributes(mode = "0755"),
- prefix = "unowned-dir",
-)
-
-pkg_mkdirs(
- name = "dirs",
- dirs = [
- "empty-owned-dir",
- "owned-dir",
- ],
-)
diff --git a/tests/install/test.py b/tests/install/test.py
deleted file mode 100644
index 996ae09..0000000
--- a/tests/install/test.py
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import itertools
-import os
-import unittest
-import stat
-import subprocess
-
-from rules_python.python.runfiles import runfiles
-from pkg.private import manifest
-
-
-class PkgInstallTest(unittest.TestCase):
- @classmethod
- def setUpClass(cls):
- cls.runfiles = runfiles.Create()
- # Somewhat of an implementation detail, but it works. I think.
- manifest_file = cls.runfiles.Rlocation("rules_pkg/tests/install/test_installer_install_script-install-manifest.json")
-
- with open(manifest_file, 'r') as fh:
- manifest_entries = manifest.read_entries_from(fh)
- cls.manifest_data = {}
-
- for entry in manifest_entries:
- cls.manifest_data[entry.dest] = entry
- cls.installdir = os.path.join(os.getenv("TEST_TMPDIR"), "installdir")
- env = {}
- env.update(cls.runfiles.EnvVars())
- subprocess.check_call([
- cls.runfiles.Rlocation("rules_pkg/tests/install/test_installer"),
- "--destdir", cls.installdir,
- "--verbose",
- ],
- env=env)
-
- def entity_type_at_path(self, path):
- if os.path.islink(path):
- return manifest.ENTRY_IS_LINK
- elif os.path.isfile(path):
- return manifest.ENTRY_IS_FILE
- elif os.path.isdir(path):
- return manifest.ENTRY_IS_DIR
- else:
- # We can't infer what TreeArtifacts are by looking at them -- the
- # build system is not aware of their contents.
- raise ValueError("Entity {} is not a link, file, or directory")
-
- def assertEntryTypeMatches(self, entry, actual_path):
- actual_entry_type = self.entity_type_at_path(actual_path)
- self.assertEqual(actual_entry_type, entry.type,
- "Entity {} should be a {}, but was actually {}".format(
- entry.dest,
- manifest.entry_type_to_string(entry.type),
- manifest.entry_type_to_string(actual_entry_type),
- ))
-
- def assertEntryModeMatches(self, entry, actual_path):
- # TODO: permissions in windows are... tricky. Don't bother
- # testing for them if we're in it for the time being
- if os.name == 'nt':
- return
-
- actual_mode = stat.S_IMODE(os.stat(actual_path).st_mode)
- expected_mode = int(entry.mode, 8)
- self.assertEqual(actual_mode, expected_mode,
- "Entry {} has mode {:04o}, expected {:04o}".format(
- entry.dest, actual_mode, expected_mode,
- ))
-
- def test_manifest_matches(self):
- unowned_dirs = set()
- owned_dirs = set()
-
- # Figure out what directories we are supposed to own, and which ones we
- # aren't.
- #
- # Unowned directories are created implicitly by requesting other
- # elements be created or installed.
- #
- # Owned directories are created explicitly with the pkg_mkdirs rule.
- for dest, data in self.manifest_data.items():
- if data.type == manifest.ENTRY_IS_DIR:
- owned_dirs.add(dest)
-
- # TODO(nacl): The initial stage of the accumulation returns an empty string,
- # which end up in the set representing the root of the manifest.
- # This may not be the best thing.
- unowned_dirs.update([p for p in itertools.accumulate(os.path.dirname(dest).split('/'),
- func=lambda accum, new: accum + '/' + new)])
-
- # In the above loop, unowned_dirs contains all possible directories that
- # are in the manifest. Prune them here.
- unowned_dirs -= owned_dirs
-
- # TODO: check for ownership (user, group)
- found_entries = {dest: False for dest in self.manifest_data.keys()}
- for root, dirs, files in os.walk(self.installdir):
- rel_root_path = os.path.relpath(root, self.installdir)
-
- # The rest of this uses string comparison. To reduce potential
- # confusion, ensure that the "." doesn't show up elsewhere.
- #
- # TODO(nacl) consider using pathlib here, which will reduce the
- # need for path cleverness.
- if rel_root_path == '.':
- rel_root_path = ''
-
- # TODO(nacl): check for treeartifacts here. If so, prune `dirs`,
- # and set the rest aside for future processing.
-
- # Directory ownership tests
- if len(files) == 0 and len(dirs) == 0:
- # Empty directories must be explicitly requested by something
- if rel_root_path not in self.manifest_data:
- self.fail("Directory {} not in manifest".format(rel_root_path))
-
- entry = self.manifest_data[rel_root_path]
- self.assertEntryTypeMatches(entry, root)
- self.assertEntryModeMatches(entry, root)
-
- found_entries[rel_root_path] = True
- else:
- # There's something in here. Depending on how it was set up, it
- # could either be owned or unowned.
- if rel_root_path in self.manifest_data:
- entry = self.manifest_data[rel_root_path]
- self.assertEntryTypeMatches(entry, root)
- self.assertEntryModeMatches(entry, root)
-
- found_entries[rel_root_path] = True
- else:
- # If any unowned directories are here, they must be the
- # prefix of some entity in the manifest.
- self.assertIn(rel_root_path, unowned_dirs)
-
- for f in files:
- # The path on the filesystem in which the file actually exists.
-
- # TODO(#382): This part of the test assumes that the path
- # separator is '/', which is not the case in Windows. However,
- # paths emitted in the JSON manifests may also be using
- # '/'-separated paths.
- #
- # Confirm the degree to which this is a problem, and remedy as
- # needed. It maybe worth setting the keys in the manifest_data
- # dictionary to pathlib.Path or otherwise converting them to
- # native paths.
- fpath = os.path.normpath("/".join([root, f]))
- # The path inside the manifest (relative to the install
- # destdir).
- rel_fpath = os.path.normpath("/".join([rel_root_path, f]))
- if rel_fpath not in self.manifest_data:
- self.fail("Entity {} not in manifest".format(rel_fpath))
-
- entry = self.manifest_data[rel_fpath]
- self.assertEntryTypeMatches(entry, fpath)
- self.assertEntryModeMatches(entry, fpath)
-
- found_entries[rel_fpath] = True
-
- # TODO(nacl): check for TreeArtifacts
-
- num_missing = 0
- for dest, present in found_entries.items():
- if present is False:
- print("Entity {} is missing from the tree".format(dest))
- num_missing += 1
- self.assertEqual(num_missing, 0)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/mappings/BUILD b/tests/mappings/BUILD
deleted file mode 100644
index eb97f9f..0000000
--- a/tests/mappings/BUILD
+++ /dev/null
@@ -1,189 +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(
- ":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")
-
-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",
- ],
-)
-
-mappings_unit_tests()
-
-mappings_analysis_tests()
-
-mappings_external_repo_analysis_tests()
-
-################################################################################
-# Packaging rule manifest tests
-################################################################################
-
-directory(
- name = "treeartifact",
- filenames = [
- "artifact_in_tree1",
- "artifact_in_tree2",
- ],
-)
-
-pkg_files(
- name = "directory-with-contents",
- srcs = ["treeartifact"],
- attributes = pkg_attributes(mode = "0644"),
-)
-
-pkg_mkdirs(
- name = "dirs",
- attributes = pkg_attributes(
- group = "bar",
- mode = "711",
- user = "foo",
- ),
- dirs = [
- "foodir",
- ],
-)
-
-pkg_files(
- name = "files",
- srcs = [
- "mappings_test.bzl",
- ],
-)
-
-write_content_manifest(
- name = "all",
- srcs = [
- "BUILD",
- ":directory-with-contents",
- ":dirs",
- ":files",
- ],
-)
-
-manifest_golden_test(
- name = "all_test",
- expected = "all.manifest.golden",
- target = "all",
-)
-
-#
-# Unicode handling tests
-#
-pkg_files(
- name = "utf8_files",
- srcs = [
- "//tests/testdata/utf8:files",
- ],
- strip_prefix = strip_prefix.from_pkg(),
- visibility = ["//tests:__subpackages__"],
-)
-
-write_content_manifest(
- name = "utf8",
- srcs = [
- ":utf8_files",
- ],
-)
-
-manifest_golden_test(
- name = "utf8_manifest_test",
- expected = "utf8_manifest.golden",
- target = "utf8",
-)
-
-# Test handling of executable + runfiles
-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",
- }),
-)
-
-manifest_golden_test(
- name = "executable_test",
- expected = ":executable_test_expected",
- target = "executable_manifest",
-)
-
-write_content_manifest(
- name = "glob_for_texts_manifest",
- srcs = ["//tests:glob_for_texts"],
-)
-
-manifest_golden_test(
- name = "glob_for_texts_manifest_test",
- expected = "glob_for_texts_manifest.golden",
- target = "glob_for_texts_manifest",
-)
-
-link_tree(
- name = "node_modules",
- links = {
- "foo": ".pnpm/foo@1.0.0/node_modules/foo",
- ".pnpm/bar@1.0.0/node_modules/bar": "STORE/bar",
- ".pnpm/bar@1.0.0/node_modules/qar": "../../qar@2.0.0/node_modules/qar",
- ".pnpm/foo@1.0.0/node_modules/foo": "STORE/foo",
- ".pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
- ".pnpm/foo@1.0.0/node_modules/qar": "../../qar@2.0.0/node_modules/qar",
- ".pnpm/qar@2.0.0/node_modules/qar": "STORE/qar",
- },
- package_dir = "node_modules",
-)
-
-write_content_manifest(
- name = "node_modules_manifest",
- srcs = [
- ":node_modules",
- ],
-)
-
-manifest_golden_test(
- name = "link_tree_test",
- expected = "node_modules_manifest.golden",
- target = "node_modules_manifest",
-)
diff --git a/tests/mappings/all.manifest.golden b/tests/mappings/all.manifest.golden
deleted file mode 100644
index 6a5f107..0000000
--- a/tests/mappings/all.manifest.golden
+++ /dev/null
@@ -1,7 +0,0 @@
-[
- {"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, "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
deleted file mode 100644
index ee86633..0000000
--- a/tests/mappings/executable.manifest.golden
+++ /dev/null
@@ -1,7 +0,0 @@
-[
-{"dest":"an_executable.runfiles/tests/BUILD","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/BUILD","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
deleted file mode 100644
index d853c0d..0000000
--- a/tests/mappings/executable.manifest.windows.golden
+++ /dev/null
@@ -1,7 +0,0 @@
-[
-{"dest":"an_executable.exe.runfiles/tests/BUILD","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/BUILD","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/WORKSPACE b/tests/mappings/external_repo/WORKSPACE
deleted file mode 100644
index ff40799..0000000
--- a/tests/mappings/external_repo/WORKSPACE
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2021 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-workspace(name = "test_external_project")
diff --git a/tests/mappings/external_repo/pkg/BUILD b/tests/mappings/external_repo/pkg/BUILD
deleted file mode 100644
index 33db6a8..0000000
--- a/tests/mappings/external_repo/pkg/BUILD
+++ /dev/null
@@ -1,58 +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: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")
-
-package(default_visibility = ["//visibility:public"])
-
-exports_files(
- glob(["**"]),
-)
-
-fake_artifact(
- name = "dir/script",
- files = ["dir/extproj.sh"],
- visibility = ["//visibility:public"],
-)
-
-pkg_files(
- name = "extproj_script_pf",
- srcs = ["dir/extproj.sh"],
- prefix = "usr/bin",
- strip_prefix = strip_prefix.from_pkg(),
- tags = ["manual"],
-)
-
-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/dir/extproj.sh b/tests/mappings/external_repo/pkg/dir/extproj.sh
deleted file mode 100644
index 3d6f2af..0000000
--- a/tests/mappings/external_repo/pkg/dir/extproj.sh
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/bash
-
-# 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.
-
-echo "External project script!"
diff --git a/tests/mappings/external_repo/pkg/test.bzl b/tests/mappings/external_repo/pkg/test.bzl
deleted file mode 100644
index c0a7713..0000000
--- a/tests/mappings/external_repo/pkg/test.bzl
+++ /dev/null
@@ -1,68 +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.
-
-"""Tests for file mapping routines in pkg/mappings.bzl.
-
-Test implementation copied from pkg/mappings.bzl
-
-"""
-
-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")
-
-#### BEGIN copied code
-
-def _pkg_files_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- expected_dests = sets.make(ctx.attr.expected_dests)
- actual_dests = sets.make(target_under_test[PackageFilesInfo].dest_src_map.keys())
-
- asserts.new_set_equals(env, expected_dests, actual_dests, "pkg_files dests do not match expectations")
-
- return analysistest.end(env)
-
-pkg_files_contents_test = analysistest.make(
- _pkg_files_contents_test_impl,
- attrs = {
- # Other attributes can be tested here, but the most important one is the
- # destinations.
- "expected_dests": attr.string_list(
- mandatory = True,
- ),
- # attrs are always passed through unchanged (and maybe rejected)
- },
-)
-
-#### END copied code
-
-# Called from the rules_pkg tests
-def test_referencing_remote_file(name):
- pkg_files(
- name = "{}_g".format(name),
- prefix = "usr/share",
- srcs = ["@//tests:loremipsum_txt"],
- # The prefix in rules_pkg. Why yes, this is knotty
- strip_prefix = strip_prefix.from_root("tests"),
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = name,
- target_under_test = ":{}_g".format(name),
- expected_dests = ["usr/share/testdata/loremipsum.txt"],
- )
diff --git a/tests/mappings/filter_directory/BUILD b/tests/mappings/filter_directory/BUILD
deleted file mode 100644
index 4b0399b..0000000
--- a/tests/mappings/filter_directory/BUILD
+++ /dev/null
@@ -1,233 +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("@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")
-
-# TODO: the below tests only check for rule success and confirmation that
-# directory structure matches expectations. A more thorough test implementation
-# would also ensure that the contents also match expectations.
-
-############################################################################
-# Base case
-############################################################################
-
-package(default_applicable_licenses = ["//:license"])
-
-inspect_directory_test(
- name = "base",
- directory = ":test_directory",
- expected_structure = [
- "a",
- "b",
- "subdir/c",
- "subdir/d",
- ],
-)
-
-############################################################################
-# Renames
-############################################################################
-
-inspect_directory_test(
- name = "renames",
- directory = ":renames_in",
- expected_structure = [
- "b",
- "c",
- "subdir/a",
- "subdir/d",
- ],
-)
-
-filter_directory(
- name = "renames_in",
- src = ":test_directory",
- renames = {
- "subdir/a": "a",
- "c": "subdir/c",
- },
-)
-
-inspect_directory_test(
- name = "renames_loop",
- directory = ":renames_loop_in",
- expected_structure = [
- "a",
- "b",
- "subdir/c",
- "subdir/d",
- ],
-)
-
-filter_directory(
- name = "renames_loop_in",
- src = ":test_directory",
- renames = {
- "subdir/c": "a",
- "a": "subdir/c",
- },
-)
-
-############################################################################
-# Prefix stripping
-############################################################################
-
-inspect_directory_test(
- name = "strip_prefix",
- directory = ":strip_prefix_in",
- expected_structure = [
- "a",
- "b",
- "subdir/c",
- "subdir/d",
- ],
-)
-
-filter_directory(
- name = "strip_prefix_in",
- src = ":test_directory_same_root",
- strip_prefix = "root/",
-)
-
-############################################################################
-# Prefixing
-############################################################################
-
-inspect_directory_test(
- name = "prefix",
- directory = ":prefix_in",
- expected_structure = [
- "extra/a",
- "extra/b",
- "extra/subdir/c",
- "extra/subdir/d",
- ],
-)
-
-filter_directory(
- name = "prefix_in",
- src = ":test_directory",
- prefix = "extra/",
-)
-
-############################################################################
-# Exclusions
-############################################################################
-
-inspect_directory_test(
- name = "exclusions",
- directory = ":exclusions_in",
- expected_structure = [
- "a",
- "subdir/c",
- ],
-)
-
-filter_directory(
- name = "exclusions_in",
- src = ":test_directory",
- excludes = [
- "b",
- "subdir/d",
- ],
-)
-
-############################################################################
-# Combinations
-############################################################################
-
-inspect_directory_test(
- name = "combo_all",
- directory = ":combo_all_in",
- expected_structure = [
- "foo/root/not_a",
- "foo/subdir/c",
- ],
-)
-
-filter_directory(
- name = "combo_all_in",
- src = ":test_directory_same_root",
- excludes = [
- "root/b",
- "root/subdir/d",
- ],
- prefix = "foo",
- renames = {"root/not_a": "root/a"},
- strip_prefix = "root/",
-)
-
-inspect_directory_test(
- name = "combo_rename_to_exclude",
- directory = ":combo_rename_to_exclude_in",
- expected_structure = [
- "a",
- "subdir/c",
- "subdir/d",
- ],
-)
-
-filter_directory(
- name = "combo_rename_to_exclude_in",
- src = ":test_directory",
- excludes = ["a"],
- renames = {"a": "b"},
-)
-
-############################################################################
-# Inputs
-############################################################################
-
-directory(
- name = "test_directory_same_root",
- filenames = [
- "root/a",
- "root/b",
- "root/subdir/c",
- "root/subdir/d",
- ],
-)
-
-directory(
- name = "test_directory",
- filenames = [
- "a",
- "b",
- "subdir/c",
- "subdir/d",
- ],
-)
-
-############################################################################
-# Negative tests
-############################################################################
-
-# The filter_directory script has numerous failing edge cases that must be
-# tested. We cannot test whether a build action failed without introducing
-# test-related hacks into the `filter_directory` rule that captures the test
-# outputs.
-
-# Given that the interface to filter_directory.py is close to the
-# filter_directory rule, doing the tests in Python should suffice. It will also
-# allow us to test some cases that might not be reachable from Bazel.
-py_test(
- name = "negative_tests",
- srcs = ["test_filter_directory.py"],
- data = ["//pkg:filter_directory"],
- main = "test_filter_directory.py",
- deps = ["@rules_python//python/runfiles"],
-)
diff --git a/tests/mappings/filter_directory/defs.bzl b/tests/mappings/filter_directory/defs.bzl
deleted file mode 100644
index eb1dd62..0000000
--- a/tests/mappings/filter_directory/defs.bzl
+++ /dev/null
@@ -1,73 +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.
-
-"""Rules and macros to support testing rules that output directories."""
-
-load("@rules_python//python:defs.bzl", "py_test")
-
-def _inspect_directory_script_impl(ctx):
- script = ctx.actions.declare_file("{}.py".format(ctx.attr.name))
- ctx.actions.expand_template(
- template = ctx.file._inspector_template,
- output = script,
- substitutions = {
- "%EXPECTED_STRUCTURE%": json.encode(ctx.attr.expected_structure),
- "%DIRECTORY_ROOT%": ctx.file.directory.short_path,
- },
- )
-
- return [DefaultInfo(files = depset([script]))]
-
-_inspect_directory_script = rule(
- doc = """Create a script for testing the contents of directories.""",
- implementation = _inspect_directory_script_impl,
- attrs = {
- "directory": attr.label(
- mandatory = True,
- allow_single_file = True,
- ),
- "expected_structure": attr.string_list(
- mandatory = True,
- ),
- "_inspector_template": attr.label(
- default = ":inspect_directory.py.tpl",
- allow_single_file = True,
- ),
- },
-)
-
-def inspect_directory_test(name, directory, expected_structure, **kwargs):
- script_name = name + "_script"
-
- _inspect_directory_script(
- name = script_name,
- directory = directory,
- expected_structure = expected_structure,
- )
-
- # This appears to be necessary because of
- # https://github.com/bazelbuild/bazel/issues/1147
- native.sh_library(
- name = name + "_dir_lib",
- srcs = [directory],
- )
-
- py_test(
- name = name,
- srcs = [":" + script_name],
- main = ":" + script_name + ".py",
- data = [name + "_dir_lib"],
- deps = ["@rules_python//python/runfiles"],
- **kwargs
- )
diff --git a/tests/mappings/filter_directory/inspect_directory.py.tpl b/tests/mappings/filter_directory/inspect_directory.py.tpl
deleted file mode 100644
index 938ddd7..0000000
--- a/tests/mappings/filter_directory/inspect_directory.py.tpl
+++ /dev/null
@@ -1,62 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import json
-import os
-import unittest
-from rules_python.python.runfiles import runfiles
-
-DIRECTORY_ROOT = "%DIRECTORY_ROOT%"
-# This is JSON, which shouldn't have any triple quotes in it.
-EXPECTED_STRUCTURE = """%EXPECTED_STRUCTURE%"""
-
-
-class DirectoryStructureTest(unittest.TestCase):
- def setUp(self):
- self.runfiles = runfiles.Create()
-
- def test_directory_structure_matches_global(self):
- real_directory_root = self.runfiles.Rlocation(
- os.path.join(os.environ["TEST_WORKSPACE"], DIRECTORY_ROOT)
- )
-
- # This may be a bazel bug -- shouldn't an empty directory be passed in
- # anyway?
- self.assertTrue(
- os.path.isdir(real_directory_root),
- "TreeArtifact root does not exist, is the input empty?",
- )
-
- expected_set = set(json.loads(EXPECTED_STRUCTURE))
- actual_set = set()
- for root, dirs, files in os.walk(real_directory_root):
- if root != real_directory_root:
- rel_root = os.path.relpath(root, real_directory_root)
- else:
- # We are in the root. Don't bother with path relativization.
- rel_root = ''
- for f in files:
- actual_set.add(os.path.join(rel_root, f))
-
- self.assertEqual(
- expected_set,
- actual_set,
- "Directory structure mismatch"
- )
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/mappings/filter_directory/test_filter_directory.py b/tests/mappings/filter_directory/test_filter_directory.py
deleted file mode 100644
index a63c20f..0000000
--- a/tests/mappings/filter_directory/test_filter_directory.py
+++ /dev/null
@@ -1,183 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-"""Negative tests for the filter_directory script
-
-For a discussion as for why this needs to exist, see """
-
-import pathlib
-import os
-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
-
-
-# TODO: These tests are largely to ensure that filter_directory fails, but it
-# does not check _why_ they fail.
-#
-# This would involve changing how filter_directory returns errors, or maybe
-# restructuring it to make it unit-testable.
-#
-# Regardless, this would be significantly more code, and is not yet attempted.
-class FilterDirectoryInternalTest(unittest.TestCase):
-
- def setUp(self):
- self.indir = tempfile.TemporaryDirectory(dir=os.environ["TEST_TMPDIR"])
- self.outdir = tempfile.TemporaryDirectory(dir=os.environ["TEST_TMPDIR"])
- indir_path = pathlib.Path(self.indir.name)
-
- (indir_path / "root").mkdir()
- (indir_path / "root" / "a").open(mode='w').close()
- (indir_path / "root" / "b").open(mode='w').close()
- (indir_path / "root" / "subdir").mkdir()
- (indir_path / "root" / "subdir" / "c").open(mode='w').close()
- (indir_path / "root" / "subdir" / "d").open(mode='w').close()
-
- def tearDown(self):
- self.indir.cleanup()
- self.outdir.cleanup()
-
- ###########################################################################
- # Test helpers
- ###########################################################################
- def callFilterDirectory(self,
- prefix=None, # str
- strip_prefix=None, # str
- renames=None, # list of tuple
- exclusions=None): # list
- args = []
- if prefix:
- args.append("--prefix={}".format(prefix))
- if strip_prefix:
- args.append("--strip_prefix={}".format(prefix))
- if renames:
- args.extend(["--rename={}={}".format(dest, src) for dest, src in renames])
- if exclusions:
- args.extend(["--exclude={}".format(e) for e in exclusions])
-
- args.append(self.indir.name)
- args.append(self.outdir.name)
-
- try:
- filter_directory.main(args)
- return 0 # Success
- except SystemExit as e:
- return e.code
-
- def assertFilterDirectoryFails(self, message=None, **kwargs):
- self.assertNotEqual(self.callFilterDirectory(**kwargs), 0, message)
-
- def assertFilterDirectorySucceeds(self, message=None, **kwargs):
- self.assertEqual(self.callFilterDirectory(**kwargs), 0, message)
-
- ###########################################################################
- # Actual tests
- ###########################################################################
-
- def test_base(self):
- # Simply verify that the "null" transformation works
- self.assertFilterDirectorySucceeds()
-
- def test_invalid_prefixes(self):
- self.assertFilterDirectoryFails(
- prefix="/absolute/path",
- message="--prefix with absolute paths should be rejected",
- )
-
- self.assertFilterDirectoryFails(
- prefix="/absolute/path",
- message="--prefix with paths outside the destroot should be rejected",
- )
-
- def test_invalid_strip_prefixes(self):
- self.assertFilterDirectoryFails(
- strip_prefix="invalid",
- message="--strip_prefix that does not apply anywhere should be rejected",
- )
-
- self.assertFilterDirectoryFails(
- strip_prefix="subdir",
- message="--strip_prefix that does not apply everywhere should be rejected",
- )
-
- def test_invalid_excludes(self):
- self.assertFilterDirectoryFails(
- exclusions=["root/a", "foo"],
- message="--exclude's that are unused should be rejected",
- )
-
- def test_invalid_renames(self):
- self.assertFilterDirectoryFails(
- renames=[("../outside", "root/a")],
- message="--rename's with paths outside the destroot should be rejected",
- )
-
- # Can't rename files to outputs that already exist
- self.assertFilterDirectoryFails(
- renames=[("root/a", "root/subdir/c")],
- message="--rename's that clobber other output files should be rejected",
- )
-
- # This is unreachable from the bazel rule, but it's worth double-checking.
- #
- # Can't rename multiple files to the same destination
- self.assertFilterDirectoryFails(
- renames=[("root/a", "root/subdir/c"), ("root/a", "root/subdir/d")],
- message="Multiple --rename's to the same destination should be rejected.",
- )
-
- # Can't rename files twice
- self.assertFilterDirectoryFails(
- renames=[("bar", "root/a"), ("foo", "root/a")],
- message="--rename's that attempt to rename the same source twice should be rejected",
- )
-
- def test_invalid_interactions(self):
- # Renames are supposed to occur after exclusions, the rename here should
- # thus be unused.
- self.assertFilterDirectoryFails(
- renames=[("foo", "root/a")],
- exclusions=["root/a"],
- message="--rename's of excluded files should be rejected",
- )
-
- # strip_prefix and renames can cause collisions, check that they they're
- # detected.
- self.assertFilterDirectoryFails(
- strip_prefix="root", # valid
- renames=[("a", "root/subdir/c")], # Since we're stripping "root/"
- # from "root/a", this should
- # cause an output collision.
- message="--rename's to paths adjusted by strip_prefix should be rejected",
- )
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/mappings/glob_for_texts_manifest.golden b/tests/mappings/glob_for_texts_manifest.golden
deleted file mode 100644
index 9ff7e21..0000000
--- a/tests/mappings/glob_for_texts_manifest.golden
+++ /dev/null
@@ -1,6 +0,0 @@
-[
- {"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
deleted file mode 100644
index f403304..0000000
--- a/tests/mappings/manifest_test_lib.py
+++ /dev/null
@@ -1,68 +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.
-"""Compare to content manifest files."""
-
-import json
-import unittest
-
-from bazel_tools.tools.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_path, got_path):
- """Check two manifest files for equality.
-
- Args:
- 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_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}
- # self.assertEqual(expected_dict, got_dict)
-
- 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:
- 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/manifest_test_main.py.tpl b/tests/mappings/manifest_test_main.py.tpl
deleted file mode 100644
index c0e9960..0000000
--- a/tests/mappings/manifest_test_main.py.tpl
+++ /dev/null
@@ -1,27 +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.
-"""Tests for generated content manifest."""
-
-import unittest
-
-from tests.mappings import manifest_test_lib
-
-class ${TEST_NAME}(manifest_test_lib.ContentManifestTest):
-
- def test_match(self):
- self.assertManifestsMatch('${EXPECTED}', '${TARGET}')
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/mappings/mappings_external_repo_test.bzl b/tests/mappings/mappings_external_repo_test.bzl
deleted file mode 100644
index 09d0e67..0000000
--- a/tests/mappings/mappings_external_repo_test.bzl
+++ /dev/null
@@ -1,142 +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.
-
-"""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")
-
-##########
-# pkg_files tests involving external repositories
-##########
-
-# Tests involving external repositories
-def _test_pkg_files_extrepo():
- # From external repo root, basenames only
- pkg_files(
- name = "pf_extrepo_strip_all_g",
- srcs = ["@mappings_test_external_repo//pkg:dir/script"],
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = "pf_extrepo_strip_all",
- target_under_test = ":pf_extrepo_strip_all_g",
- expected_dests = ["extproj.sh", "script"],
- )
-
- # From external repo root, relative to the "pkg" package
- pkg_files(
- name = "pf_extrepo_strip_from_pkg_g",
- srcs = ["@mappings_test_external_repo//pkg:dir/script"],
- strip_prefix = strip_prefix.from_pkg("dir"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_extrepo_strip_from_pkg",
- target_under_test = ":pf_extrepo_strip_from_pkg_g",
- expected_dests = [
- "extproj.sh",
- "script",
- ],
- )
-
- # From external repo root, relative to the "pkg" directory
- pkg_files(
- name = "pf_extrepo_strip_from_root_g",
- srcs = ["@mappings_test_external_repo//pkg:dir/script"],
- strip_prefix = strip_prefix.from_root("pkg"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_extrepo_strip_from_root",
- target_under_test = ":pf_extrepo_strip_from_root_g",
- expected_dests = ["dir/extproj.sh", "dir/script"],
- )
-
- native.filegroup(
- name = "extrepo_test_fg",
- srcs = ["@mappings_test_external_repo//pkg:dir/extproj.sh"],
- )
-
- # Test the case when a have a pkg_files that targets a local filegroup
- # that has files in an external repo.
- pkg_files(
- name = "pf_extrepo_filegroup_strip_from_pkg_g",
- srcs = [":extrepo_test_fg"],
- # Files within filegroups should be considered relative to their
- # destination paths.
- strip_prefix = strip_prefix.from_pkg(""),
- )
- pkg_files_contents_test(
- name = "pf_extrepo_filegroup_strip_from_pkg",
- target_under_test = ":pf_extrepo_filegroup_strip_from_pkg_g",
- expected_dests = ["dir/extproj.sh"],
- )
-
- # Ditto, except strip from the workspace root instead
- pkg_files(
- name = "pf_extrepo_filegroup_strip_from_root_g",
- srcs = [":extrepo_test_fg"],
- # Files within filegroups should be considered relative to their
- # destination paths.
- strip_prefix = strip_prefix.from_root("pkg"),
- )
- pkg_files_contents_test(
- name = "pf_extrepo_filegroup_strip_from_root",
- target_under_test = ":pf_extrepo_filegroup_strip_from_root_g",
- expected_dests = ["dir/extproj.sh"],
- )
-
- # Reference a pkg_files in @mappings_test_external_repo
- pkg_files_contents_test(
- name = "pf_pkg_files_in_extrepo",
- target_under_test = "@mappings_test_external_repo//pkg:extproj_script_pf",
- expected_dests = ["usr/bin/dir/extproj.sh"],
- )
-
-def mappings_external_repo_analysis_tests():
- """Declare mappings.bzl analysis tests"""
- _test_pkg_files_extrepo()
-
- native.test_suite(
- name = "pkg_files_external_repo_analysis_tests",
- # We should find a way to get rid of this test list; it would be nice if
- # it could be derived from something else...
- tests = [
- # buildifier: don't sort
- # Tests involving external repositories
- ":pf_extrepo_strip_all",
- ":pf_extrepo_strip_from_pkg",
- ":pf_extrepo_strip_from_root",
- ":pf_extrepo_filegroup_strip_from_pkg",
- ":pf_extrepo_filegroup_strip_from_root",
- ":pf_pkg_files_in_extrepo",
- ":pf_file_rename_to_empty",
- ":pf_directory_rename_to_empty",
- # This one fits into the same category, but can't be aliased, apparently.
- #
- # 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
deleted file mode 100644
index fcb4639..0000000
--- a/tests/mappings/mappings_test.bzl
+++ /dev/null
@@ -1,1002 +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.
-
-"""Tests for file mapping routines in pkg/mappings.bzl"""
-
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts", "unittest")
-load(
- "//pkg:providers.bzl",
- "PackageDirsInfo",
- "PackageFilegroupInfo",
- "PackageFilesInfo",
- "PackageSymlinkInfo",
-)
-load(
- "//pkg:mappings.bzl",
- "REMOVE_BASE_DIRECTORY",
- "pkg_attributes",
- "pkg_filegroup",
- "pkg_files",
- "pkg_mkdirs",
- "pkg_mklink",
- "strip_prefix",
-)
-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
-##########
-
-def _flatten(list_of_lists):
- """Transform a list of lists into a single list, preserving relative order."""
- return [item for sublist in list_of_lists for item in sublist]
-
-##########
-# pkg_files tests
-##########
-
-def _pkg_files_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- expected_dests = {e: None for e in ctx.attr.expected_dests}
- n_found = 0
- for got in target_under_test[PackageFilesInfo].dest_src_map.keys():
- asserts.true(
- got in expected_dests,
- "got <%s> not in expected set: %s" % (got, ctx.attr.expected_dests),
- )
- n_found += 1
- asserts.equals(env, len(expected_dests), n_found)
-
- # Simple equality checks for the others, if specified
- if ctx.attr.expected_attributes:
- asserts.equals(
- env,
- json.decode(ctx.attr.expected_attributes),
- target_under_test[PackageFilesInfo].attributes,
- "pkg_files attributes do not match expectations",
- )
-
- # TODO(nacl): verify DefaultInfo propagation
-
- return analysistest.end(env)
-
-pkg_files_contents_test = analysistest.make(
- _pkg_files_contents_test_impl,
- attrs = {
- # Other attributes can be tested here, but the most important one is the
- # destinations.
- "expected_dests": attr.string_list(
- mandatory = True,
- ),
- "expected_attributes": attr.string(),
- },
-)
-
-def _test_pkg_files_contents():
- # Test stripping when no arguments are provided (same as strip_prefix.files_only())
- pkg_files(
- name = "pf_no_strip_prefix_g",
- srcs = ["testdata/hello.txt"],
- attributes = pkg_attributes(
- mode = "0755",
- user = "foo",
- group = "bar",
- # kwargs begins here
- foo = "bar",
- ),
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = "pf_no_strip_prefix",
- target_under_test = ":pf_no_strip_prefix_g",
- expected_dests = ["hello.txt"],
- expected_attributes = pkg_attributes(
- mode = "0755",
- user = "foo",
- group = "bar",
- foo = "bar",
- ),
- )
-
- # And now, files_only = True
- pkg_files(
- name = "pf_files_only_g",
- srcs = ["testdata/hello.txt"],
- strip_prefix = strip_prefix.files_only(),
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = "pf_files_only",
- target_under_test = ":pf_files_only_g",
- expected_dests = ["hello.txt"],
- )
-
- # Used in the following tests
- fake_artifact(
- name = "testdata/test_script",
- files = ["testdata/a_script.sh"],
- tags = ["manual"],
- )
-
- # Test stripping from the package root
- pkg_files(
- name = "pf_from_pkg_g",
- srcs = [
- "testdata/hello.txt",
- ":testdata/test_script",
- ],
- strip_prefix = strip_prefix.from_pkg("testdata/"),
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = "pf_strip_testdata_from_pkg",
- target_under_test = ":pf_from_pkg_g",
- expected_dests = [
- # Static file
- "hello.txt",
- # The script itself
- "a_script.sh",
- # The generated target output, in this case, a symlink
- "test_script",
- ],
- )
-
- # Test the stripping from root.
- #
- # In this case, the components to be stripped are taken relative to the root
- # of the package. Local and generated files should have the same prefix in
- # all cases.
-
- pkg_files(
- name = "pf_from_root_g",
- srcs = [":testdata/test_script"],
- strip_prefix = strip_prefix.from_root("tests/mappings"),
- tags = ["manual"],
- )
-
- pkg_files_contents_test(
- name = "pf_strip_prefix_from_root",
- target_under_test = ":pf_from_root_g",
- expected_dests = [
- # The script itself
- "testdata/a_script.sh",
- # The generated target output, in this case, a symlink
- "testdata/test_script",
- ],
- )
-
- # Test that the default mode (0644) is always set regardless of the other
- # values in "attributes".
- pkg_files(
- name = "pf_attributes_mode_overlay_if_not_provided_g",
- srcs = ["foo"],
- strip_prefix = strip_prefix.from_pkg(),
- attributes = pkg_attributes(
- user = "foo",
- group = "bar",
- foo = "bar",
- ),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_attributes_mode_overlay_if_not_provided",
- target_under_test = ":pf_attributes_mode_overlay_if_not_provided_g",
- expected_dests = ["foo"],
- expected_attributes = pkg_attributes(
- mode = "0644",
- user = "foo",
- group = "bar",
- foo = "bar",
- ),
- )
-
- # Test that pkg_files rejects cases where two targets resolve to the same
- # destination.
- pkg_files(
- name = "pf_destination_collision_invalid_g",
- srcs = ["foo", "bar/foo"],
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_destination_collision_invalid",
- target_under_test = ":pf_destination_collision_invalid_g",
- )
-
- # Test strip_prefix when it can't complete the strip operation as requested.
- pkg_files(
- name = "pf_strip_prefix_from_package_invalid_g",
- srcs = ["foo/foo", "bar/foo"],
- strip_prefix = strip_prefix.from_pkg("bar"),
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_strip_prefix_from_package_invalid",
- target_under_test = ":pf_strip_prefix_from_package_invalid_g",
- )
-
- # Ditto, except strip from the root.
- pkg_files(
- name = "pf_strip_prefix_from_root_invalid_g",
- srcs = ["foo", "bar"],
- strip_prefix = strip_prefix.from_root("not/the/root"),
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_strip_prefix_from_root_invalid",
- target_under_test = ":pf_strip_prefix_from_root_invalid_g",
- )
-
-def _test_pkg_files_exclusions():
- # Normal filegroup, used in all of the below tests
- #
- # Needs to be here to test the distinction between files and label inputs to
- # "excludes". This, admittedly, may be unnecessary.
- native.filegroup(
- name = "test_base_fg",
- srcs = [
- "testdata/config",
- "testdata/hello.txt",
- ],
- )
-
- # Tests to exclude from the case where stripping is done up to filenames
- pkg_files(
- name = "pf_exclude_by_label_strip_all_g",
- srcs = [":test_base_fg"],
- excludes = ["//tests/mappings:testdata/config"],
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_label_strip_all",
- target_under_test = ":pf_exclude_by_label_strip_all_g",
- expected_dests = ["hello.txt"],
- )
-
- pkg_files(
- name = "pf_exclude_by_filename_strip_all_g",
- srcs = [":test_base_fg"],
- excludes = ["testdata/config"],
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_filename_strip_all",
- target_under_test = ":pf_exclude_by_filename_strip_all_g",
- expected_dests = ["hello.txt"],
- )
-
- # Tests to exclude from the case where stripping is done from the package root
- pkg_files(
- name = "pf_exclude_by_label_strip_from_pkg_g",
- srcs = [":test_base_fg"],
- excludes = ["//tests/mappings:testdata/config"],
- strip_prefix = strip_prefix.from_pkg("testdata"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_label_strip_from_pkg",
- target_under_test = ":pf_exclude_by_label_strip_from_pkg_g",
- expected_dests = ["hello.txt"],
- )
-
- pkg_files(
- name = "pf_exclude_by_filename_strip_from_pkg_g",
- srcs = [":test_base_fg"],
- excludes = ["testdata/config"],
- strip_prefix = strip_prefix.from_pkg("testdata"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_filename_strip_from_pkg",
- target_under_test = ":pf_exclude_by_filename_strip_from_pkg_g",
- expected_dests = ["hello.txt"],
- )
-
- # Tests to exclude from the case where stripping is done from the root
- pkg_files(
- name = "pf_exclude_by_label_strip_from_root_g",
- srcs = [":test_base_fg"],
- excludes = ["//tests/mappings:testdata/config"],
- strip_prefix = strip_prefix.from_root("tests/mappings"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_label_strip_from_root",
- target_under_test = ":pf_exclude_by_label_strip_from_root_g",
- expected_dests = ["testdata/hello.txt"],
- )
-
- pkg_files(
- name = "pf_exclude_by_filename_strip_from_root_g",
- srcs = [":test_base_fg"],
- excludes = ["testdata/config"],
- strip_prefix = strip_prefix.from_root("tests/mappings"),
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_exclude_by_filename_strip_from_root",
- target_under_test = ":pf_exclude_by_filename_strip_from_root_g",
- expected_dests = ["testdata/hello.txt"],
- )
-
-def _test_pkg_files_rename():
- pkg_files(
- name = "pf_rename_multiple_g",
- srcs = [
- "testdata/hello.txt",
- "testdata/loremipsum.txt",
- ],
- prefix = "usr",
- renames = {
- "testdata/hello.txt": "share/goodbye.txt",
- "testdata/loremipsum.txt": "doc/dolorsitamet.txt",
- },
- tags = ["manual"],
- )
- pkg_files_contents_test(
- name = "pf_rename_multiple",
- target_under_test = ":pf_rename_multiple_g",
- expected_dests = [
- "usr/share/goodbye.txt",
- "usr/doc/dolorsitamet.txt",
- ],
- )
-
- # Used in the following tests
- fake_artifact(
- name = "test_script_rename",
- files = ["testdata/a_script.sh"],
- tags = ["manual"],
- )
-
- # test_script_rename produces multiple outputs. Thus, this test should
- # fail, as pkg_files can't figure out what should actually be mapped to
- # the output destination.
- pkg_files(
- name = "pf_rename_rule_with_multiple_outputs_g",
- srcs = ["test_script_rename"],
- renames = {
- ":test_script_rename": "still_a_script",
- },
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_rename_rule_with_multiple_outputs",
- target_under_test = ":pf_rename_rule_with_multiple_outputs_g",
- )
-
- # Fail because we tried to install a file that wasn't mentioned in the deps
- # list
- pkg_files(
- name = "pf_rename_single_missing_value_g",
- srcs = ["testdata/hello.txt"],
- prefix = "usr",
- renames = {
- "a_script": "an_output_location",
- },
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_rename_single_missing_value",
- target_under_test = ":pf_rename_single_missing_value_g",
- )
-
- # Ditto, except for exclusions
- pkg_files(
- name = "pf_rename_single_excluded_value_g",
- srcs = [
- "testdata/hello.txt",
- "testdata/loremipsum.txt",
- ],
- prefix = "usr",
- excludes = [
- "testdata/hello.txt",
- ],
- renames = {
- "testdata/hello.txt": "share/goodbye.txt",
- },
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_rename_single_excluded_value",
- target_under_test = ":pf_rename_single_excluded_value_g",
- )
-
- # Test whether or not destination collisions are detected after renaming.
- pkg_files(
- name = "pf_rename_destination_collision_g",
- srcs = [
- "foo",
- "bar",
- ],
- renames = {"foo": "bar"},
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_rename_destination_collision",
- target_under_test = ":pf_rename_destination_collision_g",
- )
-
- # Test that we are *not* allowed to rename a file to nothing
- pkg_files(
- name = "pf_file_rename_to_empty_g",
- srcs = ["foo"],
- renames = {"foo": REMOVE_BASE_DIRECTORY},
- tags = ["manual"],
- )
- generic_negative_test(
- name = "pf_file_rename_to_empty",
- target_under_test = ":pf_file_rename_to_empty_g",
- )
-
- # Test that we are allowed to rename a directory to nothing (to "strip" it)
- directory(
- name = "a_directory",
- filenames = ["a_file"],
- tags = ["manual"],
- )
- pkg_files(
- name = "pf_directory_rename_to_empty_g",
- srcs = [":a_directory"],
- renames = {":a_directory": REMOVE_BASE_DIRECTORY},
- tags = ["manual"],
- )
- generic_base_case_test(
- name = "pf_directory_rename_to_empty",
- target_under_test = ":pf_directory_rename_to_empty_g",
- )
-
-##########
-# Test pkg_mkdirs
-##########
-
-def _pkg_mkdirs_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- expected_dirs = sets.make(ctx.attr.expected_dirs)
- actual_dirs = sets.make(target_under_test[PackageDirsInfo].dirs)
-
- asserts.new_set_equals(env, expected_dirs, actual_dirs, "pkg_mkdirs dirs do not match expectations")
-
- # Simple equality checks for the others
- if ctx.attr.expected_attributes != None:
- asserts.equals(
- env,
- json.decode(ctx.attr.expected_attributes),
- target_under_test[PackageDirsInfo].attributes,
- "pkg_mkdir attributes do not match expectations",
- )
-
- return analysistest.end(env)
-
-pkg_mkdirs_contents_test = analysistest.make(
- _pkg_mkdirs_contents_test_impl,
- attrs = {
- "expected_attributes": attr.string(),
- "expected_dirs": attr.string_list(
- mandatory = True,
- ),
- },
-)
-
-def _test_pkg_mkdirs():
- # Reasonable base case
- pkg_mkdirs(
- name = "pkg_mkdirs_base_g",
- dirs = ["foo/bar", "baz"],
- attributes = pkg_attributes(
- mode = "0711",
- user = "root",
- group = "sudo",
- ),
- tags = ["manual"],
- )
- pkg_mkdirs_contents_test(
- name = "pkg_mkdirs_base",
- target_under_test = ":pkg_mkdirs_base_g",
- expected_dirs = ["foo/bar", "baz"],
- expected_attributes = pkg_attributes(
- mode = "0711",
- user = "root",
- group = "sudo",
- ),
- )
-
- # Test that the default mode (0755) is always set regardless of the other
- # values in "attributes".
- pkg_mkdirs(
- name = "pkg_mkdirs_mode_overlay_if_not_provided_g",
- dirs = ["foo"],
- attributes = pkg_attributes(
- user = "root",
- group = "sudo",
- ),
- tags = ["manual"],
- )
- pkg_mkdirs_contents_test(
- name = "pkg_mkdirs_mode_overlay_if_not_provided",
- target_under_test = ":pkg_mkdirs_mode_overlay_if_not_provided_g",
- expected_dirs = ["foo"],
- expected_attributes = pkg_attributes(
- mode = "0755",
- user = "root",
- group = "sudo",
- ),
- )
-
-##########
-# Test pkg_mklink
-##########
-def _pkg_mklink_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- asserts.equals(
- env,
- ctx.attr.expected_target,
- target_under_test[PackageSymlinkInfo].target,
- "pkg_mklink target does not match expectations",
- )
-
- asserts.equals(
- env,
- ctx.attr.expected_link_name,
- target_under_test[PackageSymlinkInfo].destination,
- "pkg_mklink destination does not match expectations",
- )
-
- # Simple equality checks for the others, if specified
- if ctx.attr.expected_attributes:
- asserts.equals(
- env,
- json.decode(ctx.attr.expected_attributes),
- target_under_test[PackageSymlinkInfo].attributes,
- "pkg_mklink attributes do not match expectations",
- )
-
- return analysistest.end(env)
-
-pkg_mklink_contents_test = analysistest.make(
- _pkg_mklink_contents_test_impl,
- attrs = {
- "expected_attributes": attr.string(),
- "expected_link_name": attr.string(mandatory = True),
- "expected_target": attr.string(mandatory = True),
- },
-)
-
-def _test_pkg_mklink():
- pkg_mklink(
- name = "pkg_mklink_base_g",
- link_name = "foo",
- target = "bar",
- tags = ["manual"],
- attributes = pkg_attributes(mode = "0111"),
- )
-
- pkg_mklink_contents_test(
- name = "pkg_mklink_base",
- target_under_test = ":pkg_mklink_base_g",
- expected_link_name = "foo",
- expected_target = "bar",
- expected_attributes = pkg_attributes(mode = "0111"),
- )
-
- # Test that the default mode (0755) is always set regardless of the other
- # values in "attributes".
- pkg_mklink(
- name = "pkg_mklink_mode_overlay_if_not_provided_g",
- link_name = "foo",
- target = "bar",
- attributes = pkg_attributes(
- user = "root",
- group = "sudo",
- ),
- tags = ["manual"],
- )
- pkg_mklink_contents_test(
- name = "pkg_mklink_mode_overlay_if_not_provided",
- target_under_test = ":pkg_mklink_mode_overlay_if_not_provided_g",
- expected_link_name = "foo",
- expected_target = "bar",
- expected_attributes = pkg_attributes(
- mode = "0777",
- user = "root",
- group = "sudo",
- ),
- )
-
-############################################################
-# Test pkg_filegroup
-############################################################
-def _pkg_filegroup_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- asserts.equals(
- env,
- [t[PackageFilesInfo] for t in ctx.attr.expected_pkg_files],
- [info for info, _ in target_under_test[PackageFilegroupInfo].pkg_files],
- "pkg_filegroup file list does not match expectations",
- )
- if ctx.attr.verify_origins:
- asserts.equals(
- env,
- [t.label for t in ctx.attr.expected_pkg_files],
- [origin for _, origin in target_under_test[PackageFilegroupInfo].pkg_files],
- "pkg_filegroup file origin list does not match expectations",
- )
-
- asserts.equals(
- env,
- [t[PackageDirsInfo] for t in ctx.attr.expected_pkg_dirs],
- [info for info, _ in target_under_test[PackageFilegroupInfo].pkg_dirs],
- "pkg_filegroup directory list does not match expectations",
- )
- if ctx.attr.verify_origins:
- asserts.equals(
- env,
- [t.label for t in ctx.attr.expected_pkg_dirs],
- [origin for _, origin in target_under_test[PackageFilegroupInfo].pkg_dirs],
- "pkg_filegroup directory origin list does not match expectations",
- )
-
- asserts.equals(
- env,
- [t[PackageSymlinkInfo] for t in ctx.attr.expected_pkg_symlinks],
- [info for info, _ in target_under_test[PackageFilegroupInfo].pkg_symlinks],
- "pkg_filegroup symlink map does not match expectations",
- )
- if ctx.attr.verify_origins:
- asserts.equals(
- env,
- [t.label for t in ctx.attr.expected_pkg_symlinks],
- [origin for _, origin in target_under_test[PackageFilegroupInfo].pkg_symlinks],
- "pkg_filegroup symlink origin list does not match expectations",
- )
-
- # Verify that the DefaultInfo is propagated properly out of the input
- # pkg_files's -- these are the files that need to be passed along to the
- # packaging rules.
- expected_packaged_files = sorted(_flatten([
- t[DefaultInfo].files.to_list()
- for t in ctx.attr.expected_pkg_files
- ]))
- packaged_files = sorted(target_under_test[DefaultInfo].files.to_list())
-
- asserts.equals(
- env,
- expected_packaged_files,
- packaged_files,
- "pkg_filegroup does not propagate DefaultInfo from pkg_file inputs",
- )
-
- return analysistest.end(env)
-
-pkg_filegroup_contents_test = analysistest.make(
- _pkg_filegroup_contents_test_impl,
- attrs = {
- "expected_pkg_files": attr.label_list(
- providers = [PackageFilesInfo],
- default = [],
- ),
- "expected_pkg_dirs": attr.label_list(
- providers = [PackageDirsInfo],
- default = [],
- ),
- "expected_pkg_symlinks": attr.label_list(
- providers = [PackageSymlinkInfo],
- default = [],
- ),
- "verify_origins": attr.bool(
- default = True,
- ),
- },
-)
-
-def _test_pkg_filegroup(name):
- pkg_files(
- name = "{}_pkg_files".format(name),
- srcs = ["foo", "bar"],
- prefix = "bin",
- tags = ["manual"],
- )
-
- pkg_mkdirs(
- name = "{}_pkg_dirs".format(name),
- dirs = ["etc"],
- tags = ["manual"],
- )
-
- pkg_mklink(
- name = "{}_pkg_symlink".format(name),
- link_name = "dest",
- target = "src",
- tags = ["manual"],
- )
-
- pkg_filegroup(
- name = "{}_pfg".format(name),
- srcs = [t.format(name) for t in ["{}_pkg_files", "{}_pkg_dirs", "{}_pkg_symlink"]],
- tags = ["manual"],
- )
-
- pkg_filegroup(
- name = "{}_pfg_nested".format(name),
- srcs = [":{}_pfg".format(name)],
- tags = ["manual"],
- )
-
- # Base case: confirm that basic data translation is working
- pkg_filegroup_contents_test(
- name = "{}_contents_valid".format(name),
- target_under_test = "{}_pfg".format(name),
- expected_pkg_files = ["{}_pkg_files".format(name)],
- expected_pkg_dirs = ["{}_pkg_dirs".format(name)],
- expected_pkg_symlinks = ["{}_pkg_symlink".format(name)],
- )
-
- # Base case': ditto for nested `pkg_filegroup`s.
- pkg_filegroup_contents_test(
- name = "{}_nested_contents_valid".format(name),
- target_under_test = "{}_pfg_nested".format(name),
- expected_pkg_files = ["{}_pkg_files".format(name)],
- expected_pkg_dirs = ["{}_pkg_dirs".format(name)],
- expected_pkg_symlinks = ["{}_pkg_symlink".format(name)],
- # See below re: "The origins for everything will be wrong here...".
- verify_origins = False,
- )
-
- ##################################################
-
- pkg_files(
- name = "{}_pkg_files_prefixed".format(name),
- srcs = ["foo", "bar"],
- prefix = "prefix/bin",
- tags = ["manual"],
- )
-
- pkg_mkdirs(
- name = "{}_pkg_dirs_prefixed".format(name),
- dirs = ["prefix/etc"],
- tags = ["manual"],
- )
-
- pkg_mklink(
- name = "{}_pkg_symlink_prefixed".format(name),
- link_name = "prefix/dest",
- target = "src",
- tags = ["manual"],
- )
-
- # Test that prefixing works by using the unprefixed mapping rules we
- # initially created, and set a prefix.
- pkg_filegroup(
- name = "{}_prefixed_pfg".format(name),
- srcs = [t.format(name) for t in ["{}_pkg_files", "{}_pkg_dirs", "{}_pkg_symlink"]],
- prefix = "prefix",
- tags = ["manual"],
- )
-
- # Then test that the results are equivalent to manually specifying the
- # prefix everywhere.
- pkg_filegroup_contents_test(
- name = "{}_contents_prefix_translated".format(name),
- target_under_test = "{}_prefixed_pfg".format(name),
- expected_pkg_files = ["{}_pkg_files_prefixed".format(name)],
- expected_pkg_dirs = ["{}_pkg_dirs_prefixed".format(name)],
- expected_pkg_symlinks = ["{}_pkg_symlink_prefixed".format(name)],
- # The origins for everything will be wrong here, since they're derived
- # from the labels of the inputs to pkg_filegroup.
- #
- # The first test here should be adequate for this purpose.
- verify_origins = False,
- )
-
- # Now do the same for a nested `pkg_filegroup`.
- pkg_files(
- name = "{}_pkg_files_nested_prefixed".format(name),
- srcs = ["foo", "bar"],
- prefix = "nest/prefix/bin",
- tags = ["manual"],
- )
-
- pkg_mkdirs(
- name = "{}_pkg_dirs_nested_prefixed".format(name),
- dirs = ["nest/prefix/etc"],
- tags = ["manual"],
- )
-
- pkg_mklink(
- name = "{}_pkg_symlink_nested_prefixed".format(name),
- link_name = "nest/prefix/dest",
- target = "src",
- tags = ["manual"],
- )
-
- pkg_filegroup(
- name = "{}_nested_prefixed_pfg".format(name),
- srcs = [":{}_prefixed_pfg".format(name)],
- prefix = "nest",
- tags = ["manual"],
- )
-
- pkg_filegroup_contents_test(
- name = "{}_contents_nested_prefix_translated".format(name),
- target_under_test = "{}_nested_prefixed_pfg".format(name),
- expected_pkg_files = ["{}_pkg_files_nested_prefixed".format(name)],
- expected_pkg_dirs = ["{}_pkg_dirs_nested_prefixed".format(name)],
- expected_pkg_symlinks = ["{}_pkg_symlink_nested_prefixed".format(name)],
- # See above re: "The origins for everything will be wrong here...".
- verify_origins = False,
- )
-
- native.test_suite(
- name = name,
- tests = [
- t.format(name)
- for t in [
- "{}_contents_valid",
- "{}_nested_contents_valid",
- "{}_contents_prefix_translated",
- "{}_contents_nested_prefix_translated",
- ]
- ],
- )
-
-##########
-# Test strip_prefix pseudo-module
-##########
-
-def _strip_prefix_test_impl(ctx):
- env = unittest.begin(ctx)
- asserts.equals(env, ".", strip_prefix.files_only())
- asserts.equals(env, "path", strip_prefix.from_pkg("path"))
- asserts.equals(env, "path", strip_prefix.from_pkg("/path"))
- asserts.equals(env, "/path", strip_prefix.from_root("path"))
- asserts.equals(env, "/path", strip_prefix.from_root("/path"))
- return unittest.end(env)
-
-strip_prefix_test = unittest.make(_strip_prefix_test_impl)
-
-def mappings_analysis_tests():
- """Declare mappings.bzl analysis tests"""
- _test_pkg_files_contents()
- _test_pkg_files_exclusions()
- _test_pkg_files_rename()
- _test_pkg_mkdirs()
- _test_pkg_mklink()
-
- # TODO(nacl) migrate the above to use a scheme the one used here. At the very
- # least, the test suites should be easy to find/name.
- _test_pkg_filegroup(name = "pfg_tests")
-
- native.test_suite(
- name = "pkg_files_analysis_tests",
- # We should find a way to get rid of this test list; it would be nice if
- # it could be derived from something else...
- tests = [
- # buildifier: don't sort
- # Simple tests
- ":pf_no_strip_prefix",
- ":pf_files_only",
- ":pf_strip_testdata_from_pkg",
- ":pf_strip_prefix_from_root",
- ":pf_attributes_mode_overlay_if_not_provided",
- # Tests involving excluded files
- ":pf_exclude_by_label_strip_all",
- ":pf_exclude_by_filename_strip_all",
- ":pf_exclude_by_label_strip_from_pkg",
- ":pf_exclude_by_filename_strip_from_pkg",
- ":pf_exclude_by_label_strip_from_root",
- ":pf_exclude_by_filename_strip_from_root",
- # Negative tests
- ":pf_destination_collision_invalid",
- ":pf_strip_prefix_from_package_invalid",
- ":pf_strip_prefix_from_root_invalid",
- #
- # Tests involving file renaming
- ":pf_rename_multiple",
- ":pf_rename_rule_with_multiple_outputs",
- ":pf_rename_single_missing_value",
- ":pf_rename_single_excluded_value",
- # Tests involving pkg_mkdirs
- ":pkg_mkdirs_base",
- ":pkg_mkdirs_mode_overlay_if_not_provided",
- # Tests involving pkg_mklink
- ":pkg_mklink_base",
- ":pkg_mklink_mode_overlay_if_not_provided",
- # Tests involving pkg_filegroup
- ":pfg_tests",
- ],
- )
-
-def mappings_unit_tests():
- unittest.suite(
- "mappings_unit_tests",
- strip_prefix_test,
- )
-
-def _gen_manifest_test_main_impl(ctx):
- ctx.actions.expand_template(
- template = ctx.file._template,
- output = ctx.outputs.out,
- substitutions = {
- "${EXPECTED}": ctx.files.expected[0].short_path,
- "${TARGET}": ctx.files.target[0].short_path,
- "${TEST_NAME}": ctx.attr.test_name,
- },
- )
- return [
- DefaultInfo(files = depset([ctx.outputs.out])),
- ]
-
-_gen_manifest_test_main = rule(
- implementation = _gen_manifest_test_main_impl,
- attrs = {
- "out": attr.output(mandatory = True),
- "expected": attr.label(mandatory = True, allow_single_file = True),
- "target": attr.label(mandatory = True, allow_single_file = True),
- "test_name": attr.string(mandatory = True),
- "_template": attr.label(
- default = Label("//tests/mappings:manifest_test_main.py.tpl"),
- allow_single_file = True,
- ),
- },
-)
-
-def manifest_golden_test(name, target, expected):
- """Tests that a content manifest file matches a golden copy.
-
- This test is used to verify that a generated manifest file matches the
- expected content.
-
- Args:
- target: A target which produces a content manifest with the name
- <target> + ".manifest"
- expected: label of a file containing the expected content.
- """
- _gen_manifest_test_main(
- name = name + "_main",
- out = name + ".py",
- expected = expected,
- target = target + ".manifest",
- test_name = target + "Test",
- )
- py_test(
- name = name,
- srcs = [":" + name + ".py"],
- data = [
- ":" + target,
- ":" + target + ".manifest",
- expected,
- ],
- python_version = "PY3",
- deps = [
- ":manifest_test_lib",
- ],
- )
diff --git a/tests/mappings/node_modules_manifest.golden b/tests/mappings/node_modules_manifest.golden
deleted file mode 100755
index b234629..0000000
--- a/tests/mappings/node_modules_manifest.golden
+++ /dev/null
@@ -1,9 +0,0 @@
-[
- {"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/testdata/a_script.sh b/tests/mappings/testdata/a_script.sh
deleted file mode 100644
index dac2554..0000000
--- a/tests/mappings/testdata/a_script.sh
+++ /dev/null
@@ -1 +0,0 @@
-echo a_script
diff --git a/tests/mappings/testdata/config b/tests/mappings/testdata/config
deleted file mode 100644
index d39edc7..0000000
--- a/tests/mappings/testdata/config
+++ /dev/null
@@ -1 +0,0 @@
-# test config file
diff --git a/tests/mappings/testdata/hello.txt b/tests/mappings/testdata/hello.txt
deleted file mode 100644
index af5626b..0000000
--- a/tests/mappings/testdata/hello.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello, world!
diff --git a/tests/mappings/utf8_manifest.golden b/tests/mappings/utf8_manifest.golden
deleted file mode 100644
index 11352ca..0000000
--- a/tests/mappings/utf8_manifest.golden
+++ /dev/null
@@ -1,8 +0,0 @@
-[
- {"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/my_package_name.bzl b/tests/my_package_name.bzl
deleted file mode 100644
index ebca81b..0000000
--- a/tests/my_package_name.bzl
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Sample rule to show package naming."""
-
-load("//pkg:providers.bzl", "PackageVariablesInfo")
-
-def _my_package_naming_impl(ctx):
- values = {}
-
- # then add in my own custom values
- values["label"] = ctx.attr.label
- return PackageVariablesInfo(values = values)
-
-my_package_naming = rule(
- implementation = _my_package_naming_impl,
- attrs = {
- "label": attr.string(doc = "A label that matters to me."),
- },
-)
diff --git a/tests/package_naming_aggregate_test.sh b/tests/package_naming_aggregate_test.sh
deleted file mode 100755
index 4951b24..0000000
--- a/tests/package_naming_aggregate_test.sh
+++ /dev/null
@@ -1,27 +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.
-
-# This test simply checks that when we create packages with package_file_name
-# that we get the expected file names.
-set -e
-
-# Portably find the absolute path to the test data, even if this code has been
-# vendored in to a source tree and re-rooted.
-TEST_PACKAGE="$(echo ${TEST_TARGET} | sed -e 's/:.*$//' -e 's@//@@')"
-declare -r DATA_DIR="${TEST_SRCDIR}/${TEST_WORKSPACE}/${TEST_PACKAGE}"
-
-for pkg in test_naming_some_value.deb test_naming_some_value.tar test_naming_some_value.zip ; do
- ls -l "${DATA_DIR}/$pkg"
-done
-echo "PASS"
diff --git a/tests/path_test.bzl b/tests/path_test.bzl
deleted file mode 100644
index a2a46d2..0000000
--- a/tests/path_test.bzl
+++ /dev/null
@@ -1,92 +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.
-
-"""Tests for path.bzl"""
-
-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.
- expect = ctx.attr.expected_path
- if expect.startswith("tests"):
- expect = ctx.label.package + expect[5:]
- asserts.equals(
- env,
- expect,
- compute_data_path(ctx, ctx.attr.in_path),
- )
- return analysistest.end(env)
-
-compute_data_path_test = analysistest.make(
- _compute_data_path_test_impl,
- attrs = {
- "in_path": attr.string(mandatory = True),
- "expected_path": attr.string(mandatory = True),
- },
-)
-
-def _test_compute_data_path(name):
- pkg_mkdirs(
- name = "dummy",
- dirs = [],
- tags = ["manual"],
- )
-
- compute_data_path_test(
- name = name + "_normal_test",
- target_under_test = ":dummy",
- in_path = "a/b/c",
- expected_path = "tests/a/b/c",
- )
-
- compute_data_path_test(
- name = name + "_absolute_test",
- target_under_test = ":dummy",
- in_path = "/a/b/c",
- expected_path = "a/b/c",
- )
-
- compute_data_path_test(
- name = name + "_relative_test",
- target_under_test = ":dummy",
- in_path = "./a/b/c",
- expected_path = "tests/a/b/c",
- )
-
- compute_data_path_test(
- name = name + "_empty_test",
- target_under_test = ":dummy",
- in_path = "./",
- expected_path = "tests",
- )
-
- compute_data_path_test(
- name = name + "_empty2_test",
- target_under_test = ":dummy",
- in_path = "./.",
- expected_path = "tests",
- )
-
-def path_tests(name):
- """Declare path.bzl analysis tests."""
- _test_compute_data_path(name = name + "_compute_data_path")
diff --git a/tests/path_test.py b/tests/path_test.py
deleted file mode 100644
index 85d133f..0000000
--- a/tests/path_test.py
+++ /dev/null
@@ -1,140 +0,0 @@
-# Copyright 2016 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.
-"""Testing for helper functions."""
-
-import collections
-import imp
-import os
-import unittest
-
-
-pkg_bzl = imp.load_source('pkg_bzl', 'pkg/path.bzl')
-
-Owner = collections.namedtuple('Owner', ['workspace_name', 'workspace_root'])
-Root = collections.namedtuple('Root', ['path'])
-
-
-class File(object):
- """Mock Skylark File class for testing."""
-
- def __init__(self, short_path, is_generated=False, is_external=False):
- self.is_source = not is_generated
- self.root = Root('bazel-out/k8-fastbuild/bin' if is_generated else '')
- if is_external:
- self.owner = Owner('repo', 'external/repo')
- self.short_path = '../repo/' + short_path
- else:
- self.owner = Owner('', '')
- self.short_path = short_path
- self.path = os.path.join(
- self.root.path, self.owner.workspace_root, short_path)
-
-
-class SafeShortPathTest(unittest.TestCase):
- """Testing for safe_short_path."""
-
- def testSafeShortPath(self):
- path = pkg_bzl.safe_short_path(File('foo/bar/baz'))
- self.assertEqual('foo/bar/baz', path)
-
- def testSafeShortPathGen(self):
- path = pkg_bzl.safe_short_path(File('foo/bar/baz', is_generated=True))
- self.assertEqual('foo/bar/baz', path)
-
- def testSafeShortPathExt(self):
- path = pkg_bzl.safe_short_path(File('foo/bar/baz', is_external=True))
- self.assertEqual('external/repo/foo/bar/baz', path)
-
- def testSafeShortPathGenExt(self):
- path = pkg_bzl.safe_short_path(
- File('foo/bar/baz', is_generated=True, is_external=True))
- self.assertEqual('external/repo/foo/bar/baz', path)
-
-
-class ShortPathDirnameTest(unittest.TestCase):
- """Testing for _short_path_dirname."""
-
- def testShortPathDirname(self):
- path = pkg_bzl._short_path_dirname(File('foo/bar/baz'))
- self.assertEqual('foo/bar', path)
-
- def testShortPathDirnameGen(self):
- path = pkg_bzl._short_path_dirname(File('foo/bar/baz', is_generated=True))
- self.assertEqual('foo/bar', path)
-
- def testShortPathDirnameExt(self):
- path = pkg_bzl._short_path_dirname(File('foo/bar/baz', is_external=True))
- self.assertEqual('external/repo/foo/bar', path)
-
- def testShortPathDirnameGenExt(self):
- path = pkg_bzl._short_path_dirname(
- File('foo/bar/baz', is_generated=True, is_external=True))
- self.assertEqual('external/repo/foo/bar', path)
-
- def testTopLevel(self):
- path = pkg_bzl._short_path_dirname(File('baz'))
- self.assertEqual('', path)
-
- def testTopLevelGen(self):
- path = pkg_bzl._short_path_dirname(File('baz', is_generated=True))
- self.assertEqual('', path)
-
- def testTopLevelExt(self):
- path = pkg_bzl._short_path_dirname(File('baz', is_external=True))
- self.assertEqual('external/repo', path)
-
-
-class DestPathTest(unittest.TestCase):
- """Testing for _dest_path."""
-
- def testDestPath(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz'), 'foo')
- self.assertEqual('/bar/baz', path)
-
- def testDestPathGen(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz', is_generated=True), 'foo')
- self.assertEqual('/bar/baz', path)
-
- def testDestPathExt(self):
- path = pkg_bzl.dest_path(
- File('foo/bar/baz', is_external=True), 'external/repo/foo')
- self.assertEqual('/bar/baz', path)
-
- def testDestPathExtWrong(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz', is_external=True), 'foo')
- self.assertEqual('external/repo/foo/bar/baz', path)
-
- def testNoMatch(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz'), 'qux')
- self.assertEqual('foo/bar/baz', path)
-
- def testNoStrip(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz'), None)
- self.assertEqual('/baz', path)
-
- def testTopLevel(self):
- path = pkg_bzl.dest_path(File('baz'), None)
- self.assertEqual('baz', path)
-
- def testPartialDirectoryMatch(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz'), 'fo')
- self.assertEqual('foo/bar/baz', path)
-
- def testPartialDirectoryMatchWithDataPath(self):
- path = pkg_bzl.dest_path(File('foo/bar/baz'), 'foo/ba', 'foo')
- self.assertEqual('/bar/baz', path)
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD
deleted file mode 100644
index b1dd70b..0000000
--- a/tests/rpm/BUILD
+++ /dev/null
@@ -1,423 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-# -*- coding: utf-8 -*-
-
-load("@bazel_skylib//rules:build_test.bzl", "build_test")
-load("@bazel_skylib//rules:diff_test.bzl", "diff_test")
-load("@rules_python//python:defs.bzl", "py_library", "py_test")
-load(
- "//pkg:mappings.bzl",
- "pkg_attributes",
- "pkg_filegroup",
- "pkg_files",
- "pkg_mkdirs",
- "pkg_mklink",
-)
-load("//pkg:rpm.bzl", "pkg_rpm")
-load("analysis_tests.bzl", "analysis_tests")
-load("toolchain_tests.bzl", "create_toolchain_analysis_tests")
-
-############################################################################
-# analysis tests
-############################################################################
-
-package(default_applicable_licenses = ["//:license"])
-
-analysis_tests(name = "analysis_tests")
-
-create_toolchain_analysis_tests()
-
-exports_files(
- ["template-test.spec.tpl"],
- visibility = [":__subpackages__"],
-)
-
-############################################################################
-# pkg_filegroups for testing
-############################################################################
-
-filegroup(
- name = "ars",
- srcs = [
- "//tests:testdata/a.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",
- ],
-)
-
-pkg_files(
- name = "ars_pf",
- srcs = [
- ":ars",
- ],
- attributes = pkg_attributes(
- group = "root",
- mode = "0755",
- user = "root",
- ),
- prefix = "/test",
-)
-
-genrule(
- name = "config_empty",
- outs = ["config.txt"],
- cmd = "touch $@",
-)
-
-pkg_files(
- name = "config_file",
- srcs = [":config_empty"],
- attributes = pkg_attributes(
- group = "root",
- mode = "0644",
- rpm_filetag = "%config(missingok, noreplace)",
- user = "root",
- ),
-)
-
-pkg_mkdirs(
- name = "var_log_foo",
- attributes = pkg_attributes(
- group = "root",
- mode = "0755",
- user = "root",
- ),
- dirs = ["/var/log/foo"],
-)
-
-pkg_mklink(
- name = "test_links",
- attributes = pkg_attributes(
- group = "root",
- mode = "0777",
- user = "root",
- ),
- link_name = "/usr/bin/link-name",
- target = "/usr/bin/link-target",
-)
-
-pkg_filegroup(
- name = "test_pfg",
- # Keep this list in sync with the values of "srcs" in "test_rpm_direct",
- # below
- srcs = [
- ":ars_pf",
- ":config_file",
- ":test_links",
- ":var_log_foo",
- ],
-)
-
-############################################################################
-# Test RPMs
-############################################################################
-
-pkg_rpm(
- name = "test_rpm",
- srcs = [
- ":test_pfg",
- ],
- architecture = "noarch",
- 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""",
- 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",
-)
-
-# Just like the above one, except the compression is changed.
-pkg_rpm(
- name = "test_rpm_bzip2",
- srcs = [
- ":test_pfg",
- ],
- architecture = "noarch",
- binary_payload_compression = "w2.bzdio",
- 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""",
- 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",
-)
-
-# Like the first one, except `srcs` is now passed in without using a
-# pkg_filegroup.
-pkg_rpm(
- name = "test_rpm_direct",
- srcs = [
- ":ars_pf",
- ":config_file",
- ":test_links",
- ":var_log_foo",
- ],
- architecture = "noarch",
- 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""",
- 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",
-)
-
-############################################################################
-# Test RPM metadata -- used to verify RPM contents in tests
-############################################################################
-
-# Emit a CSV file providing a manifest providing the expected RPM contents
-genrule(
- name = "test_rpm_manifest",
- srcs = [
- ":ars",
- ":config_file",
- ],
- outs = ["manifest.csv"],
- # Keep the header (the first line echo'd below) in sync with
- # rpm_queryformat_fieldnames in pkg_rpm_basic_test.py
- cmd = """
- echo 'path,digest,user,group,mode,fflags,symlink' > $@
- for f in $(locations :ars); do
- # Destination path
- (
- echo -n /test/$$(basename $$f),
- # Hash
- $(execpath //tests/util:md5) $$f | tr '\\n' ,
- # User,Group,Mode,Fflags (fflags not provided)
- echo -n 'root,root,100755,'
- # Symlink destination (not provided)
- echo ,
- ) >> $@
- done
- # Config file
- for f in $(location :config_file); do
- (
- echo -n /$$(basename $$f),
- $(execpath //tests/util:md5) $$f | tr '\\n' ,
- # User,Group,Mode,Fflags (fflags "cmn" = config + missingok + noreplace)
- echo -n 'root,root,100644,cmn'
- # Symlink destination (not provided)
- echo ,
- ) >> $@
- done
- # Directory (has no hash)
- (
- echo -n /var/log/foo,
- # No hash (beginning), fflags (end), or symlink destination (end)
- echo ,root,root,40755,,
- ) >> $@
-
- # Symlink (has no hash)
- (
- echo -n /usr/bin/link-name,
- # No hash (beginning), or fflags (second-to-last)
- echo ,root,root,120777,,/usr/bin/link-target
- ) >> $@
- """,
- tools = ["//tests/util:md5"],
-)
-
-genrule(
- name = "test_rpm_metadata",
- srcs = [],
- outs = [
- "conflicts.csv",
- "provides.csv",
- "requires.csv",
- ],
- # In the below, we don't use the "," separator for everything, because the
- # query tags used to get the associated dependency types
- # (e.g. %{REQUIREFLAGS:deptype}) itself uses commas. This makes it so the test
- # doesn't have to rely on knowing the number of fields in each CSV file.
- cmd = """
- (
- echo 'capability:sense'
- echo 'not-a-test:manual'
- ) > $(RULEDIR)/conflicts.csv
- (
- # NOTE: excludes the "self-require" (we did nothing special to make it
- # appear)
-
- echo 'capability:sense'
- echo 'test:manual'
- echo 'config(test_rpm) = 1.1.1-2222:config'
- ) > $(RULEDIR)/provides.csv
- (
- # NOTE: excludes 'rpmlib' requires that may be version-dependent
- echo 'capability:sense'
- # Common, automatically generated
- echo '/bin/sh:pre,interp'
- echo '/bin/sh:post,interp'
- echo '/bin/sh:preun,interp'
- echo '/bin/sh:postun,interp'
- # Hand-specified, specific dependencies
- echo 'bash:preun'
- # Hand-specified
- echo 'test-lib > 1.0:manual'
- echo 'config(test_rpm) = 1.1.1-2222:config'
- ) > $(RULEDIR)/requires.csv
- """,
-)
-
-# One cannot simply pass the output of pkg_rpm as runfiles content (#161). This
-# seems to be the easiest way around this problem.
-sh_library(
- name = "pkg_rpm_basic_test_data",
- testonly = True,
- srcs = [
- ":test_rpm",
- ":test_rpm_bzip2",
- ":test_rpm_direct",
- ":test_rpm_manifest",
- ":test_rpm_metadata",
- ],
-)
-
-############################################################################
-# Confirm that the %dir tag is being applied properly (#473)
-############################################################################
-
-pkg_mkdirs(
- name = "dirtest_dirs",
- attributes = pkg_attributes(mode = "0755"),
- dirs = [
- "dir",
- ],
-)
-
-pkg_files(
- name = "dirtest_file",
- srcs = [
- ":config_empty",
- ],
- attributes = pkg_attributes(mode = "0644"),
- prefix = "dir",
-)
-
-pkg_rpm(
- name = "test_rpm_dirs",
- srcs = [
- # Do not sort. Order important for testing.
- ":dirtest_file",
- ":dirtest_dirs",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- spec_template = "template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-genrule(
- name = "test_rpm_dirs_contents",
- srcs = [":test_rpm_dirs"],
- outs = [":test_rpm_dirs_contents.txt"],
- cmd = """
- # pkg_rpm emits two outputs
- RPMS=($(SRCS))
- rpm -qp --queryformat '[%{FILEMODES:perms} %{FILENAMES}\n]' $${RPMS[0]} > $@
- """,
-)
-
-diff_test(
- name = "test_rpm_dirs_contents_golden_test",
- file1 = ":test_rpm_dirs_contents",
- file2 = "test_rpm_dirs_contents.txt.golden",
-)
-
-############################################################################
-# Common tests
-############################################################################
-
-py_library(
- name = "rpm_util",
- srcs = ["rpm_util.py"],
- imports = ["../.."],
- visibility = [":__subpackages__"],
-)
-
-py_test(
- name = "make_rpm_test",
- srcs = ["make_rpm_test.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//pkg:make_rpm_lib",
- ],
-)
-
-# RPM content verification tests
-py_test(
- name = "pkg_rpm_basic_test",
- srcs = ["pkg_rpm_basic_test.py"],
- data = [":pkg_rpm_basic_test_data"],
- python_version = "PY3",
- tags = [
- "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
- ],
- deps = [
- ":rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-# Smoke test for defaults
-pkg_rpm(
- name = "test_rpm_default_template",
- testonly = True,
- srcs = [
- ":test_pfg",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-build_test(
- name = "pkg_rpm_smoke",
- targets = [":test_rpm_default_template"],
-)
diff --git a/tests/rpm/analysis_tests.bzl b/tests/rpm/analysis_tests.bzl
deleted file mode 100644
index 3565b47..0000000
--- a/tests/rpm/analysis_tests.bzl
+++ /dev/null
@@ -1,318 +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.
-
-"""Tests for RPM generation analysis"""
-
-load(
- "//pkg:mappings.bzl",
- "pkg_filegroup",
- "pkg_files",
- "pkg_mkdirs",
- "pkg_mklink",
-)
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-load("//pkg:providers.bzl", "PackageVariablesInfo")
-load("//pkg:rpm.bzl", "pkg_rpm")
-load("//tests/util:defs.bzl", "directory", "generic_base_case_test", "generic_negative_test")
-
-def _declare_pkg_rpm(name, srcs_ungrouped, tags = None, **kwargs):
- pfg_name = "{}_pfg".format(name)
- _tags = tags or ["manual"]
-
- pkg_filegroup(
- name = pfg_name,
- srcs = srcs_ungrouped,
- tags = _tags,
- )
-
- pkg_rpm(
- name = name,
- srcs = [":" + pfg_name],
- version = "1.0",
- release = "1",
- architecture = "noarch",
- license = "N/A",
- summary = "A test",
- description = "very much a test",
- tags = _tags,
- **kwargs
- )
-
-def _declare_conflicts_test(name, srcs, **kwargs):
- rpm_name = name + "_rpm"
- _declare_pkg_rpm(
- name = rpm_name,
- srcs_ungrouped = srcs,
- tags = ["manual"],
- )
-
- generic_negative_test(
- name = name,
- target_under_test = ":" + rpm_name,
- )
-
-############################################################
-# Begin tests. Check that the conflict detection system works.
-############################################################
-
-def _test_conflicting_inputs(name):
- # The test here is to confirm if pkg_rpm rejects conflicting inputs
- #
- # The structure of the code is such that it's only necessary to test any one
- # packaged item conflicts with all others; order is irrelevant.
- #
- # So, we test how everything would conflict with a "file" entry
- pkg_files(
- name = "{}_file_base".format(name),
- srcs = ["foo"],
- tags = ["manual"],
- )
-
- _declare_pkg_rpm(
- name = name + "_base",
- srcs_ungrouped = [":{}_file_base".format(name)],
- )
-
- generic_base_case_test(
- name = name + "_base_case_passes_analysis",
- target_under_test = ":" + name + "_base",
- )
-
- ##################################################
- # file vs conflicting file
- ##################################################
-
- pkg_files(
- name = "{}_file_conflict".format(name),
- srcs = ["foo"],
- tags = ["manual"],
- )
-
- _declare_conflicts_test(
- name = name + "_conflict_with_file",
- srcs = [
- ":{}_file_base".format(name),
- ":{}_file_conflict".format(name),
- ],
- )
-
- ##################################################
- # file vs conflicting dir
- ##################################################
-
- pkg_mkdirs(
- name = "{}_dir_conflict".format(name),
- dirs = ["foo"],
- tags = ["manual"],
- )
-
- _declare_conflicts_test(
- name = name + "_conflict_with_dir",
- srcs = [
- ":{}_file_base".format(name),
- ":{}_dir_conflict".format(name),
- ],
- )
-
- ##################################################
- # file vs conflicting symbolic link
- ##################################################
-
- pkg_mklink(
- name = "{}_symlink_conflict".format(name),
- link_name = "foo",
- target = "bar",
- tags = ["manual"],
- )
-
- _declare_conflicts_test(
- name = name + "_conflict_with_symlink",
- srcs = [
- ":{}_file_base".format(name),
- ":{}_symlink_conflict".format(name),
- ],
- )
-
- native.test_suite(
- name = name,
- tests = [
- ":{}_{}".format(name, test_name)
- for test_name in [
- "base_case_passes_analysis",
- "conflict_with_file",
- "conflict_with_dir",
- "conflict_with_symlink",
- ]
- ],
- )
-
-############################################################
-# Verify that rules produce expected named outputs
-############################################################
-
-#### Setup; helpers
-
-def _package_naming_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- ogi = target_under_test[OutputGroupInfo]
-
- 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,
- rpm_file.basename,
- ctx.attr.expected_name,
- "OutputGroupInfo rpm name does not match expected value.",
- )
-
- # 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 == 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,
- rpm_file_found,
- "rpm component of OutputGroupInfo '{}' is not in DefaultInfo".format(rpm_file),
- )
- asserts.false(
- env,
- 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_name),
- )
-
- return analysistest.end(env)
-
-package_naming_test = analysistest.make(
- _package_naming_test_impl,
- attrs = {
- "expected_name": attr.string(),
- },
-)
-
-# Dummy substitution set, used in below test cases
-def _dummy_pkg_variables_impl(ctx):
- return [
- PackageVariablesInfo(
- values = {
- "FOO": "foo",
- "BAR": "bar",
- },
- ),
- ]
-
-dummy_pkg_variables = rule(
- implementation = _dummy_pkg_variables_impl,
- attrs = {},
-)
-
-#### Tests start here
-
-def _test_naming(name):
- # Test whether name templating via PackageVariablesInfo functions as expected, and ensure that
- # outputs are passed through to OutputGroupInfo.
- pkg_files(
- name = "{}_file_base".format(name),
- srcs = ["foo"],
- tags = ["manual"],
- )
-
- _declare_pkg_rpm(
- name = name + "_no_extra_rpm",
- srcs_ungrouped = [":{}_file_base".format(name)],
- )
-
- # Default "full" name defaults to the "NVR.A" format.
- package_naming_test(
- name = name + "_no_extra",
- target_under_test = ":" + name + "_no_extra_rpm",
- expected_name = name + "_no_extra_rpm-1.0-1.noarch.rpm",
- )
-
- ##################################################
- # With pkg_variables
- ##################################################
-
- dummy_pkg_variables(
- name = name + "_pkg_variables",
- )
-
- _declare_pkg_rpm(
- name = name + "_with_different_name_rpm",
- srcs_ungrouped = [":{}_file_base".format(name)],
- package_variables = ":{}_pkg_variables".format(name),
- package_file_name = name + "-{FOO}-{BAR}.rpm",
- )
-
- # Default "full" name defaults to the "NVR.A" format. Set it to something
- # super arbitrary.
- package_naming_test(
- name = name + "_with_different_name",
- target_under_test = ":" + name + "_with_different_name_rpm",
- expected_name = name + "-foo-bar.rpm",
- )
-
- ##################################################
- # Test suite declaration
- ##################################################
-
- native.test_suite(
- name = name,
- tests = [
- ":{}_{}".format(name, test_name)
- for test_name in [
- "no_extra",
- "with_different_name",
- ]
- ],
- )
-
-def analysis_tests(name, **kwargs):
- # Need to test:
- #
- # - Mutual exclusivity of certain options (low priority)
- #
- _test_conflicting_inputs(name = name + "_conflicting_inputs")
- _test_naming(name = name + "_naming")
- native.test_suite(
- name = name,
- tests = [
- name + "_conflicting_inputs",
- name + "_naming",
- ],
- )
diff --git a/tests/rpm/make_rpm_test.py b/tests/rpm/make_rpm_test.py
deleted file mode 100644
index cb8608b..0000000
--- a/tests/rpm/make_rpm_test.py
+++ /dev/null
@@ -1,179 +0,0 @@
-# Copyright 2017 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.
-"""Tests for make_rpm."""
-
-from __future__ import absolute_import
-from __future__ import division
-from __future__ import print_function
-
-import contextlib
-import os
-import unittest
-
-from pkg import make_rpm
-
-
-@contextlib.contextmanager
-def PrependPath(dirs):
- with ReplacePath(dirs + [os.environ['PATH']]):
- yield
-
-
-@contextlib.contextmanager
-def ReplacePath(dirs):
- original_path = os.environ['PATH']
- try:
- os.environ['PATH'] = os.pathsep.join(dirs)
- yield
- finally:
- os.environ['PATH'] = original_path
-
-
-def WriteFile(filename, *contents):
- with open(filename, 'w') as text_file:
- text_file.write('\n'.join(contents))
-
-
-def DirExists(dirname):
- return os.path.exists(dirname) and os.path.isdir(dirname)
-
-
-def FileExists(filename):
- return os.path.exists(filename) and not os.path.isdir(filename)
-
-
-def FileContents(filename):
- with open(filename, 'r') as text_file:
- return [s.strip() for s in text_file.readlines()]
-
-
-class MakeRpmTest(unittest.TestCase):
-
- # Python 2 alias
- if not hasattr(unittest.TestCase, 'assertCountEqual'):
-
- def assertCountEqual(self, a, b):
- # pylint: disable=g-deprecated-assert
- return self.assertItemsEqual(a, b)
-
- def testFindOutputFile(self):
- log = """
- Lots of data.
- Wrote: /path/to/file/here.rpm
- More data present.
- """
-
- result = make_rpm.FindOutputFile(log)
- self.assertEqual('/path/to/file/here.rpm', result)
-
- def testFindOutputFile_missing(self):
- log = """
- Lots of data.
- More data present.
- """
-
- result = make_rpm.FindOutputFile(log)
- self.assertEqual(None, result)
-
- def testCopyAndRewrite(self):
- with make_rpm.Tempdir():
- WriteFile('test.txt', 'Some: data1', 'Other: data2', 'More: data3')
- make_rpm.CopyAndRewrite('test.txt', 'out.txt', {
- 'Some:': 'data1a',
- 'More:': 'data3a',
- })
-
- self.assertTrue(FileExists('out.txt'))
- self.assertCountEqual(['Some: data1a', 'Other: data2', 'More: data3a'],
- FileContents('out.txt'))
-
- def testFindRpmbuild_present(self):
- with make_rpm.Tempdir() as outer:
- dummy = os.sep.join([outer, 'rpmbuild'])
- WriteFile(dummy, 'dummy rpmbuild')
- os.chmod(dummy, 0o777)
- with PrependPath([outer]):
- path = make_rpm.FindRpmbuild('')
- self.assertEqual(dummy, path)
-
- def testFindRpmbuild_missing(self):
- with make_rpm.Tempdir() as outer:
- with ReplacePath([outer]):
- with self.assertRaises(make_rpm.NoRpmbuildFoundError) as context:
- make_rpm.FindRpmbuild('')
- self.assertIsNotNone(context)
-
- def testSetupWorkdir(self):
- with make_rpm.Tempdir() as outer:
- dummy = os.sep.join([outer, 'rpmbuild'])
- WriteFile(dummy, 'dummy rpmbuild')
- os.chmod(dummy, 0o777)
-
- with PrependPath([outer]):
- # Create the builder and exercise it.
- builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', None)
-
- # Create spec_file, test files.
- WriteFile('test.spec', 'Name: test', 'Version: 0.1',
- 'Summary: test data')
- WriteFile('file1.txt', 'Hello')
- WriteFile('file2.txt', 'Goodbye')
- builder.AddFiles(['file1.txt', 'file2.txt'])
-
- with make_rpm.Tempdir():
- # Call RpmBuilder.
- builder.SetupWorkdir('test.spec', outer)
-
- # Make sure files exist.
- self.assertTrue(DirExists('SOURCES'))
- self.assertTrue(DirExists('BUILD'))
- self.assertTrue(DirExists('TMP'))
- self.assertTrue(FileExists('test.spec'))
- self.assertCountEqual(
- ['Name: test', 'Version: 1.0', 'Summary: test data'],
- FileContents('test.spec'))
- self.assertTrue(FileExists('BUILD/file1.txt'))
- self.assertCountEqual(['Hello'], FileContents('BUILD/file1.txt'))
- self.assertTrue(FileExists('BUILD/file2.txt'))
- self.assertCountEqual(['Goodbye'], FileContents('BUILD/file2.txt'))
-
- def testBuild(self):
- with make_rpm.Tempdir() as outer:
- dummy = os.sep.join([outer, 'rpmbuild'])
- WriteFile(
- dummy,
- '#!/bin/sh',
- 'mkdir -p RPMS',
- 'touch RPMS/test.rpm',
- 'echo "Wrote: $PWD/RPMS/test.rpm"',
- )
- os.chmod(dummy, 0o777)
-
- with PrependPath([outer]):
- # Create the builder and exercise it.
- builder = make_rpm.RpmBuilder('test', '1.0', '0', 'x86', None)
-
- # Create spec_file, test files.
- WriteFile('test.spec', 'Name: test', 'Version: 0.1',
- 'Summary: test data')
-
- # Call RpmBuilder.
- builder.Build('test.spec', 'test.rpm')
-
- # Make sure files exist.
- self.assertTrue(FileExists('test.rpm'))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/rpm/pkg_rpm_basic_test.py b/tests/rpm/pkg_rpm_basic_test.py
deleted file mode 100644
index 990fc4f..0000000
--- a/tests/rpm/pkg_rpm_basic_test.py
+++ /dev/null
@@ -1,255 +0,0 @@
-#!/usr/bin/env python3
-
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import unittest
-import subprocess
-import csv
-import io
-import os
-
-from rules_python.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.
-#
-# Useful reading:
-#
-# - RPM queryformat documentation (shortish):
-# https://rpm.org/user_doc/query_format.html
-#
-# - In-depth RPM query documentation:
-# http://ftp.rpm.org/max-rpm/s1-rpm-query-parts.html
-#
-# - Specifically, about the --qf/--queryformat syntax:
-# http://ftp.rpm.org/max-rpm/s1-rpm-query-parts.html#S3-RPM-QUERY-QUERYFORMAT-OPTION
-#
-# - --queryformat tags list: http://ftp.rpm.org/max-rpm/ch-queryformat-tags.html
-#
-class PkgRpmBasicTest(unittest.TestCase):
- def setUp(self):
- self.runfiles = runfiles.Create()
- self.test_rpm_path = self.runfiles.Rlocation(
- "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-1.1.1-2222.noarch.rpm")
- self.test_rpm_bzip2_path = self.runfiles.Rlocation(
- "rules_pkg/tests/rpm/test_rpm_bzip2-1.1.1-2222.noarch.rpm")
- self.maxDiff = None
-
- def test_scriptlet_content(self):
- expected = b"""\
-preinstall scriptlet (using /bin/sh):
-echo pre
-postinstall scriptlet (using /bin/sh):
-echo post
-preuninstall scriptlet (using /bin/sh):
-echo preun
-postuninstall scriptlet (using /bin/sh):
-echo postun
-"""
-
- output = subprocess.check_output(
- ["rpm", "-qp", "--scripts", self.test_rpm_path])
-
- self.assertEqual(output, expected)
-
- def test_basic_headers(self):
- fields = {
- "NAME": b"test_rpm",
- "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))
-
- def test_contents(self):
- manifest_file = self.runfiles.Rlocation(
- "rules_pkg/tests/rpm/manifest.csv")
- manifest_specs = {}
- with open(manifest_file, "r", newline='', encoding="utf-8") as fh:
- manifest_reader = csv.DictReader(fh)
- manifest_specs = {r['path']: r for r in manifest_reader}
-
- rpm_specs = rpm_util.read_rpm_filedata(self.test_rpm_path)
-
- self.assertDictEqual(manifest_specs, rpm_specs)
- # Transitively, this one should work too -- doesn't use pkg_filegroup
- # directly.
- rpm_direct_specs = rpm_util.read_rpm_filedata(self.test_rpm_direct_path)
- self.assertDictEqual(rpm_specs, rpm_direct_specs)
-
- def test_preamble_metadata(self):
- metadata_prefix = "rules_pkg/tests/rpm"
-
- rpm_filename = os.path.basename(self.test_rpm_path)
- rpm_basename = os.path.splitext(rpm_filename)[0]
-
- # Tuples of:
- # Metadata name, RPM Tag prefix, exclusion list (currently only support "startswith")
- #
- # The exclusions should probably be regexps at some point, but right
- # now, our job is relatively easy. They only operate on the
- # "capability" portion of the tag.
- test_md = [
- ("conflicts", "CONFLICT", []),
- # rpm packages implicitly provide themselves, something like:
- # "test_rpm = 1.1.1-2222". We don't bother testing this, since we
- # don't take direct action to specify it.
- ("provides", "PROVIDE", [rpm_basename]),
- # Skip rpmlib-related requirements; they are often dependent on the
- # version of `rpm` we are using.
- ("requires", "REQUIRE", ["rpmlib"]),
- ]
- for (mdtype, tag, exclusions) in test_md:
- md_file = self.runfiles.Rlocation(
- os.path.join(metadata_prefix, mdtype + ".csv"))
-
- with open(md_file, "r", newline='', encoding="utf-8") as fh:
- md_reader = csv.DictReader(fh, delimiter=':')
- # I heard you like functional programming ;)
- #
- # This produces a list of outputs whenever the "capability"
- # attribute starts with any of the values in the "exclusions"
- # list.
- md_specs_unsorted = [line for line in md_reader
- if not any(line['capability'].startswith(e)
- for e in exclusions)]
- # And this sorts it, ordering by the sorted "association list"
- # form of the dictionary.
- #
- # The sorting of the key values is not necessary with versions
- # of python3 (3.5+, I believe) that have dicts maintain
- # insertion order.
- md_specs = sorted(md_specs_unsorted,
- key = lambda x: sorted(x.items()))
-
-
- # This typically becomes the equivalent of:
- #
- # '[%{PROVIDENEVRS};%{PROVIDEFLAGS:deptype}\n]'
- #
- # as passed to `rpm --queryformat`
- rpm_queryformat = (
- # NEVRS = Name Epoch Version Release (plural), which look something like:
- # rpmlib(CompressedFileNames) <= 3.0.4-1
- # or:
- # bash
- "[%{{{tag}NEVRS}}"
- # Flags associated with the dependency type. This used to
- # evaluate in what "sense" the dependency was added.
- #
- # Values often include things like:
- #
- # - "interp" for scriptlet interpreter dependencies
- # - "postun" for dependencies of the "postun" scriptlet
- # - "manual" for values that are explicitly specified
- ":%{{{tag}FLAGS:deptype}}"
- "\n]"
- ).format(tag = tag)
-
- rpm_queryformat_fieldnames = [
- "capability",
- "sense",
- ]
-
- rpm_output = subprocess.check_output(
- ["rpm", "-qp", "--queryformat", rpm_queryformat, self.test_rpm_path])
-
- sio = io.StringIO(rpm_output.decode('utf-8'))
- rpm_output_reader = csv.DictReader(
- sio, delimiter=':', fieldnames=rpm_queryformat_fieldnames)
-
- # Get everything in the same order as the read-in metadata file
- rpm_outputs_filtered_unsorted = [line for line in rpm_output_reader
- if not any(line['capability'].startswith(e)
- for e in exclusions)]
-
- rpm_outputs_filtered = sorted(rpm_outputs_filtered_unsorted, key = lambda x: sorted(x.items()))
-
- for expected, actual in zip(md_specs, rpm_outputs_filtered):
- self.assertDictEqual(expected, actual,
- msg="{} metadata discrepancy".format(mdtype))
-
- def test_compression_none_provided(self):
- # Test when we don't provide "binary_payload_compression" to pkg_rpm
- my_rpm = self.test_rpm_path
- rpm_output = subprocess.check_output(
- ["rpm", "-qp", "--queryformat", "%{PAYLOADCOMPRESSOR}", my_rpm])
- sio = io.StringIO(rpm_output.decode('utf-8'))
- actual_compressor = sio.read()
- # `bzip2` compression was, AFAICT, never the default for rpmbuild(8),
- # and never will be, so this should be fine.
- self.assertNotEqual(actual_compressor, 'bzip2')
-
- def test_compression_passthrough(self):
- # Test when we provide "binary_payload_compression" to pkg_rpm
- my_rpm = self.test_rpm_bzip2_path
- rpm_output = subprocess.check_output(
- ["rpm", "-qp", "--queryformat", "%{PAYLOADCOMPRESSOR}", my_rpm])
- sio = io.StringIO(rpm_output.decode('utf-8'))
- actual_compressor = sio.read()
- self.assertEqual(actual_compressor, 'bzip2')
-
- def test_mtimes(self):
- # Modification times should be something close to when the package was
- # built. Since we do not know when the package was actually built, we
- # can just check for something that is non-zero.
- #
- # See also #486.
-
- filedata = rpm_util.read_rpm_filedata(
- self.test_rpm_path,
- query_tag_map={
- "FILENAMES": "path",
- "FILEMTIMES": "mtime",
- }
- )
-
- self.assertNotEqual(
- len(filedata),
- 0,
- "rpm_util.read_rpm_filedata() produced no output"
- )
-
- filedata_shortened = {
- path: int(data["mtime"])
- for path, data in filedata.items()
- }
-
- files_with_zero_mtimes = dict(filter(
- lambda kv: kv[1] == 0,
- filedata_shortened.items(),
- ))
-
- self.assertDictEqual(
- files_with_zero_mtimes,
- {},
- "No files should have zero mtimes without source_date_epoch or source_date_epoch_file")
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/rpm/rpm_util.py b/tests/rpm/rpm_util.py
deleted file mode 100644
index 5655fc5..0000000
--- a/tests/rpm/rpm_util.py
+++ /dev/null
@@ -1,130 +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.
-
-import io
-import csv
-import subprocess
-
-
-def get_rpm_version_as_tuple(rpm_bin_path="rpm"):
- """Get the current version of the requested rpm(8) binary."""
- output = subprocess.check_output(
- [rpm_bin_path, "--version"]).decode('utf-8')
-
- # e.g. RPM Version 4.13.1
- version_str = output.split()[2]
-
- return tuple(int(component) for component in version_str.split('.'))
-
-
-def invoke_rpm_with_queryformat(rpm_file_path, queryformat, rpm_bin_path="rpm"):
- """Helper to ease the invocation of an rpm query with a custom queryformat.
-
- Returns any output as a UTF-8 decoded string if the command succeeds. If it
- fails, throws CalledProcessException, like `subprocess.check_output`.
- """
-
- # The RPM tooling (at least the copy I have here, 4.14.2.1) is a bit buggy:
- #
- # - If you don't pass "-p/--package" argument, `rpm -q --queryformat` run
- # against a package will always "fail" with no explanation.
- #
- # - If you do pass "-p/--package" argument, `rpm -q --queryformat` run
- # against a package will always succeed if it can read a file, even when
- # there is an error in some other aspect of the query.
- #
- # As a workaround, you should generally know if you're expecting output.
- # Check if the output contains anything not whitespace, or if you're using
- # `read_rpm_filedata`, check if the output dict is nonempty.
- return subprocess.check_output([rpm_bin_path, "-qp", "--queryformat", queryformat, rpm_file_path]).decode("utf-8")
-
-
-# TODO(nacl): "rpm_bin_path" should be derived from a toolchain somewhere.
-#
-# At this time, the "Rpmbuild" toolchain only contains rpmbuild. Since `rpm`
-# itself is only useful for tests, this may be overkill.
-def read_rpm_filedata(rpm_file_path, rpm_bin_path="rpm", query_tag_map=None):
- """Read rpm file-based metadata into a dictionary
-
- Keys are the file names (absolute paths), values are the metadata as another
- dictionary.
-
- The metadata fields are those defined in an RPM query, and is a map of query
- tags to simple variable names. The fields must be plural, as identified by
- the names. Some examples are in the default argument, described below.
-
- - FILENAMES -> path (file absolute path)
- - FILEDIGESTS -> digest (hash of file. MD5 for compatibility)
- - FILEUSERNAME -> user (UNIX owning user)
- - FILEGROUPNAME -> group (UNIX owning group)
- - FILEMODES:octal -> mode (UNIX mode, as an octal string)
- - FILEFLAGS:fflags -> fflags (RPM file flags as a string, see upstream documentation)
- - FILELINKTOS -> Symlink target, or nothing (something "falsy") if not provided
-
- Check out the implementation for more details, and consult the RPM
- documentation even more more details. You can get a list of all tags by
- invoking `rpm --querytags`.
-
- NOTE: see also caveats in `invoke_rpm_with_queryformat`, above.
-
- """
- # It is not necessary to check for file sizes, as the hashes are
- # sufficient for determining whether or not files are the same.
- #
- # This also simplifies behavior where RPM's size calculations have
- # sometimes changed, e.g.:
- #
- # https://github.com/rpm-software-management/rpm/commit/2cf7096ba534b065feb038306c792784458ac9c7
-
- if query_tag_map is None:
- rpm_queryformat = (
- "[%{FILENAMES}"
- ",%{FILEDIGESTS}"
- ",%{FILEUSERNAME}"
- ",%{FILEGROUPNAME}"
- ",%{FILEMODES:octal}"
- ",%{FILEFLAGS:fflags}"
- ",%{FILELINKTOS}"
- "\n]"
- )
- rpm_queryformat_fieldnames = [
- "path",
- "digest",
- "user",
- "group",
- "mode",
- "fflags",
- "symlink",
- ]
- else:
- rpm_queryformat = "["
- rpm_queryformat += ",".join(["%{{{}}}".format(query_tag)
- for query_tag in query_tag_map.keys()])
- rpm_queryformat += "\n]"
-
- rpm_queryformat_fieldnames = list(query_tag_map.values())
-
- rpm_output = invoke_rpm_with_queryformat(
- rpm_file_path,
- rpm_queryformat,
- rpm_bin_path,
- )
-
- sio = io.StringIO(rpm_output)
- rpm_output_reader = csv.DictReader(
- sio,
- fieldnames=rpm_queryformat_fieldnames
- )
-
- return {r['path']: r for r in rpm_output_reader}
diff --git a/tests/rpm/source_date_epoch/BUILD b/tests/rpm/source_date_epoch/BUILD
deleted file mode 100644
index 156f844..0000000
--- a/tests/rpm/source_date_epoch/BUILD
+++ /dev/null
@@ -1,131 +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("@rules_python//python:defs.bzl", "py_test")
-load("//pkg:mappings.bzl", "pkg_filegroup", "pkg_files")
-load("//pkg:rpm.bzl", "pkg_rpm")
-
-############################################################################
-# Test handling the source_date_epoch attribute
-############################################################################
-
-package(default_applicable_licenses = ["//:license"])
-
-# The actual test. It tests whether the contents match a particular desired
-# "manifest", most notably with regards to file structure.
-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-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)
- ],
- deps = [
- "//tests/rpm:rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-# One cannot simply pass the output of pkg_rpm as runfiles content (#161). This
-# seems to be the easiest way around this problem.
-sh_library(
- name = "rpm_sde_insource_data",
- testonly = True,
- srcs = [":rpm_sde_insource"],
-)
-
-# The RPM (target under test)
-pkg_rpm(
- name = "rpm_sde_insource",
- srcs = [
- ":pfg",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- # Tue Mar 23 00:00:00 EDT 2021
- source_date_epoch = 1616472000,
- spec_template = "//tests/rpm:template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-pkg_filegroup(
- name = "pfg",
- srcs = [":pf"],
-)
-
-pkg_files(
- name = "pf",
- srcs = [":files"],
- prefix = "test_dir",
-)
-
-genrule(
- name = "files",
- outs = [
- "a",
- "b",
- ],
- cmd = """
- touch $(OUTS)
- """,
-)
-
-############################################################################
-# Test handling the source_date_epoch attribute
-############################################################################
-
-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-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)
- ],
- deps = [
- "//tests/rpm:rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-# One cannot simply pass the output of pkg_rpm as runfiles content (#161). This
-# seems to be the easiest way around this problem.
-sh_library(
- name = "rpm_sde_fromfile_data",
- testonly = True,
- srcs = [":rpm_sde_fromfile"],
-)
-
-# The RPM (target under test)
-pkg_rpm(
- name = "rpm_sde_fromfile",
- srcs = [
- ":pfg",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- # Tue Mar 23 00:00:00 EDT 2021
- source_date_epoch_file = "epoch.txt",
- spec_template = "//tests/rpm:template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
diff --git a/tests/rpm/source_date_epoch/epoch.txt b/tests/rpm/source_date_epoch/epoch.txt
deleted file mode 100644
index 7e33e1a..0000000
--- a/tests/rpm/source_date_epoch/epoch.txt
+++ /dev/null
@@ -1 +0,0 @@
-1616472000
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
deleted file mode 100644
index ca249c7..0000000
--- a/tests/rpm/source_date_epoch/rpm_contents_vs_manifest_test.py
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import csv
-import io
-import os
-import unittest
-
-from rules_python.python.runfiles import runfiles
-from tests.rpm import rpm_util
-
-# Tue Mar 23 00:00:00 EDT 2021
-EXPECTED_EPOCH = '1616472000'
-EXPECTED_RPM_MANIFEST_CSV = """
-path,mtime
-/test_dir/a,{epoch}
-/test_dir/b,{epoch}
-""".strip().format(epoch=EXPECTED_EPOCH)
-
-
-def version_to_string(version):
- return ".".join(str(i) for i in version)
-
-
-class PkgRpmCompManifest(unittest.TestCase):
- # Support for SOURCE_DATE_EPOCH is only available as of rpm
- # 4.14: http://rpm.org/wiki/Releases/4.14.0
- #
- # TODO(nacl): it would probably be better to ask the rpmbuild(8) binary for
- # this instead, since that's ultimately what's going to make or break this
- # test.
- SOURCE_DATE_EPOCH_MIN_VERSION = (4, 14, 0)
-
- def rpmBinSupportsSourceDateEpoch(self):
- return self.rpm_bin_version >= self.SOURCE_DATE_EPOCH_MIN_VERSION
-
- # TODO(nacl) consider making a fixture out of this
- def setUp(self):
- self.runfiles = runfiles.Create()
- self.maxDiff = None
-
- self.rpm_bin_version = rpm_util.get_rpm_version_as_tuple()
-
- # These tests will fail on unsupported versions of rpm(8), so skip them
- # in that case.
- if not self.rpmBinSupportsSourceDateEpoch():
- self.skipTest("RPM version too old to support SOURCE_DATE_EPOCH."
- " Must be {} or newer (is {})".format(
- version_to_string(self.SOURCE_DATE_EPOCH_MIN_VERSION),
- version_to_string(self.rpm_bin_version),
- ))
-
- if "TEST_RPM" not in os.environ:
- self.fail("TEST_RPM must be set in the environment, containing "
- "the name of the RPM to test")
-
- # Allow for parameterization of this test based on the desired RPM to
- # test.
- self.rpm_file_path = self.runfiles.Rlocation("/".join([
- os.environ["TEST_WORKSPACE"],
- "tests", "rpm", "source_date_epoch",
- # The object behind os.environ is not a dict, and thus doesn't have
- # the "getdefault()" we'd otherwise use here.
- os.environ["TEST_RPM"],
- ]))
-
- def test_contents_match(self):
- sio = io.StringIO(EXPECTED_RPM_MANIFEST_CSV)
- manifest_reader = csv.DictReader(sio)
- manifest_specs = {r['path']: r for r in manifest_reader}
-
- rpm_specs = rpm_util.read_rpm_filedata(
- self.rpm_file_path,
- query_tag_map={
- "FILENAMES": "path",
- "FILEMTIMES": "mtime",
- })
-
- self.assertDictEqual(manifest_specs, rpm_specs)
-
- # Test if the RPM build time field is set to the provided SOURCE_DATE_EPOCH.
- def test_buildtime_set(self):
- actual_epoch = rpm_util.invoke_rpm_with_queryformat(
- self.rpm_file_path,
- "%{BUILDTIME}",
- )
- self.assertEqual(actual_epoch, EXPECTED_EPOCH)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/rpm/template-test.spec.tpl b/tests/rpm/template-test.spec.tpl
deleted file mode 100644
index f771f37..0000000
--- a/tests/rpm/template-test.spec.tpl
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- rpm-spec -*-
-
-################################################################################
-# Test customizations
-
-# Force MD5 file digesting to preserve compatibility with (very old) versions of
-# rpm.
-#
-# For valid values to set here, see:
-# https://github.com/rpm-software-management/rpm/blob/8d628a138ee4c3d1b77b993a3c5b71345ce052e8/macros.in#L393-L405
-#
-# At some point, we might want to consider bumping this up to use SHA-1 (2), but
-# that would be best reserved for when we don't know of anyone using rpm < 4.6.
-%define _source_filedigest_algorithm 1
-%define _binary_filedigest_algorithm 1
-
-# Do not try to use magic to determine file types
-%define __spec_install_post %{nil}
-
-################################################################################
-
-# Hey!
-#
-# Keep the below in sync with pkg/rpm/template.spec.tpl!
-
-################################################################################
-
-# This comprises the entirety of the preamble
-%include %build_rpm_options
-
-%description
-%include %build_rpm_description
-
-%install
-%include %build_rpm_install
-
-%files -f %build_rpm_files
-
-${PRE_SCRIPTLET}
-
-${POST_SCRIPTLET}
-
-${PREUN_SCRIPTLET}
-
-${POSTUN_SCRIPTLET}
diff --git a/tests/rpm/test_rpm_dirs_contents.txt.golden b/tests/rpm/test_rpm_dirs_contents.txt.golden
deleted file mode 100644
index 8f5b9ef..0000000
--- a/tests/rpm/test_rpm_dirs_contents.txt.golden
+++ /dev/null
@@ -1,2 +0,0 @@
-drwxr-xr-x /dir
--rw-r--r-- /dir/config.txt
diff --git a/tests/rpm/toolchain_tests.bzl b/tests/rpm/toolchain_tests.bzl
deleted file mode 100644
index 0f6a499..0000000
--- a/tests/rpm/toolchain_tests.bzl
+++ /dev/null
@@ -1,123 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Tests for rpmbuild toolchain type."""
-
-load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")
-load("//toolchains/rpm:rpmbuild.bzl", "rpmbuild_toolchain")
-
-# Generic negative test boilerplate
-def _generic_neg_test_impl(ctx):
- env = analysistest.begin(ctx)
- asserts.expect_failure(env, ctx.attr.reason)
- return analysistest.end(env)
-
-generic_neg_test = analysistest.make(
- _generic_neg_test_impl,
- attrs = {
- "reason": attr.string(
- default = "",
- ),
- },
- expect_failure = True,
-)
-
-def _toolchain_contents_test_impl(ctx):
- env = analysistest.begin(ctx)
- target_under_test = analysistest.target_under_test(env)
-
- info = target_under_test[platform_common.ToolchainInfo].rpmbuild
- asserts.equals(
- env,
- ctx.attr.expect_valid,
- info.valid,
- )
- asserts.equals(
- env,
- ctx.attr.expect_label,
- info.label,
- )
- asserts.equals(
- env,
- ctx.attr.expect_path,
- info.path,
- )
- return analysistest.end(env)
-
-toolchain_contents_test = analysistest.make(
- _toolchain_contents_test_impl,
- attrs = {
- "expect_valid": attr.bool(default = True),
- "expect_label": attr.label(
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- "expect_path": attr.string(),
- },
-)
-
-def _create_toolchain_creation_tests():
- rpmbuild_toolchain(
- name = "tc_label_and_path",
- label = "foo",
- path = "bar",
- tags = ["manual"],
- )
- generic_neg_test(
- name = "tc_label_and_path_test",
- target_under_test = ":tc_label_and_path",
- reason = "rpmbuild_toolchain must not specify both label and path.",
- )
-
- rpmbuild_toolchain(
- name = "tc_no_label_or_path",
- tags = ["manual"],
- )
- toolchain_contents_test(
- name = "tc_no_label_or_path_test",
- target_under_test = ":tc_no_label_or_path",
- expect_valid = False,
- expect_label = None,
- expect_path = "",
- )
-
- rpmbuild_toolchain(
- name = "tc_just_label",
- label = ":toolchain_test.bzl", # Using self so we have a real target.
- tags = ["manual"],
- )
- toolchain_contents_test(
- name = "tc_just_label_test",
- target_under_test = ":tc_just_label",
- expect_valid = True,
- expect_label = Label("//tests/rpm:toolchain_test.bzl"),
- expect_path = "",
- )
-
- rpmbuild_toolchain(
- name = "tc_just_path",
- path = "/usr/bin/foo",
- tags = ["manual"],
- )
- toolchain_contents_test(
- name = "tc_just_path_test",
- target_under_test = ":tc_just_path",
- expect_valid = True,
- expect_label = None,
- expect_path = "/usr/bin/foo",
- )
-
-def create_toolchain_analysis_tests():
- _create_toolchain_creation_tests()
diff --git a/tests/rpm/tree_artifacts/BUILD b/tests/rpm/tree_artifacts/BUILD
deleted file mode 100644
index f962faa..0000000
--- a/tests/rpm/tree_artifacts/BUILD
+++ /dev/null
@@ -1,257 +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:mappings.bzl",
- "REMOVE_BASE_DIRECTORY",
- "pkg_attributes",
- "pkg_filegroup",
- "pkg_files",
- "strip_prefix",
-)
-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
-############################################################################
-
-# This package defines tests related to the installation of directory outputs
-# (TreeArtifacts) in RPM packages. The rules in common are:
-#
-# - The order of incoming pkg_filegroups (and their contents) does not matter
-#
-# - Each file in a TreeArtifact is installed relative to its position in the
-# TreeArtifact, which itself is relative to the desired install prefix.
-
-package(default_applicable_licenses = ["//:license"])
-
-# The actual test. It tests whether the contents match a particular desired
-# "manifest", most notably with regards to file structure.
-py_test(
- name = "layer_with_files",
- srcs = ["rpm_contents_vs_manifest_test.py"],
- data = [":layer_with_files_test_data"],
- main = "rpm_contents_vs_manifest_test.py",
- tags = [
- "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
- ],
- env = {"TEST_RPM": "test_dirs_rpm-1.1.1-2222.noarch.rpm"},
- deps = [
- "//tests/rpm:rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-# One cannot simply pass the output of pkg_rpm as runfiles content (#161). This
-# seems to be the easiest way around this problem.
-sh_library(
- name = "layer_with_files_test_data",
- testonly = True,
- srcs = [":test_dirs_rpm"],
-)
-
-# The RPM (target under test)
-pkg_rpm(
- name = "test_dirs_rpm",
- srcs = [
- ":dirs_test_pfg",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- spec_template = "//tests/rpm:template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-############################################################################
-# Test RPM Contents
-############################################################################
-
-# Establish a directory structure. This will end up looking like:
-
-# test_dir/a (created by a "directory" rule)
-# test_dir/b (created by a "directory" rule)
-# test_dir/subdir/c (created by a "directory" rule)
-# test_dir/subdir/d (created by a "directory" rule)
-# test_dir/e (created by a genrule)
-# test_dir/f (created by a genrule)
-
-pkg_filegroup(
- name = "dirs_test_pfg",
- srcs = [
- # do not sort
- ":test_dir1_pf",
- ":test_files_from_rules",
- ],
-)
-
-pkg_files(
- name = "test_dir1_pf",
- srcs = [":test_dir1"],
- attributes = pkg_attributes(
- group = "root",
- mode = "0644",
- user = "root",
- ),
- strip_prefix = strip_prefix.from_pkg(""),
-)
-
-directory(
- name = "test_dir1",
- contents = "test_dir1",
- filenames = [
- "a",
- "b",
- "subdir/c",
- "subdir/d",
- ],
- outdir = "test_dir",
-)
-
-pkg_files(
- name = "test_files_from_rules",
- srcs = [":my_files"],
- attributes = pkg_attributes(
- group = "root",
- mode = "0644",
- user = "root",
- ),
- prefix = "test_dir",
-)
-
-genrule(
- name = "my_files",
- outs = [
- "e",
- "f",
- ],
- cmd = "touch $(OUTS)",
-)
-
-############################################################################
-# Regression: Ensure that TreeArtifact installation WRT files is independent of install order
-############################################################################
-
-# The actual test, just like before, except the pkg_filegroup input is slightly
-# different.
-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-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)
- ],
- deps = [
- "//tests/rpm:rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-# One cannot simply pass the output of pkg_rpm as runfiles content (#161). This
-# seems to be the easiest way around this problem.
-sh_library(
- name = "layer_with_files_reversed_test_data",
- testonly = True,
- srcs = [":test_dirs_rpm_reversed"],
-)
-
-pkg_rpm(
- name = "test_dirs_rpm_reversed",
- srcs = [
- ":dirs_test_pfg_reversed",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- spec_template = "//tests/rpm:template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-# Like dirs_test_pfg, but the contents are reversed. One of the major issues
-# with #292 was inconsistency due to install order.
-pkg_filegroup(
- name = "dirs_test_pfg_reversed",
- srcs = [
- # do not sort
- ":test_files_from_rules",
- ":test_dir1_pf",
- ],
-)
-
-############################################################################
-# Test that renaming TreeArtifacts to nothing results in the files being dropped
-# in their prefix.
-############################################################################
-py_test(
- name = "treeartifact_ops",
- srcs = ["rpm_treeartifact_ops_test.py"],
- data = [":treeartifact_ops_rpm_test_data"],
- main = "rpm_treeartifact_ops_test.py",
- env = {"TEST_RPM": "treeartifact_ops_rpm-1.1.1-2222.noarch.rpm"},
- tags = [
- "no_windows", # Windows doesn't have rpm(8) or rpmbuild(8)
- ],
- deps = [
- "//tests/rpm:rpm_util",
- "@rules_python//python/runfiles",
- ],
-)
-
-sh_library(
- name = "treeartifact_ops_rpm_test_data",
- testonly = True,
- srcs = [":treeartifact_ops_rpm"],
-)
-
-pkg_rpm(
- name = "treeartifact_ops_rpm",
- srcs = [
- ":treeartifact_ops_pfg",
- ],
- architecture = "noarch",
- description = """pkg_rpm test rpm description""",
- license = "Apache 2.0",
- release = "2222",
- spec_template = "//tests/rpm:template-test.spec.tpl",
- summary = "pkg_rpm test rpm summary",
- version = "1.1.1",
-)
-
-pkg_filegroup(
- name = "treeartifact_ops_pfg",
- srcs = [
- ":stripped_treeartifact_pf",
- ],
-)
-
-pkg_files(
- name = "stripped_treeartifact_pf",
- srcs = [
- ":test_dir1",
- ],
- attributes = pkg_attributes(
- group = "root",
- mode = "0644",
- user = "root",
- ),
- renames = {":test_dir1": REMOVE_BASE_DIRECTORY},
-)
diff --git a/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py b/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py
deleted file mode 100644
index f0f8b3a..0000000
--- a/tests/rpm/tree_artifacts/rpm_contents_vs_manifest_test.py
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import unittest
-import csv
-import io
-import os
-
-from rules_python.python.runfiles import runfiles
-from tests.rpm import rpm_util
-
-EXPECTED_RPM_MANIFEST_CSV = """
-path,digest,user,group,mode,fflags,symlink
-/test_dir/a,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/test_dir/b,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/test_dir/subdir/c,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/test_dir/subdir/d,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/test_dir/e,d41d8cd98f00b204e9800998ecf8427e,root,root,100644,,
-/test_dir/f,d41d8cd98f00b204e9800998ecf8427e,root,root,100644,,
-""".strip()
-
-
-class PkgRpmCompManifest(unittest.TestCase):
- def setUp(self):
- self.runfiles = runfiles.Create()
- self.maxDiff = None
- # Allow for parameterization of this test based on the desired RPM to
- # test.
-
- # runfiles prefers Bazely (POSIX-style) relative paths, so we can't
- # really use os.path.join() here.
- self.rpm_path = self.runfiles.Rlocation('/'.join([
- os.environ["TEST_WORKSPACE"],
- "tests", "rpm", "tree_artifacts",
- # The object behind os.environ is not a dict, and thus doesn't have
- # the "getdefault()" we'd otherwise use here.
- os.environ["TEST_RPM"] if "TEST_RPM" in os.environ else "test_dirs_rpm.rpm",
- ]))
-
- def test_contents_match(self):
- sio = io.StringIO(EXPECTED_RPM_MANIFEST_CSV)
- manifest_reader = csv.DictReader(sio)
- manifest_specs = {r['path']: r for r in manifest_reader}
-
- rpm_specs = rpm_util.read_rpm_filedata(self.rpm_path)
-
- self.assertDictEqual(manifest_specs, rpm_specs)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py b/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py
deleted file mode 100644
index 2f74bc9..0000000
--- a/tests/rpm/tree_artifacts/rpm_treeartifact_ops_test.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import csv
-import io
-import os
-import unittest
-
-from rules_python.python.runfiles import runfiles
-from tests.rpm import rpm_util
-
-EXPECTED_RPM_MANIFEST_CSV = """
-path,digest,user,group,mode,fflags,symlink
-/a,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/b,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/subdir/c,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-/subdir/d,dc35e5df50b75e25610e1aaaa29edaa4,root,root,100644,,
-""".strip()
-
-
-class PkgRpmCompManifest(unittest.TestCase):
- def setUp(self):
- self.runfiles = runfiles.Create()
- self.maxDiff = None
- # Allow for parameterization of this test based on the desired RPM to
- # test.
- self.rpm_path = self.runfiles.Rlocation(os.path.join(
- os.environ["TEST_WORKSPACE"],
- "tests", "rpm", "tree_artifacts",
- # The object behind os.environ is not a dict, and thus doesn't have
- # the "getdefault()" we'd otherwise use here.
- os.environ["TEST_RPM"] if "TEST_RPM" in os.environ else "treeartifact_ops_rpm.rpm",
- ))
-
- def test_contents_match(self):
- sio = io.StringIO(EXPECTED_RPM_MANIFEST_CSV)
- manifest_reader = csv.DictReader(sio)
- manifest_specs = {r['path']: r for r in manifest_reader}
-
- rpm_specs = rpm_util.read_rpm_filedata(self.rpm_path)
-
- self.assertDictEqual(manifest_specs, rpm_specs)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/stamp_test.py b/tests/stamp_test.py
deleted file mode 100644
index 7ba722b..0000000
--- a/tests/stamp_test.py
+++ /dev/null
@@ -1,114 +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.
-"""Test time stamping in pkg_tar"""
-
-import datetime
-import tarfile
-import time
-import unittest
-import zipfile
-
-from bazel_tools.tools.python.runfiles import runfiles
-
-# keep in sync with archive.py
-PORTABLE_MTIME = 946684800 # 2000-01-01 00:00:00.000 UTC
-
-
-class StampTest(unittest.TestCase):
- """Test for non-epoch time stamps in packages."""
-
- target_mtime = int(time.time())
- zip_epoch_dt = datetime.datetime(1980, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
- ZIP_EPOCH = int(zip_epoch_dt.timestamp())
- # We allow the stamp on the build file to be within this delta back in
- # time from now. That allows for the test data to be built early in a clean
- # CI run and have the test run a few seconds later. Ideally, this would
- # be no greater than the expected total CI run time, but the extra margin
- # does not hurt.
- ALLOWED_DELTA_FROM_NOW = 30000 # seconds
-
- def check_mtime(self, mtime, file_path, file_name):
- """Checks that a time stamp is reasonable.
-
- This checks that a timestamp is not 0 or any of the well known EPOCH values,
- and that it is within some delta from the current time.
-
- Args:
- mtime: timestamp in seconds
- file_path: path to archive name
- file_name: file within archive
- """
- if mtime == 0:
- self.fail('Archive %s contains file %s with mtime == 0' % (
- file_path, file_name))
- if mtime == PORTABLE_MTIME:
- self.fail('Archive %s contains file %s with portable mtime' % (
- file_path, file_name))
- if mtime == StampTest.ZIP_EPOCH:
- self.fail('Archive %s contains file %s with ZIP epoch' % (
- file_path, file_name))
- if ((mtime < self.target_mtime - StampTest.ALLOWED_DELTA_FROM_NOW)
- or (mtime > self.target_mtime)):
- self.fail(
- 'Archive %s contains file %s with mtime:%d, expected:%d +/- %d.' % (
- file_path, file_name, mtime, self.target_mtime,
- StampTest.ALLOWED_DELTA_FROM_NOW) +
- ' This may be a false positive if your build cache is more than' +
- ' %s seconds old. If so, try bazel clean and rerun the test.' %
- StampTest.ALLOWED_DELTA_FROM_NOW)
-
- def assertTarFilesAreAlmostNew(self, file_name):
- """Assert that tarfile contains files with an mtime of roughly now.
-
- This is used to prove that the test data was a file which was presumably:
- built with 'stamp=1' or ('stamp=-1' and --stamp) contains files which
- all have a fairly recent mtime, thus indicating they are "current" time
- rather than the epoch or some other time.
-
- Args:
- file_name: the path to the TAR file to test.
- """
- file_path = runfiles.Create().Rlocation('rules_pkg/tests/' + file_name)
- with tarfile.open(file_path, 'r:*') as f:
- for info in f:
- self.check_mtime(info.mtime, file_path, info.name)
-
- def assertZipFilesAreAlmostNew(self, file_name):
- """Assert that zipfile contains files with an mtime of roughly now.
-
- This is used to prove that the test data was a file which was presumably:
- built with 'stamp=1' or ('stamp=-1' and --stamp) contains files which
- all have a fairly recent mtime, thus indicating they are "current" time
- rather than the epoch or some other time.
-
- Args:
- file_name: the path to the ZIP file to test.
- """
- file_path = runfiles.Create().Rlocation('rules_pkg/tests/' + file_name)
- target_mtime = int(time.time())
- with zipfile.ZipFile(file_path, mode='r') as f:
- for info in f.infolist():
- d = info.date_time
- dt = datetime.datetime(d[0], d[1], d[2], d[3], d[4], d[5], tzinfo=datetime.timezone.utc)
- self.check_mtime(int(dt.timestamp()), file_path, info.filename)
-
- def test_not_epoch_times_tar(self):
- self.assertTarFilesAreAlmostNew('stamped_tar.tar')
-
- def test_not_epoch_times_zip(self):
- self.assertZipFilesAreAlmostNew('stamped_zip.zip')
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/tar/BUILD b/tests/tar/BUILD
deleted file mode 100644
index 93f2e47..0000000
--- a/tests/tar/BUILD
+++ /dev/null
@@ -1,609 +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.
-# -*- coding: utf-8 -*-
-"""Tests for pkg_tar."""
-
-# buildifier: disable=bzl-visibility
-load("//pkg:mappings.bzl", "pkg_attributes")
-load("//pkg:mappings.bzl", "pkg_files", "pkg_mkdirs", "pkg_mklink", "strip_prefix")
-load("//pkg:verify_archive.bzl", "verify_archive_test")
-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"],
- default_visibility = ["//visibility:private"],
-)
-
-py_test(
- name = "tar_writer_test",
- srcs = [
- "tar_writer_test.py",
- ],
- imports = ["../.."],
- data = [
- ":compressor",
- ":test_tar_compression",
- ":test_tar_package_dir",
- ":test_tar_package_dir_file",
- "//tests:testdata/tar_test.tar",
- "//tests:testdata/tar_test.tar.bz2",
- "//tests:testdata/tar_test.tar.gz",
- "//tests:testdata/tar_test.tar.xz",
- "//tests:testdata/test_tar_package_dir_file.txt",
- ],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "//pkg/private/tar:tar_writer",
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-genrule(
- name = "generate_files",
- outs = [
- "etc/nsswitch.conf",
- "usr/titi",
- ],
- cmd = "for i in $(OUTS); do echo 1 >$$i; done",
-)
-
-directory(
- name = "generate_tree",
- contents = "hello there",
- filenames = [
- # buildifier: don't sort
- "b/e",
- "a/a",
- "b/c/d",
- "b/d",
- "a/b/c",
- ],
-)
-
-py_binary(
- name = "compressor",
- srcs = ["compressor.py"],
- python_version = "PY3",
- srcs_version = "PY3",
-)
-
-pkg_tar(
- name = "test_tar_compression",
- compressor = ":compressor",
- compressor_args = "-a -b -c",
- deps = ["//tests:testdata/tar_test.tar"],
-)
-
-#
-# Tests for package_file_name
-#
-my_package_naming(
- name = "my_package_variables",
- label = "some_value",
-)
-
-pkg_tar(
- name = "test_tar_naming",
- srcs = [
- ":BUILD",
- ],
- package_file_name = "test_naming_{label}.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",
-)
-
-pkg_mklink(
- name = "mylink",
- link_name = "mylink",
- target = "dangling",
-)
-
-pkg_tar(
- name = "test_tar_package_dir",
- srcs = [
- ":etc/nsswitch.conf",
- ":mylink",
- ],
- package_dir = "/my/package",
-)
-
-pkg_tar(
- name = "test_tar_package_dir_file",
- srcs = [
- ":etc/nsswitch.conf",
- ],
- package_dir_file = "//tests:testdata/test_tar_package_dir_file.txt",
-)
-
-pkg_tar(
- name = "test_tar_out",
- srcs = [
- ":BUILD",
- ],
- out = "out.tar",
-)
-
-[pkg_tar(
- name = "test-tar-basic-%s" % ext,
- srcs = [
- ":etc/nsswitch.conf",
- ":usr/titi",
- ],
- extension = "tar.%s" % ext if ext else "tar",
- mode = "0644",
- modes = {"usr/titi": "0755"},
- owner = "42.24",
- ownername = "titi.tata",
- ownernames = {"etc/nsswitch.conf": "tata.titi"},
- owners = {"etc/nsswitch.conf": "24.42"},
- package_dir = "/",
- strip_prefix = ".",
- symlinks = {"usr/bin/java": "/path/to/bin/java"},
-) for ext in SUPPORTED_TAR_COMPRESSIONS]
-
-[pkg_tar(
- name = "test-tar-inclusion-%s" % ext,
- deps = [
- ":test-tar-basic-%s" % ext,
- ":test_tar_naming",
- ],
-) for ext in SUPPORTED_TAR_COMPRESSIONS]
-
-pkg_tar(
- name = "test-tar-strip_prefix-empty",
- srcs = [
- ":etc/nsswitch.conf",
- ],
- strip_prefix = "",
-)
-
-pkg_tar(
- name = "test-tar-strip_prefix-none",
- srcs = [
- ":etc/nsswitch.conf",
- ],
-)
-
-pkg_tar(
- name = "test-tar-strip_prefix-etc",
- srcs = [
- ":etc/nsswitch.conf",
- ],
- strip_prefix = "etc",
-)
-
-pkg_tar(
- name = "test-tar-strip_prefix-dot",
- srcs = [
- ":etc/nsswitch.conf",
- "@bazel_tools//tools/python/runfiles",
- ],
- strip_prefix = ".",
-)
-
-pkg_tar(
- name = "test-tar-strip_prefix-substring",
- srcs = [
- ":etc/nsswitch.conf",
- ],
- strip_prefix = "et",
-)
-
-pkg_tar(
- name = "test-tar-files_dict",
- files = {
- ":etc/nsswitch.conf": "not-etc/mapped-filename.conf",
- },
-)
-
-pkg_tar(
- name = "test-tar-empty_files",
- empty_files = [
- "/a",
- "/b",
- ],
- mode = "0o777",
-)
-
-pkg_tar(
- name = "test-tar-empty_dirs",
- empty_dirs = [
- "/tmp",
- "/pmt",
- ],
- mode = "0o777",
-)
-
-pkg_tar(
- name = "test-tar-mtime",
- srcs = [
- ":etc/nsswitch.conf",
- ],
- mtime = 946684740, # 1999-12-31, 23:59
- portable_mtime = False,
-)
-
-pkg_tar(
- name = "test-tar-long-filename",
- srcs = [
- "//tests:testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt",
- ],
- # TODO(https://github.com/bazelbuild/rules_pkg/issues/462): The old test
- # used to have strip_prefix. But strip_prefix is just plain broken w.r.t.
- # files from other packages. We end up with an internal expected data_path
- # of tests/tar/<strip_prefix>. But the files coming in have the real paths.
- # strip_prefix = "testdata",
-)
-
-pkg_tar(
- name = "test-tar-repackaging-long-filename",
- package_dir = "can_i_repackage_a_file_with_a_long_name",
- deps = [
- ":test-tar-long-filename",
- ],
-)
-
-verify_archive_test(
- name = "repackaging_long_filename_test",
- 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_not_contain_regex = [
- "^five.is.right.out",
- ],
- target = ":test-tar-repackaging-long-filename",
-)
-
-pkg_tar(
- name = "test-tar-tree-artifact",
- srcs = [
- ":generate_tree",
- "//tests:loremipsum_txt",
- ],
- package_dir = "a_tree",
-)
-
-pkg_files(
- name = "tree_noroot",
- srcs = [
- ":generate_tree",
- ],
- strip_prefix = "generate_tree",
-)
-
-pkg_tar(
- name = "test-tar-tree-artifact-noroot",
- srcs = [
- ":tree_noroot",
- "//tests:loremipsum_txt",
- ],
- package_dir = "a_tree",
-)
-
-fake_artifact(
- name = "a_program",
- files = ["//tests:testdata/executable.sh"],
- runfiles = ["BUILD"],
-)
-
-pkg_tar(
- name = "test-tar-with-runfiles",
- srcs = [
- ":a_program",
- ],
- include_runfiles = True,
-)
-
-pkg_tar(
- name = "test_tar_leading_dotslash",
- srcs = [
- "//tests:loremipsum_txt",
- ],
- package_dir = ".",
-)
-
-py_test(
- name = "pkg_tar_test",
- size = "medium",
- srcs = [
- "pkg_tar_test.py",
- ],
- imports = ["../.."],
- data = [
- ":test-pkg-tar-from-pkg-files-with-attributes",
- ":test-pkg-tar-with-attributes",
- ":test-remap-paths-tree-artifact",
- ":test-tar-empty_dirs.tar",
- ":test-tar-empty_files.tar",
- ":test-tar-files_dict.tar",
- ":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-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",
- "//tests:testdata/tar_test.tar.xz",
- "//tests:testdata/test_tar_package_dir_file.txt",
- ] + [
- ":test-tar-basic-%s" % compression
- for compression in SUPPORTED_TAR_COMPRESSIONS
- ] + [
- ":test-tar-inclusion-%s" % compression
- for compression in SUPPORTED_TAR_COMPRESSIONS
- ],
- python_version = "PY3",
- deps = [
- "//pkg/private/tar:tar_writer",
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-test_suite(
- name = "windows_tests",
- tags = [
- "-slow",
- ],
- visibility = ["//visibility:private"],
-)
-
-test_suite(
- name = "all_windows_tests",
- tests = [":windows_tests"],
-)
-
-pkg_tar(
- name = "test-tar-compression-from-extension-targz",
- srcs = [
- "//tests:testdata/loremipsum.txt",
- ],
- 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 = [
- "//tests:testdata/loremipsum.txt",
- ],
- extension = "tgz",
-)
-
-pkg_tar(
- name = "test-tar-compression-from-extension-bz2",
- srcs = [
- "//tests:testdata/loremipsum.txt",
- ],
- extension = ".bz2",
-)
-
-py_test(
- name = "is_compressed_test",
- srcs = ["is_compressed_test.py"],
- data = [
- ":test-tar-compression-from-extension-bz2",
- ":test-tar-compression-from-extension-targz",
- ":test-tar-compression-from-extension-tgz",
- ],
- python_version = "PY3",
- srcs_version = "PY3",
- deps = [
- "@bazel_tools//tools/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 = {
- "foo": ".pnpm/foo@1.0.0/node_modules/foo",
- ".pnpm/bar@1.0.0/node_modules/bar": "STORE/bar",
- ".pnpm/foo@1.0.0/node_modules/foo": "STORE/foo",
- ".pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
- },
- package_dir = "node_modules",
-)
-
-directory(
- name = "tree_artifact_with_links",
- contents = "hello there",
- filenames = [
- "foo/hello.txt",
- "foo/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.
-# - mklinks rules.
-# - source files that are symlinks
-# - tree artifacts
-pkg_tar(
- name = "relative_links_tar",
- srcs = [
- ":node_modules",
- ":tree_artifact_with_links",
- "//tests:file_and_link",
- ],
- symlinks = {
- "tree_artifact/toss_in_another": "/foo",
- },
-)
-
-verify_archive_test(
- name = "relative_links_test",
- min_size = 10,
- must_contain = [
- "BUILD",
- "outer_BUILD",
- "node_modules/.pnpm/bar@1.0.0/node_modules/bar",
- ],
- tags = ["nowindows"],
- target = ":relative_links_tar",
- verify_links = {
- "node_modules/.pnpm/foo@1.0.0/node_modules/bar": "../../bar@1.0.0/node_modules/bar",
- "tree_artifact/toss_in_another": "/foo",
- },
-)
-
-pkg_tar(
- name = "relative_links_re_tar",
- package_dir = "new/base",
- symlinks = {
- # We expect package_dir to apply to this
- "tree_artifact/toss_in_another": "some_target",
- # But we protect the user from duplicationg package_dir in their
- # link. That was the old behavior of symlink.
- "new/base/something/this": "that",
- },
- deps = [
- ":relative_links_tar",
- ],
-)
-
-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",
- ],
- 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",
- },
-)
diff --git a/tests/tar/compressor.py b/tests/tar/compressor.py
deleted file mode 100644
index 3603d0d..0000000
--- a/tests/tar/compressor.py
+++ /dev/null
@@ -1,10 +0,0 @@
-'''Fake compressor that just prepends garbage bytes.'''
-
-import sys
-
-GARBAGE = b'garbage'
-
-if __name__ == '__main__':
- assert sys.argv[1:] == ['-a', '-b', '-c']
- sys.stdout.buffer.write(GARBAGE)
- sys.stdout.buffer.write(sys.stdin.buffer.read())
diff --git a/tests/tar/is_compressed_test.py b/tests/tar/is_compressed_test.py
deleted file mode 100644
index 6ed7386..0000000
--- a/tests/tar/is_compressed_test.py
+++ /dev/null
@@ -1,60 +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.
-"""Tests if input files are compressed."""
-
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-
-
-class IsCompressedTest(unittest.TestCase):
-
- def setUp(self):
- self.data_files = runfiles.Create()
-
- def get_file_under_test(self, file_name):
- """Get the file path to a generated archive in the runfiles."""
-
- return self.data_files.Rlocation(
- "rules_pkg/tests/tar/" + file_name
- )
-
- def is_zip_compressed(self, file_name):
- """Returns true if file_name is zip compressed."""
- with open(self.get_file_under_test(file_name), 'rb') as inp:
- content = inp.read(2)
- # A quick web search will show these magic constants are correct.
- return content[0] == 0x1f and content[1] == 0x8b
-
- def is_bz2_compressed(self, file_name):
- """Returns true if file_name is bz2 compressed."""
- with open(self.get_file_under_test(file_name), 'rb') as inp:
- content = inp.read(7)
- # A quick web search will show these magic constants are correct.
- # This is probably well beyond what we need in this test, but why not?
- return (content[0] == ord('B') and content[1] == ord('Z')
- and ord('1') <= content[3] and content[3] <= ord('9')
- and content[4] == 0x31 and content[5] == 0x41 and content[6] == 0x59)
-
- def test_guess_compression_from_extension(self):
- self.assertTrue(
- self.is_bz2_compressed("test-tar-compression-from-extension-bz2.bz2"))
- self.assertTrue(
- self.is_zip_compressed("test-tar-compression-from-extension-targz.tar.gz"))
- self.assertTrue(
- self.is_zip_compressed("test-tar-compression-from-extension-tgz.tgz"))
-
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/tests/tar/pkg_tar_test.py b/tests/tar/pkg_tar_test.py
deleted file mode 100644
index eb8a127..0000000
--- a/tests/tar/pkg_tar_test.py
+++ /dev/null
@@ -1,298 +0,0 @@
-# Copyright 2015 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.
-"""Testing for pkg_tar."""
-
-import tarfile
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-from pkg.private.tar import tar_writer
-
-PORTABLE_MTIME = 946684800 # 2000-01-01 00:00:00.000 UTC
-
-
-class PkgTarTest(unittest.TestCase):
- """Testing for pkg_tar rule."""
-
- def assertTarFileContent(self, file_name, content, verbose=False):
- """Assert that tarfile contains exactly the entry described by `content`.
-
- Args:
- file_name: the path to the TAR file to test.
- content: an array describing the expected content of the TAR file.
- Each entry in that list should be a dictionary where each field
- is a field to test in the corresponding TarInfo. For
- testing the presence of a file "x", then the entry could simply
- be `{'name': 'x'}`, the missing field will be ignored. To match
- the content of a file entry, use the key 'data'.
- """
- # NOTE: This is portable to Windows. os.path.join('rules_pkg', 'tests',
- # filename) is not.
- file_path = runfiles.Create().Rlocation('rules_pkg/tests/tar/' + file_name)
- got = []
- with tarfile.open(file_path, 'r:*') as f:
- i = 0
- for info in f:
- if verbose:
- print(' >> from tar file:', info.name)
- error_msg = 'Extraneous file at end of archive %s: %s' % (
- file_path,
- info.name
- )
- self.assertLess(i, len(content), error_msg)
- for k, v in content[i].items():
- if k == 'halt':
- return
- elif k == 'data':
- value = f.extractfile(info).read()
- elif k == 'isdir':
- value = info.isdir()
- else:
- value = getattr(info, k)
- if k == 'mode':
- p_value = '0o%o' % value
- p_v = '0o%o' % v
- else:
- p_value = str(value)
- p_v = str(v)
- error_msg = ' '.join([
- 'Value `%s` for key `%s` of file' % (p_value, k),
- '%s in archive %s does' % (info.name, file_path),
- 'not match expected value `%s`' % p_v
- ])
- self.assertEqual(value, v, error_msg)
- if value != v:
- print(error_msg)
- i += 1
- if i < len(content):
- self.fail('Missing file %s in archive %s of [%s]' % (
- content[i], file_path, ',\n '.join(got)))
-
- def test_strip_prefix_empty(self):
- content = [
- {'name': 'nsswitch.conf'},
- ]
- self.assertTarFileContent('test-tar-strip_prefix-empty.tar', content)
-
- def test_strip_prefix_none(self):
- content = [
- {'name': 'nsswitch.conf'},
- ]
- self.assertTarFileContent('test-tar-strip_prefix-none.tar', content)
-
- def test_strip_prefix_etc(self):
- content = [
- {'name': 'nsswitch.conf'},
- ]
- self.assertTarFileContent('test-tar-strip_prefix-etc.tar', content)
-
- def test_strip_prefix_substring(self):
- content = [
- {'name': 'etc', 'isdir': True},
- {'name': 'etc/nsswitch.conf'},
- ]
- self.assertTarFileContent('test-tar-strip_prefix-substring.tar', content)
-
- def 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'},
- # This is brittle. In old bazel the next file would be
- # external/bazel_tools/tools/python/runfiles/runfiles.py, but there
- # is now _runfiles_constants.py, first. So this is too brittle.
- {'halt': None},
- ]
- self.assertTarFileContent('test-tar-strip_prefix-dot.tar', content)
-
- def test_strip_files_dict(self):
- content = [
- {'name': 'not-etc'},
- {'name': 'not-etc/mapped-filename.conf'},
- ]
- self.assertTarFileContent('test-tar-files_dict.tar', content)
-
- def test_empty_files(self):
- content = [
- {'name': 'a', 'size': 0, 'uid': 0},
- {'name': 'b', 'size': 0, 'uid': 0, 'mtime': PORTABLE_MTIME},
- ]
- self.assertTarFileContent('test-tar-empty_files.tar', content)
-
- def test_empty_dirs(self):
- content = [
- {'name': 'pmt', 'isdir': True, 'size': 0, 'uid': 0,
- 'mtime': PORTABLE_MTIME},
- {'name': 'tmp', 'isdir': True, 'size': 0, 'uid': 0,
- 'mtime': PORTABLE_MTIME},
- ]
- self.assertTarFileContent('test-tar-empty_dirs.tar', content)
-
- def test_mtime(self):
- # Note strange mtime. It is specified in the BUILD file.
- content = [
- {'name': 'nsswitch.conf', 'mtime': 946684740},
- ]
- self.assertTarFileContent('test-tar-mtime.tar', content)
-
- def test_basic(self):
- # Check the set of 'test-tar-basic-*' smoke test.
- content = [
- {'name': 'etc',
- 'uid': 24, 'gid': 42, 'uname': 'tata', 'gname': 'titi'},
- {'name': 'etc/nsswitch.conf',
- 'mode': 0o644,
- 'uid': 24, 'gid': 42, 'uname': 'tata', 'gname': 'titi'
- },
- {'name': 'usr',
- 'uid': 42, 'gid': 24, 'uname': 'titi', 'gname': 'tata'},
- {'name': 'usr/bin'},
- {'name': 'usr/bin/java', 'linkname': '/path/to/bin/java'},
- {'name': 'usr/titi',
- 'mode': 0o755,
- 'uid': 42, 'gid': 24, 'uname': 'titi', 'gname': 'tata'},
- ]
- for ext in [('.' + comp if comp else '')
- for comp in tar_writer.COMPRESSIONS]:
- with self.subTest(ext=ext):
- self.assertTarFileContent('test-tar-basic-%s.tar%s' % (ext[1:], ext),
- content)
-
- def test_file_inclusion(self):
- content = [
- {'name': 'etc', 'uid': 24, 'gid': 42},
- {'name': 'etc/nsswitch.conf', 'mode': 0o644, 'uid': 24, 'gid': 42},
- {'name': 'usr', 'uid': 42, 'gid': 24},
- {'name': 'usr/bin'},
- {'name': 'usr/bin/java', 'linkname': '/path/to/bin/java'},
- {'name': 'usr/titi', 'mode': 0o755, 'uid': 42, 'gid': 24},
- {'name': 'BUILD'},
- ]
- for ext in [('.' + comp if comp else '')
- for comp in tar_writer.COMPRESSIONS]:
- with self.subTest(ext=ext):
- self.assertTarFileContent('test-tar-inclusion-%s.tar' % ext[1:],
- content)
-
- def test_strip_prefix_empty(self):
- content = [
- {'name': 'level1'},
- {'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)
-
- def test_tar_with_long_file_name(self):
- content = [
- {'name': 'file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt'}
- ]
- self.assertTarFileContent('test-tar-long-filename.tar', content)
-
- def test_repackage_file_with_long_name(self):
- content = [
- {'name': 'can_i_repackage_a_file_with_a_long_name'},
- {'name': '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'}
- ]
- self.assertTarFileContent('test-tar-repackaging-long-filename.tar', content)
-
- def test_tar_with_tree_artifact(self):
- # (sorted) list of files:
- # "a/a"
- # "a/b/c"
- # "b/c/d"
- # "b/d"
- # "b/e"
-
- content = [
- {'name': 'a_tree', 'isdir': True},
- {'name': 'a_tree/generate_tree', 'isdir': True, 'mode': 0o755},
- {'name': 'a_tree/generate_tree/a', 'isdir': True, 'mode': 0o755},
- {'name': 'a_tree/generate_tree/a/a'},
- {'name': 'a_tree/generate_tree/a/b', 'isdir': True, 'mode': 0o755},
- {'name': 'a_tree/generate_tree/a/b/c'},
- {'name': 'a_tree/generate_tree/b', 'isdir': True, 'mode': 0o755},
- {'name': 'a_tree/generate_tree/b/c', 'isdir': True, 'mode': 0o755},
- {'name': 'a_tree/generate_tree/b/c/d'},
- {'name': 'a_tree/generate_tree/b/d'},
- {'name': 'a_tree/generate_tree/b/e'},
- {'name': 'a_tree/loremipsum.txt'},
- ]
- self.assertTarFileContent('test-tar-tree-artifact.tar', content)
-
- # Now test against the tree artifact with the dir name stripped.
- noroot_content = []
- for c in content[1:]: # one less level in tree. Skip first element.
- nc = dict(c)
- nc['name'] = c['name'].replace('/generate_tree', '')
- noroot_content.append(nc)
- 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},
- {'name': 'a/a'},
- {'name': 'a/b'},
- ]
- 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
deleted file mode 100644
index 39008ea..0000000
--- a/tests/tar/tar_writer_test.py
+++ /dev/null
@@ -1,253 +0,0 @@
-# Copyright 2015 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.
-"""Testing for tar_writer."""
-
-import os
-import tarfile
-import unittest
-
-from bazel_tools.tools.python.runfiles import runfiles
-from pkg.private.tar import tar_writer
-from tests.tar import compressor
-
-
-class TarFileWriterTest(unittest.TestCase):
- """Testing for TarFileWriter class."""
-
- def assertTarFileContent(self, tar, content):
- """Assert that tarfile contains exactly the entry described by `content`.
-
- Args:
- tar: the path to the TAR file to test.
- content: an array describing the expected content of the TAR file.
- Each entry in that list should be a dictionary where each field
- is a field to test in the corresponding TarInfo. For
- testing the presence of a file "x", then the entry could simply
- be `{"name": "x"}`, the missing field will be ignored. To match
- the content of a file entry, use the key "data".
- """
- got_names = []
- with tarfile.open(tar, "r:*") as f:
- for current in f:
- got_names.append(getattr(current, "name"))
-
- with tarfile.open(tar, "r:*") as f:
- i = 0
- for current in f:
- error_msg = "Extraneous file at end of archive %s: %s" % (
- tar,
- current.name
- )
- self.assertLess(i, len(content), error_msg)
- for k, v in content[i].items():
- if k == "data":
- value = f.extractfile(current).read()
- elif k == "name" and os.name == "nt":
- value = getattr(current, k).replace("\\", "/")
- else:
- value = getattr(current, k)
- error_msg = " ".join([
- "Value `%s` for key `%s` of file" % (value, k),
- "%s in archive %s does" % (current.name, tar),
- "not match expected value `%s`" % v
- ])
- error_msg += str(got_names)
- self.assertEqual(value, v, error_msg)
- i += 1
- if i < len(content):
- self.fail("Missing file %s in archive %s" % (content[i], tar))
-
- def setUp(self):
- super(TarFileWriterTest, self).setUp()
- self.tempfile = os.path.join(os.environ["TEST_TMPDIR"], "test.tar")
- self.data_files = runfiles.Create()
-
- def tearDown(self):
- super(TarFileWriterTest, self).tearDown()
- if os.path.exists(self.tempfile):
- os.remove(self.tempfile)
-
- def testEmptyTarFile(self):
- with tar_writer.TarFileWriter(self.tempfile):
- pass
- self.assertTarFileContent(self.tempfile, [])
-
- def assertSimpleFileContent(self, names):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- for n in names:
- f.add_file(n, content=n)
- # pylint: disable=g-complex-comprehension
- content = ([{"name": n,
- "size": len(n.encode("utf-8")),
- "data": n.encode("utf-8")}
- for n in names])
- self.assertTarFileContent(self.tempfile, content)
-
- def testAddFile(self):
- self.assertSimpleFileContent(["./a"])
- self.assertSimpleFileContent(["./b"])
- self.assertSimpleFileContent(["./ab"])
- self.assertSimpleFileContent(["./a", "./b"])
- self.assertSimpleFileContent(["./a", "./ab"])
- self.assertSimpleFileContent(["./a", "./b", "./ab"])
-
- def testDottedFiles(self):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- f.add_file("a")
- f.add_file("/b")
- f.add_file("./c")
- f.add_file("./.d")
- f.add_file("..e")
- f.add_file(".f")
- content = [
- {"name": "a"},
- {"name": "/b"},
- {"name": "./c"},
- {"name": "./.d"},
- {"name": "..e"},
- {"name": ".f"}
- ]
- self.assertTarFileContent(self.tempfile, content)
-
- def testMergeTar(self):
- content = [
- {"name": "./a", "data": b"a"},
- {"name": "./ab", "data": b"ab"},
- ]
- for ext in [("." + comp if comp else "") for comp in tar_writer.COMPRESSIONS]:
- with tar_writer.TarFileWriter(self.tempfile) as f:
- datafile = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/tar_test.tar" + ext)
- f.add_tar(datafile, name_filter=lambda n: n != "./b")
- self.assertTarFileContent(self.tempfile, content)
-
- def testMergeTarRelocated(self):
- content = [
- {"name": "foo", "mode": 0o755},
- {"name": "foo/a", "data": b"a"},
- {"name": "foo/ab", "data": b"ab"},
- ]
- with tar_writer.TarFileWriter(self.tempfile) as f:
- datafile = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/tar_test.tar")
- f.add_tar(datafile, name_filter=lambda n: n != "./b", prefix="foo")
- self.assertTarFileContent(self.tempfile, content)
-
- def testDefaultMtimeNotProvided(self):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- self.assertEqual(f.default_mtime, 0)
-
- def testDefaultMtimeProvided(self):
- with tar_writer.TarFileWriter(self.tempfile, default_mtime=1234) as f:
- self.assertEqual(f.default_mtime, 1234)
-
- def testPortableMtime(self):
- with tar_writer.TarFileWriter(self.tempfile, default_mtime="portable") as f:
- self.assertEqual(f.default_mtime, 946684800)
-
- def testPreserveTarMtimesTrueByDefault(self):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- input_tar_path = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/tar_test.tar")
- f.add_tar(input_tar_path)
- input_tar = tarfile.open(input_tar_path, "r")
- for file_name in f.members:
- input_file = input_tar.getmember(file_name)
- output_file = f.tar.getmember(file_name)
- self.assertEqual(input_file.mtime, output_file.mtime)
-
- def testPreserveTarMtimesFalse(self):
- with tar_writer.TarFileWriter(self.tempfile, preserve_tar_mtimes=False) as f:
- input_tar_path = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/tar_test.tar")
- f.add_tar(input_tar_path)
- for output_file in f.tar:
- self.assertEqual(output_file.mtime, 0)
-
- def testAddingDirectoriesForFile(self):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- f.add_file("d/f")
- content = [
- {"name": "d", "mode": 0o755},
- {"name": "d/f"},
- ]
- self.assertTarFileContent(self.tempfile, content)
-
- def testAddingDirectoriesForFileManually(self):
- with tar_writer.TarFileWriter(self.tempfile) as f:
- f.add_file("d", tarfile.DIRTYPE)
- f.add_file("d/f")
-
- f.add_file("a", tarfile.DIRTYPE)
- f.add_file("a/b", tarfile.DIRTYPE)
- f.add_file("a/b", tarfile.DIRTYPE)
- f.add_file("a/b/", tarfile.DIRTYPE)
- f.add_file("a/b/c/f")
-
- f.add_file("x/y/f")
- f.add_file("x", tarfile.DIRTYPE)
- content = [
- {"name": "d", "mode": 0o755},
- {"name": "d/f"},
- {"name": "a", "mode": 0o755},
- {"name": "a/b", "mode": 0o755},
- {"name": "a/b/c", "mode": 0o755},
- {"name": "a/b/c/f"},
- {"name": "x", "mode": 0o755},
- {"name": "x/y", "mode": 0o755},
- {"name": "x/y/f"},
- ]
- self.assertTarFileContent(self.tempfile, content)
-
- def testPackageDirAttribute(self):
- """Tests package_dir of pkg_tar."""
- package_dir = self.data_files.Rlocation(
- "rules_pkg/tests/tar/test_tar_package_dir.tar")
- expected_content = [
- {"name": "my"},
- {"name": "my/package"},
- {"name": "my/package/mylink"},
- {"name": "my/package/nsswitch.conf"},
- ]
- self.assertTarFileContent(package_dir, expected_content)
-
- def testPackageDirFileAttribute(self):
- """Tests package_dir_file attributes of pkg_tar."""
- package_dir_file = self.data_files.Rlocation(
- "rules_pkg/tests/tar/test_tar_package_dir_file.tar")
- expected_content = [
- {"name": "package"},
- {"name": "package/nsswitch.conf"},
- ]
- self.assertTarFileContent(package_dir_file, expected_content)
-
- def testCustomCompression(self):
- original = self.data_files.Rlocation(
- "rules_pkg/tests/testdata/tar_test.tar")
- compressed = self.data_files.Rlocation(
- "rules_pkg/tests/tar/test_tar_compression.tar")
- with open(compressed, "rb") as f_in, open(self.tempfile, "wb") as f_out:
- # "Decompress" by skipping garbage bytes
- f_in.seek(len(compressor.GARBAGE))
- f_out.write(f_in.read())
-
- expected_content = [
- {"name": "./" + x, "data": x.encode("utf-8")} for x in ["a", "b", "ab"]
- ]
- self.assertTarFileContent(original, expected_content)
- self.assertTarFileContent(self.tempfile, expected_content)
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/testdata/README.md b/tests/testdata/README.md
deleted file mode 100644
index d833016..0000000
--- a/tests/testdata/README.md
+++ /dev/null
@@ -1,20 +0,0 @@
-This folder contains test data.
-
-The utf8 folder contains a set of files whose names are not ASCII or ISO-8859-1.
-They may be used for testing the ability to handle files using non ASCII
-file names. Along with those we have 4 samples of what native tar and zip
-utilities do with these file names:
-
-- utf8_linux.tar: From linux: `tar cf utf8_linux.tar utf8`
-- utf8_linux.zip From linux: `zip -r utf8_linux.zip utf8`
-- utf8_mac.tar: From macos: `tar cf utf8_linux.tar utf8`
-- utf8_mac.zip From macos: `zip -r utf8_linux.zip utf8`
-- utf8_win.tar: From window: `tar cf utf8_win.tar utf8`
-- utf8_win.zip From window: `7z a -r utf8_win.zip utf8`
-
-The samples are are intended to be used as input data for tests
-of capabilities that read data (such as unpacking and filtering
-a tar file). Code must be able to read tar and zip files produced
-on a different OS and interpret file names correctly. For now we
-can study the differences by platform.
-
diff --git a/tests/testdata/a.ar b/tests/testdata/a.ar
deleted file mode 100644
index d2594df..0000000
--- a/tests/testdata/a.ar
+++ /dev/null
@@ -1,3 +0,0 @@
-!<arch>
-a/ 1439231934 1000 1000 100664 1 `
-a
diff --git a/tests/testdata/a_ab.ar b/tests/testdata/a_ab.ar
deleted file mode 100644
index f6b7217..0000000
--- a/tests/testdata/a_ab.ar
+++ /dev/null
@@ -1,5 +0,0 @@
-!<arch>
-a/ 1439231934 1000 1000 100664 1 `
-a
-ab/ 1439231936 1000 1000 100664 2 `
-ab
diff --git a/tests/testdata/a_b.ar b/tests/testdata/a_b.ar
deleted file mode 100644
index 6f2d79c..0000000
--- a/tests/testdata/a_b.ar
+++ /dev/null
@@ -1,5 +0,0 @@
-!<arch>
-a/ 1439231934 1000 1000 100664 1 `
-a
-b/ 1439231939 1000 1000 100664 1 `
-b
diff --git a/tests/testdata/a_b_ab.ar b/tests/testdata/a_b_ab.ar
deleted file mode 100644
index 07dc3e7..0000000
--- a/tests/testdata/a_b_ab.ar
+++ /dev/null
@@ -1,7 +0,0 @@
-!<arch>
-a/ 1439231934 1000 1000 100664 1 `
-a
-b/ 1439231939 1000 1000 100664 1 `
-b
-ab/ 1439231936 1000 1000 100664 2 `
-ab
diff --git a/tests/testdata/ab.ar b/tests/testdata/ab.ar
deleted file mode 100644
index 29f56be..0000000
--- a/tests/testdata/ab.ar
+++ /dev/null
@@ -1,3 +0,0 @@
-!<arch>
-ab/ 1439231936 1000 1000 100664 2 `
-ab
diff --git a/tests/testdata/b.ar b/tests/testdata/b.ar
deleted file mode 100644
index 3f41a7e..0000000
--- a/tests/testdata/b.ar
+++ /dev/null
@@ -1,3 +0,0 @@
-!<arch>
-b/ 1439231939 1000 1000 100664 1 `
-b
diff --git a/tests/testdata/config b/tests/testdata/config
deleted file mode 100644
index d39edc7..0000000
--- a/tests/testdata/config
+++ /dev/null
@@ -1 +0,0 @@
-# test config file
diff --git a/tests/testdata/deb_preinst b/tests/testdata/deb_preinst
deleted file mode 100644
index 9a88ab0..0000000
--- a/tests/testdata/deb_preinst
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/usr/bin/env bash
-# tete ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é
-echo fnord
diff --git a/tests/testdata/deb_triggers b/tests/testdata/deb_triggers
deleted file mode 100644
index e7c1249..0000000
--- a/tests/testdata/deb_triggers
+++ /dev/null
@@ -1,2 +0,0 @@
-# tutu ®, Й, ק ,م, ๗, あ, 叶, 葉, 말, ü and é
-some-trigger
diff --git a/tests/testdata/empty.ar b/tests/testdata/empty.ar
deleted file mode 100644
index 8b277f0..0000000
--- a/tests/testdata/empty.ar
+++ /dev/null
@@ -1 +0,0 @@
-!<arch>
diff --git a/tests/testdata/executable.sh b/tests/testdata/executable.sh
deleted file mode 100755
index e5d3986..0000000
--- a/tests/testdata/executable.sh
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-echo "Hello"
diff --git a/tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt b/tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt
deleted file mode 100644
index cd773cd..0000000
--- a/tests/testdata/file_with_a_ridiculously_long_name_consectetur_adipiscing_elit_fusce_laoreet_lorem_neque_sed_pharetra_erat.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello there! \ No newline at end of file
diff --git a/tests/testdata/hello.txt b/tests/testdata/hello.txt
deleted file mode 100644
index af5626b..0000000
--- a/tests/testdata/hello.txt
+++ /dev/null
@@ -1 +0,0 @@
-Hello, world!
diff --git a/tests/testdata/loremipsum.txt b/tests/testdata/loremipsum.txt
deleted file mode 100644
index ab7ff0e..0000000
--- a/tests/testdata/loremipsum.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla sit amet nunc
-lectus. Sed at nulla vel turpis egestas pharetra et at velit. Cras pharetra
-iaculis dui, id vestibulum odio auctor eget. Class aptent taciti sociosqu ad
-litora torquent per conubia nostra, per inceptos himenaeos. Ut massa lectus,
-lobortis vel vehicula id, mattis id odio. Mauris eget imperdiet nisi. Nunc id
-urna a lorem porttitor varius ut vitae risus. Ut faucibus, magna eget rutrum
-efficitur, nulla nulla porta lectus, venenatis convallis nisi magna auctor arcu.
diff --git a/tests/testdata/outer_BUILD b/tests/testdata/outer_BUILD
deleted file mode 120000
index c447d20..0000000
--- a/tests/testdata/outer_BUILD
+++ /dev/null
@@ -1 +0,0 @@
-../BUILD \ No newline at end of file
diff --git a/tests/testdata/tar_test.tar b/tests/testdata/tar_test.tar
deleted file mode 100644
index 70b043b..0000000
--- a/tests/testdata/tar_test.tar
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/tar_test.tar.bz2 b/tests/testdata/tar_test.tar.bz2
deleted file mode 100644
index c6f7edf..0000000
--- a/tests/testdata/tar_test.tar.bz2
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/tar_test.tar.gz b/tests/testdata/tar_test.tar.gz
deleted file mode 100644
index 4b85171..0000000
--- a/tests/testdata/tar_test.tar.gz
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/tar_test.tar.xz b/tests/testdata/tar_test.tar.xz
deleted file mode 100644
index 1ea3c8b..0000000
--- a/tests/testdata/tar_test.tar.xz
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/templates b/tests/testdata/templates
deleted file mode 100644
index 0576bc0..0000000
--- a/tests/testdata/templates
+++ /dev/null
@@ -1,6 +0,0 @@
-Template: deb/test
-Type: string
-Default:
-Description: test question
- test question to check that templates are included into
- debian directory
diff --git a/tests/testdata/test_tar_package_dir_file.txt b/tests/testdata/test_tar_package_dir_file.txt
deleted file mode 100755
index 1337ba4..0000000
--- a/tests/testdata/test_tar_package_dir_file.txt
+++ /dev/null
@@ -1 +0,0 @@
-/package
diff --git a/tests/testdata/utf8/1-a b/tests/testdata/utf8/1-a
deleted file mode 100644
index c4d36ef..0000000
--- a/tests/testdata/utf8/1-a
+++ /dev/null
@@ -1 +0,0 @@
-my name takes 3 octets in utf-8
diff --git a/tests/testdata/utf8/2-λ b/tests/testdata/utf8/2-λ
deleted file mode 100644
index 259e8c7..0000000
--- a/tests/testdata/utf8/2-λ
+++ /dev/null
@@ -1 +0,0 @@
-my name takes 4 octets in utf-8
diff --git a/tests/testdata/utf8/3-世 b/tests/testdata/utf8/3-世
deleted file mode 100644
index 5eee6f9..0000000
--- a/tests/testdata/utf8/3-世
+++ /dev/null
@@ -1 +0,0 @@
-my name takes 5 octets in utf-8
diff --git a/tests/testdata/utf8/BUILD b/tests/testdata/utf8/BUILD
deleted file mode 100644
index 7f7df7b..0000000
--- a/tests/testdata/utf8/BUILD
+++ /dev/null
@@ -1,21 +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.
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "files",
- srcs = glob(["**"]),
- visibility = ["//visibility:public"],
-)
diff --git a/tests/testdata/utf8/sübdir/2-λ b/tests/testdata/utf8/sübdir/2-λ
deleted file mode 100644
index 259e8c7..0000000
--- a/tests/testdata/utf8/sübdir/2-λ
+++ /dev/null
@@ -1 +0,0 @@
-my name takes 4 octets in utf-8
diff --git a/tests/testdata/utf8/sübdir/hello b/tests/testdata/utf8/sübdir/hello
deleted file mode 100644
index ce01362..0000000
--- a/tests/testdata/utf8/sübdir/hello
+++ /dev/null
@@ -1 +0,0 @@
-hello
diff --git a/tests/testdata/utf8_linux.tar b/tests/testdata/utf8_linux.tar
deleted file mode 100644
index 9d80445..0000000
--- a/tests/testdata/utf8_linux.tar
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/utf8_linux.zip b/tests/testdata/utf8_linux.zip
deleted file mode 100644
index d9bd445..0000000
--- a/tests/testdata/utf8_linux.zip
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/utf8_mac.tar b/tests/testdata/utf8_mac.tar
deleted file mode 100644
index e2957e6..0000000
--- a/tests/testdata/utf8_mac.tar
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/utf8_mac.zip b/tests/testdata/utf8_mac.zip
deleted file mode 100644
index 3709637..0000000
--- a/tests/testdata/utf8_mac.zip
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/utf8_win.tar b/tests/testdata/utf8_win.tar
deleted file mode 100755
index c5b934b..0000000
--- a/tests/testdata/utf8_win.tar
+++ /dev/null
Binary files differ
diff --git a/tests/testdata/utf8_win.zip b/tests/testdata/utf8_win.zip
deleted file mode 100755
index 7ede87f..0000000
--- a/tests/testdata/utf8_win.zip
+++ /dev/null
Binary files differ
diff --git a/tests/util/BUILD b/tests/util/BUILD
deleted file mode 100644
index c4f4a31..0000000
--- a/tests/util/BUILD
+++ /dev/null
@@ -1,39 +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.
-
-# Test utilities
-
-load("@rules_python//python:defs.bzl", "py_binary")
-
-package(default_applicable_licenses = ["//:license"])
-
-licenses(["notice"])
-
-exports_files(["defs.bzl"])
-
-py_binary(
- name = "md5",
- srcs = ["md5.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
-)
-
-py_binary(
- name = "create_directory_with_contents",
- srcs = ["create_directory_with_contents.py"],
- python_version = "PY3",
- srcs_version = "PY3",
- visibility = ["//visibility:public"],
-)
diff --git a/tests/util/create_directory_with_contents.py b/tests/util/create_directory_with_contents.py
deleted file mode 100644
index 7138884..0000000
--- a/tests/util/create_directory_with_contents.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-import sys
-import os
-
-"""Creates a directory containing some files with provided contents
-
-Usage: ./this.py output_dir_name file1 contents1 ... fileN contentsN
-"""
-
-dirname = sys.argv[1]
-
-files_contents_map = {}
-
-# Simple way of grouping over pairs. There are other ones, like
-# https://stackoverflow.com/a/16789836, but they either requiring copying a
-# bunch of code around or having something that's a smidge unreadable.
-rest_args_iter = iter(sys.argv[2:])
-for a in rest_args_iter:
- files_contents_map[a] = next(rest_args_iter)
-
-os.makedirs(dirname, exist_ok=True)
-
-for fname, contents in files_contents_map.items():
- path = os.path.join(dirname, fname)
- os.makedirs(
- os.path.dirname(path),
- exist_ok=True,
- )
- if contents.startswith('@@'):
- os.symlink(contents[2:], path)
- else:
- with open(path, 'w') as fh:
- fh.write(contents)
diff --git a/tests/util/defs.bzl b/tests/util/defs.bzl
deleted file mode 100644
index e26b16f..0000000
--- a/tests/util/defs.bzl
+++ /dev/null
@@ -1,219 +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.
-"""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")
-
-def _directory_impl(ctx):
- out_dir_file = ctx.actions.declare_directory(ctx.attr.outdir or ctx.attr.name)
-
- args = ctx.actions.args()
- args.add(out_dir_file.path)
-
- # This helper is horrible. We should pass all the args in files.
- for fn in ctx.attr.filenames:
- args.add(fn)
- args.add(ctx.attr.contents)
-
- for link, target in ctx.attr.links.items():
- args.add(link)
- args.add('@@' + target)
-
- ctx.actions.run(
- outputs = [out_dir_file],
- inputs = [],
- executable = ctx.executable._dir_creator,
- arguments = [args],
- )
- return DefaultInfo(files = depset([out_dir_file]))
-
-directory = rule(
- doc = """Helper rule to create simple TreeArtifact structures
-
-We would normally just use genrules for this, but their directory output
-creation capabilities are "unsound".
- """,
- implementation = _directory_impl,
- attrs = {
- "filenames": attr.string_list(
- doc = """Paths to create in the directory.
-
-Paths containing directories will also have the intermediate directories created too.""",
- ),
- "links": attr.string_dict(
- doc = """Set of (virtual) links to create.
-
-The keys of links are paths to create. The values are the target of the links.""",
- ),
- "contents": attr.string(),
- "outdir": attr.string(),
- "_dir_creator": attr.label(
- default = ":create_directory_with_contents",
- executable = True,
- cfg = "exec",
- ),
- },
-)
-
-def _fake_artifact_impl(ctx):
- out_file = ctx.actions.declare_file(ctx.attr.name)
- content = ["echo " + rf.path for rf in ctx.files.runfiles]
- ctx.actions.write(
- output = out_file,
- content = "\r\n".join(content),
- is_executable = ctx.attr.executable,
- )
- return DefaultInfo(
- files = depset([out_file] + ctx.files.files),
- runfiles = ctx.runfiles(files = ctx.files.runfiles),
- executable = out_file if ctx.attr.executable else None,
- )
-
-fake_artifact = rule(
- doc = """Rule to create a fake artifact that depends on its srcs.
-
-This rule creates a file that appears to depend on its srcs and passes along
-other targets in DefaultInfo as files and/or runfiles. It creates a script that
-echos all the file names. It is useful for building an object that is like a
-cc_binary in complexity, but does not depend on a large toolchain.""",
- implementation = _fake_artifact_impl,
- attrs = {
- "deps": attr.label_list(
- doc = "Dependencies to trigger other rules, but are then discarded.",
- allow_files = True,
- ),
- "files": attr.label_list(
- doc = "Deps which are passed in DefaultInfo as files.",
- allow_files = True,
- ),
- "runfiles": attr.label_list(
- doc = "Deps which are passed in DefaultInfo as runfiles.",
- allow_files = True,
- ),
- "executable": attr.bool(
- doc = "If True, the DefaultInfo will be marked as executable.",
- default = False,
- ),
- },
-)
-
-def _link_tree_impl(ctx):
- links = []
- prefix = ctx.attr.package_dir or ""
- if prefix and not prefix.endswith('/'):
- prefix = prefix + "/"
- for link, target in ctx.attr.links.items():
- # DBG print(' %s -> %s ' % (link, target))
- links.append(
- (PackageSymlinkInfo(destination = prefix + link, target = target),
- ctx.label))
- return [PackageFilegroupInfo(pkg_symlinks = links)]
-
-link_tree = rule(
- doc = """Helper rule to create a lot of fake symlinks.
-
-The inspiration is to create test data for the kinds of layouts needed by
-nodejs. See. https://pnpm.io/symlinked-node-modules-structure
- """,
- implementation = _link_tree_impl,
- attrs = {
- "links": attr.string_dict(
- doc = """Set of (virtual) links to create.
-
-The keys of links are paths to create. The values are the target of the links.""",
- mandatory = True,
- ),
- "package_dir": attr.string(doc = """Prefix to apply to all link paths."""),
- },
- provides = [PackageFilegroupInfo],
-)
-
-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)
-
-_write_content_manifest = rule(
- doc = """Helper rule to write the content manifest for a pkg_*.
-
-This is intended only for testing the manifest creation features.""",
- implementation = _write_content_manifest_impl,
- attrs = {
- "srcs": attr.label_list(
- doc = """List of source inputs.""",
- allow_files = True,
- ),
- "out": attr.output(),
- "use_short_path": attr.bool(
- doc = """Use the rootless path in the manifest.
-
- Useful to ensure that the platform-specific prefix (i.e. parts
- including something like "x64_windows-fastbuild") isn't present in
- paths in the manifest.
-
- See also https://docs.bazel.build/versions/main/skylark/lib/File.html#path
- """,
- default = True,
- ),
- "include_runfiles": attr.bool(),
- },
-)
-
-def write_content_manifest(name, srcs, **kwargs):
- out = kwargs.pop("out", name + ".manifest")
- use_short_path = kwargs.pop("use_short_path", True)
- _write_content_manifest(
- name = name,
- srcs = srcs,
- out = out,
- use_short_path = use_short_path,
- **kwargs,
- )
-
-############################################################
-# Test boilerplate
-############################################################
-def _generic_base_case_test_impl(ctx):
- env = analysistest.begin(ctx)
-
- # Nothing here intentionally, this is simply an attempt to verify successful
- # analysis.
-
- return analysistest.end(env)
-
-generic_base_case_test = analysistest.make(
- _generic_base_case_test_impl,
- attrs = {},
-)
-
-# Generic negative test boilerplate
-def _generic_negative_test_impl(ctx):
- env = analysistest.begin(ctx)
-
- asserts.expect_failure(env, ctx.attr.reason)
-
- return analysistest.end(env)
-
-generic_negative_test = analysistest.make(
- _generic_negative_test_impl,
- attrs = {
- "reason": attr.string(
- default = "",
- ),
- },
- expect_failure = True,
-)
diff --git a/tests/util/md5.py b/tests/util/md5.py
deleted file mode 100644
index 6f0f81c..0000000
--- a/tests/util/md5.py
+++ /dev/null
@@ -1,29 +0,0 @@
-#!/usr/bin/env python3
-
-# 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.
-
-'''Simple cross-platform md5sum tool for computing hashes in packaging tests.'''
-
-import hashlib
-import sys
-
-fname = sys.argv[1]
-
-md5 = hashlib.md5()
-
-with open(fname, 'rb') as fh:
- md5.update(fh.read())
-
-print(md5.hexdigest())
diff --git a/tests/zip/BUILD b/tests/zip/BUILD
deleted file mode 100644
index 52b17f0..0000000
--- a/tests/zip/BUILD
+++ /dev/null
@@ -1,338 +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.
-# -*- coding: utf-8 -*-
-
-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")
-
-package(default_applicable_licenses = ["//:license"])
-
-licenses(["notice"])
-
-py_library(
- name = "zip_test_lib",
- srcs = [
- "zip_test_lib.py",
- ],
- imports = ["../.."],
- srcs_version = "PY3",
- deps = [
- "@bazel_tools//tools/python/runfiles",
- ],
-)
-
-genrule(
- name = "generate_files",
- outs = [
- "etc/nsswitch.conf",
- "usr/titi",
- ],
- cmd = "for i in $(OUTS); do echo 1 >$$i; done",
-)
-
-pkg_mkdirs(
- name = "dirs",
- attributes = pkg_attributes(
- group = "bar",
- mode = "711",
- user = "foo",
- ),
- dirs = [
- "foodir",
- ],
-)
-
-pkg_mklink(
- name = "link",
- attributes = pkg_attributes(
- mode = "555",
- ),
- link_name = "/usr/bin/foo",
- target = "/usr/local/foo/foo.real",
-)
-
-directory(
- name = "generate_tree",
- contents = "hello there",
- filenames = [
- # buildifier: don't sort
- "b/e",
- "a/a",
- "b/c/d",
- "b/d",
- "a/b/c",
- ],
-)
-
-copy_file(
- name = "zipcontent_loremipsum",
- src = "//tests:testdata/loremipsum.txt",
- out = "zipcontent/loremipsum.txt",
-)
-
-pkg_zip(
- name = "test_zip_empty",
- srcs = [],
-)
-
-# The contents of this file should equal test_zip_empty
-pkg_zip(
- name = "test_zip_basic_renamed",
- srcs = [
- ":dirs",
- ":link",
- "//tests:an_executable",
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
- package_file_name = "test_zip_basic_renamed.foo",
-)
-
-pkg_zip(
- name = "test_zip_basic",
- srcs = [
- ":dirs",
- ":link",
- "//tests:an_executable",
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
-)
-
-pkg_zip(
- name = "test_zip_out",
- srcs = [
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
- out = "test_zip_out.foo",
-)
-
-pkg_zip(
- name = "test_zip_timestamp",
- srcs = [
- "//tests:testdata/hello.txt",
- ],
- timestamp = 1234567890,
-)
-
-pkg_zip(
- name = "test_zip_tree",
- srcs = [":generate_tree"],
-)
-
-pkg_zip(
- name = "test_zip_permissions",
- srcs = [
- "//tests:testdata/executable.sh",
- ],
- mode = "644",
- timestamp = 1234567890,
-)
-
-# This should be equal to test_zip_basic because timestamps are rounded
-# up to Jan 1 1980.
-pkg_zip(
- name = "test_zip_basic_timestamp_before_epoch",
- srcs = [
- ":dirs",
- ":link",
- "//tests:an_executable",
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
- timestamp = 0,
-)
-
-pkg_zip(
- name = "test-zip-strip_prefix-empty",
- srcs = [
- "zipcontent_loremipsum",
- ],
- strip_prefix = "",
-)
-
-pkg_zip(
- name = "test-zip-strip_prefix-none",
- srcs = [
- "zipcontent_loremipsum",
- ],
-)
-
-pkg_zip(
- name = "test-zip-strip_prefix-zipcontent",
- srcs = [
- "zipcontent_loremipsum",
- ],
- strip_prefix = "zipcontent",
-)
-
-pkg_zip(
- name = "test-zip-strip_prefix-dot",
- srcs = [
- "zipcontent_loremipsum",
- ],
- strip_prefix = ".",
-)
-
-filegroup(
- name = "test_zip_strip_prefix",
- srcs = [
- "test-zip-strip_prefix-dot",
- "test-zip-strip_prefix-empty",
- "test-zip-strip_prefix-none",
- "test-zip-strip_prefix-zipcontent",
- ],
-)
-
-pkg_mklink(
- name = "mylink",
- link_name = "mylink",
- target = "dangling",
-)
-
-# All of these should produce the same zip file.
-[pkg_zip(
- name = "test_zip_package_dir" + str(idx),
- srcs = [
- ":mylink",
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
- package_dir = package_dir,
-) for (idx, package_dir) in enumerate([
- "abc/def",
- "/abc/def",
- "/abc/def/",
-])]
-
-my_package_naming(
- name = "my_package_variables",
- label = "some_value",
-)
-
-pkg_zip(
- name = "test_zip_package_dir_substitution",
- srcs = [
- "//tests:testdata/hello.txt",
- "//tests:testdata/loremipsum.txt",
- ],
- package_dir = "/level1/{label}/level3",
- package_variables = ":my_package_variables",
-)
-
-# Different compressions
-pkg_zip(
- name = "test_zip_deflated_level_3",
- srcs = [
- "//tests:testdata/loremipsum.txt",
- ],
- compression_type = "deflated",
- compression_level = 3,
-)
-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 = [
- "zip_test.py",
- ],
- data = [
- ":test-zip-strip_prefix-dot.zip",
- ":test-zip-strip_prefix-empty.zip",
- ":test-zip-strip_prefix-none.zip",
- ":test-zip-strip_prefix-zipcontent.zip",
- ":test_zip_basic.zip",
- ":test_zip_empty.zip",
- ":test_zip_package_dir0.zip",
- ":test_zip_package_dir_substitution.zip",
- ":test_zip_permissions.zip",
- ":test_zip_timestamp.zip",
- ":test_zip_tree.zip",
- ":test_zip_deflated_level_3",
- ":test_zip_bzip2",
- ":test_zip_lzma",
- ":test_zip_stored",
- ],
- python_version = "PY3",
- deps = [
- ":zip_test_lib",
- ],
-)
-
-py_test(
- name = "zip_byte_for_byte_test",
- srcs = [
- "zip_byte_for_byte_test.py",
- ],
- data = [
- ":test_zip_basic.zip",
- ":test_zip_basic_renamed",
- # We do not actually use this file, we just want to make sure we build
- # it with this name.
- ":test_zip_out.foo",
- ":test_zip_package_dir0.zip",
- # these could be replaced with diff_test() rules (from skylib)
- ":test_zip_basic_timestamp_before_epoch.zip",
- ":test_zip_package_dir1.zip",
- ":test_zip_package_dir2.zip",
- ],
- python_version = "PY3",
- deps = [
- ":zip_test_lib",
- ],
-)
-
-pkg_zip(
- name = "unicode_names",
- srcs = ["//tests:utf8_files"]
-)
-
-py_test(
- name = "unicode_test",
- srcs = [
- "unicode_test.py",
- ],
- data = [
- ":unicode_names",
- ],
- python_version = "PY3",
- deps = [
- ":zip_test_lib",
- ],
-)
diff --git a/tests/zip/unicode_test.py b/tests/zip/unicode_test.py
deleted file mode 100644
index 641394a..0000000
--- a/tests/zip/unicode_test.py
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2022 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.
-
-import unittest
-
-from tests.zip import zip_test_lib
-
-class UnicodeHandlingTests(zip_test_lib.ZipContentsTestBase):
-
- def test_unicode_file_names(self):
- self.assertZipFileContent("unicode_names.zip", [
- {"filename": "1-a"},
- {"filename": "2-λ"},
- {"filename": "3-世"},
- {"filename": "BUILD"},
- {"filename": "sübdir/", "isdir": True},
- {"filename": "sübdir/2-λ"},
- {"filename": "sübdir/hello"},
- ])
-
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/zip/zip_byte_for_byte_test.py b/tests/zip/zip_byte_for_byte_test.py
deleted file mode 100644
index 05744d4..0000000
--- a/tests/zip/zip_byte_for_byte_test.py
+++ /dev/null
@@ -1,58 +0,0 @@
-# Copyright 2019 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.
-
-import filecmp
-import unittest
-
-from tests.zip import zip_test_lib
-
-
-class ZipEquivalency(zip_test_lib.ZipTest):
- """Check that some generated zip files are equivalent to each-other."""
-
- def assertFilesEqual(self, actual, expected):
- """Assert that two zip files contain the same bytes."""
-
- zips_are_equal = filecmp.cmp(
- self.get_test_zip(actual),
- self.get_test_zip(expected),
- )
- self.assertTrue(zips_are_equal)
-
- def test_small_timestamp(self):
- self.assertFilesEqual(
- "test_zip_basic_timestamp_before_epoch.zip",
- "test_zip_basic.zip",
- )
-
- def test_extension(self):
- self.assertFilesEqual(
- "test_zip_basic_renamed.foo",
- "test_zip_basic.zip",
- )
-
- def test_package_dir1(self):
- self.assertFilesEqual(
- "test_zip_package_dir1.zip",
- "test_zip_package_dir0.zip",
- )
-
- def test_package_dir2(self):
- self.assertFilesEqual(
- "test_zip_package_dir2.zip",
- "test_zip_package_dir0.zip",
- )
-
-if __name__ == "__main__":
- unittest.main()
diff --git a/tests/zip/zip_test.py b/tests/zip/zip_test.py
deleted file mode 100644
index e5955eb..0000000
--- a/tests/zip/zip_test.py
+++ /dev/null
@@ -1,156 +0,0 @@
-# Copyright 2019 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.
-
-import datetime
-import filecmp
-import os
-import sys
-import unittest
-import zipfile
-
-from bazel_tools.tools.python.runfiles import runfiles
-from tests.zip import zip_test_lib
-
-HELLO_CRC = 2069210904
-LOREM_CRC = 2178844372
-EXECUTABLE_CRC = 342626072
-
-
-class ZipContentsTests(zip_test_lib.ZipContentsTestBase):
-
- def test_empty(self):
- self.assertZipFileContent("test_zip_empty.zip", [])
-
- def test_basic(self):
- if os.name == "nt":
- expect = [
- {"filename": "an_executable.exe", "isexe": True},
- {"filename": "foodir/", "isdir": True, "attr": 0o711},
- {"filename": "hello.txt", "crc": HELLO_CRC},
- {"filename": "loremipsum.txt", "crc": LOREM_CRC},
- {"filename": "usr/", "isdir": True, "attr": 0o755},
- {"filename": "usr/bin/", "isdir": True, "attr": 0o755},
- {"filename": "usr/bin/foo", "isexe": True, "data": "/usr/local/foo/foo.real"},
- ]
- else:
- expect = [
- {"filename": "an_executable", "isexe": True},
- {"filename": "foodir/", "isdir": True, "attr": 0o711},
- {"filename": "hello.txt", "crc": HELLO_CRC},
- {"filename": "loremipsum.txt", "crc": LOREM_CRC},
- {"filename": "usr/", "isdir": True, "attr": 0o755},
- {"filename": "usr/bin/", "isdir": True, "attr": 0o755},
- {"filename": "usr/bin/foo", "isexe": True, "data": "/usr/local/foo/foo.real"},
- ]
-
- self.assertZipFileContent("test_zip_basic.zip", expect)
-
- def test_timestamp(self):
- self.assertZipFileContent("test_zip_timestamp.zip", [
- {"filename": "hello.txt", "crc": HELLO_CRC, "timestamp": 1234567890},
- ])
-
- def test_permissions(self):
- self.assertZipFileContent("test_zip_permissions.zip", [
- {
- "filename": "executable.sh",
- "crc": EXECUTABLE_CRC,
- "timestamp": 1234567890,
- "attr": 0o644,
- }
- ])
-
- def test_package_dir(self):
- self.assertZipFileContent("test_zip_package_dir0.zip", [
- {"filename": "abc/", "isdir": True, "attr": 0o755},
- {"filename": "abc/def/", "isdir": True, "attr": 0o755},
- {"filename": "abc/def/hello.txt", "crc": HELLO_CRC},
- {"filename": "abc/def/loremipsum.txt", "crc": LOREM_CRC},
- {"filename": "abc/def/mylink", "attr": 0o777},
- ])
-
- def test_package_dir_substitution(self):
- self.assertZipFileContent("test_zip_package_dir_substitution.zip", [
- {"filename": "level1/", "isdir": True, "attr": 0o755},
- {"filename": "level1/some_value/", "isdir": True, "attr": 0o755},
- {"filename": "level1/some_value/level3/", "isdir": True, "attr": 0o755},
- {"filename": "level1/some_value/level3/hello.txt", "crc": HELLO_CRC},
- {"filename": "level1/some_value/level3/loremipsum.txt", "crc": LOREM_CRC},
- ])
-
- def test_zip_strip_prefix_empty(self):
- self.assertZipFileContent("test-zip-strip_prefix-empty.zip", [
- {"filename": "loremipsum.txt", "crc": LOREM_CRC},
- ])
-
- def test_zip_strip_prefix_none(self):
- self.assertZipFileContent("test-zip-strip_prefix-none.zip", [
- {"filename": "loremipsum.txt", "crc": LOREM_CRC},
- ])
-
- def test_zip_strip_prefix_zipcontent(self):
- self.assertZipFileContent("test-zip-strip_prefix-zipcontent.zip", [
- {"filename": "loremipsum.txt", "crc": LOREM_CRC},
- ])
-
- def test_zip_strip_prefix_dot(self):
- self.assertZipFileContent("test-zip-strip_prefix-dot.zip", [
- {"filename": "zipcontent/", "isdir": True, "attr": 0o755},
- {"filename": "zipcontent/loremipsum.txt", "crc": LOREM_CRC},
- ])
-
- def test_zip_tree(self):
- self.assertZipFileContent("test_zip_tree.zip", [
- {"filename": "generate_tree/", "isdir": True, "attr": 0o755},
- {"filename": "generate_tree/a/", "isdir": True, "attr": 0o755},
- {"filename": "generate_tree/a/a"},
- {"filename": "generate_tree/a/b/", "isdir": True, "attr": 0o755},
- {"filename": "generate_tree/a/b/c"},
- {"filename": "generate_tree/b/", "isdir": True, "attr": 0o755},
- {"filename": "generate_tree/b/c/", "isdir": True, "attr": 0o755},
- {"filename": "generate_tree/b/c/d"},
- {"filename": "generate_tree/b/d"},
- {"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
deleted file mode 100644
index a9d237c..0000000
--- a/tests/zip/zip_test_lib.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# Copyright 2019 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.
-
-import datetime
-import filecmp
-import unittest
-import zipfile
-
-from bazel_tools.tools.python.runfiles import runfiles
-
-
-# Unix dir bit and Windows dir bit. Magic from zip spec
-UNIX_DIR_BIT = 0o40000
-MSDOS_DIR_BIT = 0x10
-UNIX_RWX_BITS = 0o777
-UNIX_RX_BITS = 0o555
-
-# The ZIP epoch date: (1980, 1, 1, 0, 0, 0)
-_ZIP_EPOCH_DT = datetime.datetime(1980, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc)
-_ZIP_EPOCH_S = int(_ZIP_EPOCH_DT.timestamp())
-
-def seconds_to_ziptime(s):
- dt = datetime.datetime.utcfromtimestamp(s)
- return (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
-
-
-class ZipTest(unittest.TestCase):
-
- def setUp(self):
- super(ZipTest, self).setUp()
- self.data_files = runfiles.Create()
-
- 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
- )
-
-
-class ZipContentsTestBase(ZipTest):
- """Use zipfile to check the contents of some generated zip files."""
-
- def assertZipFileContent(self, zip_file, content):
- """Assert that zip_file contains the entries described by content.
-
- Args:
- zip_file: the test-package-relative path to a zip file to test.
- content: an array of dictionaries containing a filename and crc key,
- and optionally a timestamp key.
- """
- with zipfile.ZipFile(self.get_test_zip(zip_file)) as f:
- infos = f.infolist()
- self.assertEqual(len(infos), len(content))
-
- for info, expected in zip(infos, content):
- self.assertEqual(info.filename, expected["filename"])
- if "crc" in expected:
- self.assertEqual(info.CRC, expected["crc"])
-
- ts = seconds_to_ziptime(expected.get("timestamp", _ZIP_EPOCH_S))
- self.assertEqual(info.date_time, ts)
- if "isdir" in expected:
- expect_dir_bits = UNIX_DIR_BIT << 16 | MSDOS_DIR_BIT
- self.assertEqual(oct(info.external_attr & expect_dir_bits),
- oct(expect_dir_bits))
- self.assertEqual(oct((info.external_attr >> 16) & UNIX_RWX_BITS),
- oct(expected.get("attr", 0o755)))
- 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:
- attr = expected.get("attr")
- if "attr_mask" in expected:
- attr &= expected.get("attr_mask")
- else:
- # 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),
- oct(attr),
- msg = info.filename)
diff --git a/toolchains/BUILD b/toolchains/BUILD
deleted file mode 100644
index ca3a5a1..0000000
--- a/toolchains/BUILD
+++ /dev/null
@@ -1,27 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*",
- ]),
- visibility = ["//distro:__pkg__"],
-)
-
-exports_files(
- glob(["*"]),
- visibility = ["//visibility:public"],
-)
diff --git a/toolchains/git/BUILD b/toolchains/git/BUILD
deleted file mode 100644
index 7d1596e..0000000
--- a/toolchains/git/BUILD
+++ /dev/null
@@ -1,75 +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.
-"""toolchain to wrap the git binary.
-
-Type: @rules_pkg//toolchains/git:git_toolchain_type
-
-Toolchains:
-- 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
- git_configure.bzl%find_system_git for usage.
-"""
-
-load("//toolchains/git:git.bzl", "git_toolchain", "is_git_available")
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = glob(["*"]),
- visibility = ["//distro:__pkg__"],
-)
-
-exports_files(
- glob(["*"]),
- visibility = ["//visibility:public"],
-)
-
-# Expose the availability of an actual git as a config_setting, so we can
-# select() on it.
-config_setting(
- name = "have_git",
- flag_values = {
- ":is_git_available": "1",
- },
- visibility = ["//visibility:public"],
-)
-
-# Expose the availability of an actual git as a feature flag, so we can
-# create a config_setting from it.
-is_git_available(
- name = "is_git_available",
- visibility = ["//:__subpackages__"],
-)
-
-toolchain_type(
- name = "git_toolchain_type",
- visibility = ["//visibility:public"],
-)
-
-# git_missing_toolchain provides a fallback toolchain so that toolchain
-# resolution can succeed even on platforms that do not have a working git.
-# If this toolchain is selected, the constraint ":have_git" will not be
-# satistifed.
-git_toolchain(
- name = "no_git",
-)
-
-toolchain(
- name = "git_missing_toolchain",
- toolchain = ":no_git",
- toolchain_type = ":git_toolchain_type",
-)
diff --git a/toolchains/git/BUILD.tpl b/toolchains/git/BUILD.tpl
deleted file mode 100644
index f009c1b..0000000
--- a/toolchains/git/BUILD.tpl
+++ /dev/null
@@ -1,16 +0,0 @@
-# This content is generated by {GENERATOR}
-load("@rules_pkg//toolchains/git:git.bzl", "git_toolchain")
-
-git_toolchain(
- name = "git_auto",
- # path to git executable
- path = "{GIT_PATH}",
- # path to the top of the git client (but really any folder under it)
- client_top = "{GIT_ROOT}",
-)
-
-toolchain(
- name = "git_auto_toolchain",
- toolchain = ":git_auto",
- toolchain_type = "@rules_pkg//toolchains/git:git_toolchain_type",
-)
diff --git a/toolchains/git/git.bzl b/toolchains/git/git.bzl
deleted file mode 100644
index f58ef81..0000000
--- a/toolchains/git/git.bzl
+++ /dev/null
@@ -1,81 +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.
-"""toolchain to provide access to git from Bazel.
-
-A git toolchain is somewhat unusual compared to other toolchains.
-It not only provides a path to the git executable, but it also
-holds the absolute path to our workspace, which is presumed to
-be under revision control. This allows us to write helper tools
-that escape the Bazel sandbox and pop back to the workspace/repo.
-"""
-
-GitInfo = provider(
- doc = """Information needed to invoke git.""",
- fields = {
- "name": "The name of the toolchain",
- "valid": "Is this toolchain valid and usable?",
- "label": "Label of a target providing a git binary",
- "path": "The path to a pre-built git",
- "client_top": "The path to the top of the git client." +
- " In reality, we use the path to the WORKSPACE file as" +
- " a proxy for a folder underneath the git client top.",
- },
-)
-
-def _git_toolchain_impl(ctx):
- if ctx.attr.label and ctx.attr.path:
- fail("git_toolchain must not specify both label and path.")
- valid = bool(ctx.attr.label) or bool(ctx.attr.path)
- toolchain_info = platform_common.ToolchainInfo(
- git = GitInfo(
- name = str(ctx.label),
- valid = valid,
- label = ctx.attr.label,
- path = ctx.attr.path,
- client_top = ctx.attr.client_top,
- ),
- )
- return [toolchain_info]
-
-git_toolchain = rule(
- implementation = _git_toolchain_impl,
- attrs = {
- "label": attr.label(
- doc = "A valid label of a target to build or a prebuilt binary. Mutually exclusive with path.",
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- "path": attr.string(
- doc = "The path to the git executable. Mutually exclusive with label.",
- ),
- "client_top": attr.string(
- doc = "The top of your git client.",
- ),
- },
-)
-
-# Expose the presence of a git in the resolved toolchain as a flag.
-def _is_git_available_impl(ctx):
- toolchain = ctx.toolchains["@rules_pkg//toolchains/git:git_toolchain_type"]
- available = toolchain and toolchain.git.valid
- return [config_common.FeatureFlagInfo(
- value = ("1" if available else "0"),
- )]
-
-is_git_available = rule(
- implementation = _is_git_available_impl,
- attrs = {},
- toolchains = ["@rules_pkg//toolchains/git:git_toolchain_type"],
-)
diff --git a/toolchains/git/git_configure.bzl b/toolchains/git/git_configure.bzl
deleted file mode 100644
index c1f9a0e..0000000
--- a/toolchains/git/git_configure.bzl
+++ /dev/null
@@ -1,78 +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.
-"""Repository rule to autoconfigure a toolchain using the system git."""
-
-def _write_build(rctx, path, workspace_dir):
- if not path:
- path = ""
- rctx.template(
- "BUILD",
- Label("//toolchains/git:BUILD.tpl"),
- substitutions = {
- "{GENERATOR}": "@rules_pkg//toolchains/git/git_configure.bzl%find_system_git",
- "{GIT_PATH}": str(path),
- "{GIT_ROOT}": workspace_dir,
- },
- executable = False,
- )
-
-def _find_system_git_impl(rctx):
- git_path = rctx.which("git")
- if rctx.attr.verbose:
- if git_path:
- print("Found git at '%s'" % git_path) # buildifier: disable=print
- else:
- print("No system git found.") # buildifier: disable=print
-
- # In a conventional setup the directory of the WORKSPACE file is under the git client.
- # So we use the absolute path to WORKSPACE dir as a surrogate for git-ness.
- ws_dir = str(rctx.path(rctx.attr.workspace_file).dirname.realpath)
- if rctx.attr.verbose:
- print("Found WORKSPACE in", ws_dir) # buildifier: disable=print
- _write_build(rctx = rctx, path = git_path, workspace_dir = ws_dir)
-
-_find_system_git = repository_rule(
- implementation = _find_system_git_impl,
- doc = """Create a repository that defines an git toolchain based on the system git.""",
- local = True,
- attrs = {
- "workspace_file": attr.label(
- doc = "Reference to calling repository WORKSPACE file.",
- allow_single_file = True,
- mandatory = True,
- ),
- "verbose": attr.bool(
- doc = "If true, print status messages.",
- ),
- },
-)
-
-def experimental_find_system_git(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("//:WORKSPACE")
- _find_system_git(name = name, workspace_file = workspace_file, verbose = verbose)
- native.register_toolchains(
- "@%s//:git_auto_toolchain" % name,
- "@rules_pkg//toolchains/git:git_missing_toolchain",
- )
diff --git a/toolchains/rpm/BUILD b/toolchains/rpm/BUILD
deleted file mode 100644
index 58ec5db..0000000
--- a/toolchains/rpm/BUILD
+++ /dev/null
@@ -1,78 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""toolchain to wrap an rpmbuild binary.
-
-Type: @rules_pkg//toolchains/rpm:rpmbuild_toolchain_type
-
-Toolchains:
-- 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
- rpmbuild_configure.bzl%find_system_rpmbuild for usage.
-"""
-
-load("//toolchains/rpm:rpmbuild.bzl", "is_rpmbuild_available", "rpmbuild_toolchain")
-
-package(default_applicable_licenses = ["//:license"])
-
-filegroup(
- name = "standard_package",
- srcs = glob([
- "*",
- ]),
- visibility = ["//distro:__pkg__"],
-)
-
-exports_files(
- glob(["*"]),
- visibility = ["//visibility:public"],
-)
-
-# Expose the availability of an actual rpmbuild as a config_setting, so we can
-# select() on it.
-config_setting(
- name = "have_rpmbuild",
- flag_values = {
- ":is_rpmbuild_available": "1",
- },
- visibility = ["//visibility:public"],
-)
-
-# Expose the availability of an actual rpmbuild as a feature flag, so we can
-# create a config_setting from it.
-is_rpmbuild_available(
- name = "is_rpmbuild_available",
- visibility = ["//:__subpackages__"],
-)
-
-toolchain_type(
- name = "rpmbuild_toolchain_type",
- visibility = ["//visibility:public"],
-)
-
-# rpmbuild_missing_toolchain provides a fallback toolchain so that toolchain
-# resolution can succeed even on platforms that do not have a working rpmbuild.
-# If this toolchain is selected, the constraint ":have_rpmbuild" will not be
-# satistifed.
-rpmbuild_toolchain(
- name = "no_rpmbuild",
-)
-
-toolchain(
- name = "rpmbuild_missing_toolchain",
- toolchain = ":no_rpmbuild",
- toolchain_type = ":rpmbuild_toolchain_type",
-)
diff --git a/toolchains/rpm/BUILD.tpl b/toolchains/rpm/BUILD.tpl
deleted file mode 100644
index ca4b218..0000000
--- a/toolchains/rpm/BUILD.tpl
+++ /dev/null
@@ -1,14 +0,0 @@
-# This content is generated by {GENERATOR}
-load("@rules_pkg//toolchains/rpm:rpmbuild.bzl", "rpmbuild_toolchain")
-
-rpmbuild_toolchain(
- name = "rpmbuild_auto",
- path = "{RPMBUILD_PATH}",
- version = "{RPMBUILD_VERSION}",
-)
-
-toolchain(
- name = "rpmbuild_auto_toolchain",
- toolchain = ":rpmbuild_auto",
- toolchain_type = "@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type",
-)
diff --git a/toolchains/rpm/rpmbuild.bzl b/toolchains/rpm/rpmbuild.bzl
deleted file mode 100644
index 3aa0ea0..0000000
--- a/toolchains/rpm/rpmbuild.bzl
+++ /dev/null
@@ -1,74 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""toolchain to provide an rpmbuild binary."""
-
-RpmbuildInfo = provider(
- doc = """Platform inde artifact.""",
- fields = {
- "name": "The name of the toolchain",
- "valid": "Is this toolchain valid and usable?",
- "label": "The path to a target I will build",
- "path": "The path to a pre-built rpmbuild",
- "version": "The version string of rpmbuild",
- },
-)
-
-def _rpmbuild_toolchain_impl(ctx):
- if ctx.attr.label and ctx.attr.path:
- fail("rpmbuild_toolchain must not specify both label and path.")
- valid = bool(ctx.attr.label) or bool(ctx.attr.path)
- toolchain_info = platform_common.ToolchainInfo(
- rpmbuild = RpmbuildInfo(
- name = str(ctx.label),
- valid = valid,
- label = ctx.attr.label,
- path = ctx.attr.path,
- version = ctx.attr.version,
- ),
- )
- return [toolchain_info]
-
-rpmbuild_toolchain = rule(
- implementation = _rpmbuild_toolchain_impl,
- attrs = {
- "label": attr.label(
- doc = "A valid label of a target to build or a prebuilt binary. Mutually exclusive with path.",
- cfg = "exec",
- executable = True,
- allow_files = True,
- ),
- "path": attr.string(
- doc = "The path to the rpmbuild executable. Mutually exclusive with label.",
- ),
- "version": attr.string(
- doc = "The version string of the rpmbuild executable. This should be manually set.",
- ),
- },
-)
-
-# Expose the presence of an rpmbuild in the resolved toolchain as a flag.
-def _is_rpmbuild_available_impl(ctx):
- toolchain = ctx.toolchains["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"].rpmbuild
- return [config_common.FeatureFlagInfo(
- value = ("1" if toolchain.valid else "0"),
- )]
-
-is_rpmbuild_available = rule(
- implementation = _is_rpmbuild_available_impl,
- attrs = {},
- toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
-)
-
-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
deleted file mode 100644
index f50a9ad..0000000
--- a/toolchains/rpm/rpmbuild_configure.bzl
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-"""Repository rule to autoconfigure a toolchain using the system rpmbuild."""
-
-def _write_build(rctx, path, version):
- if not path:
- path = ""
- rctx.template(
- "BUILD",
- Label("//toolchains/rpm:BUILD.tpl"),
- substitutions = {
- "{GENERATOR}": "@rules_pkg//toolchains/rpm/rpmbuild_configure.bzl%find_system_rpmbuild",
- "{RPMBUILD_PATH}": str(path),
- "{RPMBUILD_VERSION}": version,
- },
- executable = False,
- )
-
-def _find_system_rpmbuild_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
- version = "unknown"
- if rpmbuild_path:
- res = rctx.execute([rpmbuild_path, "--version"])
- if res.return_code == 0:
- # expect stdout like: RPM version 4.16.1.2
- parts = res.stdout.strip().split(" ")
- if parts[0] == "RPM" and parts[1] == "version":
- version = parts[2]
- _write_build(rctx = rctx, path = rpmbuild_path, version = version)
-
-_find_system_rpmbuild = repository_rule(
- implementation = _find_system_rpmbuild_impl,
- doc = """Create a repository that defines an rpmbuild toolchain based on the system rpmbuild.""",
- local = True,
- environ = ["PATH"],
- attrs = {
- "verbose": attr.bool(
- doc = "If true, print status messages.",
- ),
- },
-)
-
-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")
diff --git a/version.bzl b/version.bzl
deleted file mode 100644
index 97a72f5..0000000
--- a/version.bzl
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright 2019 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.
-"""The version of rules_pkg."""
-
-version = "0.10.0"