Upgrade rules_pkg to 4afd0b3ccd8379af11f67f7ddff525fd1a9c5834

This project was upgraded with external_updater.
Usage: tools/external_updater/updater.sh update external/bazelbuild-rules_pkg
For more info, check https://cs.android.com/android/platform/superproject/main/+/main:tools/external_updater/README.md

This updates rules_pkg from 0.10.1 to ToT. See list of changes here:
https://github.com/bazelbuild/rules_pkg/compare/0.10.1...4afd0b3ccd8379af11f67f7ddff525fd1a9c5834
In particular, we use ToT so pkg_install has the latest changes to
replace copy_to_dist_dir().

Note:
On main-kernel-build-2024, because the branch is already frozen, the
least surprising thing would be to just cherry-pick the two changes
for pkg_install(). However, main-kernel-build-2023 was recently created
to branch off main, at 4afd0b3ccd8379af11f67f7ddff525fd1a9c5834. So for
the least surprising result, and make main-kernel-build-2024 not lag
behind main-kernel-build-2023, we do a full merge in
main-kernel-build-2024 as well to update it to
4afd0b3ccd8379af11f67f7ddff525fd1a9c5834.

Bug: 331730853
Bug: 367689074
Test: TreeHugger
Change-Id: I2f5c435df91da759c7262a38ed5c14dcdee1a33f
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
index 11b04d4..94ca75a 100644
--- a/.bazelci/integration.yml
+++ b/.bazelci/integration.yml
@@ -11,7 +11,4 @@
   integration:
     name: rolling_distro
     platform: ubuntu1804
-    bazel: rolling
-    build_flags:
-    - "--noenable_bzlmod"
     <<: *common
diff --git a/.github/workflows/scorecard.yml b/.github/workflows/scorecard.yml
index 171697d..fa75f38 100644
--- a/.github/workflows/scorecard.yml
+++ b/.github/workflows/scorecard.yml
@@ -31,13 +31,16 @@
       # actions: read
 
     steps:
+      - name: Setup Node.js environment
+        uses: actions/setup-node@v4
+
       - name: "Checkout code"
-        uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
+        uses: actions/checkout@v4
         with:
           persist-credentials: false
 
       - name: "Run analysis"
-        uses: ossf/scorecard-action@e38b1902ae4f44df626f11ba0734b14fb91f8f86 # v2.1.2
+        uses: ossf/scorecard-action@v2
         with:
           results_file: results.sarif
           results_format: sarif
@@ -59,7 +62,7 @@
       # 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
+        uses: actions/upload-artifact@v3
         with:
           name: SARIF file
           path: results.sarif
diff --git a/METADATA b/METADATA
index 5aed98d..91ec30b 100644
--- a/METADATA
+++ b/METADATA
@@ -1,6 +1,6 @@
 # This project was upgraded with external_updater.
 # Usage: tools/external_updater/updater.sh update external/bazelbuild-rules_pkg
-# For more info, check https://cs.android.com/android/platform/superproject/+/main:tools/external_updater/README.md
+# For more info, check https://cs.android.com/android/platform/superproject/main/+/main:tools/external_updater/README.md
 
 name: "rules_pkg"
 description: "Bazel package building"
@@ -8,12 +8,12 @@
   license_type: NOTICE
   last_upgrade_date {
     year: 2024
-    month: 4
-    day: 4
+    month: 8
+    day: 28
   }
   identifier {
     type: "Git"
     value: "https://github.com/bazelbuild/rules_pkg"
-    version: "0.10.1"
+    version: "4afd0b3ccd8379af11f67f7ddff525fd1a9c5834"
   }
 }
diff --git a/MODULE.bazel b/MODULE.bazel
index 16d9549..50f7590 100644
--- a/MODULE.bazel
+++ b/MODULE.bazel
@@ -1,19 +1,19 @@
 module(
     name = "rules_pkg",
-    version = "0.10.1",  # Must sync with version.bzl.
+    version = "1.0.1",  # Must sync with version.bzl.
     compatibility_level = 1,
     repo_name = "rules_pkg",
 )
 
 # Do not update to newer versions until you need a specific new feature.
-bazel_dep(name = "rules_license", version = "0.0.4")
-bazel_dep(name = "rules_python", version = "0.24.0")
-bazel_dep(name = "bazel_skylib", version = "1.2.0")
+bazel_dep(name = "rules_license", version = "0.0.7")
+bazel_dep(name = "rules_python", version = "0.31.0")
+bazel_dep(name = "bazel_skylib", version = "1.4.2")
 
 # Only for development
-bazel_dep(name = "platforms", version = "0.0.5", dev_dependency = True)
-bazel_dep(name = "stardoc", version = "0.5.3", dev_dependency = True)
+bazel_dep(name = "platforms", version = "0.0.9", dev_dependency = True)
 bazel_dep(name = "rules_cc", version = "0.0.9", dev_dependency = True)
+bazel_dep(name = "stardoc", version = "0.6.2", dev_dependency = True)
 
 # Find the system rpmbuild if one is available.
 find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod", dev_dependency = True)
diff --git a/WORKSPACE b/WORKSPACE
index fe06be5..fee32ef 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -36,10 +36,9 @@
 
 http_archive(
     name = "platforms",
-    sha256 = "3a561c99e7bdbe9173aa653fd579fe849f1d8d67395780ab4770b1f381431d51",
+    sha256 = "5eda539c841265031c2f82d8ae7a3a6490bd62176e0c038fc469eabf91f6149b",
     urls = [
-        "https://mirror.bazel.build/github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
-        "https://github.com/bazelbuild/platforms/releases/download/0.0.7/platforms-0.0.7.tar.gz",
+        "https://github.com/bazelbuild/platforms/releases/download/0.0.9/platforms-0.0.9.tar.gz",
     ],
 )
 
diff --git a/doc_build/BUILD b/doc_build/BUILD
index 725da8e..9a7ec75 100644
--- a/doc_build/BUILD
+++ b/doc_build/BUILD
@@ -20,7 +20,7 @@
 """
 
 load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
-load("@bazel_stardoc//stardoc:stardoc.bzl", "stardoc")
+load("@stardoc//stardoc:stardoc.bzl", "stardoc")
 load("//:version.bzl", "version")
 
 package(default_applicable_licenses = ["//:license"])
@@ -53,6 +53,7 @@
     ("common", None),
     ("pkg_deb", "//pkg/private/deb:deb.bzl"),
     ("pkg_deb_impl", "//pkg/private/deb:deb.bzl"),
+    ("pkg_sub_rpm", "//pkg:rpm_pfg.bzl"),
     ("pkg_rpm", "//pkg:rpm_pfg.bzl"),
     ("pkg_tar", "//pkg/private/tar:tar.bzl"),
     ("pkg_tar_impl", "//pkg/private/tar:tar.bzl"),
diff --git a/doc_build/merge.py b/doc_build/merge.py
index 02eb8f1..ae67d10 100755
--- a/doc_build/merge.py
+++ b/doc_build/merge.py
@@ -23,7 +23,7 @@
 import typing
 
 
-ID_RE = re.compile(r'<a id="#(.*)">')
+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>')
@@ -78,9 +78,10 @@
   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)
+    print("We didn't use all the @wraps()", wrapper_map, file=sys.stderr)
     sys.exit(1)
+  return 0
 
 
 if __name__ == '__main__':
-  main(sys.argv)
+  sys.exit(main(sys.argv))
diff --git a/docs/1.0.1/reference.md b/docs/1.0.1/reference.md
new file mode 100755
index 0000000..e6eb916
--- /dev/null
+++ b/docs/1.0.1/reference.md
@@ -0,0 +1,770 @@
+# rules_pkg - 1.0.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-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>,
+             <a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>,
+             <a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>, <a href="#pkg_deb-license">license</a>,
+             <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-package">package</a>, <a href="#pkg_deb-package_file_name">package_file_name</a>, <a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>,
+             <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>, <a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-section">section</a>, <a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>,
+             <a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>)
+</pre>
+
+Create a Debian package.
+
+This rule produces 2 artifacts: a .deb and a .changes file. The DefaultInfo will
+include both. If you need downstream rule to specifically depend on only the .deb or
+.changes file then you can use `filegroup` to select distinct output groups.
+
+**OutputGroupInfo**
+- `out` the Debian package or a symlink to the actual package.
+- `deb` the package with any precise file name created with `package_file_name`.
+- `changes` the .changes file.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_deb-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_deb-data"></a>data |  A tar file that contains the data for the debian package.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_deb-out"></a>out |  See [Common Attributes](#out)   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_deb-architecture"></a>architecture |  Package architecture. Must not be used with architecture_file.   | String | optional |  `"all"`  |
+| <a id="pkg_deb-architecture_file"></a>architecture_file |  File that contains the package architecture. Must not be used with architecture.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-breaks"></a>breaks |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-built_using"></a>built_using |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | String | optional |  `""`  |
+| <a id="pkg_deb-built_using_file"></a>built_using_file |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-changelog"></a>changelog |  The package changelog. See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-conffiles"></a>conffiles |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-conffiles_file"></a>conffiles_file |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-config"></a>config |  config file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-conflicts"></a>conflicts |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-depends"></a>depends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-depends_file"></a>depends_file |  File that contains a list of package dependencies. Must not be used with `depends`. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-description"></a>description |  The package description. Must not be used with `description_file`.   | String | optional |  `""`  |
+| <a id="pkg_deb-description_file"></a>description_file |  The package description. Must not be used with `description`.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-distribution"></a>distribution |  "distribution: See http://www.debian.org/doc/debian-policy.   | String | optional |  `"unstable"`  |
+| <a id="pkg_deb-enhances"></a>enhances |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-homepage"></a>homepage |  The homepage of the project.   | String | optional |  `""`  |
+| <a id="pkg_deb-license"></a>license |  The license of the project.   | String | optional |  `""`  |
+| <a id="pkg_deb-maintainer"></a>maintainer |  The maintainer of the package.   | String | required |  |
+| <a id="pkg_deb-package"></a>package |  The name of the package   | String | required |  |
+| <a id="pkg_deb-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name). Default: "{package}-{version}-{architecture}.deb   | String | optional |  `""`  |
+| <a id="pkg_deb-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-postinst"></a>postinst |  The post-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-postrm"></a>postrm |  The post-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-predepends"></a>predepends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-preinst"></a>preinst |  "The pre-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-prerm"></a>prerm |  The pre-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-priority"></a>priority |  The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities.   | String | optional |  `""`  |
+| <a id="pkg_deb-provides"></a>provides |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-recommends"></a>recommends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-replaces"></a>replaces |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-section"></a>section |  The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections.   | String | optional |  `""`  |
+| <a id="pkg_deb-suggests"></a>suggests |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-templates"></a>templates |  templates file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-triggers"></a>triggers |  triggers file for configuring installation events exchanged by packages. See https://wiki.debian.org/DpkgTriggers.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-urgency"></a>urgency |  "urgency: See http://www.debian.org/doc/debian-policy.   | String | optional |  `"medium"`  |
+| <a id="pkg_deb-version"></a>version |  Package version. Must not be used with `version_file`.   | String | optional |  `""`  |
+| <a id="pkg_deb-version_file"></a>version_file |  File that contains the package version. Must not be used with `version`.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Provides rules for creating RPM packages via pkg_filegroup and friends.
+
+pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will
+find to convenient to use the one provided with their system. To enable that
+toolchain add the following stanza to WORKSPACE:
+
+```
+# Find rpmbuild if it exists.
+load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
+find_system_rpmbuild(name="rules_pkg_rpmbuild")
+```
+
+<a id="pkg_sub_rpm"></a>
+
+## pkg_sub_rpm
+
+<pre>
+pkg_sub_rpm(<a href="#pkg_sub_rpm-name">name</a>, <a href="#pkg_sub_rpm-srcs">srcs</a>, <a href="#pkg_sub_rpm-architecture">architecture</a>, <a href="#pkg_sub_rpm-conflicts">conflicts</a>, <a href="#pkg_sub_rpm-description">description</a>, <a href="#pkg_sub_rpm-epoch">epoch</a>, <a href="#pkg_sub_rpm-group">group</a>, <a href="#pkg_sub_rpm-obsoletes">obsoletes</a>, <a href="#pkg_sub_rpm-package_name">package_name</a>,
+            <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>)
+</pre>
+
+Define a sub RPM to be built as part of a parent RPM
+
+This rule uses the outputs of the rules in `mappings.bzl` to define an sub
+RPM that will be built as part of a larger RPM defined by a `pkg_rpm` instance.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_sub_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_sub_rpm-srcs"></a>srcs |  Mapping groups to include in this RPM   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_sub_rpm-architecture"></a>architecture |  Sub RPM architecture   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-conflicts"></a>conflicts |  List of RPM capability expressions that conflict with this package   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-description"></a>description |  Multi-line description of this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-epoch"></a>epoch |  RPM `Epoch` tag for this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-group"></a>group |  Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag.  Other distributions may require it, but it is harmless in any case.   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-obsoletes"></a>obsoletes |  List of RPM capability expressions that this package obsoletes   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-package_name"></a>package_name |  name of the subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-post_scriptlet"></a>post_scriptlet |  RPM `%post` scriplet for this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-provides"></a>provides |  List of RPM capability expressions that this package provides   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-requires"></a>requires |  List of RPM capability expressions that this package requires   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-summary"></a>summary |  Sub RPM `Summary` tag   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-version"></a>version |  RPM `Version` tag for this subrpm   | String | optional |  `""`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Provides rules for creating RPM packages via pkg_filegroup and friends.
+
+pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will
+find to convenient to use the one provided with their system. To enable that
+toolchain add the following stanza to WORKSPACE:
+
+```
+# Find rpmbuild if it exists.
+load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
+find_system_rpmbuild(name="rules_pkg_rpmbuild")
+```
+
+<a id="pkg_rpm"></a>
+
+## pkg_rpm
+
+<pre>
+pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>,
+        <a href="#pkg_rpm-debuginfo">debuginfo</a>, <a href="#pkg_rpm-defines">defines</a>, <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-epoch">epoch</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>,
+        <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>, <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>,
+        <a href="#pkg_rpm-posttrans_scriptlet">posttrans_scriptlet</a>, <a href="#pkg_rpm-posttrans_scriptlet_file">posttrans_scriptlet_file</a>, <a href="#pkg_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_rpm-postun_scriptlet_file">postun_scriptlet_file</a>,
+        <a href="#pkg_rpm-pre_scriptlet">pre_scriptlet</a>, <a href="#pkg_rpm-pre_scriptlet_file">pre_scriptlet_file</a>, <a href="#pkg_rpm-preun_scriptlet">preun_scriptlet</a>, <a href="#pkg_rpm-preun_scriptlet_file">preun_scriptlet_file</a>, <a href="#pkg_rpm-provides">provides</a>, <a href="#pkg_rpm-release">release</a>,
+        <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-requires">requires</a>, <a href="#pkg_rpm-requires_contextual">requires_contextual</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>,
+        <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_template">spec_template</a>, <a href="#pkg_rpm-subrpms">subrpms</a>, <a href="#pkg_rpm-summary">summary</a>, <a href="#pkg_rpm-url">url</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
+</pre>
+
+Creates an RPM format package via `pkg_filegroup` and friends.
+
+The uses the outputs of the rules in `mappings.bzl` to construct arbitrary
+RPM packages.  Attributes of this rule provide preamble information and
+scriptlets, which are then used to compose a valid RPM spec file.
+
+This rule will fail at analysis time if:
+
+- Any `srcs` input creates the same destination, regardless of other
+  attributes.
+
+This rule only functions on UNIXy platforms. The following tools must be
+available on your system for this to function properly:
+
+- `rpmbuild` (as specified in `rpmbuild_path`, or available in `$PATH`)
+
+- GNU coreutils.  BSD coreutils may work, but are not tested.
+
+To set RPM file attributes (like `%config` and friends), set the
+`rpm_filetag` in corresponding packaging rule (`pkg_files`, etc).  The value
+is prepended with "%" and added to the `%files` list, for example:
+
+```
+attrs = {"rpm_filetag": ("config(missingok, noreplace)",)},
+```
+
+Is the equivalent to `%config(missingok, noreplace)` in the `%files` list.
+
+This rule produces 2 artifacts: an .rpm and a .changes file. The DefaultInfo will
+include both. If you need downstream rule to specifically depend on only the .rpm or
+.changes file then you can use `filegroup` to select distinct output groups.
+
+**OutputGroupInfo**
+- `out` the RPM or a symlink to the actual package.
+- `rpm` the package with any precise file name created with `package_file_name`.
+- `changes` the .changes file.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_rpm-srcs"></a>srcs |  Mapping groups to include in this RPM.<br><br>These are typically brought into life as `pkg_filegroup`s.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_rpm-architecture"></a>architecture |  Package architecture.<br><br>This currently sets the `BuildArch` tag, which influences the output architecture of the package.<br><br>Typically, `BuildArch` only needs to be set when the package is known to be cross-platform (e.g. written in an interpreted language), or, less common, when it is known that the application is only valid for specific architectures.<br><br>When no attribute is provided, this will default to your host's architecture.  This is usually what you want.   | String | optional |  `""`  |
+| <a id="pkg_rpm-binary_payload_compression"></a>binary_payload_compression |  Compression mode used for this RPM<br><br>Must be a form that `rpmbuild(8)` knows how to process, which will depend on the version of `rpmbuild` in use.  The value corresponds to the `%_binary_payload` macro and is set on the `rpmbuild(8)` command line if provided.<br><br>Some examples of valid values (which may not be supported on your system) can be found [here](https://git.io/JU9Wg).  On CentOS systems (also likely Red Hat and Fedora), you can find some supported values by looking for `%_binary_payload` in `/usr/lib/rpm/macros`.  Other systems have similar files and configurations.<br><br>If not provided, the compression mode will be computed by `rpmbuild` itself.  Defaults may vary per distribution or build of `rpm`; consult the relevant documentation for more details.<br><br>WARNING: Bazel is currently not aware of action threading requirements for non-test actions.  Using threaded compression may result in overcommitting your system.   | String | optional |  `""`  |
+| <a id="pkg_rpm-changelog"></a>changelog |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-conflicts"></a>conflicts |  List of capabilities that conflict with this package when it is installed.<br><br>Corresponds to the "Conflicts" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-debug"></a>debug |  Debug the RPM helper script and RPM generation   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-debuginfo"></a>debuginfo |  Enable generation of debuginfo RPMs<br><br>For supported platforms this will enable the generation of debuginfo RPMs adjacent to the regular RPMs.  Currently this is supported by Fedora 40, CentOS7 and CentOS Stream 9.   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-defines"></a>defines |  Additional definitions to pass to rpmbuild   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_rpm-description"></a>description |  Multi-line description of this package, corresponds to RPM %description.<br><br>Exactly one of `description` or `description_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-description_file"></a>description_file |  File containing a multi-line description of this package, corresponds to RPM %description.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-epoch"></a>epoch |  Optional; RPM "Epoch" tag.   | String | optional |  `""`  |
+| <a id="pkg_rpm-group"></a>group |  Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag.  Other distributions may require it, but it is harmless in any case.   | String | optional |  `""`  |
+| <a id="pkg_rpm-license"></a>license |  RPM "License" tag.<br><br>The software license for the code distributed in this package.<br><br>The underlying RPM builder requires you to put something here; if your package is not going to be distributed, feel free to set this to something like "Internal".   | String | required |  |
+| <a id="pkg_rpm-obsoletes"></a>obsoletes |  List of rpm capability expressions that this package obsoletes.<br><br>Corresponds to the "Obsoletes" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-package_file_name"></a>package_file_name |  See 'Common Attributes' in the rules_pkg reference.<br><br>If this is not provided, the package file given a NVRA-style (name-version-release.arch) output, which is preferred by most RPM repositories.   | String | optional |  `""`  |
+| <a id="pkg_rpm-package_name"></a>package_name |  Optional; RPM name override.<br><br>If not provided, the `name` attribute of this rule will be used instead.<br><br>This influences values like the spec file name.   | String | optional |  `""`  |
+| <a id="pkg_rpm-package_variables"></a>package_variables |  See 'Common Attributes' in the rules_pkg reference   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet |  RPM `%post` scriptlet.  Currently only allowed to be a shell script.<br><br>`post_scriptlet` and `post_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file |  File containing the RPM `%post` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet |  RPM `%posttrans` scriptlet.  Currently only allowed to be a shell script.<br><br>`posttrans_scriptlet` and `posttrans_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file |  File containing the RPM `%posttrans` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet |  RPM `%postun` scriptlet.  Currently only allowed to be a shell script.<br><br>`postun_scriptlet` and `postun_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file |  File containing the RPM `%postun` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet |  RPM `%pre` scriptlet.  Currently only allowed to be a shell script.<br><br>`pre_scriptlet` and `pre_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file |  File containing the RPM `%pre` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet |  RPM `%preun` scriptlet.  Currently only allowed to be a shell script.<br><br>`preun_scriptlet` and `preun_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file |  File containing the RPM `%preun` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-provides"></a>provides |  List of rpm capabilities that this package provides.<br><br>Corresponds to the "Provides" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-release"></a>release |  RPM "Release" tag<br><br>Exactly one of `release` or `release_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-release_file"></a>release_file |  File containing RPM "Release" tag.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-requires"></a>requires |  List of rpm capability expressions that this package requires.<br><br>Corresponds to the "Requires" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-requires_contextual"></a>requires_contextual |  Contextualized requirement specifications<br><br>This is a map of various properties (often scriptlet types) to capability name specifications, e.g.:<br><br><pre><code class="language-python">{"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}</code></pre><br><br>Which causes the below to be added to the spec file's preamble:<br><br><pre><code>Requires(pre): GConf2&#10;Requires(post): GConf2&#10;Requires(postun): GConf2</code></pre><br><br>This is most useful for ensuring that required tools exist when scriptlets are run, although there may be other valid use cases. Valid keys for this attribute may include, but are not limited to:<br><br>- `pre` - `post` - `preun` - `postun` - `pretrans` - `posttrans`<br><br>For capabilities that are always required by packages at runtime, use the `requires` attribute instead.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br>NOTE: `pkg_rpm` does not check if the keys of this dictionary are acceptable to `rpm(8)`.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional |  `{}`  |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path |  Path to a `rpmbuild` binary.  Deprecated in favor of the rpmbuild toolchain   | String | optional |  `""`  |
+| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch |  Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps.<br><br>Negative values (like the default) disable this feature.   | Integer | optional |  `-1`  |
+| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file |  File containing the SOURCE_DATE_EPOCH value.<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-spec_template"></a>spec_template |  Spec file template.<br><br>Use this if you need to add additional logic to your spec files that is not available by default.<br><br>In most cases, you should not need to override this attribute.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_pkg//pkg/rpm:template.spec.tpl"`  |
+| <a id="pkg_rpm-subrpms"></a>subrpms |  Sub RPMs to build with this RPM<br><br>A list of `pkg_sub_rpm` instances that can be used to create sub RPMs as part of the overall package build.<br><br>NOTE: use of `subrpms` is incompatible with the legacy `spec_file` mode   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_rpm-summary"></a>summary |  RPM "Summary" tag.<br><br>One-line summary of this package.  Must not contain newlines.   | String | required |  |
+| <a id="pkg_rpm-url"></a>url |  RPM "URL" tag; this project/vendor's home on the Internet.   | String | optional |  `""`  |
+| <a id="pkg_rpm-version"></a>version |  RPM "Version" tag.<br><br>Exactly one of `version` or `version_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-version_file"></a>version_file |  File containing RPM "Version" tag.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Rules for making .tar files.
+
+<a id="pkg_tar"></a>
+
+## pkg_tar
+
+<pre>
+pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-allow_duplicates_from_deps">allow_duplicates_from_deps</a>,
+             <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-create_parents">create_parents</a>,
+             <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-owner">owner</a>,
+             <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>,
+             <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-stamp">stamp</a>,
+             <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
+</pre>
+
+
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_tar-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_tar-deps"></a>deps |  tar files which will be unpacked and repacked into the archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_tar-srcs"></a>srcs |  Inputs which will become part of the tar archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_tar-out"></a>out |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_tar-allow_duplicates_from_deps"></a>allow_duplicates_from_deps |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-compressor"></a>compressor |  External tool which can compress the archive.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-compressor_args"></a>compressor_args |  Arg list for `compressor`.   | String | optional |  `""`  |
+| <a id="pkg_tar-create_parents"></a>create_parents |  -   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-empty_dirs"></a>empty_dirs |  -   | List of strings | optional |  `[]`  |
+| <a id="pkg_tar-empty_files"></a>empty_files |  -   | List of strings | optional |  `[]`  |
+| <a id="pkg_tar-extension"></a>extension |  -   | String | optional |  `"tar"`  |
+| <a id="pkg_tar-files"></a>files |  Obsolete. Do not use.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-include_runfiles"></a>include_runfiles |  Include runfiles for executables. These appear as they would in bazel-bin.For example: 'path/to/myprog.runfiles/path/to/my_data.txt'.   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-mode"></a>mode |  -   | String | optional |  `"0555"`  |
+| <a id="pkg_tar-modes"></a>modes |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-mtime"></a>mtime |  -   | Integer | optional |  `-1`  |
+| <a id="pkg_tar-owner"></a>owner |  Default numeric owner.group to apply to files when not set via pkg_attributes.   | String | optional |  `"0.0"`  |
+| <a id="pkg_tar-ownername"></a>ownername |  -   | String | optional |  `"."`  |
+| <a id="pkg_tar-ownernames"></a>ownernames |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-owners"></a>owners |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-package_dir"></a>package_dir |  Prefix to be prepend to all paths written.<br><br>This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See [package_file_name](#package_file_name) for examples.   | String | optional |  `""`  |
+| <a id="pkg_tar-package_dir_file"></a>package_dir_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional |  `""`  |
+| <a id="pkg_tar-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-portable_mtime"></a>portable_mtime |  -   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-remap_paths"></a>remap_paths |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div>   | Integer | optional |  `0`  |
+| <a id="pkg_tar-strip_prefix"></a>strip_prefix |  (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)   | String | optional |  `""`  |
+| <a id="pkg_tar-symlinks"></a>symlinks |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Zip archive creation rule and associated logic.
+
+<a id="pkg_zip"></a>
+
+## pkg_zip
+
+<pre>
+pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>,
+             <a href="#pkg_zip-compression_type">compression_type</a>, <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>,
+             <a href="#pkg_zip-package_variables">package_variables</a>, <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>)
+</pre>
+
+
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_zip-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_zip-srcs"></a>srcs |  List of files that should be included in the archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_zip-out"></a>out |  output file name. Default: name + ".zip".   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_zip-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional |  `True`  |
+| <a id="pkg_zip-compression_level"></a>compression_level |  The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used   | Integer | optional |  `6`  |
+| <a id="pkg_zip-compression_type"></a>compression_type |  The compression to use. Note that lzma and bzip2 might not be supported by all readers. The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED   | String | optional |  `"deflated"`  |
+| <a id="pkg_zip-include_runfiles"></a>include_runfiles |  See standard attributes.   | Boolean | optional |  `False`  |
+| <a id="pkg_zip-mode"></a>mode |  The default mode for all files in the archive.   | String | optional |  `"0555"`  |
+| <a id="pkg_zip-package_dir"></a>package_dir |  Prefix to be prepend to all paths written. The name may contain variables, same as [package_file_name](#package_file_name)   | String | optional |  `"/"`  |
+| <a id="pkg_zip-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional |  `""`  |
+| <a id="pkg_zip-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_zip-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag.   | Integer | optional |  `0`  |
+| <a id="pkg_zip-strip_prefix"></a>strip_prefix |  -   | String | optional |  `""`  |
+| <a id="pkg_zip-timestamp"></a>timestamp |  Time stamp to place on all files in the archive, expressed as seconds since the Unix Epoch, as per RFC 3339.  The default is January 01, 1980, 00:00 UTC.<br><br>Due to limitations in the format of zip files, values before Jan 1, 1980 will be rounded up and the precision in the zip file is limited to a granularity of 2 seconds.   | Integer | optional |  `315532800`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Package creation helper mapping rules.
+
+This module declares Provider interfaces and rules for specifying the contents
+of packages in a package-type-agnostic way.  The main rules supported here are
+the following:
+
+- `pkg_files` describes destinations for rule outputs
+- `pkg_mkdirs` describes directory structures
+- `pkg_mklink` describes symbolic links
+- `pkg_filegroup` creates groupings of above to add to packages
+
+Rules that actually make use of the outputs of the above rules are not specified
+here.
+
+<a id="filter_directory"></a>
+
+## filter_directory
+
+<pre>
+filter_directory(<a href="#filter_directory-name">name</a>, <a href="#filter_directory-src">src</a>, <a href="#filter_directory-excludes">excludes</a>, <a href="#filter_directory-outdir_name">outdir_name</a>, <a href="#filter_directory-prefix">prefix</a>, <a href="#filter_directory-renames">renames</a>, <a href="#filter_directory-strip_prefix">strip_prefix</a>)
+</pre>
+
+Transform directories (TreeArtifacts) using pkg_filegroup-like semantics.
+
+Effective order of operations:
+
+1) Files are `exclude`d
+2) `renames` _or_ `strip_prefix` is applied.
+3) `prefix` is applied
+
+In particular, if a `rename` applies to an individual file, `strip_prefix`
+will not be applied to that particular file.
+
+Each non-`rename``d path will look like this:
+
+```
+$OUTPUT_DIR/$PREFIX/$FILE_WITHOUT_STRIP_PREFIX
+```
+
+Each `rename`d path will look like this:
+
+```
+$OUTPUT_DIR/$PREFIX/$FILE_RENAMED
+```
+
+If an operation cannot be applied (`strip_prefix`) to any component in the
+directory, or if one is unused (`exclude`, `rename`), the underlying command
+will fail.  See the individual attributes for details.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="filter_directory-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="filter_directory-src"></a>src |  Directory (TreeArtifact) to process.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="filter_directory-excludes"></a>excludes |  Files to exclude from the output directory.<br><br>Each element must refer to an individual file in `src`.<br><br>All exclusions must be used.   | List of strings | optional |  `[]`  |
+| <a id="filter_directory-outdir_name"></a>outdir_name |  Name of output directory (otherwise defaults to the rule's name)   | String | optional |  `""`  |
+| <a id="filter_directory-prefix"></a>prefix |  Prefix to add to all paths in the output directory.<br><br>This does not include the output directory name, which will be added regardless.   | String | optional |  `""`  |
+| <a id="filter_directory-renames"></a>renames |  Files to rename in the output directory.<br><br>Keys are destinations, values are sources prior to any path modifications (e.g. via `prefix` or `strip_prefix`).  Files that are `exclude`d must not be renamed.<br><br>This currently only operates on individual files.  `strip_prefix` does not apply to them.<br><br>All renames must be used.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="filter_directory-strip_prefix"></a>strip_prefix |  Prefix to remove from all paths in the output directory.<br><br>Must apply to all paths in the directory, even those rename'd.   | String | optional |  `""`  |
+
+
+<a id="pkg_filegroup"></a>
+
+## pkg_filegroup
+
+<pre>
+pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-srcs">srcs</a>, <a href="#pkg_filegroup-prefix">prefix</a>)
+</pre>
+
+Package contents grouping rule.
+
+This rule represents a collection of packaging specifications (e.g. those
+created by `pkg_files`, `pkg_mklink`, etc.) that have something in common,
+such as a prefix or a human-readable category.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_filegroup-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_filegroup-srcs"></a>srcs |  A list of packaging specifications to be grouped together.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_filegroup-prefix"></a>prefix |  A prefix to prepend to provided paths, applied like so:<br><br>- For files and directories, this is simply prepended to the destination - For symbolic links, this is prepended to the "destination" part.   | String | optional |  `""`  |
+
+
+<a id="pkg_files"></a>
+
+## pkg_files
+
+<pre>
+pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-include_runfiles">include_runfiles</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>)
+</pre>
+
+General-purpose package target-to-destination mapping rule.
+
+This rule provides a specification for the locations and attributes of
+targets when they are packaged. No outputs are created other than Providers
+that are intended to be consumed by other packaging rules, such as
+`pkg_rpm`. `pkg_files` targets may be consumed by other `pkg_files` or
+`pkg_filegroup` to build up complex layouts, or directly by top level
+packaging rules such as `pkg_files`.
+
+Consumers of `pkg_files`s will, where possible, create the necessary
+directory structure for your files so you do not have to unless you have
+special requirements.  Consult `pkg_mkdirs` for more details.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_files-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_files-srcs"></a>srcs |  Files/Labels to include in the outputs of these rules   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_files-attributes"></a>attributes |  Attributes to set on packaged files.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the file's mode will be set to UNIX "0644", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_files-excludes"></a>excludes |  List of files or labels to exclude from the inputs to this rule.<br><br>Mostly useful for removing files from generated outputs or preexisting `filegroup`s.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_files-include_runfiles"></a>include_runfiles |  Add runfiles for all srcs.<br><br>The runfiles are in the paths that Bazel uses. For example, for the target `//my_prog:foo`, we would see files under paths like `foo.runfiles/<repo name>/my_prog/<file>`   | Boolean | optional |  `False`  |
+| <a id="pkg_files-prefix"></a>prefix |  Installation prefix.<br><br>This may be an arbitrary string, but it should be understandable by the packaging system you are using to have the desired outcome.  For example, RPM macros like `%{_libdir}` may work correctly in paths for RPM packages, not, say, Debian packages.<br><br>If any part of the directory structure of the computed destination of a file provided to `pkg_filegroup` or any similar rule does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`).<br><br>It is possible to establish directory structures with arbitrary permissions using `pkg_mkdirs`.   | String | optional |  `""`  |
+| <a id="pkg_files-renames"></a>renames |  Destination override map.<br><br>This attribute allows the user to override destinations of files in `pkg_file`s relative to the `prefix` attribute.  Keys to the dict are source files/labels, values are destinations relative to the `prefix`, ignoring whatever value was provided for `strip_prefix`.<br><br>If the key refers to a TreeArtifact (directory output), you may specify the constant `REMOVE_BASE_DIRECTORY` as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the `prefix` and `strip_prefix` attributes), not the directory name.<br><br>The following keys are rejected:<br><br>- Any label that expands to more than one file (mappings must be   one-to-one).<br><br>- Any label or file that was either not provided or explicitly   `exclude`d.<br><br>The following values result in undefined behavior:<br><br>- "" (the empty string)<br><br>- "."<br><br>- Anything containing ".."   | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional |  `{}`  |
+| <a id="pkg_files-strip_prefix"></a>strip_prefix |  What prefix of a file's path to discard prior to installation.<br><br>This specifies what prefix of an incoming file's path should not be included in the output package at after being appended to the install prefix (the `prefix` attribute).  Note that this is only applied to full directory names, see `strip_prefix` for more details.<br><br>Use the `strip_prefix` struct to define this attribute.  If this attribute is not specified, all directories will be stripped from all files prior to being included in packages (`strip_prefix.files_only()`).<br><br>If prefix stripping fails on any file provided in `srcs`, the build will fail.<br><br>Note that this only functions on paths that are known at analysis time.  Specifically, this will not consider directories within TreeArtifacts (directory outputs), or the directories themselves. See also #269.   | String | optional |  `"."`  |
+
+
+<a id="pkg_mkdirs"></a>
+
+## pkg_mkdirs
+
+<pre>
+pkg_mkdirs(<a href="#pkg_mkdirs-name">name</a>, <a href="#pkg_mkdirs-attributes">attributes</a>, <a href="#pkg_mkdirs-dirs">dirs</a>)
+</pre>
+
+Defines creation and ownership of directories in packages
+
+Use this if:
+
+1) You need to create an empty directory in your package.
+
+2) Your package needs to explicitly own a directory, even if it already owns
+   files in those directories.
+
+3) You need nonstandard permissions (typically, not "0755") on a directory
+   in your package.
+
+For some package management systems (e.g. RPM), directory ownership (2) may
+imply additional semantics.  Consult your package manager's and target
+distribution's documentation for more details.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_mkdirs-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_mkdirs-attributes"></a>attributes |  Attributes to set on packaged directories.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the directory's mode will be set to UNIX "0755", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_mkdirs-dirs"></a>dirs |  Directory names to make within the package<br><br>If any part of the requested directory structure does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`).   | List of strings | required |  |
+
+
+<a id="pkg_mklink_impl"></a>
+
+## pkg_mklink_impl
+
+<pre>
+pkg_mklink_impl(<a href="#pkg_mklink_impl-name">name</a>, <a href="#pkg_mklink_impl-attributes">attributes</a>, <a href="#pkg_mklink_impl-link_name">link_name</a>, <a href="#pkg_mklink_impl-target">target</a>)
+</pre>
+
+Define a symlink  within packages
+
+This rule results in the creation of a single link within a package.
+
+Symbolic links specified by this rule may point at files/directories outside of the
+package, or otherwise left dangling.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_mklink_impl-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_mklink_impl-attributes"></a>attributes |  Attributes to set on packaged symbolic links.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>Symlink permissions may have different meanings depending on your host operating system; consult its documentation for more details.<br><br>If not otherwise overridden, the link's mode will be set to UNIX "0777", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_mklink_impl-link_name"></a>link_name |  Link "destination", a path within the package.<br><br>This is the actual created symbolic link.<br><br>If the directory structure provided by this attribute is not otherwise created when exist within the package when it is built, it will be created implicitly, much like with `pkg_files`.<br><br>This path may be prefixed or rooted by grouping or packaging rules.   | String | required |  |
+| <a id="pkg_mklink_impl-target"></a>target |  Link "target", a path on the filesystem.<br><br>This is what the link "points" to, and may point to an arbitrary filesystem path, even relative paths.   | String | required |  |
+
+
+<a id="pkg_attributes"></a>
+
+## pkg_attributes
+
+<pre>
+pkg_attributes(<a href="#pkg_attributes-mode">mode</a>, <a href="#pkg_attributes-user">user</a>, <a href="#pkg_attributes-group">group</a>, <a href="#pkg_attributes-uid">uid</a>, <a href="#pkg_attributes-gid">gid</a>, <a href="#pkg_attributes-kwargs">kwargs</a>)
+</pre>
+
+Format attributes for use in package mapping rules.
+
+If "mode" is not provided, it will default to the mapping rule's default
+mode.  These vary per mapping rule; consult the respective documentation for
+more details.
+
+Not providing any of "user", "group", "uid", or "gid" will result in the package
+builder choosing one for you.  The chosen value should not be relied upon.
+
+Well-known attributes outside of the above are documented in the rules_pkg
+reference.
+
+This is the only supported means of passing in attributes to package mapping
+rules (e.g. `pkg_files`).
+
+
+**PARAMETERS**
+
+
+| Name  | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="pkg_attributes-mode"></a>mode |  string: UNIXy octal permissions, as a string.   |  `None` |
+| <a id="pkg_attributes-user"></a>user |  string: Filesystem owning user name.   |  `None` |
+| <a id="pkg_attributes-group"></a>group |  string: Filesystem owning group name.   |  `None` |
+| <a id="pkg_attributes-uid"></a>uid |  int: Filesystem owning user id.   |  `None` |
+| <a id="pkg_attributes-gid"></a>gid |  int: Filesystem owning group id.   |  `None` |
+| <a id="pkg_attributes-kwargs"></a>kwargs |  any other desired attributes.   |  none |
+
+**RETURNS**
+
+A value usable in the "attributes" attribute in package mapping rules.
+
+
+<a id="pkg_mklink"></a>
+
+## pkg_mklink
+
+<pre>
+pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">link_name</a>, <a href="#pkg_mklink-target">target</a>, <a href="#pkg_mklink-attributes">attributes</a>, <a href="#pkg_mklink-src">src</a>, <a href="#pkg_mklink-kwargs">kwargs</a>)
+</pre>
+
+Create a symlink.
+
+Wraps [pkg_mklink_impl](#pkg_mklink_impl)
+
+
+**PARAMETERS**
+
+
+| Name  | Description | Default Value |
+| :------------- | :------------- | :------------- |
+| <a id="pkg_mklink-name"></a>name |  target name   |  none |
+| <a id="pkg_mklink-link_name"></a>link_name |  the path in the package that should point to the target.   |  none |
+| <a id="pkg_mklink-target"></a>target |  target path that the link should point to.   |  none |
+| <a id="pkg_mklink-attributes"></a>attributes |  file attributes.   |  `None` |
+| <a id="pkg_mklink-src"></a>src |   -    |  `None` |
+| <a id="pkg_mklink-kwargs"></a>kwargs |   -    |  none |
+
+
+<a id="strip_prefix.files_only"></a>
+
+## strip_prefix.files_only
+
+<pre>
+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 |   -    |  `""` |
+
+
+<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 |   -    |  `""` |
+
+
+
+<!-- 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-data">data</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>,
+        <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_file">spec_file</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
+</pre>
+
+Legacy version
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_rpm-data"></a>data |  -   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_rpm-architecture"></a>architecture |  -   | String | optional |  `"all"`  |
+| <a id="pkg_rpm-changelog"></a>changelog |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-debug"></a>debug |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-release"></a>release |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-release_file"></a>release_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch |  -   | Integer | optional |  `0`  |
+| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-spec_file"></a>spec_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_rpm-version"></a>version |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-version_file"></a>version_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+
+
+
diff --git a/docs/index.md b/docs/index.md
index b7b0259..89e83f6 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -16,6 +16,7 @@
 consult more than one place to get a complete picture.
 
 *   [Latest Snapshot at head](latest.md)
+*   [Version 1.0.0](1.0.0/reference.md)
 *   [Version 0.10.0](0.10.0/reference.md)
 *   [Version 0.9.1](0.9.1/reference.md)
 *   [Version 0.8.0](0.8.0/reference.md)
diff --git a/docs/latest.md b/docs/latest.md
index eea6982..d2fb47f 100755
--- a/docs/latest.md
+++ b/docs/latest.md
@@ -1,4 +1,4 @@
-# rules_pkg - 0.10.1
+# rules_pkg - 1.0.1
 
 <div class="toc">
   <h2>Common Attributes</h2>
@@ -85,78 +85,76 @@
 
 Rule for creating Debian packages.
 
-<a id="#pkg_deb"></a>
+<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>,
+pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>,
+             <a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>,
+             <a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>, <a href="#pkg_deb-license">license</a>,
+             <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-package">package</a>, <a href="#pkg_deb-package_file_name">package_file_name</a>, <a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>,
              <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>, <a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-section">section</a>, <a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>,
              <a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>)
 </pre>
 
+Create a Debian package.
 
-    Create a Debian package.
+This rule produces 2 artifacts: a .deb and a .changes file. The DefaultInfo will
+include both. If you need downstream rule to specifically depend on only the .deb or
+.changes file then you can use `filegroup` to select distinct output groups.
 
-    This rule produces 2 artifacts: a .deb and a .changes file. The DefaultInfo will
-    include both. If you need downstream rule to specifically depend on only the .deb or
-    .changes file then you can use `filegroup` to select distinct output groups.
-
-    **OutputGroupInfo**
-    - `out` the Debian package or a symlink to the actual package.
-    - `deb` the package with any precise file name created with `package_file_name`.
-    - `changes` the .changes file.
-    
+**OutputGroupInfo**
+- `out` the Debian package or a symlink to the actual package.
+- `deb` the package with any precise file name created with `package_file_name`.
+- `changes` the .changes file.
 
 **ATTRIBUTES**
 
 
 | Name  | Description | Type | Mandatory | Default |
 | :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_deb-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
-| <a id="pkg_deb-architecture"></a>architecture |  Package architecture. Must not be used with architecture_file.   | String | optional | "all" |
-| <a id="pkg_deb-architecture_file"></a>architecture_file |  File that contains the package architecture.             Must not be used with architecture.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-breaks"></a>breaks |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional | [] |
-| <a id="pkg_deb-built_using"></a>built_using |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | String | optional | "" |
-| <a id="pkg_deb-built_using_file"></a>built_using_file |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-changelog"></a>changelog |  The package changelog.             See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-conffiles"></a>conffiles |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | List of strings | optional | [] |
-| <a id="pkg_deb-conffiles_file"></a>conffiles_file |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-config"></a>config |  config file used for debconf integration.             See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-conflicts"></a>conflicts |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional | [] |
-| <a id="pkg_deb-data"></a>data |  A tar file that contains the data for the debian package.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required |  |
-| <a id="pkg_deb-depends"></a>depends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional | [] |
-| <a id="pkg_deb-depends_file"></a>depends_file |  File that contains a list of package dependencies. Must not be used with <code>depends</code>.             See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-description"></a>description |  The package description. Must not be used with <code>description_file</code>.   | String | optional | "" |
-| <a id="pkg_deb-description_file"></a>description_file |  The package description. Must not be used with <code>description</code>.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_deb-distribution"></a>distribution |  "distribution: See http://www.debian.org/doc/debian-policy.   | String | optional | "unstable" |
-| <a id="pkg_deb-enhances"></a>enhances |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional | [] |
-| <a id="pkg_deb-homepage"></a>homepage |  The homepage of the project.   | String | optional | "" |
-| <a id="pkg_deb-license"></a>license |  The license of the project.   | String | optional | "" |
+| <a id="pkg_deb-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_deb-data"></a>data |  A tar file that contains the data for the debian package.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_deb-out"></a>out |  See [Common Attributes](#out)   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_deb-architecture"></a>architecture |  Package architecture. Must not be used with architecture_file.   | String | optional |  `"all"`  |
+| <a id="pkg_deb-architecture_file"></a>architecture_file |  File that contains the package architecture. Must not be used with architecture.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-breaks"></a>breaks |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-built_using"></a>built_using |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | String | optional |  `""`  |
+| <a id="pkg_deb-built_using_file"></a>built_using_file |  The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file).   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-changelog"></a>changelog |  The package changelog. See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-conffiles"></a>conffiles |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-conffiles_file"></a>conffiles_file |  The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-config"></a>config |  config file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-conflicts"></a>conflicts |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-depends"></a>depends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-depends_file"></a>depends_file |  File that contains a list of package dependencies. Must not be used with `depends`. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-description"></a>description |  The package description. Must not be used with `description_file`.   | String | optional |  `""`  |
+| <a id="pkg_deb-description_file"></a>description_file |  The package description. Must not be used with `description`.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-distribution"></a>distribution |  "distribution: See http://www.debian.org/doc/debian-policy.   | String | optional |  `"unstable"`  |
+| <a id="pkg_deb-enhances"></a>enhances |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-homepage"></a>homepage |  The homepage of the project.   | String | optional |  `""`  |
+| <a id="pkg_deb-license"></a>license |  The license of the project.   | String | optional |  `""`  |
 | <a id="pkg_deb-maintainer"></a>maintainer |  The maintainer of the package.   | String | required |  |
-| <a id="pkg_deb-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 |
+| <a id="pkg_deb-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name). Default: "{package}-{version}-{architecture}.deb   | String | optional |  `""`  |
+| <a id="pkg_deb-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-postinst"></a>postinst |  The post-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-postrm"></a>postrm |  The post-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-predepends"></a>predepends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-preinst"></a>preinst |  "The pre-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-prerm"></a>prerm |  The pre-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-priority"></a>priority |  The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities.   | String | optional |  `""`  |
+| <a id="pkg_deb-provides"></a>provides |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-recommends"></a>recommends |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-replaces"></a>replaces |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-section"></a>section |  The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections.   | String | optional |  `""`  |
+| <a id="pkg_deb-suggests"></a>suggests |  See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps.   | List of strings | optional |  `[]`  |
+| <a id="pkg_deb-templates"></a>templates |  templates file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-triggers"></a>triggers |  triggers file for configuring installation events exchanged by packages. See https://wiki.debian.org/DpkgTriggers.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_deb-urgency"></a>urgency |  "urgency: See http://www.debian.org/doc/debian-policy.   | String | optional |  `"medium"`  |
+| <a id="pkg_deb-version"></a>version |  Package version. Must not be used with `version_file`.   | String | optional |  `""`  |
+| <a id="pkg_deb-version_file"></a>version_file |  File that contains the package version. Must not be used with `version`.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
 
 
 
@@ -174,103 +172,154 @@
 find_system_rpmbuild(name="rules_pkg_rpmbuild")
 ```
 
+<a id="pkg_sub_rpm"></a>
 
-<a id="#pkg_rpm"></a>
-
-## pkg_rpm
+## pkg_sub_rpm
 
 <pre>
-pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-defines">defines</a>,
-        <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>, <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>,
-        <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>, <a href="#pkg_rpm-posttrans_scriptlet">posttrans_scriptlet</a>,
-        <a href="#pkg_rpm-posttrans_scriptlet_file">posttrans_scriptlet_file</a>, <a href="#pkg_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_rpm-postun_scriptlet_file">postun_scriptlet_file</a>, <a href="#pkg_rpm-pre_scriptlet">pre_scriptlet</a>,
-        <a href="#pkg_rpm-pre_scriptlet_file">pre_scriptlet_file</a>, <a href="#pkg_rpm-preun_scriptlet">preun_scriptlet</a>, <a href="#pkg_rpm-preun_scriptlet_file">preun_scriptlet_file</a>, <a href="#pkg_rpm-provides">provides</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>,
-        <a href="#pkg_rpm-requires">requires</a>, <a href="#pkg_rpm-requires_contextual">requires_contextual</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>,
-        <a href="#pkg_rpm-spec_template">spec_template</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-summary">summary</a>, <a href="#pkg_rpm-url">url</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
+pkg_sub_rpm(<a href="#pkg_sub_rpm-name">name</a>, <a href="#pkg_sub_rpm-srcs">srcs</a>, <a href="#pkg_sub_rpm-architecture">architecture</a>, <a href="#pkg_sub_rpm-conflicts">conflicts</a>, <a href="#pkg_sub_rpm-description">description</a>, <a href="#pkg_sub_rpm-epoch">epoch</a>, <a href="#pkg_sub_rpm-group">group</a>, <a href="#pkg_sub_rpm-obsoletes">obsoletes</a>, <a href="#pkg_sub_rpm-package_name">package_name</a>,
+            <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>)
 </pre>
 
-Creates an RPM format package via `pkg_filegroup` and friends.
+Define a sub RPM to be built as part of a parent RPM
 
-    The uses the outputs of the rules in `mappings.bzl` to construct arbitrary
-    RPM packages.  Attributes of this rule provide preamble information and
-    scriptlets, which are then used to compose a valid RPM spec file.
-
-    This rule will fail at analysis time if:
-
-    - Any `srcs` input creates the same destination, regardless of other
-      attributes.
-
-    This rule only functions on UNIXy platforms. The following tools must be
-    available on your system for this to function properly:
-
-    - `rpmbuild` (as specified in `rpmbuild_path`, or available in `$PATH`)
-
-    - GNU coreutils.  BSD coreutils may work, but are not tested.
-
-    To set RPM file attributes (like `%config` and friends), set the
-    `rpm_filetag` in corresponding packaging rule (`pkg_files`, etc).  The value
-    is prepended with "%" and added to the `%files` list, for example:
-
-    ```
-    attrs = {"rpm_filetag": ("config(missingok, noreplace)",)},
-    ```
-
-    Is the equivalent to `%config(missingok, noreplace)` in the `%files` list.
-
-    This rule produces 2 artifacts: an .rpm and a .changes file. The DefaultInfo will
-    include both. If you need downstream rule to specifically depend on only the .rpm or
-    .changes file then you can use `filegroup` to select distinct output groups.
-
-    **OutputGroupInfo**
-    - `out` the RPM or a symlink to the actual package.
-    - `rpm` the package with any precise file name created with `package_file_name`.
-    - `changes` the .changes file.
-    
+This rule uses the outputs of the rules in `mappings.bzl` to define an sub
+RPM that will be built as part of a larger RPM defined by a `pkg_rpm` instance.
 
 **ATTRIBUTES**
 
 
 | Name  | Description | Type | Mandatory | Default |
 | :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
-| <a id="pkg_rpm-architecture"></a>architecture |  Package architecture.<br><br>            This currently sets the <code>BuildArch</code> tag, which influences the output             architecture of the package.<br><br>            Typically, <code>BuildArch</code> only needs to be set when the package is             known to be cross-platform (e.g. written in an interpreted             language), or, less common, when it is known that the application is             only valid for specific architectures.<br><br>            When no attribute is provided, this will default to your host's             architecture.  This is usually what you want.   | String | optional | "" |
-| <a id="pkg_rpm-binary_payload_compression"></a>binary_payload_compression |  Compression mode used for this RPM<br><br>            Must be a form that <code>rpmbuild(8)</code> knows how to process, which will             depend on the version of <code>rpmbuild</code> in use.  The value corresponds             to the <code>%_binary_payload</code> macro and is set on the <code>rpmbuild(8)</code>             command line if provided.<br><br>            Some examples of valid values (which may not be supported on your             system) can be found [here](https://git.io/JU9Wg).  On CentOS             systems (also likely Red Hat and Fedora), you can find some             supported values by looking for <code>%_binary_payload</code> in             <code>/usr/lib/rpm/macros</code>.  Other systems have similar files and             configurations.<br><br>            If not provided, the compression mode will be computed by <code>rpmbuild</code>             itself.  Defaults may vary per distribution or build of <code>rpm</code>;             consult the relevant documentation for more details.<br><br>            WARNING: Bazel is currently not aware of action threading requirements             for non-test actions.  Using threaded compression may result in             overcommitting your system.   | String | optional | "" |
-| <a id="pkg_rpm-changelog"></a>changelog |  -   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-conflicts"></a>conflicts |  List of capabilities that conflict with this package when it is installed.<br><br>            Corresponds to the "Conflicts" preamble tag.<br><br>            See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional | [] |
-| <a id="pkg_rpm-debug"></a>debug |  Debug the RPM helper script and RPM generation   | Boolean | optional | False |
-| <a id="pkg_rpm-defines"></a>defines |  Additional definitions to pass to rpmbuild   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_rpm-description"></a>description |  Multi-line description of this package, corresponds to RPM %description.<br><br>            Exactly one of <code>description</code> or <code>description_file</code> must be provided.   | String | optional | "" |
-| <a id="pkg_rpm-description_file"></a>description_file |  File containing a multi-line description of this package, corresponds to RPM             %description.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-group"></a>group |  Optional; RPM "Group" tag.<br><br>            NOTE: some distributions (as of writing, Fedora &gt; 17 and CentOS/RHEL             &gt; 5) have deprecated this tag.  Other distributions may require it,             but it is harmless in any case.   | String | optional | "" |
-| <a id="pkg_rpm-license"></a>license |  RPM "License" tag.<br><br>            The software license for the code distributed in this package.<br><br>            The underlying RPM builder requires you to put something here; if             your package is not going to be distributed, feel free to set this             to something like "Internal".   | String | required |  |
-| <a id="pkg_rpm-obsoletes"></a>obsoletes |  List of rpm capability expressions that this package obsoletes.<br><br>            Corresponds to the "Obsoletes" preamble tag.<br><br>            See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional | [] |
-| <a id="pkg_rpm-package_file_name"></a>package_file_name |  See 'Common Attributes' in the rules_pkg reference.<br><br>            If this is not provided, the package file given a NVRA-style             (name-version-release.arch) output, which is preferred by most RPM             repositories.   | String | optional | "" |
-| <a id="pkg_rpm-package_name"></a>package_name |  Optional; RPM name override.<br><br>            If not provided, the <code>name</code> attribute of this rule will be used             instead.<br><br>            This influences values like the spec file name.   | String | optional | "" |
-| <a id="pkg_rpm-package_variables"></a>package_variables |  See 'Common Attributes' in the rules_pkg reference   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet |  RPM <code>%post</code> scriptlet.  Currently only allowed to be a shell script.<br><br>            <code>post_scriptlet</code> and <code>post_scriptlet_file</code> are mutually exclusive.   | String | optional | "" |
-| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file |  File containing the RPM <code>%post</code> scriptlet   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet |  RPM <code>%posttrans</code> scriptlet.  Currently only allowed to be a shell script.<br><br>            <code>posttrans_scriptlet</code> and <code>posttrans_scriptlet_file</code> are mutually exclusive.   | String | optional | "" |
-| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file |  File containing the RPM <code>%posttrans</code> scriptlet   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet |  RPM <code>%postun</code> scriptlet.  Currently only allowed to be a shell script.<br><br>            <code>postun_scriptlet</code> and <code>postun_scriptlet_file</code> are mutually exclusive.   | String | optional | "" |
-| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file |  File containing the RPM <code>%postun</code> scriptlet   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet |  RPM <code>%pre</code> scriptlet.  Currently only allowed to be a shell script.<br><br>            <code>pre_scriptlet</code> and <code>pre_scriptlet_file</code> are mutually exclusive.   | String | optional | "" |
-| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file |  File containing the RPM <code>%pre</code> scriptlet   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet |  RPM <code>%preun</code> scriptlet.  Currently only allowed to be a shell script.<br><br>            <code>preun_scriptlet</code> and <code>preun_scriptlet_file</code> are mutually exclusive.   | String | optional | "" |
-| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file |  File containing the RPM <code>%preun</code> scriptlet   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-provides"></a>provides |  List of rpm capabilities that this package provides.<br><br>            Corresponds to the "Provides" preamble tag.<br><br>            See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional | [] |
-| <a id="pkg_rpm-release"></a>release |  RPM "Release" tag<br><br>            Exactly one of <code>release</code> or <code>release_file</code> must be provided.   | String | optional | "" |
-| <a id="pkg_rpm-release_file"></a>release_file |  File containing RPM "Release" tag.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-requires"></a>requires |  List of rpm capability expressions that this package requires.<br><br>            Corresponds to the "Requires" preamble tag.<br><br>            See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional | [] |
-| <a id="pkg_rpm-requires_contextual"></a>requires_contextual |  Contextualized requirement specifications<br><br>            This is a map of various properties (often scriptlet types) to             capability name specifications, e.g.:<br><br>            <pre><code>python             {"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}             </code></pre><br><br>            Which causes the below to be added to the spec file's preamble:<br><br>            <pre><code>             Requires(pre): GConf2             Requires(post): GConf2             Requires(postun): GConf2             </code></pre><br><br>            This is most useful for ensuring that required tools exist when             scriptlets are run, although there may be other valid use cases.             Valid keys for this attribute may include, but are not limited to:<br><br>            - <code>pre</code>             - <code>post</code>             - <code>preun</code>             - <code>postun</code>             - <code>pretrans</code>             - <code>posttrans</code><br><br>            For capabilities that are always required by packages at runtime,             use the <code>requires</code> attribute instead.<br><br>            See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br>            NOTE: <code>pkg_rpm</code> does not check if the keys of this dictionary are             acceptable to <code>rpm(8)</code>.   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> List of strings</a> | optional | {} |
-| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path |  Path to a <code>rpmbuild</code> binary.  Deprecated in favor of the rpmbuild toolchain   | String | optional | "" |
-| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch |  Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds<br><br>            Implicitly sets the <code>%clamp_mtime_to_source_date_epoch</code> in the             subordinate call to <code>rpmbuild</code> to facilitate more consistent in-RPM             file timestamps.<br><br>            Negative values (like the default) disable this feature.   | Integer | optional | -1 |
-| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file |  File containing the SOURCE_DATE_EPOCH value.<br><br>            Implicitly sets the <code>%clamp_mtime_to_source_date_epoch</code> in the             subordinate call to <code>rpmbuild</code> to facilitate more consistent in-RPM             file timestamps.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_rpm-spec_template"></a>spec_template |  Spec file template.<br><br>            Use this if you need to add additional logic to your spec files that             is not available by default.<br><br>            In most cases, you should not need to override this attribute.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | //pkg/rpm:template.spec.tpl |
-| <a id="pkg_rpm-srcs"></a>srcs |  Mapping groups to include in this RPM.<br><br>            These are typically brought into life as <code>pkg_filegroup</code>s.   | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | required |  |
-| <a id="pkg_rpm-summary"></a>summary |  RPM "Summary" tag.<br><br>            One-line summary of this package.  Must not contain newlines.   | String | required |  |
-| <a id="pkg_rpm-url"></a>url |  RPM "URL" tag; this project/vendor's home on the Internet.   | String | optional | "" |
-| <a id="pkg_rpm-version"></a>version |  RPM "Version" tag.<br><br>            Exactly one of <code>version</code> or <code>version_file</code> must be provided.   | String | optional | "" |
-| <a id="pkg_rpm-version_file"></a>version_file |  File containing RPM "Version" tag.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
+| <a id="pkg_sub_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_sub_rpm-srcs"></a>srcs |  Mapping groups to include in this RPM   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_sub_rpm-architecture"></a>architecture |  Sub RPM architecture   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-conflicts"></a>conflicts |  List of RPM capability expressions that conflict with this package   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-description"></a>description |  Multi-line description of this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-epoch"></a>epoch |  RPM `Epoch` tag for this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-group"></a>group |  Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag.  Other distributions may require it, but it is harmless in any case.   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-obsoletes"></a>obsoletes |  List of RPM capability expressions that this package obsoletes   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-package_name"></a>package_name |  name of the subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-post_scriptlet"></a>post_scriptlet |  RPM `%post` scriplet for this subrpm   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-provides"></a>provides |  List of RPM capability expressions that this package provides   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-requires"></a>requires |  List of RPM capability expressions that this package requires   | List of strings | optional |  `[]`  |
+| <a id="pkg_sub_rpm-summary"></a>summary |  Sub RPM `Summary` tag   | String | optional |  `""`  |
+| <a id="pkg_sub_rpm-version"></a>version |  RPM `Version` tag for this subrpm   | String | optional |  `""`  |
+
+
+
+<!-- Generated with Stardoc: http://skydoc.bazel.build -->
+
+Provides rules for creating RPM packages via pkg_filegroup and friends.
+
+pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will
+find to convenient to use the one provided with their system. To enable that
+toolchain add the following stanza to WORKSPACE:
+
+```
+# Find rpmbuild if it exists.
+load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
+find_system_rpmbuild(name="rules_pkg_rpmbuild")
+```
+
+<a id="pkg_rpm"></a>
+
+## pkg_rpm
+
+<pre>
+pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>,
+        <a href="#pkg_rpm-debuginfo">debuginfo</a>, <a href="#pkg_rpm-defines">defines</a>, <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-epoch">epoch</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>,
+        <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>, <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>,
+        <a href="#pkg_rpm-posttrans_scriptlet">posttrans_scriptlet</a>, <a href="#pkg_rpm-posttrans_scriptlet_file">posttrans_scriptlet_file</a>, <a href="#pkg_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_rpm-postun_scriptlet_file">postun_scriptlet_file</a>,
+        <a href="#pkg_rpm-pre_scriptlet">pre_scriptlet</a>, <a href="#pkg_rpm-pre_scriptlet_file">pre_scriptlet_file</a>, <a href="#pkg_rpm-preun_scriptlet">preun_scriptlet</a>, <a href="#pkg_rpm-preun_scriptlet_file">preun_scriptlet_file</a>, <a href="#pkg_rpm-provides">provides</a>, <a href="#pkg_rpm-release">release</a>,
+        <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-requires">requires</a>, <a href="#pkg_rpm-requires_contextual">requires_contextual</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>,
+        <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_template">spec_template</a>, <a href="#pkg_rpm-subrpms">subrpms</a>, <a href="#pkg_rpm-summary">summary</a>, <a href="#pkg_rpm-url">url</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
+</pre>
+
+Creates an RPM format package via `pkg_filegroup` and friends.
+
+The uses the outputs of the rules in `mappings.bzl` to construct arbitrary
+RPM packages.  Attributes of this rule provide preamble information and
+scriptlets, which are then used to compose a valid RPM spec file.
+
+This rule will fail at analysis time if:
+
+- Any `srcs` input creates the same destination, regardless of other
+  attributes.
+
+This rule only functions on UNIXy platforms. The following tools must be
+available on your system for this to function properly:
+
+- `rpmbuild` (as specified in `rpmbuild_path`, or available in `$PATH`)
+
+- GNU coreutils.  BSD coreutils may work, but are not tested.
+
+To set RPM file attributes (like `%config` and friends), set the
+`rpm_filetag` in corresponding packaging rule (`pkg_files`, etc).  The value
+is prepended with "%" and added to the `%files` list, for example:
+
+```
+attrs = {"rpm_filetag": ("config(missingok, noreplace)",)},
+```
+
+Is the equivalent to `%config(missingok, noreplace)` in the `%files` list.
+
+This rule produces 2 artifacts: an .rpm and a .changes file. The DefaultInfo will
+include both. If you need downstream rule to specifically depend on only the .rpm or
+.changes file then you can use `filegroup` to select distinct output groups.
+
+**OutputGroupInfo**
+- `out` the RPM or a symlink to the actual package.
+- `rpm` the package with any precise file name created with `package_file_name`.
+- `changes` the .changes file.
+
+**ATTRIBUTES**
+
+
+| Name  | Description | Type | Mandatory | Default |
+| :------------- | :------------- | :------------- | :------------- | :------------- |
+| <a id="pkg_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_rpm-srcs"></a>srcs |  Mapping groups to include in this RPM.<br><br>These are typically brought into life as `pkg_filegroup`s.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_rpm-architecture"></a>architecture |  Package architecture.<br><br>This currently sets the `BuildArch` tag, which influences the output architecture of the package.<br><br>Typically, `BuildArch` only needs to be set when the package is known to be cross-platform (e.g. written in an interpreted language), or, less common, when it is known that the application is only valid for specific architectures.<br><br>When no attribute is provided, this will default to your host's architecture.  This is usually what you want.   | String | optional |  `""`  |
+| <a id="pkg_rpm-binary_payload_compression"></a>binary_payload_compression |  Compression mode used for this RPM<br><br>Must be a form that `rpmbuild(8)` knows how to process, which will depend on the version of `rpmbuild` in use.  The value corresponds to the `%_binary_payload` macro and is set on the `rpmbuild(8)` command line if provided.<br><br>Some examples of valid values (which may not be supported on your system) can be found [here](https://git.io/JU9Wg).  On CentOS systems (also likely Red Hat and Fedora), you can find some supported values by looking for `%_binary_payload` in `/usr/lib/rpm/macros`.  Other systems have similar files and configurations.<br><br>If not provided, the compression mode will be computed by `rpmbuild` itself.  Defaults may vary per distribution or build of `rpm`; consult the relevant documentation for more details.<br><br>WARNING: Bazel is currently not aware of action threading requirements for non-test actions.  Using threaded compression may result in overcommitting your system.   | String | optional |  `""`  |
+| <a id="pkg_rpm-changelog"></a>changelog |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-conflicts"></a>conflicts |  List of capabilities that conflict with this package when it is installed.<br><br>Corresponds to the "Conflicts" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-debug"></a>debug |  Debug the RPM helper script and RPM generation   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-debuginfo"></a>debuginfo |  Enable generation of debuginfo RPMs<br><br>For supported platforms this will enable the generation of debuginfo RPMs adjacent to the regular RPMs.  Currently this is supported by Fedora 40, CentOS7 and CentOS Stream 9.   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-defines"></a>defines |  Additional definitions to pass to rpmbuild   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_rpm-description"></a>description |  Multi-line description of this package, corresponds to RPM %description.<br><br>Exactly one of `description` or `description_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-description_file"></a>description_file |  File containing a multi-line description of this package, corresponds to RPM %description.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-epoch"></a>epoch |  Optional; RPM "Epoch" tag.   | String | optional |  `""`  |
+| <a id="pkg_rpm-group"></a>group |  Optional; RPM "Group" tag.<br><br>NOTE: some distributions (as of writing, Fedora > 17 and CentOS/RHEL > 5) have deprecated this tag.  Other distributions may require it, but it is harmless in any case.   | String | optional |  `""`  |
+| <a id="pkg_rpm-license"></a>license |  RPM "License" tag.<br><br>The software license for the code distributed in this package.<br><br>The underlying RPM builder requires you to put something here; if your package is not going to be distributed, feel free to set this to something like "Internal".   | String | required |  |
+| <a id="pkg_rpm-obsoletes"></a>obsoletes |  List of rpm capability expressions that this package obsoletes.<br><br>Corresponds to the "Obsoletes" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-package_file_name"></a>package_file_name |  See 'Common Attributes' in the rules_pkg reference.<br><br>If this is not provided, the package file given a NVRA-style (name-version-release.arch) output, which is preferred by most RPM repositories.   | String | optional |  `""`  |
+| <a id="pkg_rpm-package_name"></a>package_name |  Optional; RPM name override.<br><br>If not provided, the `name` attribute of this rule will be used instead.<br><br>This influences values like the spec file name.   | String | optional |  `""`  |
+| <a id="pkg_rpm-package_variables"></a>package_variables |  See 'Common Attributes' in the rules_pkg reference   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-post_scriptlet"></a>post_scriptlet |  RPM `%post` scriptlet.  Currently only allowed to be a shell script.<br><br>`post_scriptlet` and `post_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-post_scriptlet_file"></a>post_scriptlet_file |  File containing the RPM `%post` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-posttrans_scriptlet"></a>posttrans_scriptlet |  RPM `%posttrans` scriptlet.  Currently only allowed to be a shell script.<br><br>`posttrans_scriptlet` and `posttrans_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-posttrans_scriptlet_file"></a>posttrans_scriptlet_file |  File containing the RPM `%posttrans` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-postun_scriptlet"></a>postun_scriptlet |  RPM `%postun` scriptlet.  Currently only allowed to be a shell script.<br><br>`postun_scriptlet` and `postun_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-postun_scriptlet_file"></a>postun_scriptlet_file |  File containing the RPM `%postun` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-pre_scriptlet"></a>pre_scriptlet |  RPM `%pre` scriptlet.  Currently only allowed to be a shell script.<br><br>`pre_scriptlet` and `pre_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-pre_scriptlet_file"></a>pre_scriptlet_file |  File containing the RPM `%pre` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-preun_scriptlet"></a>preun_scriptlet |  RPM `%preun` scriptlet.  Currently only allowed to be a shell script.<br><br>`preun_scriptlet` and `preun_scriptlet_file` are mutually exclusive.   | String | optional |  `""`  |
+| <a id="pkg_rpm-preun_scriptlet_file"></a>preun_scriptlet_file |  File containing the RPM `%preun` scriptlet   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-provides"></a>provides |  List of rpm capabilities that this package provides.<br><br>Corresponds to the "Provides" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-release"></a>release |  RPM "Release" tag<br><br>Exactly one of `release` or `release_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-release_file"></a>release_file |  File containing RPM "Release" tag.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-requires"></a>requires |  List of rpm capability expressions that this package requires.<br><br>Corresponds to the "Requires" preamble tag.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html   | List of strings | optional |  `[]`  |
+| <a id="pkg_rpm-requires_contextual"></a>requires_contextual |  Contextualized requirement specifications<br><br>This is a map of various properties (often scriptlet types) to capability name specifications, e.g.:<br><br><pre><code class="language-python">{"pre": ["GConf2"],"post": ["GConf2"], "postun": ["GConf2"]}</code></pre><br><br>Which causes the below to be added to the spec file's preamble:<br><br><pre><code>Requires(pre): GConf2&#10;Requires(post): GConf2&#10;Requires(postun): GConf2</code></pre><br><br>This is most useful for ensuring that required tools exist when scriptlets are run, although there may be other valid use cases. Valid keys for this attribute may include, but are not limited to:<br><br>- `pre` - `post` - `preun` - `postun` - `pretrans` - `posttrans`<br><br>For capabilities that are always required by packages at runtime, use the `requires` attribute instead.<br><br>See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html<br><br>NOTE: `pkg_rpm` does not check if the keys of this dictionary are acceptable to `rpm(8)`.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional |  `{}`  |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path |  Path to a `rpmbuild` binary.  Deprecated in favor of the rpmbuild toolchain   | String | optional |  `""`  |
+| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch |  Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps.<br><br>Negative values (like the default) disable this feature.   | Integer | optional |  `-1`  |
+| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file |  File containing the SOURCE_DATE_EPOCH value.<br><br>Implicitly sets the `%clamp_mtime_to_source_date_epoch` in the subordinate call to `rpmbuild` to facilitate more consistent in-RPM file timestamps.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-spec_template"></a>spec_template |  Spec file template.<br><br>Use this if you need to add additional logic to your spec files that is not available by default.<br><br>In most cases, you should not need to override this attribute.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_pkg//pkg/rpm:template.spec.tpl"`  |
+| <a id="pkg_rpm-subrpms"></a>subrpms |  Sub RPMs to build with this RPM<br><br>A list of `pkg_sub_rpm` instances that can be used to create sub RPMs as part of the overall package build.<br><br>NOTE: use of `subrpms` is incompatible with the legacy `spec_file` mode   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_rpm-summary"></a>summary |  RPM "Summary" tag.<br><br>One-line summary of this package.  Must not contain newlines.   | String | required |  |
+| <a id="pkg_rpm-url"></a>url |  RPM "URL" tag; this project/vendor's home on the Internet.   | String | optional |  `""`  |
+| <a id="pkg_rpm-version"></a>version |  RPM "Version" tag.<br><br>Exactly one of `version` or `version_file` must be provided.   | String | optional |  `""`  |
+| <a id="pkg_rpm-version_file"></a>version_file |  File containing RPM "Version" tag.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
 
 
 
@@ -278,15 +327,16 @@
 
 Rules for making .tar files.
 
-<a id="#pkg_tar"></a>
+<a id="pkg_tar"></a>
 
 ## pkg_tar
 
 <pre>
-pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-deps">deps</a>,
-             <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-out">out</a>,
-             <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>,
-             <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-stamp">stamp</a>,
+pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-allow_duplicates_from_deps">allow_duplicates_from_deps</a>,
+             <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-create_parents">create_parents</a>,
+             <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-owner">owner</a>,
+             <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>,
+             <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-stamp">stamp</a>,
              <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
 </pre>
 
@@ -297,35 +347,37 @@
 
 | Name  | Description | Type | Mandatory | Default |
 | :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_tar-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
-| <a id="pkg_tar-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional | True |
-| <a id="pkg_tar-compressor"></a>compressor |  External tool which can compress the archive.   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-compressor_args"></a>compressor_args |  Arg list for <code>compressor</code>.   | String | optional | "" |
-| <a id="pkg_tar-deps"></a>deps |  tar files which will be unpacked and repacked into the archive.   | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
-| <a id="pkg_tar-empty_dirs"></a>empty_dirs |  -   | List of strings | optional | [] |
-| <a id="pkg_tar-empty_files"></a>empty_files |  -   | List of strings | optional | [] |
-| <a id="pkg_tar-extension"></a>extension |  -   | String | optional | "tar" |
-| <a id="pkg_tar-files"></a>files |  Obsolete. Do not use.   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: Label -> String</a> | optional | {} |
-| <a id="pkg_tar-include_runfiles"></a>include_runfiles |  Include runfiles for executables. These appear as they would in bazel-bin.For example: 'path/to/myprog.runfiles/path/to/my_data.txt'.   | Boolean | optional | False |
-| <a id="pkg_tar-mode"></a>mode |  -   | String | optional | "0555" |
-| <a id="pkg_tar-modes"></a>modes |  -   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-mtime"></a>mtime |  -   | Integer | optional | -1 |
-| <a id="pkg_tar-out"></a>out |  -   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required |  |
-| <a id="pkg_tar-owner"></a>owner |  Default numeric owner.group to apply to files when not set via pkg_attributes.   | String | optional | "0.0" |
-| <a id="pkg_tar-ownername"></a>ownername |  -   | String | optional | "." |
-| <a id="pkg_tar-ownernames"></a>ownernames |  -   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-owners"></a>owners |  -   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-package_dir"></a>package_dir |  Prefix to be prepend to all paths written.<br><br>            This is applied as a final step, while writing to the archive.             Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir.             The value may contain variables. See [package_file_name](#package_file_name) for examples.   | String | optional | "" |
-| <a id="pkg_tar-package_dir_file"></a>package_dir_file |  -   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional | "" |
-| <a id="pkg_tar-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_tar-portable_mtime"></a>portable_mtime |  -   | Boolean | optional | True |
-| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional | False |
-| <a id="pkg_tar-remap_paths"></a>remap_paths |  -   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
-| <a id="pkg_tar-srcs"></a>srcs |  Inputs which will become part of the tar archive.   | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
-| <a id="pkg_tar-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div>   | Integer | optional | 0 |
-| <a id="pkg_tar-strip_prefix"></a>strip_prefix |  (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)   | String | optional | "" |
-| <a id="pkg_tar-symlinks"></a>symlinks |  -   | <a href="https://bazel.build/docs/skylark/lib/dict.html">Dictionary: String -> String</a> | optional | {} |
+| <a id="pkg_tar-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_tar-deps"></a>deps |  tar files which will be unpacked and repacked into the archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_tar-srcs"></a>srcs |  Inputs which will become part of the tar archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_tar-out"></a>out |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_tar-allow_duplicates_from_deps"></a>allow_duplicates_from_deps |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-compressor"></a>compressor |  External tool which can compress the archive.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-compressor_args"></a>compressor_args |  Arg list for `compressor`.   | String | optional |  `""`  |
+| <a id="pkg_tar-create_parents"></a>create_parents |  -   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-empty_dirs"></a>empty_dirs |  -   | List of strings | optional |  `[]`  |
+| <a id="pkg_tar-empty_files"></a>empty_files |  -   | List of strings | optional |  `[]`  |
+| <a id="pkg_tar-extension"></a>extension |  -   | String | optional |  `"tar"`  |
+| <a id="pkg_tar-files"></a>files |  Obsolete. Do not use.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-include_runfiles"></a>include_runfiles |  Include runfiles for executables. These appear as they would in bazel-bin.For example: 'path/to/myprog.runfiles/path/to/my_data.txt'.   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-mode"></a>mode |  -   | String | optional |  `"0555"`  |
+| <a id="pkg_tar-modes"></a>modes |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-mtime"></a>mtime |  -   | Integer | optional |  `-1`  |
+| <a id="pkg_tar-owner"></a>owner |  Default numeric owner.group to apply to files when not set via pkg_attributes.   | String | optional |  `"0.0"`  |
+| <a id="pkg_tar-ownername"></a>ownername |  -   | String | optional |  `"."`  |
+| <a id="pkg_tar-ownernames"></a>ownernames |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-owners"></a>owners |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-package_dir"></a>package_dir |  Prefix to be prepend to all paths written.<br><br>This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See [package_file_name](#package_file_name) for examples.   | String | optional |  `""`  |
+| <a id="pkg_tar-package_dir_file"></a>package_dir_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional |  `""`  |
+| <a id="pkg_tar-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_tar-portable_mtime"></a>portable_mtime |  -   | Boolean | optional |  `True`  |
+| <a id="pkg_tar-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_tar-remap_paths"></a>remap_paths |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="pkg_tar-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag. <div class="since"><i>Since 0.5.0</i></div>   | Integer | optional |  `0`  |
+| <a id="pkg_tar-strip_prefix"></a>strip_prefix |  (note: Use strip_prefix = "." to strip path to the package but preserve relative paths of sub directories beneath the package.)   | String | optional |  `""`  |
+| <a id="pkg_tar-symlinks"></a>symlinks |  -   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
 
 
 
@@ -333,14 +385,14 @@
 
 Zip archive creation rule and associated logic.
 
-<a id="#pkg_zip"></a>
+<a id="pkg_zip"></a>
 
 ## pkg_zip
 
 <pre>
-pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>, <a href="#pkg_zip-compression_type">compression_type</a>,
-             <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>, <a href="#pkg_zip-package_variables">package_variables</a>,
-             <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>)
+pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>,
+             <a href="#pkg_zip-compression_type">compression_type</a>, <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>,
+             <a href="#pkg_zip-package_variables">package_variables</a>, <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>)
 </pre>
 
 
@@ -350,21 +402,21 @@
 
 | Name  | Description | Type | Mandatory | Default |
 | :------------- | :------------- | :------------- | :------------- | :------------- |
-| <a id="pkg_zip-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/docs/build-ref.html#name">Name</a> | required |  |
-| <a id="pkg_zip-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional | True |
-| <a id="pkg_zip-compression_level"></a>compression_level |  The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used   | Integer | optional | 6 |
-| <a id="pkg_zip-compression_type"></a>compression_type |  The compression to use. Note that lzma and bzip2 might not be supported by all readers. The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED   | String | optional | "deflated" |
-| <a id="pkg_zip-include_runfiles"></a>include_runfiles |  See standard attributes.   | Boolean | optional | False |
-| <a id="pkg_zip-mode"></a>mode |  The default mode for all files in the archive.   | String | optional | "0555" |
-| <a id="pkg_zip-out"></a>out |  output file name. Default: name + ".zip".   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | required |  |
-| <a id="pkg_zip-package_dir"></a>package_dir |  Prefix to be prepend to all paths written. The name may contain variables, same as [package_file_name](#package_file_name)   | String | optional | "/" |
-| <a id="pkg_zip-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional | "" |
-| <a id="pkg_zip-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/docs/build-ref.html#labels">Label</a> | optional | None |
-| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional | False |
-| <a id="pkg_zip-srcs"></a>srcs |  List of files that should be included in the archive.   | <a href="https://bazel.build/docs/build-ref.html#labels">List of labels</a> | optional | [] |
-| <a id="pkg_zip-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag.   | Integer | optional | 0 |
-| <a id="pkg_zip-strip_prefix"></a>strip_prefix |  -   | String | optional | "" |
-| <a id="pkg_zip-timestamp"></a>timestamp |  Time stamp to place on all files in the archive, expressed as seconds since the Unix Epoch, as per RFC 3339.  The default is January 01, 1980, 00:00 UTC.<br><br>Due to limitations in the format of zip files, values before Jan 1, 1980 will be rounded up and the precision in the zip file is limited to a granularity of 2 seconds.   | Integer | optional | 315532800 |
+| <a id="pkg_zip-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_zip-srcs"></a>srcs |  List of files that should be included in the archive.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_zip-out"></a>out |  output file name. Default: name + ".zip".   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_zip-allow_duplicates_with_different_content"></a>allow_duplicates_with_different_content |  If true, will allow you to reference multiple pkg_* which conflict (writing different content or metadata to the same destination). Such behaviour is always incorrect, but we provide a flag to support it in case old builds were accidentally doing it. Never explicitly set this to true for new code.   | Boolean | optional |  `True`  |
+| <a id="pkg_zip-compression_level"></a>compression_level |  The compression level to use, 1 is the fastest, 9 gives the smallest results. 0 skips compression, depending on the method used   | Integer | optional |  `6`  |
+| <a id="pkg_zip-compression_type"></a>compression_type |  The compression to use. Note that lzma and bzip2 might not be supported by all readers. The list of compressions is the same as Python's ZipFile: https://docs.python.org/3/library/zipfile.html#zipfile.ZIP_STORED   | String | optional |  `"deflated"`  |
+| <a id="pkg_zip-include_runfiles"></a>include_runfiles |  See standard attributes.   | Boolean | optional |  `False`  |
+| <a id="pkg_zip-mode"></a>mode |  The default mode for all files in the archive.   | String | optional |  `"0555"`  |
+| <a id="pkg_zip-package_dir"></a>package_dir |  Prefix to be prepend to all paths written. The name may contain variables, same as [package_file_name](#package_file_name)   | String | optional |  `"/"`  |
+| <a id="pkg_zip-package_file_name"></a>package_file_name |  See [Common Attributes](#package_file_name)   | String | optional |  `""`  |
+| <a id="pkg_zip-package_variables"></a>package_variables |  See [Common Attributes](#package_variables)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_zip-private_stamp_detect"></a>private_stamp_detect |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_zip-stamp"></a>stamp |  Enable file time stamping.  Possible values: <li>stamp = 1: Use the time of the build as the modification time of each file in the archive. <li>stamp = 0: Use an "epoch" time for the modification time of each file. This gives good build result caching. <li>stamp = -1: Control the chosen modification time using the --[no]stamp flag.   | Integer | optional |  `0`  |
+| <a id="pkg_zip-strip_prefix"></a>strip_prefix |  -   | String | optional |  `""`  |
+| <a id="pkg_zip-timestamp"></a>timestamp |  Time stamp to place on all files in the archive, expressed as seconds since the Unix Epoch, as per RFC 3339.  The default is January 01, 1980, 00:00 UTC.<br><br>Due to limitations in the format of zip files, values before Jan 1, 1980 will be rounded up and the precision in the zip file is limited to a granularity of 2 seconds.   | Integer | optional |  `315532800`  |
 
 
 
@@ -384,120 +436,116 @@
 Rules that actually make use of the outputs of the above rules are not specified
 here.
 
-
-<a id="#filter_directory"></a>
+<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>)
+filter_directory(<a href="#filter_directory-name">name</a>, <a href="#filter_directory-src">src</a>, <a href="#filter_directory-excludes">excludes</a>, <a href="#filter_directory-outdir_name">outdir_name</a>, <a href="#filter_directory-prefix">prefix</a>, <a href="#filter_directory-renames">renames</a>, <a href="#filter_directory-strip_prefix">strip_prefix</a>)
 </pre>
 
 Transform directories (TreeArtifacts) using pkg_filegroup-like semantics.
 
-    Effective order of operations:
-    
-    1) Files are `exclude`d
-    2) `renames` _or_ `strip_prefix` is applied.
-    3) `prefix` is applied 
-    
-    In particular, if a `rename` applies to an individual file, `strip_prefix`
-    will not be applied to that particular file.
-    
-    Each non-`rename``d path will look like this:
+Effective order of operations:
 
-    ```
-    $OUTPUT_DIR/$PREFIX/$FILE_WITHOUT_STRIP_PREFIX
-    ```
+1) Files are `exclude`d
+2) `renames` _or_ `strip_prefix` is applied.
+3) `prefix` is applied
 
-    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.
-    
+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="filter_directory-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="filter_directory-src"></a>src |  Directory (TreeArtifact) to process.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="filter_directory-excludes"></a>excludes |  Files to exclude from the output directory.<br><br>Each element must refer to an individual file in `src`.<br><br>All exclusions must be used.   | List of strings | optional |  `[]`  |
+| <a id="filter_directory-outdir_name"></a>outdir_name |  Name of output directory (otherwise defaults to the rule's name)   | String | optional |  `""`  |
+| <a id="filter_directory-prefix"></a>prefix |  Prefix to add to all paths in the output directory.<br><br>This does not include the output directory name, which will be added regardless.   | String | optional |  `""`  |
+| <a id="filter_directory-renames"></a>renames |  Files to rename in the output directory.<br><br>Keys are destinations, values are sources prior to any path modifications (e.g. via `prefix` or `strip_prefix`).  Files that are `exclude`d must not be renamed.<br><br>This currently only operates on individual files.  `strip_prefix` does not apply to them.<br><br>All renames must be used.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
+| <a id="filter_directory-strip_prefix"></a>strip_prefix |  Prefix to remove from all paths in the output directory.<br><br>Must apply to all paths in the directory, even those rename'd.   | String | optional |  `""`  |
 
 
-<a id="#pkg_filegroup"></a>
+<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>)
+pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-srcs">srcs</a>, <a href="#pkg_filegroup-prefix">prefix</a>)
 </pre>
 
 Package contents grouping rule.
 
-    This rule represents a collection of packaging specifications (e.g. those
-    created by `pkg_files`, `pkg_mklink`, etc.) that have something in common,
-    such as a prefix or a human-readable category.
-    
+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_filegroup-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_filegroup-srcs"></a>srcs |  A list of packaging specifications to be grouped together.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_filegroup-prefix"></a>prefix |  A prefix to prepend to provided paths, applied like so:<br><br>- For files and directories, this is simply prepended to the destination - For symbolic links, this is prepended to the "destination" part.   | String | optional |  `""`  |
 
 
-<a id="#pkg_files"></a>
+<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>)
+pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-include_runfiles">include_runfiles</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>)
 </pre>
 
 General-purpose package target-to-destination mapping rule.
 
-    This rule provides a specification for the locations and attributes of
-    targets when they are packaged. No outputs are created other than Providers
-    that are intended to be consumed by other packaging rules, such as
-    `pkg_rpm`. `pkg_files` targets may be consumed by other `pkg_files` or
-    `pkg_filegroup` to build up complex layouts, or directly by top level
-    packaging rules such as `pkg_files`.
+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.
-    
+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_files-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_files-srcs"></a>srcs |  Files/Labels to include in the outputs of these rules   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_files-attributes"></a>attributes |  Attributes to set on packaged files.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the file's mode will be set to UNIX "0644", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_files-excludes"></a>excludes |  List of files or labels to exclude from the inputs to this rule.<br><br>Mostly useful for removing files from generated outputs or preexisting `filegroup`s.   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
+| <a id="pkg_files-include_runfiles"></a>include_runfiles |  Add runfiles for all srcs.<br><br>The runfiles are in the paths that Bazel uses. For example, for the target `//my_prog:foo`, we would see files under paths like `foo.runfiles/<repo name>/my_prog/<file>`   | Boolean | optional |  `False`  |
+| <a id="pkg_files-prefix"></a>prefix |  Installation prefix.<br><br>This may be an arbitrary string, but it should be understandable by the packaging system you are using to have the desired outcome.  For example, RPM macros like `%{_libdir}` may work correctly in paths for RPM packages, not, say, Debian packages.<br><br>If any part of the directory structure of the computed destination of a file provided to `pkg_filegroup` or any similar rule does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`).<br><br>It is possible to establish directory structures with arbitrary permissions using `pkg_mkdirs`.   | String | optional |  `""`  |
+| <a id="pkg_files-renames"></a>renames |  Destination override map.<br><br>This attribute allows the user to override destinations of files in `pkg_file`s relative to the `prefix` attribute.  Keys to the dict are source files/labels, values are destinations relative to the `prefix`, ignoring whatever value was provided for `strip_prefix`.<br><br>If the key refers to a TreeArtifact (directory output), you may specify the constant `REMOVE_BASE_DIRECTORY` as the value, which will result in all containing files and directories being installed relative to the otherwise specified install prefix (via the `prefix` and `strip_prefix` attributes), not the directory name.<br><br>The following keys are rejected:<br><br>- Any label that expands to more than one file (mappings must be   one-to-one).<br><br>- Any label or file that was either not provided or explicitly   `exclude`d.<br><br>The following values result in undefined behavior:<br><br>- "" (the empty string)<br><br>- "."<br><br>- Anything containing ".."   | <a href="https://bazel.build/rules/lib/dict">Dictionary: Label -> String</a> | optional |  `{}`  |
+| <a id="pkg_files-strip_prefix"></a>strip_prefix |  What prefix of a file's path to discard prior to installation.<br><br>This specifies what prefix of an incoming file's path should not be included in the output package at after being appended to the install prefix (the `prefix` attribute).  Note that this is only applied to full directory names, see `strip_prefix` for more details.<br><br>Use the `strip_prefix` struct to define this attribute.  If this attribute is not specified, all directories will be stripped from all files prior to being included in packages (`strip_prefix.files_only()`).<br><br>If prefix stripping fails on any file provided in `srcs`, the build will fail.<br><br>Note that this only functions on paths that are known at analysis time.  Specifically, this will not consider directories within TreeArtifacts (directory outputs), or the directories themselves. See also #269.   | String | optional |  `"."`  |
 
 
-<a id="#pkg_mkdirs"></a>
+<a id="pkg_mkdirs"></a>
 
 ## pkg_mkdirs
 
@@ -507,32 +555,31 @@
 
 Defines creation and ownership of directories in packages
 
-    Use this if:
+Use this if:
 
-    1) You need to create an empty directory in your package.
+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.
+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.
+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.
-    
+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_mkdirs-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_mkdirs-attributes"></a>attributes |  Attributes to set on packaged directories.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>If not otherwise overridden, the directory's mode will be set to UNIX "0755", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_mkdirs-dirs"></a>dirs |  Directory names to make within the package<br><br>If any part of the requested directory structure does not already exist within a package, the package builder will create it for you with a reasonable set of default permissions (typically `0755 root.root`).   | List of strings | required |  |
 
 
-<a id="#pkg_mklink_impl"></a>
+<a id="pkg_mklink_impl"></a>
 
 ## pkg_mklink_impl
 
@@ -542,25 +589,23 @@
 
 Define a symlink  within packages
 
-    This rule results in the creation of a single link within a package.
+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.
-
-    
+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_mklink_impl-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_mklink_impl-attributes"></a>attributes |  Attributes to set on packaged symbolic links.<br><br>Always use `pkg_attributes()` to set this rule attribute.<br><br>Symlink permissions may have different meanings depending on your host operating system; consult its documentation for more details.<br><br>If not otherwise overridden, the link's mode will be set to UNIX "0777", or the target platform's equivalent.<br><br>Consult the "Mapping Attributes" documentation in the rules_pkg reference for more details.   | String | optional |  `"{}"`  |
+| <a id="pkg_mklink_impl-link_name"></a>link_name |  Link "destination", a path within the package.<br><br>This is the actual created symbolic link.<br><br>If the directory structure provided by this attribute is not otherwise created when exist within the package when it is built, it will be created implicitly, much like with `pkg_files`.<br><br>This path may be prefixed or rooted by grouping or packaging rules.   | String | required |  |
+| <a id="pkg_mklink_impl-target"></a>target |  Link "target", a path on the filesystem.<br><br>This is what the link "points" to, and may point to an arbitrary filesystem path, even relative paths.   | String | required |  |
 
 
-<a id="#pkg_attributes"></a>
+<a id="pkg_attributes"></a>
 
 ## pkg_attributes
 
@@ -589,11 +634,11 @@
 
 | 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-mode"></a>mode |  string: UNIXy octal permissions, as a string.   |  `None` |
+| <a id="pkg_attributes-user"></a>user |  string: Filesystem owning user name.   |  `None` |
+| <a id="pkg_attributes-group"></a>group |  string: Filesystem owning group name.   |  `None` |
+| <a id="pkg_attributes-uid"></a>uid |  int: Filesystem owning user id.   |  `None` |
+| <a id="pkg_attributes-gid"></a>gid |  int: Filesystem owning group id.   |  `None` |
 | <a id="pkg_attributes-kwargs"></a>kwargs |  any other desired attributes.   |  none |
 
 **RETURNS**
@@ -601,7 +646,7 @@
 A value usable in the "attributes" attribute in package mapping rules.
 
 
-<a id="#pkg_mklink"></a>
+<a id="pkg_mklink"></a>
 
 ## pkg_mklink
 
@@ -622,12 +667,12 @@
 | <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-attributes"></a>attributes |  file attributes.   |  `None` |
+| <a id="pkg_mklink-src"></a>src |   -    |  `None` |
 | <a id="pkg_mklink-kwargs"></a>kwargs |   -    |  none |
 
 
-<a id="#strip_prefix.files_only"></a>
+<a id="strip_prefix.files_only"></a>
 
 ## strip_prefix.files_only
 
@@ -639,7 +684,7 @@
 
 
 
-<a id="#strip_prefix.from_pkg"></a>
+<a id="strip_prefix.from_pkg"></a>
 
 ## strip_prefix.from_pkg
 
@@ -654,10 +699,10 @@
 
 | Name  | Description | Default Value |
 | :------------- | :------------- | :------------- |
-| <a id="strip_prefix.from_pkg-path"></a>path |   -    |  <code>""</code> |
+| <a id="strip_prefix.from_pkg-path"></a>path |   -    |  `""` |
 
 
-<a id="#strip_prefix.from_root"></a>
+<a id="strip_prefix.from_root"></a>
 
 ## strip_prefix.from_root
 
@@ -672,7 +717,7 @@
 
 | Name  | Description | Default Value |
 | :------------- | :------------- | :------------- |
-| <a id="strip_prefix.from_root-path"></a>path |   -    |  <code>""</code> |
+| <a id="strip_prefix.from_root-path"></a>path |   -    |  `""` |
 
 
 
@@ -691,13 +736,12 @@
     load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
     find_system_rpmbuild(name="rules_pkg_rpmbuild")
 
-
-<a id="#pkg_rpm"></a>
+<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>,
+pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-data">data</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>,
         <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_file">spec_file</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
 </pre>
 
@@ -708,19 +752,19 @@
 
 | 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 |
+| <a id="pkg_rpm-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
+| <a id="pkg_rpm-data"></a>data |  -   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
+| <a id="pkg_rpm-architecture"></a>architecture |  -   | String | optional |  `"all"`  |
+| <a id="pkg_rpm-changelog"></a>changelog |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-debug"></a>debug |  -   | Boolean | optional |  `False`  |
+| <a id="pkg_rpm-release"></a>release |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-release_file"></a>release_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-rpmbuild_path"></a>rpmbuild_path |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-source_date_epoch"></a>source_date_epoch |  -   | Integer | optional |  `0`  |
+| <a id="pkg_rpm-source_date_epoch_file"></a>source_date_epoch_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
+| <a id="pkg_rpm-spec_file"></a>spec_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="pkg_rpm-version"></a>version |  -   | String | optional |  `""`  |
+| <a id="pkg_rpm-version_file"></a>version_file |  -   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
 
 
 
diff --git a/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/rich_structure/MODULE.bazel b/examples/rich_structure/MODULE.bazel
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/rich_structure/MODULE.bazel
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/rpm/debuginfo/BUILD
similarity index 73%
copy from examples/prebuilt_rpmbuild/BUILD
copy to examples/rpm/debuginfo/BUILD
index 5b8f762..72dc80f 100644
--- a/examples/prebuilt_rpmbuild/BUILD
+++ b/examples/rpm/debuginfo/BUILD
@@ -13,19 +13,36 @@
 # limitations under the License.
 # -*- coding: utf-8 -*-
 
+
+load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
 load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")
 
+cc_binary(
+    name = "test",
+    copts = ["-g"],
+    srcs = [
+        "test.c",
+    ],
+)
+
+pkg_files(
+    name = "rpm_files",
+    srcs = [
+        ":test",
+    ],
+)
+
 pkg_rpm(
     name = "test-rpm",
-    data = [
-        "BUILD",
-        "WORKSPACE",
-        "readme.md",
-        "test_rpm.spec",
+    srcs = [
+        ":rpm_files",
     ],
     release = "0",
-    spec_file = "test_rpm.spec",
     version = "1",
+    license = "Some license",
+    summary = "Summary",
+    description = "Description",
+    debuginfo = True,
 )
 
 # If you have rpmbuild, you probably have rpm2cpio too.
diff --git a/examples/rpm/debuginfo/MODULE.bazel b/examples/rpm/debuginfo/MODULE.bazel
new file mode 100644
index 0000000..b2d8a8f
--- /dev/null
+++ b/examples/rpm/debuginfo/MODULE.bazel
@@ -0,0 +1,32 @@
+# Copyright 2024 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")
+
+bazel_dep(name = "rules_pkg")
+
+local_path_override(
+    module_name = "rules_pkg",
+    path = "../../..",
+)
+
+find_rpmbuild = use_extension(
+    "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
+    "find_system_rpmbuild_bzlmod",
+)
+use_repo(find_rpmbuild, "rules_pkg_rpmbuild")
+
+register_toolchains(
+    "@rules_pkg_rpmbuild//:all",
+)
diff --git a/examples/rpm/debuginfo/README.md b/examples/rpm/debuginfo/README.md
new file mode 100644
index 0000000..d42b117
--- /dev/null
+++ b/examples/rpm/debuginfo/README.md
@@ -0,0 +1,17 @@
+# Using system rpmbuild with bzlmod and generating debuginfo
+
+## Summary
+
+This example uses the `find_system_rpmbuild_bzlmod` module extension to help
+us register the system rpmbuild as a toolchain in a bzlmod environment.
+
+It configures the system toolchain to be aware of which debuginfo configuration
+to use (defaults to "none", the example uses "centos7").
+
+## To use
+
+```
+bazel build :*
+rpm2cpio bazel-bin/test-rpm.rpm | cpio -ivt
+cat bazel-bin/content.txt
+```
diff --git a/examples/rpm/debuginfo/test.c b/examples/rpm/debuginfo/test.c
new file mode 100644
index 0000000..4cce7f6
--- /dev/null
+++ b/examples/rpm/debuginfo/test.c
@@ -0,0 +1,3 @@
+int main() {
+  return 0;
+}
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/rpm/nospecfile/BUILD
similarity index 66%
copy from examples/prebuilt_rpmbuild/BUILD
copy to examples/rpm/nospecfile/BUILD
index 5b8f762..3cf1b3b 100644
--- a/examples/prebuilt_rpmbuild/BUILD
+++ b/examples/rpm/nospecfile/BUILD
@@ -1,4 +1,4 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
+# Copyright 2024 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.
@@ -13,19 +13,35 @@
 # limitations under the License.
 # -*- coding: utf-8 -*-
 
+load("@rules_pkg//pkg:mappings.bzl", "pkg_files")
 load("@rules_pkg//pkg:rpm.bzl", "pkg_rpm")
 
+pkg_files(
+    name = "rpm_files",
+    srcs = [
+        "BUILD",
+        "MODULE.bazel",
+        "README.md",
+    ],
+)
+
 pkg_rpm(
     name = "test-rpm",
-    data = [
-        "BUILD",
-        "WORKSPACE",
-        "readme.md",
-        "test_rpm.spec",
+    srcs = [
+        ":rpm_files",
     ],
     release = "0",
-    spec_file = "test_rpm.spec",
     version = "1",
+    summary = "rules_pkg example RPM",
+    description = "This is a package description.",
+    license = "Apache License, v2.0",
+    architecture = "x86_64",
+    requires = [
+        "somerpm",
+    ],
+    provides = [
+        "somefile",
+    ],
 )
 
 # If you have rpmbuild, you probably have rpm2cpio too.
diff --git a/examples/rpm/nospecfile/MODULE.bazel b/examples/rpm/nospecfile/MODULE.bazel
new file mode 100644
index 0000000..b2d8a8f
--- /dev/null
+++ b/examples/rpm/nospecfile/MODULE.bazel
@@ -0,0 +1,32 @@
+# Copyright 2024 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")
+
+bazel_dep(name = "rules_pkg")
+
+local_path_override(
+    module_name = "rules_pkg",
+    path = "../../..",
+)
+
+find_rpmbuild = use_extension(
+    "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
+    "find_system_rpmbuild_bzlmod",
+)
+use_repo(find_rpmbuild, "rules_pkg_rpmbuild")
+
+register_toolchains(
+    "@rules_pkg_rpmbuild//:all",
+)
diff --git a/examples/rpm/nospecfile/README.md b/examples/rpm/nospecfile/README.md
new file mode 100644
index 0000000..1229e8a
--- /dev/null
+++ b/examples/rpm/nospecfile/README.md
@@ -0,0 +1,14 @@
+# Using system rpmbuild with bzlmod
+
+## Summary
+
+This example builds an RPM using the system `rpmbuild` from a pure bazel
+`pkg_rpm()` definition instead of using a separate specfile.
+
+## To use
+
+```
+bazel build :*
+rpm2cpio bazel-bin/test-rpm.rpm | cpio -ivt
+cat bazel-bin/content.txt
+```
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/rpm/prebuilt_rpmbuild/BUILD
similarity index 97%
rename from examples/prebuilt_rpmbuild/BUILD
rename to examples/rpm/prebuilt_rpmbuild/BUILD
index 5b8f762..3f57592 100644
--- a/examples/prebuilt_rpmbuild/BUILD
+++ b/examples/rpm/prebuilt_rpmbuild/BUILD
@@ -20,7 +20,7 @@
     data = [
         "BUILD",
         "WORKSPACE",
-        "readme.md",
+        "README.md",
         "test_rpm.spec",
     ],
     release = "0",
diff --git a/examples/rpm/prebuilt_rpmbuild/README.md b/examples/rpm/prebuilt_rpmbuild/README.md
new file mode 100644
index 0000000..4b12b39
--- /dev/null
+++ b/examples/rpm/prebuilt_rpmbuild/README.md
@@ -0,0 +1,18 @@
+# Using a prebuilt rpmbuild instead of the system one.
+
+## Summary
+
+This example defines a rpmbuild toolchain in `local` that can be used
+by rules_pkg.  This must be copied into place as `local/rpmbuild_binary`
+for use by `register_toolchains()`.
+
+The RPM itself is based on a user provided spec file.
+
+## 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/WORKSPACE b/examples/rpm/prebuilt_rpmbuild/WORKSPACE
similarity index 90%
rename from examples/prebuilt_rpmbuild/WORKSPACE
rename to examples/rpm/prebuilt_rpmbuild/WORKSPACE
index 4fc8a59..530620a 100644
--- a/examples/prebuilt_rpmbuild/WORKSPACE
+++ b/examples/rpm/prebuilt_rpmbuild/WORKSPACE
@@ -12,11 +12,11 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-workspace(name = "rules_pkg_example_prebuilt_rpmbuild")
+workspace(name = "rules_pkg_example_rpm_prebuilt_rpmbuild")
 
 local_repository(
     name = "rules_pkg",
-    path = "../..",
+    path = "../../..",
 )
 
 load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
diff --git a/examples/prebuilt_rpmbuild/local/BUILD b/examples/rpm/prebuilt_rpmbuild/local/BUILD
similarity index 100%
rename from examples/prebuilt_rpmbuild/local/BUILD
rename to examples/rpm/prebuilt_rpmbuild/local/BUILD
diff --git a/examples/prebuilt_rpmbuild/local/rpmbuild.bzl b/examples/rpm/prebuilt_rpmbuild/local/rpmbuild.bzl
similarity index 100%
rename from examples/prebuilt_rpmbuild/local/rpmbuild.bzl
rename to examples/rpm/prebuilt_rpmbuild/local/rpmbuild.bzl
diff --git a/examples/prebuilt_rpmbuild/local/rpmbuild_binary b/examples/rpm/prebuilt_rpmbuild/local/rpmbuild_binary
similarity index 100%
rename from examples/prebuilt_rpmbuild/local/rpmbuild_binary
rename to examples/rpm/prebuilt_rpmbuild/local/rpmbuild_binary
diff --git a/examples/prebuilt_rpmbuild/test_rpm.spec b/examples/rpm/prebuilt_rpmbuild/test_rpm.spec
similarity index 85%
rename from examples/prebuilt_rpmbuild/test_rpm.spec
rename to examples/rpm/prebuilt_rpmbuild/test_rpm.spec
index c52dc24..3b18f98 100644
--- a/examples/prebuilt_rpmbuild/test_rpm.spec
+++ b/examples/rpm/prebuilt_rpmbuild/test_rpm.spec
@@ -15,10 +15,10 @@
 %build
 
 %install
-cp WORKSPACE BUILD readme.md test_rpm.spec %{buildroot}/
+cp WORKSPACE BUILD README.md test_rpm.spec %{buildroot}/
 
 %files
 /WORKSPACE
 /BUILD
-/readme.md
+/README.md
 /test_rpm.spec
diff --git a/examples/rpm/subrpm/BUILD b/examples/rpm/subrpm/BUILD
new file mode 100644
index 0000000..0da73ca
--- /dev/null
+++ b/examples/rpm/subrpm/BUILD
@@ -0,0 +1,79 @@
+# Copyright 2024 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:mappings.bzl", "pkg_files")
+load("@rules_pkg//pkg:rpm.bzl", "pkg_sub_rpm", "pkg_rpm")
+
+pkg_files(
+    name = "subrpm_files",
+    srcs = [
+        "BUILD",
+    ],
+)
+
+pkg_sub_rpm(
+    name = "subrpm",
+    package_name = "subrpm",
+    summary = "Test subrpm",
+    description = "Test subrpm description",
+    requires = [
+        "somerpm",
+    ],
+    provides = [
+        "someprovision",
+    ],
+    srcs = [
+        ":subrpm_files",
+    ],
+)
+
+pkg_files(
+    name = "rpm_files",
+    srcs = [
+        "MODULE.bazel",
+        "README.md",
+    ],
+)
+
+pkg_rpm(
+    name = "test-rpm",
+    srcs = [
+        ":rpm_files",
+    ],
+    release = "0",
+    version = "1",
+    summary = "rules_pkg example RPM",
+    description = "This is a package description.",
+    license = "Apache License, v2.0",
+    architecture = "x86_64",
+    requires = [
+        "somerpm",
+    ],
+    provides = [
+        "somefile",
+    ],
+    subrpms = [
+        ":subrpm",
+    ],
+)
+
+# 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/rpm/subrpm/MODULE.bazel b/examples/rpm/subrpm/MODULE.bazel
new file mode 100644
index 0000000..b2d8a8f
--- /dev/null
+++ b/examples/rpm/subrpm/MODULE.bazel
@@ -0,0 +1,32 @@
+# Copyright 2024 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")
+
+bazel_dep(name = "rules_pkg")
+
+local_path_override(
+    module_name = "rules_pkg",
+    path = "../../..",
+)
+
+find_rpmbuild = use_extension(
+    "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
+    "find_system_rpmbuild_bzlmod",
+)
+use_repo(find_rpmbuild, "rules_pkg_rpmbuild")
+
+register_toolchains(
+    "@rules_pkg_rpmbuild//:all",
+)
diff --git a/examples/rpm/subrpm/README.md b/examples/rpm/subrpm/README.md
new file mode 100644
index 0000000..1229e8a
--- /dev/null
+++ b/examples/rpm/subrpm/README.md
@@ -0,0 +1,14 @@
+# Using system rpmbuild with bzlmod
+
+## Summary
+
+This example builds an RPM using the system `rpmbuild` from a pure bazel
+`pkg_rpm()` definition instead of using a separate specfile.
+
+## To use
+
+```
+bazel build :*
+rpm2cpio bazel-bin/test-rpm.rpm | cpio -ivt
+cat bazel-bin/content.txt
+```
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/rpm/system_rpmbuild/BUILD
similarity index 97%
copy from examples/prebuilt_rpmbuild/BUILD
copy to examples/rpm/system_rpmbuild/BUILD
index 5b8f762..3f57592 100644
--- a/examples/prebuilt_rpmbuild/BUILD
+++ b/examples/rpm/system_rpmbuild/BUILD
@@ -20,7 +20,7 @@
     data = [
         "BUILD",
         "WORKSPACE",
-        "readme.md",
+        "README.md",
         "test_rpm.spec",
     ],
     release = "0",
diff --git a/examples/rpm/system_rpmbuild/README.md b/examples/rpm/system_rpmbuild/README.md
new file mode 100644
index 0000000..ea27429
--- /dev/null
+++ b/examples/rpm/system_rpmbuild/README.md
@@ -0,0 +1,17 @@
+# Using system rpmbuild
+
+## Summary
+
+This example uses the `find_system_rpmbuild()` macro built into `rules_pkg`
+to search for `rpmbuild` in on the local system and use that to drive the
+packaging process.
+
+The RPM itself is based on a user provided spec file.
+
+## To use
+
+```
+bazel build :*
+rpm2cpio bazel-bin/test-rpm.rpm | cpio -ivt
+cat bazel-bin/content.txt
+```
diff --git a/examples/prebuilt_rpmbuild/WORKSPACE b/examples/rpm/system_rpmbuild/WORKSPACE
similarity index 71%
copy from examples/prebuilt_rpmbuild/WORKSPACE
copy to examples/rpm/system_rpmbuild/WORKSPACE
index 4fc8a59..9dac982 100644
--- a/examples/prebuilt_rpmbuild/WORKSPACE
+++ b/examples/rpm/system_rpmbuild/WORKSPACE
@@ -1,4 +1,4 @@
-# Copyright 2020 The Bazel Authors. All rights reserved.
+# Copyright 2024 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.
@@ -12,17 +12,20 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-workspace(name = "rules_pkg_example_prebuilt_rpmbuild")
+workspace(name = "rules_pkg_example_rpm_system_rpmbuild")
 
 local_repository(
     name = "rules_pkg",
-    path = "../..",
+    path = "../../..",
 )
 
 load("@rules_pkg//pkg:deps.bzl", "rules_pkg_dependencies")
 
 rules_pkg_dependencies()
 
-load("//local:rpmbuild.bzl", "register_my_rpmbuild_toolchain")
+load(
+    "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
+    "find_system_rpmbuild",
+)
 
-register_my_rpmbuild_toolchain()
+find_system_rpmbuild(name="my_rpmbuild")
diff --git a/examples/prebuilt_rpmbuild/test_rpm.spec b/examples/rpm/system_rpmbuild/test_rpm.spec
similarity index 85%
copy from examples/prebuilt_rpmbuild/test_rpm.spec
copy to examples/rpm/system_rpmbuild/test_rpm.spec
index c52dc24..3b18f98 100644
--- a/examples/prebuilt_rpmbuild/test_rpm.spec
+++ b/examples/rpm/system_rpmbuild/test_rpm.spec
@@ -15,10 +15,10 @@
 %build
 
 %install
-cp WORKSPACE BUILD readme.md test_rpm.spec %{buildroot}/
+cp WORKSPACE BUILD README.md test_rpm.spec %{buildroot}/
 
 %files
 /WORKSPACE
 /BUILD
-/readme.md
+/README.md
 /test_rpm.spec
diff --git a/examples/prebuilt_rpmbuild/BUILD b/examples/rpm/system_rpmbuild_bzlmod/BUILD
similarity index 95%
copy from examples/prebuilt_rpmbuild/BUILD
copy to examples/rpm/system_rpmbuild_bzlmod/BUILD
index 5b8f762..1f007ed 100644
--- a/examples/prebuilt_rpmbuild/BUILD
+++ b/examples/rpm/system_rpmbuild_bzlmod/BUILD
@@ -19,8 +19,8 @@
     name = "test-rpm",
     data = [
         "BUILD",
-        "WORKSPACE",
-        "readme.md",
+        "MODULE.bazel",
+        "README.md",
         "test_rpm.spec",
     ],
     release = "0",
diff --git a/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel b/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel
new file mode 100644
index 0000000..b2d8a8f
--- /dev/null
+++ b/examples/rpm/system_rpmbuild_bzlmod/MODULE.bazel
@@ -0,0 +1,32 @@
+# Copyright 2024 The Bazel Authors. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+module(name = "rules_pkg_example_rpm_system_rpmbuild_bzlmod")
+
+bazel_dep(name = "rules_pkg")
+
+local_path_override(
+    module_name = "rules_pkg",
+    path = "../../..",
+)
+
+find_rpmbuild = use_extension(
+    "@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl",
+    "find_system_rpmbuild_bzlmod",
+)
+use_repo(find_rpmbuild, "rules_pkg_rpmbuild")
+
+register_toolchains(
+    "@rules_pkg_rpmbuild//:all",
+)
diff --git a/examples/rpm/system_rpmbuild_bzlmod/README.md b/examples/rpm/system_rpmbuild_bzlmod/README.md
new file mode 100644
index 0000000..88f9cd4
--- /dev/null
+++ b/examples/rpm/system_rpmbuild_bzlmod/README.md
@@ -0,0 +1,16 @@
+# Using system rpmbuild with bzlmod
+
+## Summary
+
+This example uses the `find_system_rpmbuild_bzlmod` module extension to help
+us register the system rpmbuild as a toolchain in a bzlmod environment.
+
+The RPM itself is based on a user provided spec file.
+
+## To use
+
+```
+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/rpm/system_rpmbuild_bzlmod/test_rpm.spec
similarity index 82%
copy from examples/prebuilt_rpmbuild/test_rpm.spec
copy to examples/rpm/system_rpmbuild_bzlmod/test_rpm.spec
index c52dc24..0858b95 100644
--- a/examples/prebuilt_rpmbuild/test_rpm.spec
+++ b/examples/rpm/system_rpmbuild_bzlmod/test_rpm.spec
@@ -15,10 +15,10 @@
 %build
 
 %install
-cp WORKSPACE BUILD readme.md test_rpm.spec %{buildroot}/
+cp MODULE.bazel BUILD README.md test_rpm.spec %{buildroot}/
 
 %files
-/WORKSPACE
+/MODULE.bazel
 /BUILD
-/readme.md
+/README.md
 /test_rpm.spec
diff --git a/examples/time_stamping/MODULE.bazel b/examples/time_stamping/MODULE.bazel
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/time_stamping/MODULE.bazel
diff --git a/examples/where_is_my_output/MODULE.bazel b/examples/where_is_my_output/MODULE.bazel
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/examples/where_is_my_output/MODULE.bazel
diff --git a/pkg/install.bzl b/pkg/install.bzl
index e7b0e42..7b415ab 100644
--- a/pkg/install.bzl
+++ b/pkg/install.bzl
@@ -62,6 +62,7 @@
             "{WORKSPACE_NAME}": ctx.workspace_name,
             # Used to annotate --help with "bazel run //path/to/your:installer"
             "{TARGET_LABEL}": label_str,
+            "{DEFAULT_DESTDIR}": ctx.attr.destdir,
         },
         is_executable = True,
     )
@@ -98,6 +99,7 @@
             ],
             doc = "Source mapping/grouping targets",
         ),
+        "destdir": attr.string(),
         # 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.
@@ -109,7 +111,7 @@
     executable = True,
 )
 
-def pkg_install(name, srcs, **kwargs):
+def pkg_install(name, srcs, destdir = None, **kwargs):
     """Create an installer script from pkg_filegroups and friends.
 
     This macro allows users to create `bazel run`nable installation scripts
@@ -123,6 +125,7 @@
         srcs = [
             # mapping/grouping targets here
         ],
+        destdir = "out/install",
     )
     ```
 
@@ -153,15 +156,28 @@
     https://github.com/bazelbuild/rules_pkg/issues/388.
 
     Args:
-      name: rule name
-      srcs: pkg_filegroup framework mapping or grouping targets
-      **kwargs: common rule attributes
+        name: rule name
+        srcs: pkg_filegroup framework mapping or grouping targets
+        destdir: The default destination directory.
+
+            If it is specified, this is the default destination to install
+            the files. It is overridable by explicitly specifying `--destdir`
+            in the command line or specifying the `DESTDIR` environment
+            variable.
+
+            If it is not specified, `--destdir` must be set on the command line,
+            or the `DESTDIR` environment variable must be set.
+
+            If this is an absolute path, it is used as-is. If this is a relative
+            path, it is interpreted against `BUILD_WORKSPACE_DIRECTORY`.
+        **kwargs: common rule attributes
 
     """
 
     _pkg_install_script(
         name = name + "_install_script",
         srcs = srcs,
+        destdir = destdir,
         **kwargs
     )
 
diff --git a/pkg/make_rpm.py b/pkg/make_rpm.py
index dd30a49..6a9c37a 100644
--- a/pkg/make_rpm.py
+++ b/pkg/make_rpm.py
@@ -81,10 +81,9 @@
 
 def FindOutputFile(log):
   """Find the written file from the log information."""
-
-  m = WROTE_FILE_RE.search(log)
+  m = WROTE_FILE_RE.findall(log)
   if m:
-    return m.group('rpm_path')
+    return m
   return None
 
 def SlurpFile(input_path):
@@ -173,6 +172,7 @@
 
   SOURCE_DIR = 'SOURCES'
   BUILD_DIR = 'BUILD'
+  BUILD_SUBDIR = 'BUILD_SUB'
   BUILDROOT_DIR = 'BUILDROOT'
   TEMP_DIR = 'TMP'
   RPMS_DIR = 'RPMS'
@@ -187,7 +187,7 @@
     self.arch = arch
     self.files = []
     self.rpmbuild_path = FindRpmbuild(rpmbuild_path)
-    self.rpm_path = None
+    self.rpm_paths = None
     self.source_date_epoch = helpers.GetFlagValue(source_date_epoch)
     self.debug = debug
 
@@ -204,6 +204,7 @@
     self.post_scriptlet = None
     self.preun_scriptlet = None
     self.postun_scriptlet = None
+    self.subrpms = None
 
   def AddFiles(self, paths, root=''):
     """Add a set of files to the current RPM.
@@ -227,6 +228,7 @@
                    preamble_file=None,
                    description_file=None,
                    install_script_file=None,
+                   subrpms_file=None,
                    pre_scriptlet_path=None,
                    post_scriptlet_path=None,
                    preun_scriptlet_path=None,
@@ -258,15 +260,17 @@
 
     # Slurp in the scriptlets...
     self.pre_scriptlet = \
-      SlurpFile(os.path.join(original_dir, pre_scriptlet_path)) if pre_scriptlet_path is not None else ''
+      SlurpFile(os.path.join(original_dir, pre_scriptlet_path)) if pre_scriptlet_path else ''
     self.post_scriptlet = \
-      SlurpFile(os.path.join(original_dir, post_scriptlet_path)) if post_scriptlet_path is not None else ''
+      SlurpFile(os.path.join(original_dir, post_scriptlet_path)) if post_scriptlet_path else ''
     self.preun_scriptlet = \
-      SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path is not None else ''
+      SlurpFile(os.path.join(original_dir, preun_scriptlet_path)) if preun_scriptlet_path else ''
     self.postun_scriptlet = \
-      SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path is not None else ''
+      SlurpFile(os.path.join(original_dir, postun_scriptlet_path)) if postun_scriptlet_path else ''
     self.posttrans_scriptlet = \
-      SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path is not None else ''
+      SlurpFile(os.path.join(original_dir, posttrans_scriptlet_path)) if posttrans_scriptlet_path else ''
+    self.subrpms = \
+      SlurpFile(os.path.join(original_dir, subrpms_file)) if subrpms_file else ''
 
     # Then prepare for textual substitution.  This is typically only the case for the
     # experimental `pkg_rpm`.
@@ -276,6 +280,7 @@
       'PREUN_SCRIPTLET': ("%preun\n" + self.preun_scriptlet) if self.preun_scriptlet else "",
       'POSTUN_SCRIPTLET': ("%postun\n" + self.postun_scriptlet) if self.postun_scriptlet else "",
       'POSTTRANS_SCRIPTLET': ("%posttrans\n" + self.posttrans_scriptlet) if self.posttrans_scriptlet else "",
+      'SUBRPMS' : self.subrpms,
       'CHANGELOG': ""
     }
 
@@ -341,7 +346,7 @@
       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):
+  def CallRpmBuild(self, dirname, rpmbuild_args, debuginfo_type):
     """Call rpmbuild with the correct arguments."""
 
     buildroot = os.path.join(dirname, RpmBuilder.BUILDROOT_DIR)
@@ -357,13 +362,31 @@
     if self.debug:
       args.append('-vv')
 
+    if debuginfo_type == "fedora40":
+      os.makedirs(f'{dirname}/{RpmBuilder.BUILD_DIR}/{RpmBuilder.BUILD_SUBDIR}')
+
     # Common options
+    # NOTE: There may be a need to add '--define', 'buildsubdir .' for some
+    # rpmbuild versions. But that breaks other rpmbuild versions, so before
+    # adding it back in, add extensive tests.
     args += [
-        '--define', '_topdir %s' % dirname,
-        '--define', '_tmppath %s/TMP' % dirname,
-        '--define', '_builddir %s/BUILD' % dirname,
-        '--bb',
-        '--buildroot=%s' % buildroot,
+      '--define', '_topdir %s' % dirname,
+      '--define', '_tmppath %s/TMP' % dirname,
+      '--define', '_builddir %s/BUILD' % dirname,
+    ]
+
+    if debuginfo_type in ["fedora40", "centos7", "centos9", "almalinux9.3"]:
+      args += ['--undefine', '_debugsource_packages']
+
+    if debuginfo_type in ["centos7", "centos9", "almalinux9.3"]:
+      args += ['--define', 'buildsubdir .']
+
+    if debuginfo_type == "fedora40":
+      args += ['--define', f'buildsubdir {RpmBuilder.BUILD_SUBDIR}']
+
+    args += [
+      '--bb',
+      '--buildroot=%s' % buildroot,
     ]  # yapf: disable
 
     # Macro-based RPM parameter substitution, if necessary inputs provided.
@@ -375,7 +398,11 @@
       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)]
+      base_path = os.path.basename(self.file_list_path)
+      if debuginfo_type == "fedora40":
+        base_path = os.path.join("..", base_path)
+
+      args += ['--define', 'build_rpm_files %s' % base_path]
 
     args.extend(rpmbuild_args)
 
@@ -405,9 +432,9 @@
 
     if p.returncode == 0:
       # Find the created file.
-      self.rpm_path = FindOutputFile(output)
+      self.rpm_paths = FindOutputFile(output)
 
-    if p.returncode != 0 or not self.rpm_path:
+    if p.returncode != 0 or not self.rpm_paths:
       print('Error calling rpmbuild:')
       print(output)
     elif self.debug:
@@ -416,20 +443,35 @@
     # Return the status.
     return p.returncode
 
-  def SaveResult(self, out_file):
+  def SaveResult(self, out_file, subrpm_out_files):
     """Save the result RPM out of the temporary working directory."""
+    if self.rpm_paths:
+      for p in self.rpm_paths:
+         is_subrpm = False
 
-    if self.rpm_path:
-      shutil.copy(self.rpm_path, out_file)
-      if self.debug:
-        print('Saved RPM file to %s' % out_file)
+         for subrpm_name, subrpm_out_file in subrpm_out_files:
+            subrpm_prefix = self.name + '-' + subrpm_name
+
+            if os.path.basename(p).startswith(subrpm_prefix):
+               shutil.copy(p, subrpm_out_file)
+               is_subrpm = True
+               if self.debug or True:
+                  print('Saved %s sub RPM file to %s' % (
+                     subrpm_name, subrpm_out_file))
+               break
+
+         if not is_subrpm:
+            shutil.copy(p, out_file)
+            if self.debug or True:
+               print('Saved RPM file to %s' % out_file)
     else:
       print('No RPM file created.')
 
-  def Build(self, spec_file, out_file,
+  def Build(self, spec_file, out_file, subrpm_out_files=None,
             preamble_file=None,
             description_file=None,
             install_script_file=None,
+            subrpms_file=None,
             pre_scriptlet_path=None,
             post_scriptlet_path=None,
             preun_scriptlet_path=None,
@@ -437,7 +479,8 @@
             posttrans_scriptlet_path=None,
             file_list_path=None,
             changelog_file=None,
-            rpmbuild_args=None):
+            rpmbuild_args=None,
+            debuginfo_type=None):
     """Build the RPM described by the spec_file, with other metadata in keyword arguments"""
 
     if self.debug:
@@ -446,12 +489,21 @@
     original_dir = os.getcwd()
     spec_file = os.path.join(original_dir, spec_file)
     out_file = os.path.join(original_dir, out_file)
+
+    if subrpm_out_files:
+      subrpm_out_files = (s.split(':') for s in subrpm_out_files)
+      subrpm_out_files = [
+         (s[0], os.path.join(original_dir, s[1])) for s in subrpm_out_files]
+    else:
+      subrpm_out_files = []
+
     with Tempdir() as dirname:
       self.SetupWorkdir(spec_file,
                         original_dir,
                         preamble_file=preamble_file,
                         description_file=description_file,
                         install_script_file=install_script_file,
+                        subrpms_file=subrpms_file,
                         file_list_path=file_list_path,
                         pre_scriptlet_path=pre_scriptlet_path,
                         post_scriptlet_path=post_scriptlet_path,
@@ -459,8 +511,8 @@
                         postun_scriptlet_path=postun_scriptlet_path,
                         posttrans_scriptlet_path=posttrans_scriptlet_path,
                         changelog_file=changelog_file)
-      status = self.CallRpmBuild(dirname, rpmbuild_args or [])
-      self.SaveResult(out_file)
+      status = self.CallRpmBuild(dirname, rpmbuild_args or [], debuginfo_type)
+      self.SaveResult(out_file, subrpm_out_files)
 
     return status
 
@@ -483,6 +535,9 @@
                       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('--subrpm_out_file', action='append',
+                      help='List of destinations to save resulting ' +
+                      'Sub RPMs to in the form of name:destination')
   parser.add_argument('--rpmbuild', help='Path to rpmbuild executable.')
   parser.add_argument('--source_date_epoch',
                       help='Value for the SOURCE_DATE_EPOCH rpmbuild '
@@ -499,6 +554,8 @@
                       help='File containing the RPM Preamble')
   parser.add_argument('--description',
                       help='File containing the RPM %description text')
+  parser.add_argument('--subrpms',
+                      help='File containing the RPM subrpm details')
   parser.add_argument('--pre_scriptlet',
                       help='File containing the RPM %pre scriptlet, if to be substituted')
   parser.add_argument('--post_scriptlet',
@@ -514,6 +571,8 @@
 
   parser.add_argument('--rpmbuild_arg', dest='rpmbuild_args', action='append',
                       help='Any additional arguments to pass to rpmbuild')
+  parser.add_argument('--debuginfo_type', dest='debuginfo_type', default='none',
+                      help='debuginfo type to use (centos7, fedora40, or none)')
   parser.add_argument('files', nargs='*')
 
   options = parser.parse_args(argv or ())
@@ -526,9 +585,11 @@
                          debug=options.debug)
     builder.AddFiles(options.files)
     return builder.Build(options.spec_file, options.out_file,
+                         options.subrpm_out_file,
                          preamble_file=options.preamble,
                          description_file=options.description,
                          install_script_file=options.install_script,
+                         subrpms_file=options.subrpms,
                          file_list_path=options.file_list,
                          pre_scriptlet_path=options.pre_scriptlet,
                          post_scriptlet_path=options.post_scriptlet,
@@ -536,7 +597,8 @@
                          postun_scriptlet_path=options.postun_scriptlet,
                          posttrans_scriptlet_path=options.posttrans_scriptlet,
                          changelog_file=options.changelog,
-                         rpmbuild_args=options.rpmbuild_args)
+                         rpmbuild_args=options.rpmbuild_args,
+                         debuginfo_type=options.debuginfo_type)
   except NoRpmbuildFoundError:
     print('ERROR: rpmbuild is required but is not present in PATH')
     return 1
diff --git a/pkg/mappings.bzl b/pkg/mappings.bzl
index 704a8db..be863ec 100644
--- a/pkg/mappings.bzl
+++ b/pkg/mappings.bzl
@@ -29,6 +29,7 @@
 
 load("@bazel_skylib//lib:paths.bzl", "paths")
 load("//pkg:providers.bzl", "PackageDirsInfo", "PackageFilegroupInfo", "PackageFilesInfo", "PackageSymlinkInfo")
+load("//pkg/private:util.bzl", "get_repo_mapping_manifest")
 
 # TODO(#333): strip_prefix module functions should produce unique outputs.  In
 # particular, this one and `_sp_from_pkg` can overlap.
@@ -298,7 +299,7 @@
             target = file_to_target[src]
             runfiles = target[DefaultInfo].default_runfiles
             if runfiles:
-                base_path = src_dest_paths_map[src] + ".runfiles"
+                base_path = src_dest_paths_map[src] + ".runfiles/" + ctx.workspace_name
                 for rf in runfiles.files.to_list():
                     dest_path = paths.join(base_path, rf.short_path)
 
@@ -311,6 +312,13 @@
                     else:
                         src_dest_paths_map[rf] = dest_path
 
+                # if repo_mapping manifest exists (for e.g. with --enable_bzlmod),
+                # create _repo_mapping under runfiles directory
+                repo_mapping_manifest = get_repo_mapping_manifest(target)
+                if repo_mapping_manifest:
+                    dest_path = paths.join(src_dest_paths_map[src] + ".runfiles", "_repo_mapping")
+                    src_dest_paths_map[repo_mapping_manifest] = 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
diff --git a/pkg/private/install.py.tpl b/pkg/private/install.py.tpl
index 1e82fae..3a29f05 100644
--- a/pkg/private/install.py.tpl
+++ b/pkg/private/install.py.tpl
@@ -20,6 +20,7 @@
 import argparse
 import logging
 import os
+import pathlib
 import shutil
 import sys
 
@@ -74,11 +75,11 @@
                 logging.info("CHOWN %s:%s %s", user, group, dest)
                 shutil.chown(dest, user, group)
 
-    def _do_file_copy(self, src, dest, mode, user, group):
+    def _do_file_copy(self, src, dest):
         logging.info("COPY %s <- %s", dest, src)
         shutil.copyfile(src, dest)
 
-    def _do_mkdir(self, dirname, mode, user, group):
+    def _do_mkdir(self, dirname, mode):
         logging.info("MKDIR %s %s", mode, dirname)
         os.makedirs(dirname, int(mode, 8), exist_ok=True)
 
@@ -93,25 +94,56 @@
 
     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._do_file_copy(entry.src, entry.dest)
         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._do_mkdir(entry.dest, entry.mode)
         self._chown_chmod(entry.dest, entry.mode, entry.user, entry.group)
 
+    def _install_treeartifact_file(self, entry, src, dst):
+        self._do_file_copy(src, dst)
+        self._chown_chmod(dst, 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))
+        shutil.copytree(
+            src=entry.src,
+            dst=entry.dest,
+            copy_function=lambda s, d:
+                self._install_treeartifact_file(entry, s, d),
+            dirs_exist_ok=True,
+            # Bazel gives us a directory of symlinks, so we dereference it.
+            # TODO: Handle symlinks within the TreeArtifact. This is not yet
+            # tested for other rules (e.g.
+            # https://github.com/bazelbuild/rules_pkg/issues/750)
+            symlinks=False,
+            ignore_dangling_symlinks=True,
+        )
 
-            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)
+        # Set mode/user/group for intermediate directories.
+        # 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
+        intermediate_dir_mode = "755"
+        for root, dirs, _ in os.walk(entry.src, topdown=False):
+            relative_installdir = os.path.join(entry.dest,
+                                               os.path.relpath(root, entry.src))
+            for d in dirs:
+                self._chown_chmod(os.path.join(relative_installdir, d),
+                                  intermediate_dir_mode,
+                                  entry.user, entry.group)
+
+        # For top-level directory, use entry.mode +r +x if specified, otherwise
+        # use least-surprising canonical rwxr-xr-x
+        top_dir_mode = entry.mode
+        if top_dir_mode:
+            top_dir_mode = int(top_dir_mode, 8)
+            top_dir_mode |= 0o555
+            top_dir_mode = oct(top_dir_mode).removeprefix("0o")
+        else:
+            top_dir_mode = "755"
+        self._chown_chmod(entry.dest, top_dir_mode, entry.user, entry.group)
 
     def _install_symlink(self, entry):
         raise NotImplementedError("symlinking not yet supported")
@@ -151,6 +183,36 @@
                 raise ValueError("Unrecognized entry type '{}'".format(entry.type))
 
 
+def _default_destdir():
+    # If --destdir is not specified, use these values, in this order
+    # Use env var if specified and non-empty
+    env = os.getenv("DESTDIR")
+    if env:
+        return env
+
+    # Checks if DEFAULT_DESTDIR is an empty string
+    target_attr = "{DEFAULT_DESTDIR}"
+    if target_attr:
+        return target_attr
+
+    return None
+
+
+def _resolve_destdir(path_s):
+    if not path_s:
+        raise argparse.ArgumentTypeError("destdir is not set!")
+    path = pathlib.Path(path_s)
+    if path.is_absolute():
+        return path_s
+    build_workspace_directory = os.getenv("BUILD_WORKSPACE_DIRECTORY")
+    if not build_workspace_directory:
+        raise argparse.ArgumentTypeError(f"BUILD_WORKSPACE_DIRECTORY is not set"
+                                         f" and destdir {path} is relative. "
+                                         f"Unable to infer an absolute path.")
+    ret = str(pathlib.Path(build_workspace_directory) / path)
+    return ret
+
+
 def main(args):
     parser = argparse.ArgumentParser(
         prog="bazel run -- {TARGET_LABEL}",
@@ -163,12 +225,16 @@
                         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.")
+    default_destdir = _default_destdir()
+    default_destdir_text = f" or {default_destdir}" if default_destdir else ""
+    parser.add_argument('--destdir', action='store', default=default_destdir,
+                        required=default_destdir is None,
+                        type=_resolve_destdir,
+                        help=f"Installation root directory (defaults to DESTDIR"
+                             f" environment variable{default_destdir_text}). "
+                             f"Relative paths are interpreted against "
+                             f"BUILD_WORKSPACE_DIRECTORY "
+                             f"({os.getenv('BUILD_WORKSPACE_DIRECTORY')})")
 
     args = parser.parse_args()
 
diff --git a/pkg/private/pkg_files.bzl b/pkg/private/pkg_files.bzl
index 6fc0971..2595aef 100644
--- a/pkg/private/pkg_files.bzl
+++ b/pkg/private/pkg_files.bzl
@@ -39,6 +39,11 @@
     "PackageFilesInfo",
     "PackageSymlinkInfo",
 )
+load(
+    "//pkg/private:util.bzl",
+    "get_files_to_run_provider",
+    "get_repo_mapping_manifest",
+)
 
 ENTRY_IS_FILE = "file"  # Entry is a file: take content from <src>
 ENTRY_IS_LINK = "symlink"  # Entry is a symlink: dest -> <src>
@@ -73,8 +78,8 @@
         # Behaviors
         "allow_duplicates_with_different_content": "bool: don't fail when you double mapped files",
         "include_runfiles": "bool: include runfiles",
+        "workspace_name": "string: name of the main workspace",
         "strip_prefix": "strip_prefix",
-
         "path_mapper": "function to map destination paths",
 
         # Defaults
@@ -94,8 +99,7 @@
         strip_prefix = None,
         include_runfiles = None,
         default_mode = None,
-        path_mapper = None
-    ):
+        path_mapper = None):
     """Construct a MappingContext.
 
     Args: See the provider definition.
@@ -119,6 +123,7 @@
         allow_duplicates_with_different_content = allow_duplicates_with_different_content,
         strip_prefix = strip_prefix,
         include_runfiles = include_runfiles,
+        workspace_name = ctx.workspace_name,
         default_mode = default_mode,
         path_mapper = path_mapper or (lambda x: x),
         # TODO(aiuto): allow these to be passed in as needed. But, before doing
@@ -370,7 +375,8 @@
                 src,
                 data_path,
                 data_path_without_prefix,
-                include_runfiles = mapping_context.include_runfiles,
+                mapping_context.include_runfiles,
+                mapping_context.workspace_name,
             )
 
 def add_from_default_info(
@@ -378,7 +384,8 @@
         src,
         data_path,
         data_path_without_prefix,
-        include_runfiles = False):
+        include_runfiles,
+        workspace_name):
     """Helper method to add the DefaultInfo of a target to a content_map.
 
     Args:
@@ -396,7 +403,8 @@
     all_files = src[DefaultInfo].files.to_list()
     for f in all_files:
         d_path = mapping_context.path_mapper(
-            dest_path(f, data_path, data_path_without_prefix))
+            dest_path(f, data_path, data_path_without_prefix),
+        )
         if f.is_directory:
             add_tree_artifact(
                 mapping_context.content_map,
@@ -418,6 +426,7 @@
                 user = mapping_context.default_user,
                 group = mapping_context.default_group,
             )
+
     if include_runfiles:
         runfiles = src[DefaultInfo].default_runfiles
         if runfiles:
@@ -428,7 +437,7 @@
             # the first file of DefaultInfo.files should be the right target.
             base_file = the_executable or all_files[0]
             base_file_path = dest_path(base_file, data_path, data_path_without_prefix)
-            base_path = base_file_path + ".runfiles"
+            base_path = base_file_path + ".runfiles/" + workspace_name
 
             for rf in runfiles.files.to_list():
                 d_path = mapping_context.path_mapper(base_path + "/" + rf.short_path)
@@ -436,7 +445,7 @@
                 _check_dest(mapping_context.content_map, d_path, rf, src.label, mapping_context.allow_duplicates_with_different_content)
                 mapping_context.content_map[d_path] = _DestFile(
                     src = rf,
-                    entry_type = ENTRY_IS_FILE,
+                    entry_type = ENTRY_IS_TREE if rf.is_directory else ENTRY_IS_FILE,
                     origin = src.label,
                     mode = fmode,
                     user = mapping_context.default_user,
@@ -445,6 +454,43 @@
                     gid = mapping_context.default_gid,
                 )
 
+            # if repo_mapping manifest exists (for e.g. with --enable_bzlmod),
+            # create _repo_mapping under runfiles directory
+            repo_mapping_manifest = get_repo_mapping_manifest(src)
+            if repo_mapping_manifest:
+                mapping_context.file_deps.append(depset([repo_mapping_manifest]))
+
+                # TODO: This should really be a symlink into .runfiles/_repo_mapping
+                # that also respects remap_paths. For now this is duplicated with the
+                # repo_mapping file within the runfiles directory
+                d_path = mapping_context.path_mapper(dest_path(
+                    repo_mapping_manifest,
+                    data_path,
+                    data_path_without_prefix,
+                ))
+                add_single_file(
+                    mapping_context,
+                    dest_path = d_path,
+                    src = repo_mapping_manifest,
+                    origin = src.label,
+                    mode = mapping_context.default_mode,
+                    user = mapping_context.default_user,
+                    group = mapping_context.default_group,
+                )
+
+                runfiles_repo_mapping_path = mapping_context.path_mapper(
+                    base_file_path + ".runfiles/_repo_mapping",
+                )
+                add_single_file(
+                    mapping_context,
+                    dest_path = runfiles_repo_mapping_path,
+                    src = repo_mapping_manifest,
+                    origin = src.label,
+                    mode = mapping_context.default_mode,
+                    user = mapping_context.default_user,
+                    group = mapping_context.default_group,
+                )
+
 def get_my_executable(src):
     """If a target represents an executable, return its file handle.
 
@@ -457,21 +503,15 @@
     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
+
+    files_to_run_provider = get_files_to_run_provider(src)
 
     # 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
+    if getattr(files_to_run_provider, "runfiles_manifest"):
+        # DEBUG print("Got an manifest executable", files_to_run_provider.executable)
+        return files_to_run_provider.executable
     return None
 
 def add_single_file(mapping_context, dest_path, src, origin, mode = None, user = None, group = None, uid = None, gid = None):
diff --git a/pkg/private/tar/BUILD b/pkg/private/tar/BUILD
index b4eee99..68a2b43 100644
--- a/pkg/private/tar/BUILD
+++ b/pkg/private/tar/BUILD
@@ -22,8 +22,6 @@
     default_applicable_licenses = ["//:license"],
 )
 
-licenses(["notice"])
-
 filegroup(
     name = "standard_package",
     srcs = [
diff --git a/pkg/private/tar/build_tar.py b/pkg/private/tar/build_tar.py
index f4b9f0d..ce80a9f 100644
--- a/pkg/private/tar/build_tar.py
+++ b/pkg/private/tar/build_tar.py
@@ -42,7 +42,7 @@
   class DebError(Exception):
     pass
 
-  def __init__(self, output, directory, compression, compressor, default_mtime):
+  def __init__(self, output, directory, compression, compressor, create_parents, allow_dups_from_deps, default_mtime):
     # Directory prefix on all output paths
     d = directory.strip('/')
     self.directory = (d + '/') if d else None
@@ -50,12 +50,16 @@
     self.compression = compression
     self.compressor = compressor
     self.default_mtime = default_mtime
+    self.create_parents = create_parents
+    self.allow_dups_from_deps = allow_dups_from_deps
 
   def __enter__(self):
     self.tarfile = tar_writer.TarFileWriter(
         self.output,
         self.compression,
         self.compressor,
+        self.create_parents,
+        self.allow_dups_from_deps,
         default_mtime=self.default_mtime)
     return self
 
@@ -182,7 +186,10 @@
       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)
+    if not symlink.startswith("./"):
+      dest = self.normalize_path(symlink)
+    else:
+      dest = symlink
     self.tarfile.add_file(
         dest,
         tarfile.SYMTYPE,
@@ -383,6 +390,13 @@
            'path/to/file=root.root.')
   parser.add_argument('--stamp_from', default='',
                       help='File to find BUILD_STAMP in')
+  parser.add_argument('--create_parents',
+                      action='store_true',
+                      help='Automatically creates parent directories implied by a'
+                           ' prefix if they do not exist')
+  parser.add_argument('--allow_dups_from_deps',
+                      action='store_true',
+                      help='')
   options = parser.parse_args()
 
   # Parse modes arguments
@@ -432,7 +446,9 @@
       directory = helpers.GetFlagValue(options.directory),
       compression = options.compression,
       compressor = options.compressor,
-      default_mtime=default_mtime) as output:
+      default_mtime=default_mtime,
+      create_parents=options.create_parents,
+      allow_dups_from_deps=options.allow_dups_from_deps) as output:
 
     def file_attributes(filename):
       if filename.startswith('/'):
diff --git a/pkg/private/tar/tar.bzl b/pkg/private/tar/tar.bzl
index 963cb5a..120820a 100644
--- a/pkg/private/tar/tar.bzl
+++ b/pkg/private/tar/tar.bzl
@@ -173,6 +173,12 @@
     args.set_param_file_format("flag_per_line")
     args.use_param_file("@%s", use_always = False)
 
+    if ctx.attr.create_parents:
+        args.add("--create_parents")
+
+    if ctx.attr.allow_duplicates_from_deps:
+        args.add("--allow_dups_from_deps")
+
     inputs = depset(
         direct = ctx.files.deps + files,
         transitive = mapping_context.file_deps,
@@ -264,6 +270,8 @@
         "compressor_args": attr.string(
             doc = """Arg list for `compressor`.""",
         ),
+        "create_parents": attr.bool(default = True),
+        "allow_duplicates_from_deps": attr.bool(default = False),
 
         # Common attributes
         "out": attr.output(mandatory = True),
diff --git a/pkg/private/tar/tar_writer.py b/pkg/private/tar/tar_writer.py
index 325db76..cee232d 100644
--- a/pkg/private/tar/tar_writer.py
+++ b/pkg/private/tar/tar_writer.py
@@ -46,6 +46,8 @@
                name,
                compression='',
                compressor='',
+               create_parents=False,
+               allow_dups_from_deps=True,
                default_mtime=None,
                preserve_tar_mtimes=True):
     """TarFileWriter wraps tarfile.open().
@@ -106,6 +108,8 @@
     # we can adjust that here based on the setting of root_dirctory.
     self.directories.add('/')
     self.directories.add('./')
+    self.create_parents = create_parents
+    self.allow_dups_from_deps = allow_dups_from_deps
 
   def __enter__(self):
     return self
@@ -123,14 +127,15 @@
       # 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)
+    if not self.allow_dups_from_deps and self._have_added(info.name):
+        print('Duplicate file in archive: %s, '
+              'picking first occurrence' % info.name)
+        return
+
+    self.tar.addfile(info, fileobj)
+    self.members.add(info.name)
+    if info.type == tarfile.DIRTYPE:
+      self.directories.add(info.name)
 
   def add_directory_path(self,
                          path,
@@ -152,7 +157,7 @@
       mode: unix permission mode of the file, default: 0755.
     """
     assert path[-1] == '/'
-    if not path or self._have_added(path):
+    if not path:
       return
     if _DEBUG_VERBOSITY > 1:
       print('DEBUG: adding directory', path)
@@ -166,12 +171,14 @@
     tarinfo.gname = gname
     self._addfile(tarinfo)
 
-  def add_parents(self, path, uid=0, gid=0, uname='', gname='', mtime=0, mode=0o755):
+  def conditionally_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(
+
+      if self.create_parents and not self._have_added(parent_path):
+        self.add_directory_path(
           parent_path,
           uid=uid,
           gid=gid,
@@ -212,14 +219,14 @@
       return
     if name == '.':
       return
-    if name in self.members:
+    if not self.allow_dups_from_deps and 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)
+    self.conditionally_add_parents(name, mtime=mtime, mode=0o755, uid=uid, gid=gid, uname=uname, gname=gname)
 
     tarinfo = tarfile.TarInfo(name)
     tarinfo.mtime = mtime
@@ -291,7 +298,7 @@
         if prefix:
           in_name = os.path.normpath(prefix + in_name).replace(os.path.sep, '/')
         tarinfo.name = in_name
-        self.add_parents(
+        self.conditionally_add_parents(
             path=tarinfo.name,
             mtime=tarinfo.mtime,
             mode=0o755,
diff --git a/pkg/private/util.bzl b/pkg/private/util.bzl
index 7225456..3786314 100644
--- a/pkg/private/util.bzl
+++ b/pkg/private/util.bzl
@@ -92,4 +92,37 @@
         attribute_value = attribute_value.replace("$(", "{", 1)
         attribute_value = attribute_value.replace(")", "}", 1)
 
-    return attribute_value.format(**vars)
\ No newline at end of file
+    return attribute_value.format(**vars)
+
+def get_files_to_run_provider(src):
+    """Safely retrieve FilesToRunProvider from a target.
+
+    Args:
+        src: target to get FilesToRunProvider from
+
+    Returns:
+        FilesToRunProvider or None: FilesToRunProvider if found in target
+            provider, otherwise None
+    """
+    if not DefaultInfo in src:
+        return None
+    di = src[DefaultInfo]
+    if not hasattr(di, "files_to_run"):
+        return None
+    return di.files_to_run
+
+def get_repo_mapping_manifest(src):
+    """Safely retrieve repo_mapping_manifest from a target if it exists.
+
+    Args:
+        src: target to get repo_mapping_manifest from
+
+    Returns:
+        File or None: repo_mapping_manifest
+    """
+    files_to_run_provider = get_files_to_run_provider(src)
+    if files_to_run_provider:
+        # repo_mapping_manifest may not exist in older Bazel versions (<7.0.0)
+        # https://github.com/bazelbuild/bazel/issues/19937
+        return getattr(files_to_run_provider, "repo_mapping_manifest")
+    return None
diff --git a/pkg/private/zip/build_zip.py b/pkg/private/zip/build_zip.py
index 5a191b7..c2ff364 100644
--- a/pkg/private/zip/build_zip.py
+++ b/pkg/private/zip/build_zip.py
@@ -74,7 +74,7 @@
 
 
 def parse_date(ts):
-  ts = datetime.datetime.utcfromtimestamp(ts)
+  ts = datetime.datetime.fromtimestamp(ts, tz=datetime.timezone.utc)
   return (ts.year, ts.month, ts.day, ts.hour, ts.minute, ts.second)
 
 
diff --git a/pkg/releasing/git.bzl b/pkg/releasing/git.bzl
index 787e75b..f37e6c6 100644
--- a/pkg/releasing/git.bzl
+++ b/pkg/releasing/git.bzl
@@ -26,9 +26,9 @@
     if toolchain.path:
         args.add("--git_path", toolchain.path)
     else:
-        executable = toolchain.label.files_to_run.executable
+        executable = toolchain.label[DefaultInfo].files_to_run.executable
         tools.append(executable)
-        tools.append(toolchain.label.default_runfiles.files.to_list())
+        tools.append(toolchain.label[DefaultInfo].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)
diff --git a/pkg/rpm.bzl b/pkg/rpm.bzl
index 2fc5804..c9d9e3b 100644
--- a/pkg/rpm.bzl
+++ b/pkg/rpm.bzl
@@ -29,10 +29,12 @@
 
 """
 
-load("//pkg:rpm_pfg.bzl", pkg_rpm_pfg = "pkg_rpm")
+load("//pkg:rpm_pfg.bzl", _pkg_sub_rpm = "pkg_sub_rpm", pkg_rpm_pfg = "pkg_rpm")
 load("//pkg/legacy:rpm.bzl", pkg_rpm_legacy = "pkg_rpm")
 
-def pkg_rpm(name, srcs = None, spec_file = None, **kwargs):
+pkg_sub_rpm = _pkg_sub_rpm
+
+def pkg_rpm(name, srcs = None, spec_file = None, subrpms = None, **kwargs):
     """pkg_rpm wrapper
 
     This rule selects between the two implementations of pkg_rpm as described in
@@ -51,16 +53,20 @@
                 depending on mode
 
     """
-    if srcs and spec_file:
+    if srcs != None 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:
+    if subrpms and spec_file:
+        fail("Cannot build sub RPMs with a specfile.  `subrpms` and `spec_file` are mutually exclusive")
+
+    if srcs == None and not spec_file:
         fail("Either `srcs` or `spec_file` must be provided.")
 
-    if srcs:
+    if srcs != None:
         pkg_rpm_pfg(
             name = name,
             srcs = srcs,
+	    subrpms = subrpms,
             **kwargs
         )
     elif spec_file:
diff --git a/pkg/rpm/BUILD b/pkg/rpm/BUILD
index f7564b2..a2742f4 100644
--- a/pkg/rpm/BUILD
+++ b/pkg/rpm/BUILD
@@ -18,7 +18,6 @@
 
 exports_files(
     glob([
-        "*.bzl",
         "*.tpl",
     ]),
     visibility = ["//visibility:public"],
@@ -27,7 +26,6 @@
 filegroup(
     name = "standard_package",
     srcs = glob([
-        "*.bzl",
         "*.py",
         "*.tpl",
     ]) + [
diff --git a/pkg/rpm/template.spec.tpl b/pkg/rpm/template.spec.tpl
index ba25db8..839a48d 100644
--- a/pkg/rpm/template.spec.tpl
+++ b/pkg/rpm/template.spec.tpl
@@ -21,4 +21,6 @@
 
 ${POSTTRANS_SCRIPTLET}
 
+${SUBRPMS}
+
 ${CHANGELOG}
diff --git a/pkg/rpm_pfg.bzl b/pkg/rpm_pfg.bzl
index 0ccdbaf..cf6cb6b 100644
--- a/pkg/rpm_pfg.bzl
+++ b/pkg/rpm_pfg.bzl
@@ -39,6 +39,28 @@
 
 spec_filetype = [".spec", ".spec.in", ".spec.tpl"]
 
+PackageSubRPMInfo = provider(
+    doc = """Provider representing a sub-RPM that can be built as part of a larger RPM""",
+    fields = {
+        "package_name": "name of the subpackage",
+        "summary": "RPM subpackage `Summary` tag",
+        "group": "RPM subpackage `Group` tag",
+        "description": "Multi-line description of this subpackage",
+        "post_scriptlet": "RPM `$post` scriplet for this subpackage",
+        "architecture": "Subpackage architecture",
+        "epoch": "RPM `Epoch` tag for this subpackage",
+        "version": "RPM `Version` tag for this subpackage",
+        "requires": "List of RPM capability expressions that this package requires",
+        "provides": "List of RPM capability expressions that this package provides",
+        "conflicts": "List of RPM capability expressions that conflict with this package",
+        "obsoletes": "List of RPM capability expressions that this package obsoletes",
+        "srcs": "Mapping groups to include in this RPM",
+    },
+)
+
+# default mode for %files
+DEFAULT_FILE_MODE = "%defattr(-,root,root)"
+
 # TODO(nacl): __install, __cp
 # {0} is the source, {1} is the dest
 #
@@ -46,6 +68,13 @@
 _INSTALL_FILE_STANZA_FMT = """
 install -d "%{{buildroot}}/$(dirname '{1}')"
 cp '{0}' '%{{buildroot}}/{1}'
+chmod +w '%{{buildroot}}/{1}'
+""".strip()
+
+_INSTALL_FILE_STANZA_FMT_FEDORA40_DEBUGINFO = """
+install -d "%{{buildroot}}/$(dirname '{1}')"
+cp '../{0}' '%{{buildroot}}/{1}'
+chmod +w '%{{buildroot}}/{1}'
 """.strip()
 
 # TODO(nacl): __install
@@ -146,25 +175,41 @@
     # this can be inlined easily.
     return path if path.startswith(("/", "%")) else "/" + path
 
+def _make_rpm_filename(rpm_name, version, architecture, package_name=None, release=None):
+    prefix = "%s-%s"
+    items = [rpm_name, version]
+
+    if package_name:
+        prefix += "-%s"
+        items = [rpm_name, package_name, version]
+
+    if release:
+        prefix += "-%s"
+        items += [release]
+
+    fmt = prefix + ".%s.rpm"
+
+    return fmt % tuple(items + [architecture])
+
 #### 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):
+def _process_files(pfi, origin_label, grouping_label, file_base, rpm_ctx, debuginfo_type):
     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])
+        if dest in rpm_ctx.dest_check_map:
+            _conflicting_contents_error(dest, metadata, rpm_ctx.dest_check_map[dest])
         else:
-            dest_check_map[dest] = metadata
+            rpm_ctx.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({
+            rpm_ctx.packaged_directories.append({
                 "src": src,
                 "dest": abs_dest,
                 # This doesn't exactly make it extensible, but it saves
@@ -174,56 +219,254 @@
             })
         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(
+            rpm_ctx.rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dest))
+
+            install_stanza_fmt = _INSTALL_FILE_STANZA_FMT
+            if debuginfo_type == "fedora40":
+                install_stanza_fmt = _INSTALL_FILE_STANZA_FMT_FEDORA40_DEBUGINFO
+
+            rpm_ctx.install_script_pieces.append(install_stanza_fmt.format(
                 src.path,
                 abs_dest,
             ))
 
-def _process_dirs(pdi, origin_label, grouping_label, file_base, dest_check_map, _, rpm_files_list, install_script_pieces):
+def _process_dirs(pdi, origin_label, grouping_label, file_base, rpm_ctx):
     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])
+        if dest in rpm_ctx.dest_check_map:
+            _conflicting_contents_error(dest, metadata, rpm_ctx.dest_check_map[dest])
         else:
-            dest_check_map[dest] = metadata
+            rpm_ctx.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))
+        rpm_ctx.rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dirname))
 
-        install_script_pieces.append(_INSTALL_DIR_STANZA_FMT.format(
+        rpm_ctx.install_script_pieces.append(_INSTALL_DIR_STANZA_FMT.format(
             abs_dirname,
         ))
 
-def _process_symlink(psi, origin_label, grouping_label, file_base, dest_check_map, _, rpm_files_list, install_script_pieces):
+def _process_symlink(psi, origin_label, grouping_label, file_base, rpm_ctx):
     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])
+    if psi.destination in rpm_ctx.dest_check_map:
+        _conflicting_contents_error(psi.destination, metadata, rpm_ctx.dest_check_map[psi.destination])
     else:
-        dest_check_map[psi.destination] = metadata
+        rpm_ctx.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(
+    rpm_ctx.rpm_files_list.append(_FILE_MODE_STANZA_FMT.format(file_base, abs_dest))
+    rpm_ctx.install_script_pieces.append(_INSTALL_SYMLINK_STANZA_FMT.format(
         abs_dest,
         psi.target,
         psi.attributes["mode"],
     ))
 
+def _process_dep(dep, rpm_ctx, debuginfo_type):
+    # 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
+            rpm_ctx,
+            debuginfo_type,
+        )
+
+    if PackageDirsInfo in dep:
+        _process_dirs(
+            dep[PackageDirsInfo],
+            dep.label,  # origin label
+            None,  # group label
+            _make_filetags(dep[PackageDirsInfo].attributes, "%dir"),  # file_base
+            rpm_ctx,
+        )
+
+    if PackageSymlinkInfo in dep:
+        _process_symlink(
+            dep[PackageSymlinkInfo],
+            dep.label,  # origin label
+            None,  # group label
+            _make_filetags(dep[PackageSymlinkInfo].attributes),  # file_base
+            rpm_ctx,
+        )
+
+    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,
+                rpm_ctx,
+                debuginfo_type
+            )
+        for entry, origin in pfg_info.pkg_dirs:
+            file_base = _make_filetags(entry.attributes, "%dir")
+            _process_dirs(
+                entry,
+                origin,
+                dep.label,
+                file_base,
+                rpm_ctx,
+            )
+
+        for entry, origin in pfg_info.pkg_symlinks:
+            file_base = _make_filetags(entry.attributes)
+            _process_symlink(
+                entry,
+                origin,
+                dep.label,
+                file_base,
+                rpm_ctx,
+            )
+
+def _process_subrpm(ctx, rpm_name, rpm_info, rpm_ctx, debuginfo_type):
+    sub_rpm_ctx = struct(
+        dest_check_map = {},
+        install_script_pieces = [],
+        packaged_directories = [],
+        rpm_files_list = [],
+    )
+
+    rpm_lines = [
+        "%%package %s" % rpm_info.package_name,
+        "Summary: %s" % rpm_info.summary,
+    ]
+
+    if rpm_info.architecture:
+        rpm_lines += ["BuildArch: %s" % rpm_info.architecture]
+
+    if rpm_info.epoch:
+        rpm_lines += ["Epoch: %s" % rpm_info.epoch]
+
+    if rpm_info.version:
+        rpm_lines += ["Version: %s" % rpm_info.version]
+
+    for r in rpm_info.requires:
+        rpm_lines += ["Requires: %s" % r]
+
+    for p in rpm_info.provides:
+        rpm_lines += ["Provides: %s" % p]
+
+    for c in rpm_info.conflicts:
+        rpm_lines += ["Conflicts: %s" % c]
+
+    for o in rpm_info.obsoletes:
+        rpm_lines += ["Obsoletes: %s" % o]
+
+    rpm_lines += [
+        "",
+        "%%description %s" % rpm_info.package_name,
+        rpm_info.description,
+    ]
+
+    if rpm_info.post_scriptlet:
+        rpm_lines += [
+            "",
+            "%%post %s" % rpm_info.package_name,
+        ]
+
+    if rpm_info.srcs:
+        rpm_lines += [
+            "",
+            "%%files %s" % rpm_info.package_name,
+        ]
+
+        for dep in rpm_info.srcs:
+            _process_dep(dep, sub_rpm_ctx, debuginfo_type)
+
+        # rpmbuild will be unhappy if we have no files so we stick
+        # default file mode in for that scenario
+        rpm_lines += [DEFAULT_FILE_MODE]
+        rpm_lines += sub_rpm_ctx.rpm_files_list
+
+        rpm_lines += [""]
+
+    rpm_ctx.install_script_pieces.extend(sub_rpm_ctx.install_script_pieces)
+    rpm_ctx.packaged_directories.extend(sub_rpm_ctx.packaged_directories)
+
+    package_file_name = _make_rpm_filename(
+        rpm_name = rpm_name,
+        version = rpm_info.version or ctx.attr.version,
+        architecture = rpm_info.architecture or ctx.attr.architecture,
+        package_name = rpm_info.package_name,
+        release = ctx.attr.release,
+    )
+
+    default_file = ctx.actions.declare_file("{}-{}.rpm".format(rpm_name, rpm_info.package_name))
+
+    _, output_file, _ = setup_output_files(
+        ctx,
+        package_file_name = package_file_name,
+        default_output_file = default_file,
+    )
+
+    rpm_ctx.output_rpm_files.append(output_file)
+    rpm_ctx.make_rpm_args.append("--subrpm_out_file=%s:%s" % (
+        rpm_info.package_name,
+        output_file.path,
+    ))
+
+    return rpm_lines
+
 #### Rule implementation
 
 def _pkg_rpm_impl(ctx):
     """Implements the pkg_rpm rule."""
 
+    rpm_ctx = struct(
+        # 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 = [],
+
+        # 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 = [],
+
+        # RPM files we expect to generate
+        output_rpm_files = [],
+
+        # Arguments that we pass to make_rpm.py
+        make_rpm_args = [],
+    )
+
     files = []
     tools = []
-    args = ["--name=" + ctx.label.name]
+    debuginfo_type = "none"
+    name = ctx.attr.package_name if ctx.attr.package_name else ctx.label.name
+    rpm_ctx.make_rpm_args.append("--name=" + name)
 
     if ctx.attr.debug:
-        args.append("--debug")
+        rpm_ctx.make_rpm_args.append("--debug")
 
     if ctx.attr.rpmbuild_path:
-        args.append("--rpmbuild=" + ctx.attr.rpmbuild_path)
+        rpm_ctx.make_rpm_args.append("--rpmbuild=" + ctx.attr.rpmbuild_path)
 
         # buildifier: disable=print
         print("rpmbuild_path is deprecated. See the README for instructions on how" +
@@ -234,11 +477,15 @@
             fail("The rpmbuild_toolchain is not properly configured: " +
                  toolchain.name)
         if toolchain.path:
-            args.append("--rpmbuild=" + toolchain.path)
+            rpm_ctx.make_rpm_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)
+            rpm_ctx.make_rpm_args.append("--rpmbuild=%s" % executable_files.executable.path)
+
+        if ctx.attr.debuginfo:
+            debuginfo_type = toolchain.debuginfo_type
+            rpm_ctx.make_rpm_args.append("--debuginfo_type=%s" % debuginfo_type)
 
     #### Calculate output file name
     # rpm_name takes precedence over name if provided
@@ -251,19 +498,13 @@
 
     package_file_name = ctx.attr.package_file_name
     if not package_file_name:
-        package_file_name = "%s-%s-%s.%s.rpm" % (
+        package_file_name = _make_rpm_filename(
             rpm_name,
             ctx.attr.version,
-            ctx.attr.release,
             ctx.attr.architecture,
+            release = ctx.attr.release,
         )
 
-    _, output_file, _ = setup_output_files(
-        ctx,
-        package_file_name = package_file_name,
-        default_output_file = default_file,
-    )
-
     #### rpm spec "preamble"
     preamble_pieces = []
 
@@ -275,7 +516,7 @@
             fail("Both version and version_file attributes were specified")
 
         preamble_pieces.append("Version: ${{VERSION_FROM_FILE}}")
-        args.append("--version=@" + ctx.file.version_file.path)
+        rpm_ctx.make_rpm_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)
@@ -288,7 +529,7 @@
             fail("Both release and release_file attributes were specified")
 
         preamble_pieces.append("Release: ${{RELEASE_FROM_FILE}}")
-        args.append("--release=@" + ctx.file.release_file.path)
+        rpm_ctx.make_rpm_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)
@@ -304,11 +545,13 @@
     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)
+        rpm_ctx.make_rpm_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))
+        rpm_ctx.make_rpm_args.append("--source_date_epoch=" + str(ctx.attr.source_date_epoch))
 
+    if ctx.attr.epoch:
+        preamble_pieces.append("Epoch: " + ctx.attr.epoch)
     if ctx.attr.summary:
         preamble_pieces.append("Summary: " + ctx.attr.summary)
     if ctx.attr.url:
@@ -352,7 +595,7 @@
         content = substitute_package_variables(ctx, "\n".join(preamble_pieces)),
     )
     files.append(preamble_file)
-    args.append("--preamble=" + preamble_file.path)
+    rpm_ctx.make_rpm_args.append("--preamble=" + preamble_file.path)
 
     #### %description
 
@@ -372,11 +615,11 @@
         fail("None of the description or description_file attributes were specified")
 
     files.append(description_file)
-    args.append("--description=" + description_file.path)
+    rpm_ctx.make_rpm_args.append("--description=" + description_file.path)
 
     if ctx.attr.changelog:
         files.append(ctx.file.changelog)
-        args.append("--changelog=" + ctx.file.changelog.path)
+        rpm_ctx.make_rpm_args.append("--changelog=" + ctx.file.changelog.path)
 
     #### Non-procedurally-generated scriptlets
 
@@ -386,60 +629,60 @@
             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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_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)
+        rpm_ctx.make_rpm_args.append("--postun_scriptlet=" + scriptlet_file.path)
 
     if ctx.attr.posttrans_scriptlet_file:
         if ctx.attr.posttrans_scriptlet:
             fail("Both posttrans_scriptlet and posttrans_scriptlet_file attributes were specified")
         posttrans_scriptlet_file = ctx.file.posttrans_scriptlet_file
         files.append(posttrans_scriptlet_file)
-        args.append("--posttrans_scriptlet=" + posttrans_scriptlet_file.path)
+        rpm_ctx.make_rpm_args.append("--posttrans_scriptlet=" + posttrans_scriptlet_file.path)
     elif ctx.attr.posttrans_scriptlet:
         scriptlet_file = ctx.actions.declare_file(ctx.label.name + ".posttrans_scriptlet")
         files.append(scriptlet_file)
         ctx.actions.write(scriptlet_file, ctx.attr.posttrans_scriptlet)
-        args.append("--posttrans_scriptlet=" + scriptlet_file.path)
+        rpm_ctx.make_rpm_args.append("--posttrans_scriptlet=" + scriptlet_file.path)
 
     #### Expand the spec file template; prepare data files
 
@@ -449,34 +692,23 @@
         output = spec_file,
         substitutions = substitutions,
     )
-    args.append("--spec_file=" + spec_file.path)
+    rpm_ctx.make_rpm_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
+    files += ctx.files.srcs + ctx.files.subrpms
 
-    #### Consistency checking; input processing
+    _, output_file, _ = setup_output_files(
+        ctx,
+        package_file_name = package_file_name,
+        default_output_file = default_file,
+    )
 
-    # 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 = {}
+    rpm_ctx.make_rpm_args.append("--out_file=" + output_file.path)
+    rpm_ctx.output_rpm_files.append(output_file)
 
-    # 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 = []
+        rpm_ctx.install_script_pieces.append("set -x")
 
     # Iterate over all incoming data, checking for conflicts and creating
     # datasets as we go from the actual contents of the RPM.
@@ -485,98 +717,47 @@
     # 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.
+        _process_dep(dep, rpm_ctx, debuginfo_type)
 
-        # 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,
-            )
+    #### subrpms
+    if ctx.attr.subrpms:
+        subrpm_lines = []
+        for s in ctx.attr.subrpms:
+            subrpm_lines.extend(_process_subrpm(
+                ctx, rpm_name, s[PackageSubRPMInfo], rpm_ctx, debuginfo_type))
 
-        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,
-            )
+        subrpm_file = ctx.actions.declare_file(
+            "{}.spec.subrpms".format(rpm_name),
+        )
+        ctx.actions.write(
+            output = subrpm_file,
+            content = "\n".join(subrpm_lines),
+        )
+        files.append(subrpm_file)
+        rpm_ctx.make_rpm_args.append("--subrpms=" + subrpm_file.path)
 
-        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 debuginfo_type != "none":
+        debuginfo_default_file = ctx.actions.declare_file(
+            "{}-debuginfo.rpm".format(rpm_name))
+        debuginfo_package_file_name = _make_rpm_filename(
+            rpm_name,
+            ctx.attr.version,
+            ctx.attr.architecture,
+            package_name = "debuginfo",
+            release = ctx.attr.release,
+        )
 
-        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,
-                )
+        _, debuginfo_output_file, _ = setup_output_files(
+            ctx,
+            debuginfo_package_file_name,
+            default_output_file = debuginfo_default_file,
+        )
 
-            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,
-                )
+        rpm_ctx.output_rpm_files.append(debuginfo_output_file)
+        rpm_ctx.make_rpm_args.append(
+            "--subrpm_out_file=debuginfo:%s" % debuginfo_output_file.path )
 
     #### Procedurally-generated scripts/lists (%install, %files)
 
@@ -585,22 +766,23 @@
     install_script = ctx.actions.declare_file("{}.spec.install".format(rpm_name))
     ctx.actions.write(
         install_script,
-        "\n".join(install_script_pieces),
+        "\n".join(rpm_ctx.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),
-    )
+
+    # rpmbuild will be unhappy if we have no files so we stick
+    # default file mode in for that scenario
+    rpm_files_contents = [DEFAULT_FILE_MODE] + rpm_ctx.rpm_files_list
+    ctx.actions.write(rpm_files_file, "\n".join(rpm_files_contents))
 
     # TreeArtifact processing work
-    if packaged_directories:
+    if rpm_ctx.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]
+        packaged_directories_inputs = [d["src"] for d in rpm_ctx.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
@@ -609,10 +791,10 @@
         # 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:
+        for d in rpm_ctx.packaged_directories:
             d["src"] = d["src"].path
 
-        ctx.actions.write(packaged_directories_file, json.encode(packaged_directories))
+        ctx.actions.write(packaged_directories_file, json.encode(rpm_ctx.packaged_directories))
 
         # Overwrite all following uses of the install script and files lists to
         # use the ones generated below.
@@ -640,10 +822,10 @@
     # And then we're done.  Yay!
 
     files.append(install_script)
-    args.append("--install_script=" + install_script.path)
+    rpm_ctx.make_rpm_args.append("--install_script=" + install_script.path)
 
     files.append(rpm_files_file)
-    args.append("--file_list=" + rpm_files_file.path)
+    rpm_ctx.make_rpm_args.append("--file_list=" + rpm_files_file.path)
 
     #### Remaining setup
 
@@ -660,10 +842,10 @@
             "{} {}".format(key, value),
         ])
 
-    args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args])
+    rpm_ctx.make_rpm_args.extend(["--rpmbuild_arg=" + a for a in additional_rpmbuild_args])
 
-    for f in ctx.files.srcs:
-        args.append(f.path)
+    for f in ctx.files.srcs + ctx.files.subrpms:
+        rpm_ctx.make_rpm_args.append(f.path)
 
     #### Call the generator script.
 
@@ -671,9 +853,9 @@
         mnemonic = "MakeRpm",
         executable = ctx.executable._make_rpm,
         use_default_shell_env = True,
-        arguments = args,
+        arguments = rpm_ctx.make_rpm_args,
         inputs = files,
-        outputs = [output_file],
+        outputs = rpm_ctx.output_rpm_files,
         env = {
             "LANG": "en_US.UTF-8",
             "LC_CTYPE": "UTF-8",
@@ -689,13 +871,13 @@
 
     output_groups = {
         "out": [default_file],
-        "rpm": [output_file],
+        "rpm": rpm_ctx.output_rpm_files,
         "changes": changes,
     }
     return [
         OutputGroupInfo(**output_groups),
         DefaultInfo(
-            files = depset([output_file]),
+            files = depset(rpm_ctx.output_rpm_files),
         ),
     ]
 
@@ -761,6 +943,9 @@
             doc = "See 'Common Attributes' in the rules_pkg reference",
             providers = [PackageVariablesInfo],
         ),
+        "epoch": attr.string(
+            doc = """Optional; RPM "Epoch" tag.""",
+        ),
         "version": attr.string(
             doc = """RPM "Version" tag.
 
@@ -961,7 +1146,7 @@
 
             See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html
             """,
-	),
+        ),
         "requires": attr.string_list(
             doc = """List of rpm capability expressions that this package requires.
 
@@ -1046,6 +1231,27 @@
         "defines": attr.string_dict(
             doc = """Additional definitions to pass to rpmbuild""",
         ),
+        "subrpms": attr.label_list(
+            doc = """Sub RPMs to build with this RPM
+
+	    A list of `pkg_sub_rpm` instances that can be used to create sub RPMs as part of the
+	    overall package build.
+
+            NOTE: use of `subrpms` is incompatible with the legacy `spec_file` mode
+	    """,
+            providers = [
+                [PackageSubRPMInfo],
+            ],
+        ),
+        "debuginfo": attr.bool(
+            doc = """Enable generation of debuginfo RPMs
+
+            For supported platforms this will enable the generation of debuginfo RPMs adjacent
+            to the regular RPMs.  Currently this is supported by Fedora 40, CentOS7 and
+            CentOS Stream 9.
+            """,
+            default = False,
+        ),
         "rpmbuild_path": attr.string(
             doc = """Path to a `rpmbuild` binary.  Deprecated in favor of the rpmbuild toolchain""",
         ),
@@ -1067,3 +1273,80 @@
     implementation = _pkg_rpm_impl,
     toolchains = ["@rules_pkg//toolchains/rpm:rpmbuild_toolchain_type"],
 )
+
+def _pkg_sub_rpm_impl(ctx):
+    mapped_files_depsets = []
+
+    for s in ctx.attr.srcs:
+        if PackageFilegroupInfo in s:
+            mapped_files_depsets.append(s[DefaultInfo].files)
+
+        if PackageFilesInfo in s:
+            # dict.values() returns a list, not an iterator like in python3
+            mapped_files_depsets.append(s[DefaultInfo].files)
+
+    return [
+        PackageSubRPMInfo(
+            package_name = ctx.attr.package_name,
+            summary = ctx.attr.summary,
+            group = ctx.attr.group,
+            description = ctx.attr.description,
+            post_scriptlet = ctx.attr.post_scriptlet,
+            architecture = ctx.attr.architecture,
+            epoch = ctx.attr.epoch,
+            version = ctx.attr.version,
+            requires = ctx.attr.requires,
+            provides = ctx.attr.provides,
+            conflicts = ctx.attr.conflicts,
+            obsoletes = ctx.attr.obsoletes,
+            srcs = ctx.attr.srcs,
+        ),
+        DefaultInfo(
+            files = depset(transitive = mapped_files_depsets),
+        ),
+    ]
+
+pkg_sub_rpm = rule(
+    doc = """Define a sub RPM to be built as part of a parent RPM
+
+    This rule uses the outputs of the rules in `mappings.bzl` to define an sub
+    RPM that will be built as part of a larger RPM defined by a `pkg_rpm` instance.
+
+    """,
+    implementation = _pkg_sub_rpm_impl,
+    # @unsorted-dict-items
+    attrs = {
+        "package_name": attr.string(doc = "name of the subrpm"),
+        "summary": attr.string(doc = "Sub RPM `Summary` tag"),
+        "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.
+
+            """,
+        ),
+        "description": attr.string(doc = "Multi-line description of this subrpm"),
+        "post_scriptlet": attr.string(doc = "RPM `%post` scriplet for this subrpm"),
+        "architecture": attr.string(doc = "Sub RPM architecture"),
+        "epoch": attr.string(doc = "RPM `Epoch` tag for this subrpm"),
+        "version": attr.string(doc = "RPM `Version` tag for this subrpm"),
+        "requires": attr.string_list(doc = "List of RPM capability expressions that this package requires"),
+        "provides": attr.string_list(doc = "List of RPM capability expressions that this package provides"),
+        "conflicts": attr.string_list(doc = "List of RPM capability expressions that conflict with this package"),
+        "obsoletes": attr.string_list(doc = "List of RPM capability expressions that this package obsoletes"),
+        "srcs": attr.label_list(
+            doc = "Mapping groups to include in this RPM",
+            mandatory = True,
+            providers = [
+                [PackageSubRPMInfo, DefaultInfo],
+                [PackageFilegroupInfo, DefaultInfo],
+                [PackageFilesInfo, DefaultInfo],
+                [PackageDirsInfo],
+                [PackageSymlinkInfo],
+            ],
+        ),
+    },
+    provides = [PackageSubRPMInfo],
+)
diff --git a/tests/BUILD b/tests/BUILD
index f6ab2b0..93774a2 100644
--- a/tests/BUILD
+++ b/tests/BUILD
@@ -27,8 +27,6 @@
     default_visibility = ["//tests:__subpackages__"],
 )
 
-licenses(["notice"])
-
 exports_files(glob(["testdata/**"]))
 
 filegroup(
diff --git a/tests/install/BUILD b/tests/install/BUILD
index 5a2c127..4449a89 100644
--- a/tests/install/BUILD
+++ b/tests/install/BUILD
@@ -15,7 +15,7 @@
 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")
+load("//tests/util:defs.bzl", "directory", "fake_artifact")
 
 package(default_applicable_licenses = ["//:license"])
 
@@ -47,6 +47,7 @@
         ":artifact-in-owned-dir",
         ":artifact-in-unowned-dir",
         ":dirs",
+        ":generate_tree_pkg_files",
     ],
 )
 
@@ -75,3 +76,24 @@
         "owned-dir",
     ],
 )
+
+directory(
+    name = "generate_tree",
+    contents = "hello there",
+    filenames = [
+        # buildifier: don't sort
+        "b/e",
+        "a/a",
+        "b/c/d",
+        "b/d",
+        "a/b/c",
+    ],
+)
+
+pkg_files(
+    name = "generate_tree_pkg_files",
+    srcs = [":generate_tree"],
+    attributes = pkg_attributes(
+        mode = "640",
+    ),
+)
diff --git a/tests/install/test.py b/tests/install/test.py
index bbb02ab..3ee2562 100644
--- a/tests/install/test.py
+++ b/tests/install/test.py
@@ -61,6 +61,12 @@
 
     def assertEntryTypeMatches(self, entry, actual_path):
         actual_entry_type = self.entity_type_at_path(actual_path)
+
+        # TreeArtifacts looks like directories.
+        if (entry.type == manifest.ENTRY_IS_TREE and
+                actual_entry_type == manifest.ENTRY_IS_DIR):
+            return
+
         self.assertEqual(actual_entry_type, entry.type,
                         "Entity {} should be a {}, but was actually {}".format(
                             entry.dest,
@@ -68,7 +74,8 @@
                             manifest.entry_type_to_string(actual_entry_type),
                         ))
 
-    def assertEntryModeMatches(self, entry, actual_path):
+    def assertEntryModeMatches(self, entry, actual_path,
+                               is_tree_artifact_content=False):
         # 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':
@@ -76,14 +83,28 @@
 
         actual_mode = stat.S_IMODE(os.stat(actual_path).st_mode)
         expected_mode = int(entry.mode, 8)
+
+        if (not is_tree_artifact_content and
+                entry.type == manifest.ENTRY_IS_TREE):
+            expected_mode |= 0o555
+
         self.assertEqual(actual_mode, expected_mode,
-                         "Entry {} has mode {:04o}, expected {:04o}".format(
-                            entry.dest, actual_mode, expected_mode,
-                        ))
+            "Entry {}{} has mode {:04o}, expected {:04o}".format(
+            entry.dest,
+            f" ({actual_path})" if is_tree_artifact_content else "",
+            actual_mode, expected_mode,
+        ))
+
+    def _find_tree_entry(self, path, owned_trees):
+        for tree_root in owned_trees:
+            if path == tree_root or path.startswith(tree_root + "/"):
+                return tree_root
+        return None
 
     def test_manifest_matches(self):
         unowned_dirs = set()
         owned_dirs = set()
+        owned_trees = dict()
 
         # Figure out what directories we are supposed to own, and which ones we
         # aren't.
@@ -95,6 +116,8 @@
         for dest, data in self.manifest_data.items():
             if data.type == manifest.ENTRY_IS_DIR:
                 owned_dirs.add(dest)
+            elif data.type == manifest.ENTRY_IS_TREE:
+                owned_trees[dest] = data
 
             # TODO(nacl): The initial stage of the accumulation returns an empty string,
             # which end up in the set representing the root of the manifest.
@@ -119,9 +142,6 @@
             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
@@ -145,7 +165,10 @@
                 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)
+                    is_unowned = rel_root_path in unowned_dirs
+                    is_tree_intermediate_dir = bool(
+                        self._find_tree_entry(rel_root_path, owned_trees))
+                    self.assertTrue(is_unowned or is_tree_intermediate_dir)
 
             for f in files:
                 # The path on the filesystem in which the file actually exists.
@@ -163,17 +186,23 @@
                 # 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:
+                entity_in_manifest = rel_fpath in self.manifest_data
+                entity_tree_root = self._find_tree_entry(rel_fpath, owned_trees)
+                if not entity_in_manifest and not entity_tree_root:
                     self.fail("Entity {} not in manifest".format(rel_fpath))
 
-                entry = self.manifest_data[rel_fpath]
-                self.assertEntryTypeMatches(entry, fpath)
-                self.assertEntryModeMatches(entry, fpath)
+                if entity_in_manifest:
+                    entry = self.manifest_data[rel_fpath]
+                    self.assertEntryTypeMatches(entry, fpath)
+                    self.assertEntryModeMatches(entry, fpath)
+
+                if entity_tree_root:
+                    entry = owned_trees[entity_tree_root]
+                    self.assertEntryModeMatches(entry, fpath,
+                                                is_tree_artifact_content=True)
 
                 found_entries[rel_fpath] = True
 
-        # TODO(nacl): check for TreeArtifacts
-
         num_missing = 0
         for dest, present in found_entries.items():
             if present is False:
diff --git a/tests/mappings/BUILD b/tests/mappings/BUILD
index fd3469b..e913c0b 100644
--- a/tests/mappings/BUILD
+++ b/tests/mappings/BUILD
@@ -27,6 +27,8 @@
     "mappings_analysis_tests",
     "mappings_unit_tests",
 )
+load("@rules_python//python:defs.bzl", "py_library")
+
 
 package(default_applicable_licenses = ["//:license"])
 
diff --git a/tests/mappings/executable.manifest.golden b/tests/mappings/executable.manifest.golden
index 9219554..4c7a5cb 100644
--- a/tests/mappings/executable.manifest.golden
+++ b/tests/mappings/executable.manifest.golden
@@ -1,7 +1,9 @@
 [
-{"dest":"an_executable.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
-{"dest":"an_executable.runfiles/tests/an_executable","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable","type":"file","uid":null,"user":null},
-{"dest":"an_executable.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null},
+{"dest":"an_executable.runfiles/_main/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/_main/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
+{"dest":"an_executable.runfiles/_main/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":"an_executable.repo_mapping","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/an_executable.repo_mapping","type":"file","uid":null,"user":null},
+{"dest":"an_executable.runfiles/_repo_mapping","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/an_executable.repo_mapping","type":"file","uid":null,"user":null},
 {"dest":"mappings_test.bzl","gid":null,"group":null,"mode":"","origin":"@//tests/mappings:mappings_test.bzl","src":"tests/mappings/mappings_test.bzl","type":"file","uid":null,"user":null}
 ]
diff --git a/tests/mappings/executable.manifest.windows.golden b/tests/mappings/executable.manifest.windows.golden
index 150f477..f76077f 100644
--- a/tests/mappings/executable.manifest.windows.golden
+++ b/tests/mappings/executable.manifest.windows.golden
@@ -1,7 +1,9 @@
 [
-{"dest":"an_executable.exe.runfiles/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
-{"dest":"an_executable.exe.runfiles/tests/an_executable.exe","gid":null,"group":null,"mode":"0755","origin":"@//tests:an_executable","src":"tests/an_executable.exe","type":"file","uid":null,"user":null},
-{"dest":"an_executable.exe.runfiles/tests/testdata/hello.txt","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/testdata/hello.txt","type":"file","uid":null,"user":null},
+{"dest":"an_executable.exe.runfiles/_main/tests/foo.cc","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src":"tests/foo.cc","type":"file","uid":null,"user":null},
+{"dest":"an_executable.exe.runfiles/_main/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/_main/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":"an_executable.exe.repo_mapping","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src": "tests/an_executable.exe.repo_mapping","type": "file","uid":null,"user":null},
+{"dest":"an_executable.exe.runfiles/_repo_mapping","gid":null,"group":null,"mode":"","origin":"@//tests:an_executable","src": "tests/an_executable.exe.repo_mapping","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/mappings_test.bzl b/tests/mappings/mappings_test.bzl
index d5dc0c2..235a71c 100644
--- a/tests/mappings/mappings_test.bzl
+++ b/tests/mappings/mappings_test.bzl
@@ -59,14 +59,21 @@
     target_under_test = analysistest.target_under_test(env)
 
     expected_dests = {e: None for e in ctx.attr.expected_dests}
+    actual_dests = target_under_test[PackageFilesInfo].dest_src_map.keys()
     n_found = 0
-    for got in target_under_test[PackageFilesInfo].dest_src_map.keys():
+
+    for actual in actual_dests:
         asserts.true(
-            got in expected_dests,
-            "got <%s> not in expected set: %s" % (got, ctx.attr.expected_dests),
+            env,
+            actual in expected_dests,
+            "actual dest <%s> not in expected expected set: %s" % (actual, ctx.attr.expected_dests),
         )
-        n_found += 1
-    asserts.equals(env, len(expected_dests), n_found)
+    for expected in expected_dests:
+        asserts.true(
+            env,
+            expected in actual_dests,
+            "expected dest <%s> missing from actual set: %s" % (expected, actual_dests),
+        )
 
     # Simple equality checks for the others, if specified
     if ctx.attr.expected_attributes:
@@ -250,6 +257,35 @@
         target_under_test = ":pf_strip_prefix_from_root_invalid_g",
     )
 
+    # Test include_runfiles.
+    pkg_files(
+        name = "pf_include_runfiles_g",
+        include_runfiles = True,
+        srcs = ["//tests:an_executable"],
+        tags = ["manual"],
+    )
+
+    pkg_files_contents_test(
+        name = "pf_include_runfiles",
+        target_under_test = ":pf_include_runfiles_g",
+        expected_dests = select(
+            {
+                "@bazel_tools//src/conditions:windows": [
+                    "an_executable.exe",
+                    "an_executable.exe.runfiles/_repo_mapping",
+                    "an_executable.exe.runfiles/_main/tests/foo.cc",
+                    "an_executable.exe.runfiles/_main/tests/testdata/hello.txt",
+                ],
+                "//conditions:default": [
+                    "an_executable",
+                    "an_executable.runfiles/_repo_mapping",
+                    "an_executable.runfiles/_main/tests/foo.cc",
+                    "an_executable.runfiles/_main/tests/testdata/hello.txt",
+                ],
+            },
+        ),
+    )
+
 def _test_pkg_files_exclusions():
     # Normal filegroup, used in all of the below tests
     #
@@ -970,7 +1006,6 @@
     },
 )
 
-# buildifier: disable=function-docstring-args
 def manifest_golden_test(name, target, expected):
     """Tests that a content manifest file matches a golden copy.
 
@@ -978,6 +1013,7 @@
     expected content.
 
     Args:
+      name: name
       target: A target which produces a content manifest with the name
           <target> + ".manifest"
       expected: label of a file containing the expected content.
diff --git a/tests/rpm/BUILD b/tests/rpm/BUILD
index f51d75b..7aeaa8f 100644
--- a/tests/rpm/BUILD
+++ b/tests/rpm/BUILD
@@ -24,7 +24,7 @@
     "pkg_mkdirs",
     "pkg_mklink",
 )
-load("//pkg:rpm.bzl", "pkg_rpm")
+load("//pkg:rpm.bzl", "pkg_rpm", "pkg_sub_rpm")
 load("analysis_tests.bzl", "analysis_tests")
 load("toolchain_tests.bzl", "create_toolchain_analysis_tests")
 
@@ -280,6 +280,7 @@
     architecture = "noarch",
     conflicts = ["not-a-test"],
     description = """pkg_rpm test rpm description""",
+    epoch = "1",
     license = "Apache 2.0",
     post_scriptlet_file = ":post",
     postun_scriptlet_file = ":postun",
@@ -295,6 +296,31 @@
     version_file = ":version_file",
 )
 
+# Like the first one, except we set an epoch
+pkg_rpm(
+    name = "test_rpm_epoch",
+    srcs = [
+        ":test_pfg",
+    ],
+    architecture = "noarch",
+    conflicts = ["not-a-test"],
+    description = """pkg_rpm test rpm description""",
+    epoch = "1",
+    license = "Apache 2.0",
+    post_scriptlet = _POST_SCRIPTLET,
+    postun_scriptlet = _POSTUN_SCRIPTLET,
+    pre_scriptlet = _PRE_SCRIPTLET,
+    preun_scriptlet = _PREUN_SCRIPTLET,
+    posttrans_scriptlet = _POSTTRANS_SCRIPTLET,
+    provides = ["test"],
+    release = _RELEASE,
+    requires = ["test-lib > 1.0"],
+    requires_contextual = {"preun": ["bash"]},
+    spec_template = "template-test.spec.tpl",
+    summary = "pkg_rpm test rpm summary",
+    version = _VERSION,
+)
+
 ############################################################################
 # Test RPM metadata -- used to verify RPM contents in tests
 ############################################################################
@@ -407,6 +433,7 @@
         ":test_rpm_metadata",
         ":test_rpm_scriptlets_files",
         ":test_rpm_release_version_files",
+        ":test_rpm_epoch",
     ],
 )
 
@@ -465,6 +492,136 @@
 )
 
 ############################################################################
+# pkg_sub_rpm tests
+############################################################################
+genrule(
+    name = "test_sub_rpm_file_input",
+    outs = ["test_sub_rpm_file_input.txt"],
+    cmd = """
+    echo "test subrpm data" > $@
+    """,
+)
+
+pkg_files(
+    name = "test_sub_rpm_files",
+    srcs = [":test_sub_rpm_file_input"],
+)
+
+pkg_sub_rpm(
+    name = "sub_rpm",
+    package_name = "test_sub_rpm",
+    description = "Test subrpm description",
+    summary = "Test subrpm",
+    srcs = [
+        ":test_sub_rpm_files",
+    ],
+)
+
+genrule(
+    name = "test_sub_rpm_main_file_input",
+    outs = ["test_sub_rpm_main_file_input.txt"],
+    cmd = """
+    echo "test main rpm data" > $@
+    """,
+)
+
+pkg_files(
+    name = "test_sub_rpm_main_files",
+    srcs = [":test_sub_rpm_main_file_input"],
+)
+
+pkg_rpm(
+    name = "test_sub_rpm_main",
+    description = "This is a package description.",
+    summary = "rules_pkg example RPM",
+    architecture = "noarch",
+    version = "1",
+    license = "Apache License, v2.0",
+    release = "0",
+    srcs = [
+        ":test_sub_rpm_main_files",
+    ],
+    subrpms = [
+        ":sub_rpm",
+    ],
+)
+
+genrule(
+    name = "test_sub_rpm_contents",
+    srcs = [":test_sub_rpm_main"],
+    outs = [":test_sub_rpm_contents.txt"],
+    cmd = """
+    # pkg_rpm emits two outputs
+    RPMS=($(SRCS))
+    echo "===== main RPM =====" > $@
+    rpm -qpi --list $${RPMS[0]} | \
+        grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' >> $@
+    echo "===== sub RPM ======" >> $@
+    rpm -qpi --list $${RPMS[1]} | \
+        grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' >> $@
+    """,
+)
+
+diff_test(
+    name = "test_golden_sub_rpm_contents",
+    file1 = ":test_sub_rpm_contents",
+    file2 = "test_sub_rpm_contents.txt.golden",
+)
+
+############################################################################
+# debuginfo tests
+############################################################################
+cc_binary(
+    name = "test_debuginfo",
+    copts = ["-g"],
+    srcs = [
+        "test.c",
+    ],
+)
+
+pkg_files(
+    name = "test_debuginfo_rpm_files",
+    srcs = [
+        ":test_debuginfo",
+    ],
+)
+
+pkg_rpm(
+    name = "test_debuginfo_rpm",
+        srcs = [
+        ":test_debuginfo_rpm_files",
+    ],
+    release = "0",
+    version = "1",
+    license = "Some license",
+    summary = "Summary",
+    description = "Description",
+    debuginfo = True,
+)
+
+genrule(
+    name = "test_debuginfo_rpm_contents",
+    srcs = [":test_debuginfo_rpm"],
+    outs = [":test_debuginfo_rpm_contents.txt"],
+    cmd = """
+    # pkg_rpm emits two outputs
+    RPMS=($(SRCS))
+    echo "===== main RPM =====" > $@
+    rpm -qpi --list $${RPMS[0]} | \
+        grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' | grep -v 'Architecture' | grep -v 'Size' | grep -v '.build-id' >> $@
+    echo "===== sub RPM ======" >> $@
+    rpm -qpi --list $${RPMS[1]} | \
+        grep -v 'Build Date' | grep -v 'Build Host' | grep -v 'Relocations' | grep -v 'Architecture' | grep -v 'Size' | grep -v '.build-id' >> $@
+    """,
+)
+
+diff_test(
+    name = "test_golden_debuginfo_rpm_contents",
+    file1 = ":test_debuginfo_rpm_contents",
+    file2 = "test_debuginfo_rpm_contents.txt.golden",
+)
+
+############################################################################
 # Common tests
 ############################################################################
 
diff --git a/tests/rpm/make_rpm_test.py b/tests/rpm/make_rpm_test.py
index cb8608b..1399f8f 100644
--- a/tests/rpm/make_rpm_test.py
+++ b/tests/rpm/make_rpm_test.py
@@ -75,7 +75,7 @@
     """
 
     result = make_rpm.FindOutputFile(log)
-    self.assertEqual('/path/to/file/here.rpm', result)
+    self.assertEqual(['/path/to/file/here.rpm'], result)
 
   def testFindOutputFile_missing(self):
     log = """
diff --git a/tests/rpm/pkg_rpm_basic_test.py b/tests/rpm/pkg_rpm_basic_test.py
index 8b29934..8e4dff2 100644
--- a/tests/rpm/pkg_rpm_basic_test.py
+++ b/tests/rpm/pkg_rpm_basic_test.py
@@ -51,7 +51,9 @@
         self.test_rpm_scriptlets_files_path = self.runfiles.Rlocation(
             "rules_pkg/tests/rpm/test_rpm_scriptlets_files-1.1.1-2222.noarch.rpm")
         self.test_rpm_release_version_files = self.runfiles.Rlocation(
-            "rules_pkg/tests/rpm/test_rpm_release_version_files--.noarch.rpm")
+            "rules_pkg/tests/rpm/test_rpm_release_version_files-.noarch.rpm")
+        self.test_rpm_epoch = self.runfiles.Rlocation(
+            "rules_pkg/tests/rpm/test_rpm_epoch-1.1.1-2222.noarch.rpm")
         self.maxDiff = None
 
     def test_scriptlet_content(self):
@@ -83,6 +85,7 @@
         for rpm, fields in [
             (self.test_rpm_path, {"NAME": b"test_rpm"}),
             (self.test_rpm_release_version_files, {"NAME": b"test_rpm_release_version_files"}),
+            (self.test_rpm_epoch, {"NAME": b"test_rpm_epoch", "EPOCH": b"1"}),
         ]:
             fields.update(common_fields)
             for fieldname, expected in fields.items():
@@ -176,7 +179,7 @@
                 # - "interp" for scriptlet interpreter dependencies
                 # - "postun" for dependencies of the "postun" scriptlet
                 # - "manual" for values that are explicitly specified
-                ":%{{{tag}FLAGS:deptype}}"
+                ":%{{{tag}FLAGS!deptype}}"
                 "\n]"
             ).format(tag = tag)
 
@@ -190,7 +193,7 @@
 
             sio = io.StringIO(rpm_output.decode('utf-8'))
             rpm_output_reader = csv.DictReader(
-                sio, delimiter=':', fieldnames=rpm_queryformat_fieldnames)
+                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
diff --git a/tests/rpm/test.c b/tests/rpm/test.c
new file mode 100644
index 0000000..4cce7f6
--- /dev/null
+++ b/tests/rpm/test.c
@@ -0,0 +1,3 @@
+int main() {
+  return 0;
+}
diff --git a/tests/rpm/test_debuginfo_rpm_contents.txt.golden b/tests/rpm/test_debuginfo_rpm_contents.txt.golden
new file mode 100755
index 0000000..0f65f11
--- /dev/null
+++ b/tests/rpm/test_debuginfo_rpm_contents.txt.golden
@@ -0,0 +1,29 @@
+===== main RPM =====
+Name        : test_debuginfo_rpm
+Version     : 1
+Release     : 0
+Install Date: (not installed)
+Group       : Unspecified
+License     : Some license
+Signature   : (none)
+Source RPM  : test_debuginfo_rpm-1-0.src.rpm
+Summary     : Summary
+Description :
+Description
+/test_debuginfo
+===== sub RPM ======
+Name        : test_debuginfo_rpm-debuginfo
+Version     : 1
+Release     : 0
+Install Date: (not installed)
+Group       : Development/Debug
+License     : Some license
+Signature   : (none)
+Source RPM  : test_debuginfo_rpm-1-0.src.rpm
+Summary     : Debug information for package test_debuginfo_rpm
+Description :
+This package provides debug information for package test_debuginfo_rpm.
+Debug information is useful when developing applications that use this
+package or when debugging this package.
+/usr/lib/debug
+/usr/lib/debug/test_debuginfo.debug
diff --git a/tests/rpm/test_sub_rpm_contents.txt.golden b/tests/rpm/test_sub_rpm_contents.txt.golden
new file mode 100755
index 0000000..9760069
--- /dev/null
+++ b/tests/rpm/test_sub_rpm_contents.txt.golden
@@ -0,0 +1,30 @@
+===== main RPM =====
+Name        : test_sub_rpm_main
+Version     : 1
+Release     : 0
+Architecture: noarch
+Install Date: (not installed)
+Group       : Unspecified
+Size        : 19
+License     : Apache License, v2.0
+Signature   : (none)
+Source RPM  : test_sub_rpm_main-1-0.src.rpm
+Summary     : rules_pkg example RPM
+Description :
+This is a package description.
+/test_sub_rpm_main_file_input.txt
+===== sub RPM ======
+Name        : test_sub_rpm_main-test_sub_rpm
+Version     : 1
+Release     : 0
+Architecture: noarch
+Install Date: (not installed)
+Group       : Unspecified
+Size        : 17
+License     : Apache License, v2.0
+Signature   : (none)
+Source RPM  : test_sub_rpm_main-1-0.src.rpm
+Summary     : Test subrpm
+Description :
+Test subrpm description
+/test_sub_rpm_file_input.txt
diff --git a/tests/tar/BUILD b/tests/tar/BUILD
index d0fc200..9480a46 100644
--- a/tests/tar/BUILD
+++ b/tests/tar/BUILD
@@ -91,6 +91,13 @@
     deps = ["//tests:testdata/tar_test.tar"],
 )
 
+pkg_tar(
+    name = "test-respect-externally-defined-duplicates",
+    deps = ["//tests:testdata/duplicate_entries.tar"],
+    create_parents = False,
+    allow_duplicates_from_deps = True,
+)
+
 #
 # Tests for package_file_name
 #
@@ -342,20 +349,20 @@
     target = ":test-tar-with-runfiles",
     must_contain = [
         "a_program",
-        "a_program.runfiles/tests/tar/BUILD",
+        "a_program.runfiles/_main/tests/tar/BUILD",
         "executable.sh",
     ] + select({
         "@platforms//os:windows": [
             "an_executable.exe",
-            "an_executable.exe.runfiles/tests/foo.cc",
-            "an_executable.exe.runfiles/tests/an_executable.exe",
-            "an_executable.exe.runfiles/tests/testdata/hello.txt",
+            "an_executable.exe.runfiles/_main/tests/foo.cc",
+            "an_executable.exe.runfiles/_main/tests/an_executable.exe",
+            "an_executable.exe.runfiles/_main/tests/testdata/hello.txt",
         ],
         "//conditions:default": [
             "an_executable",
-            "an_executable.runfiles/tests/foo.cc",
-            "an_executable.runfiles/tests/an_executable",
-            "an_executable.runfiles/tests/testdata/hello.txt",
+            "an_executable.runfiles/_main/tests/foo.cc",
+            "an_executable.runfiles/_main/tests/an_executable",
+            "an_executable.runfiles/_main/tests/testdata/hello.txt",
         ]
     }),
 )
@@ -377,20 +384,20 @@
     name = "runfiles_remap_base_path_test",
     must_contain = [
         "new_name",
-        "new_name.runfiles/tests/tar/BUILD",
+        "new_name.runfiles/_main/tests/tar/BUILD",
         "executable.sh",
     ] + select({
         "@platforms//os:windows": [
             "other/different_name.exe",
-            "other/different_name.exe.runfiles/tests/foo.cc",
-            "other/different_name.exe.runfiles/tests/an_executable.exe",
-            "other/different_name.exe.runfiles/tests/testdata/hello.txt",
+            "other/different_name.exe.runfiles/_main/tests/foo.cc",
+            "other/different_name.exe.runfiles/_main/tests/an_executable.exe",
+            "other/different_name.exe.runfiles/_main/tests/testdata/hello.txt",
         ],
         "//conditions:default": [
             "other/different_name",
-            "other/different_name.runfiles/tests/foo.cc",
-            "other/different_name.runfiles/tests/an_executable",
-            "other/different_name.runfiles/tests/testdata/hello.txt",
+            "other/different_name.runfiles/_main/tests/foo.cc",
+            "other/different_name.runfiles/_main/tests/an_executable",
+            "other/different_name.runfiles/_main/tests/testdata/hello.txt",
         ],
     }),
     target = ":test-tar-remap-runfiles-base-path",
@@ -407,11 +414,11 @@
         # rename the entire runfiles directory
         "/a_program.runfiles/": "/a/program/runfiles/",
         # rename a specific file
-        "/an_executable.runfiles/tests/testdata/hello.txt": "/myfiles/hello.txt",
-        "/an_executable.exe.runfiles/tests/testdata/hello.txt": "/myfiles/hello.txt",
+        "/an_executable.runfiles/_main/tests/testdata/hello.txt": "/myfiles/hello.txt",
+        "/an_executable.exe.runfiles/_main/tests/testdata/hello.txt": "/myfiles/hello.txt",
         # rename a specific subdirectory
-        "/an_executable.runfiles/tests/": "/mytests/",
-        "/an_executable.exe.runfiles/tests/": "/mytests/",
+        "/an_executable.runfiles/_main/tests/": "/mytests/",
+        "/an_executable.exe.runfiles/_main/tests/": "/mytests/",
     },
 )
 
@@ -419,7 +426,7 @@
     name = "runfiles_remap_full_paths_test",
     must_contain = [
         "a_program",
-        "a/program/runfiles/tests/tar/BUILD",
+        "a/program/runfiles/_main/tests/tar/BUILD",
         "executable.sh",
     ] + select({
         "@platforms//os:windows": [
@@ -456,6 +463,7 @@
         ":test-pkg-tar-from-pkg-files-with-attributes",
         ":test-pkg-tar-with-attributes",
         ":test-remap-paths-tree-artifact",
+        ":test-respect-externally-defined-duplicates.tar",
         ":test-tar-empty_dirs.tar",
         ":test-tar-empty_files.tar",
         ":test-tar-files_dict.tar",
@@ -710,3 +718,41 @@
         "new/base/something/this": "that",
     },
 )
+fake_artifact(
+    name = "program_with_dir_runfiles",
+    files = ["//tests:testdata/executable.sh"],
+    runfiles = [
+        ":generate_tree",
+    ],
+)
+
+pkg_tar(
+    name = "program_with_dir_runfiles_tar",
+    srcs = [
+        ":program_with_dir_runfiles",
+    ],
+    include_runfiles = True,
+)
+
+verify_archive_test(
+    name = "program_with_dir_runfiles_test",
+    must_contain = [
+        "program_with_dir_runfiles.runfiles",
+        "program_with_dir_runfiles.runfiles/_main",
+        "program_with_dir_runfiles.runfiles/_main/tests",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/a",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/b",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/a/b/c",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/c",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/c/d",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/d",
+        "program_with_dir_runfiles.runfiles/_main/tests/tar/generate_tree/b/e",
+        "executable.sh",
+        "program_with_dir_runfiles",
+    ],
+    target = ":program_with_dir_runfiles_tar",
+)
diff --git a/tests/tar/pkg_tar_test.py b/tests/tar/pkg_tar_test.py
index d18c49c..012c7de 100644
--- a/tests/tar/pkg_tar_test.py
+++ b/tests/tar/pkg_tar_test.py
@@ -284,6 +284,15 @@
     ]
     self.assertTarFileContent('test-remap-paths-tree-artifact.tar', content)
 
+  def test_externally_defined_duplicate_structure(self):
+    content = [
+      {'name': './a'},
+      {'name': './b'},
+      {'name': './ab'},
+      {'name': './ab'},
+    ]
+    self.assertTarFileContent('test-respect-externally-defined-duplicates.tar', content)
+
 
 if __name__ == '__main__':
   unittest.main()
diff --git a/tests/tar/tar_writer_test.py b/tests/tar/tar_writer_test.py
index ad31b0c..e7d9c59 100644
--- a/tests/tar/tar_writer_test.py
+++ b/tests/tar/tar_writer_test.py
@@ -138,7 +138,7 @@
         {"name": "foo/a", "data": b"a"},
         {"name": "foo/ab", "data": b"ab"},
         ]
-    with tar_writer.TarFileWriter(self.tempfile) as f:
+    with tar_writer.TarFileWriter(self.tempfile, create_parents=True, allow_dups_from_deps=False) 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")
@@ -176,7 +176,7 @@
         self.assertEqual(output_file.mtime, 0)
 
   def testAddingDirectoriesForFile(self):
-    with tar_writer.TarFileWriter(self.tempfile) as f:
+    with tar_writer.TarFileWriter(self.tempfile, create_parents=True) as f:
       f.add_file("d/f")
     content = [
         {"name": "d", "mode": 0o755},
@@ -185,7 +185,7 @@
     self.assertTarFileContent(self.tempfile, content)
 
   def testAddingDirectoriesForFileManually(self):
-    with tar_writer.TarFileWriter(self.tempfile) as f:
+    with tar_writer.TarFileWriter(self.tempfile, create_parents=True, allow_dups_from_deps=False) as f:
       f.add_file("d", tarfile.DIRTYPE)
       f.add_file("d/f")
 
@@ -210,6 +210,19 @@
     ]
     self.assertTarFileContent(self.tempfile, content)
 
+  def testAddingOnlySpecifiedFiles(self):
+    with tar_writer.TarFileWriter(self.tempfile, allow_dups_from_deps=False) as 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/c/f")
+    content = [
+        {"name": "a", "mode": 0o755},
+        {"name": "a/b", "mode": 0o755},
+        {"name": "a/b/c/f"},
+    ]
+    self.assertTarFileContent(self.tempfile, content)
+
   def testPackageDirAttribute(self):
     """Tests package_dir of pkg_tar."""
     package_dir = self.data_files.Rlocation(
@@ -248,6 +261,46 @@
     self.assertTarFileContent(original, expected_content)
     self.assertTarFileContent(self.tempfile, expected_content)
 
+  def testAdditionOfDuplicatePath(self):
+    expected_content = [
+        {"name": "./" + x} for x in ["a", "b", "ab"]] + [
+        {"name": "./b", "data": "q".encode("utf-8")}
+    ]
+    with tar_writer.TarFileWriter(self.tempfile) as f:
+      datafile = self.data_files.Rlocation(
+        "rules_pkg/tests/testdata/tar_test.tar")
+      f.add_tar(datafile)
+      f.add_file('./b', content="q")
+
+    self.assertTarFileContent(self.tempfile, expected_content)
+
+  def testAdditionOfArchives(self):
+
+    expected_content = [
+        {"name": "./" + x} for x in ["a", "b", "ab", "a", "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)
+      f.add_tar(datafile)
+
+    self.assertTarFileContent(self.tempfile, expected_content)
+
+  def testOnlyIntermediateParentsInferred(self):
+    expected_content = [
+      {"name": "./a", "mode": 0o111},
+      {"name": "./a/b", "mode": 0o755},
+      {"name": "./a/b/c"},
+    ]
+    with tar_writer.TarFileWriter(self.tempfile, create_parents=True) as f:
+      f.add_file('./a', tarfile.DIRTYPE, mode=0o111)
+      f.add_file('./a/b/c')
+
+    self.assertTarFileContent(self.tempfile, expected_content)
+
+
 
 if __name__ == "__main__":
   unittest.main()
diff --git a/tests/testdata/duplicate_entries.tar b/tests/testdata/duplicate_entries.tar
new file mode 100644
index 0000000..d182341
--- /dev/null
+++ b/tests/testdata/duplicate_entries.tar
Binary files differ
diff --git a/tests/util/BUILD b/tests/util/BUILD
index c4f4a31..0be6482 100644
--- a/tests/util/BUILD
+++ b/tests/util/BUILD
@@ -18,8 +18,6 @@
 
 package(default_applicable_licenses = ["//:license"])
 
-licenses(["notice"])
-
 exports_files(["defs.bzl"])
 
 py_binary(
diff --git a/tests/zip/BUILD b/tests/zip/BUILD
index 0727b2e..f6942e4 100644
--- a/tests/zip/BUILD
+++ b/tests/zip/BUILD
@@ -22,8 +22,6 @@
 
 package(default_applicable_licenses = ["//:license"])
 
-licenses(["notice"])
-
 py_library(
     name = "zip_test_lib",
     srcs = [
diff --git a/tests/zip/zip_test_lib.py b/tests/zip/zip_test_lib.py
index ebb0b60..e6c305f 100644
--- a/tests/zip/zip_test_lib.py
+++ b/tests/zip/zip_test_lib.py
@@ -31,7 +31,7 @@
 _ZIP_EPOCH_S = int(_ZIP_EPOCH_DT.timestamp())
 
 def seconds_to_ziptime(s):
-  dt = datetime.datetime.utcfromtimestamp(s)
+  dt = datetime.datetime.fromtimestamp(s, tz=datetime.timezone.utc)
   return (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second)
 
 
diff --git a/toolchains/rpm/BUILD.tpl b/toolchains/rpm/BUILD.tpl
index 8547062..5045bff 100644
--- a/toolchains/rpm/BUILD.tpl
+++ b/toolchains/rpm/BUILD.tpl
@@ -5,6 +5,7 @@
     name = "rpmbuild_auto",
     path = "{RPMBUILD_PATH}",
     version = "{RPMBUILD_VERSION}",
+    debuginfo_type = "{RPMBUILD_DEBUGINFO_TYPE}",
 )
 
 toolchain(
diff --git a/toolchains/rpm/rpmbuild.bzl b/toolchains/rpm/rpmbuild.bzl
index 7e22752..7cb4459 100644
--- a/toolchains/rpm/rpmbuild.bzl
+++ b/toolchains/rpm/rpmbuild.bzl
@@ -21,6 +21,7 @@
         "label": "The path to a target I will build",
         "path": "The path to a pre-built rpmbuild",
         "version": "The version string of rpmbuild",
+        "debuginfo_type": "The variant of the underlying debuginfo config",
     },
 )
 
@@ -35,6 +36,7 @@
             label = ctx.attr.label,
             path = ctx.attr.path,
             version = ctx.attr.version,
+            debuginfo_type = ctx.attr.debuginfo_type,
         ),
     )
     return [toolchain_info]
@@ -54,6 +56,14 @@
         "version": attr.string(
             doc = "The version string of the rpmbuild executable. This should be manually set.",
         ),
+        "debuginfo_type": attr.string(
+            doc = """
+            The underlying debuginfo configuration for the system rpmbuild.
+
+            One of centos7, fedora40, or none
+            """,
+            default = "none",
+        ),
     },
 )
 
diff --git a/toolchains/rpm/rpmbuild_configure.bzl b/toolchains/rpm/rpmbuild_configure.bzl
index a3cb83a..067333c 100644
--- a/toolchains/rpm/rpmbuild_configure.bzl
+++ b/toolchains/rpm/rpmbuild_configure.bzl
@@ -17,8 +17,9 @@
 # MODULE.bazel files.  It seems like we should have a better interface that
 # allows for this module name to be specified from a single point.
 NAME = "rules_pkg_rpmbuild"
+RELEASE_PATH = "/etc/os-release"
 
-def _write_build(rctx, path, version):
+def _write_build(rctx, path, version, debuginfo_type):
     if not path:
         path = ""
     rctx.template(
@@ -28,17 +29,58 @@
             "{GENERATOR}": "@rules_pkg//toolchains/rpm/rpmbuild_configure.bzl%find_system_rpmbuild",
             "{RPMBUILD_PATH}": str(path),
             "{RPMBUILD_VERSION}": version,
+            "{RPMBUILD_DEBUGINFO_TYPE}": debuginfo_type,
         },
         executable = False,
     )
 
+def _strip_quote(s):
+    if s.startswith("\"") and s.endswith("\"") and len(s) > 1:
+        return s[1:-1]
+
+    return s
+
+def _parse_release_info(release_info):
+    os_name = "unknown"
+    os_version = "unknown"
+
+    for line in release_info.splitlines():
+        if "=" not in line:
+            continue
+
+        key, value = line.split("=")
+        if key == "ID":
+            os_name = _strip_quote(value)
+
+        if key == "VERSION_ID":
+            os_version = _strip_quote(value)
+
+    return os_name, os_version
+
+KNOWN_DEBUGINFO_VERSIONS = {
+    "almalinux": ["9.3"],
+    "centos": ["7", "9"],
+    "fedora": ["40"],
+}
+
 def _build_repo_for_rpmbuild_toolchain_impl(rctx):
+    debuginfo_type = "none"
+    if rctx.path(RELEASE_PATH).exists:
+        os_name, os_version = _parse_release_info(rctx.read(RELEASE_PATH))
+        if (os_name in KNOWN_DEBUGINFO_VERSIONS and
+            os_version in KNOWN_DEBUGINFO_VERSIONS[os_name]):
+            debuginfo_type = os_name + os_version
+
     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
+
+    if rctx.attr.debuginfo_type not in ["centos7", "fedora40", "none"]:
+        fail("debuginfo_type must be one of centos7, fedora40, or none")
+
     version = "unknown"
     if rpmbuild_path:
         res = rctx.execute([rpmbuild_path, "--version"])
@@ -47,7 +89,13 @@
             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)
+
+    _write_build(
+        rctx = rctx,
+        path = rpmbuild_path,
+        version = version,
+        debuginfo_type = debuginfo_type,
+    )
 
 build_repo_for_rpmbuild_toolchain = repository_rule(
     implementation = _build_repo_for_rpmbuild_toolchain_impl,
@@ -58,6 +106,14 @@
         "verbose": attr.bool(
             doc = "If true, print status messages.",
         ),
+        "debuginfo_type": attr.string(
+            doc = """
+            The underlying debuginfo configuration for the system rpmbuild.
+
+            One of centos7, fedora40, or none
+            """,
+            default = "none",
+        ),
     },
 )
 
diff --git a/version.bzl b/version.bzl
index 7e93127..62b7ee1 100644
--- a/version.bzl
+++ b/version.bzl
@@ -13,4 +13,4 @@
 # limitations under the License.
 """The version of rules_pkg."""
 
-version = "0.10.1"
+version = "1.0.1"