These attributes are used in several rules within this module.
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| out | Name of the output file. This file will always be created and used to access the package content. If package_file_name is also specified, out will be a symlink. | String | required | |
| package_file_name | The name of the file which will contain the package. The name may contain variables in the forms {var} and $(var). The values for substitution are specified through package_variables` or taken from ctx.var. | String | optional | package type specific |
| package_variables | A target that provides PackageVariablesInfo to substitute into package_file_name. pkg_zip and pkg_tar also support this in package_dir | Label | 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 for examples of how out, package_file_name, and package_variables interact.
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:
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.
Rule for creating Debian packages.
load("@rules_pkg//pkg/private/deb:deb.bzl", "pkg_deb") pkg_deb(<a href="#pkg_deb-name">name</a>, <a href="#pkg_deb-data">data</a>, <a href="#pkg_deb-out">out</a>, <a href="#pkg_deb-architecture">architecture</a>, <a href="#pkg_deb-architecture_file">architecture_file</a>, <a href="#pkg_deb-breaks">breaks</a>, <a href="#pkg_deb-built_using">built_using</a>, <a href="#pkg_deb-built_using_file">built_using_file</a>, <a href="#pkg_deb-changelog">changelog</a>, <a href="#pkg_deb-conffiles">conffiles</a>, <a href="#pkg_deb-conffiles_file">conffiles_file</a>, <a href="#pkg_deb-config">config</a>, <a href="#pkg_deb-conflicts">conflicts</a>, <a href="#pkg_deb-depends">depends</a>, <a href="#pkg_deb-depends_file">depends_file</a>, <a href="#pkg_deb-description">description</a>, <a href="#pkg_deb-description_file">description_file</a>, <a href="#pkg_deb-distribution">distribution</a>, <a href="#pkg_deb-enhances">enhances</a>, <a href="#pkg_deb-homepage">homepage</a>, <a href="#pkg_deb-license">license</a>, <a href="#pkg_deb-maintainer">maintainer</a>, <a href="#pkg_deb-package">package</a>, <a href="#pkg_deb-package_file_name">package_file_name</a>, <a href="#pkg_deb-package_variables">package_variables</a>, <a href="#pkg_deb-postinst">postinst</a>, <a href="#pkg_deb-postrm">postrm</a>, <a href="#pkg_deb-predepends">predepends</a>, <a href="#pkg_deb-preinst">preinst</a>, <a href="#pkg_deb-prerm">prerm</a>, <a href="#pkg_deb-priority">priority</a>, <a href="#pkg_deb-provides">provides</a>, <a href="#pkg_deb-recommends">recommends</a>, <a href="#pkg_deb-replaces">replaces</a>, <a href="#pkg_deb-section">section</a>, <a href="#pkg_deb-suggests">suggests</a>, <a href="#pkg_deb-templates">templates</a>, <a href="#pkg_deb-triggers">triggers</a>, <a href="#pkg_deb-urgency">urgency</a>, <a href="#pkg_deb-version">version</a>, <a href="#pkg_deb-version_file">version_file</a>)
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 |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| data | A tar file that contains the data for the debian package. | Label | required | |
| out | See Common Attributes | Label | required | |
| architecture | Package architecture. Must not be used with architecture_file. | String | optional | "all" |
| architecture_file | File that contains the package architecture. Must not be used with architecture. | Label | optional | None |
| breaks | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| built_using | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | String | optional | "" |
| built_using_file | The tool that were used to build this package provided either inline (with built_using) or from a file (with built_using_file). | Label | optional | None |
| changelog | The package changelog. See https://www.debian.org/doc/debian-policy/ch-source.html#s-dpkgchangelog. | Label | optional | None |
| conffiles | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | List of strings | optional | [] |
| conffiles_file | The list of conffiles or a file containing one conffile per line. Each item is an absolute path on the target system where the deb is installed. See https://www.debian.org/doc/debian-policy/ch-files.html#s-config-files. | Label | optional | None |
| config | config file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | Label | optional | None |
| conflicts | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| depends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| depends_file | File that contains a list of package dependencies. Must not be used with depends. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | Label | optional | None |
| description | The package description. Must not be used with description_file. | String | optional | "" |
| description_file | The package description. Must not be used with description. | Label | optional | None |
| distribution | "distribution: See http://www.debian.org/doc/debian-policy. | String | optional | "unstable" |
| enhances | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| homepage | The homepage of the project. | String | optional | "" |
| license | The license of the project. | String | optional | "" |
| maintainer | The maintainer of the package. | String | required | |
| package | The name of the package | String | required | |
| package_file_name | See Common Attributes. Default: "{package}-{version}-{architecture}.deb | String | optional | "" |
| package_variables | See Common Attributes | Label | optional | None |
| postinst | The post-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | Label | optional | None |
| postrm | The post-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | Label | optional | None |
| predepends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| preinst | "The pre-install script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | Label | optional | None |
| prerm | The pre-remove script for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. | Label | optional | None |
| priority | The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities. | String | optional | "" |
| provides | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| recommends | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| replaces | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| section | The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections. | String | optional | "" |
| suggests | See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. | List of strings | optional | [] |
| templates | templates file used for debconf integration. See https://www.debian.org/doc/debian-policy/ch-binary.html#prompting-in-maintainer-scripts. | Label | optional | None |
| triggers | triggers file for configuring installation events exchanged by packages. See https://wiki.debian.org/DpkgTriggers. | Label | optional | None |
| urgency | "urgency: See http://www.debian.org/doc/debian-policy. | String | optional | "medium" |
| version | Package version. Must not be used with version_file. | String | optional | "" |
| version_file | File that contains the package version. Must not be used with version. | Label | optional | None |
Provides rules for creating RPM packages via pkg_filegroup and friends.
pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will find to convenient to use the one provided with their system. To enable that toolchain add the following stanza to WORKSPACE:
# Find rpmbuild if it exists.
load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
find_system_rpmbuild(name="rules_pkg_rpmbuild")
load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_sub_rpm") pkg_sub_rpm(<a href="#pkg_sub_rpm-name">name</a>, <a href="#pkg_sub_rpm-srcs">srcs</a>, <a href="#pkg_sub_rpm-architecture">architecture</a>, <a href="#pkg_sub_rpm-conflicts">conflicts</a>, <a href="#pkg_sub_rpm-description">description</a>, <a href="#pkg_sub_rpm-epoch">epoch</a>, <a href="#pkg_sub_rpm-group">group</a>, <a href="#pkg_sub_rpm-obsoletes">obsoletes</a>, <a href="#pkg_sub_rpm-package_name">package_name</a>, <a href="#pkg_sub_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_sub_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_sub_rpm-provides">provides</a>, <a href="#pkg_sub_rpm-requires">requires</a>, <a href="#pkg_sub_rpm-summary">summary</a>, <a href="#pkg_sub_rpm-version">version</a>)
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
Provides rules for creating RPM packages via pkg_filegroup and friends.
pkg_rpm() depends on the existence of an rpmbuild toolchain. Many users will find to convenient to use the one provided with their system. To enable that toolchain add the following stanza to WORKSPACE:
# Find rpmbuild if it exists.
load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")
find_system_rpmbuild(name="rules_pkg_rpmbuild")
load("@rules_pkg//pkg:rpm_pfg.bzl", "pkg_rpm") pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-srcs">srcs</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-binary_payload_compression">binary_payload_compression</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-conflicts">conflicts</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-debuginfo">debuginfo</a>, <a href="#pkg_rpm-defines">defines</a>, <a href="#pkg_rpm-description">description</a>, <a href="#pkg_rpm-description_file">description_file</a>, <a href="#pkg_rpm-epoch">epoch</a>, <a href="#pkg_rpm-group">group</a>, <a href="#pkg_rpm-license">license</a>, <a href="#pkg_rpm-obsoletes">obsoletes</a>, <a href="#pkg_rpm-package_file_name">package_file_name</a>, <a href="#pkg_rpm-package_name">package_name</a>, <a href="#pkg_rpm-package_variables">package_variables</a>, <a href="#pkg_rpm-post_scriptlet">post_scriptlet</a>, <a href="#pkg_rpm-post_scriptlet_file">post_scriptlet_file</a>, <a href="#pkg_rpm-posttrans_scriptlet">posttrans_scriptlet</a>, <a href="#pkg_rpm-posttrans_scriptlet_file">posttrans_scriptlet_file</a>, <a href="#pkg_rpm-postun_scriptlet">postun_scriptlet</a>, <a href="#pkg_rpm-postun_scriptlet_file">postun_scriptlet_file</a>, <a href="#pkg_rpm-pre_scriptlet">pre_scriptlet</a>, <a href="#pkg_rpm-pre_scriptlet_file">pre_scriptlet_file</a>, <a href="#pkg_rpm-preun_scriptlet">preun_scriptlet</a>, <a href="#pkg_rpm-preun_scriptlet_file">preun_scriptlet_file</a>, <a href="#pkg_rpm-provides">provides</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-requires">requires</a>, <a href="#pkg_rpm-requires_contextual">requires_contextual</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_template">spec_template</a>, <a href="#pkg_rpm-subrpms">subrpms</a>, <a href="#pkg_rpm-summary">summary</a>, <a href="#pkg_rpm-url">url</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
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:
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 |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| srcs | Mapping groups to include in this RPM. These are typically brought into life as pkg_filegroups. | List of labels | required | |
| architecture | Package architecture. This currently sets the BuildArch tag, which influences the output architecture of the package.Typically, BuildArch only needs to be set when the package is known to be cross-platform (e.g. written in an interpreted language), or, less common, when it is known that the application is only valid for specific architectures.When no attribute is provided, this will default to your host's architecture. This is usually what you want. | String | optional | "" |
| binary_payload_compression | Compression mode used for this RPM Must be a form that rpmbuild(8) knows how to process, which will depend on the version of rpmbuild in use. The value corresponds to the %_binary_payload macro and is set on the rpmbuild(8) command line if provided.Some examples of valid values (which may not be supported on your system) can be found here. On CentOS systems (also likely Red Hat and Fedora), you can find some supported values by looking for %_binary_payload in /usr/lib/rpm/macros. Other systems have similar files and configurations.If not provided, the compression mode will be computed by rpmbuild itself. Defaults may vary per distribution or build of rpm; consult the relevant documentation for more details.WARNING: Bazel is currently not aware of action threading requirements for non-test actions. Using threaded compression may result in overcommitting your system. | String | optional | "" |
| changelog | - | Label | optional | None |
| conflicts | List of capabilities that conflict with this package when it is installed. Corresponds to the “Conflicts” preamble tag. See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| debug | Debug the RPM helper script and RPM generation | Boolean | optional | False |
| debuginfo | 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. | Boolean | optional | False |
| defines | Additional definitions to pass to rpmbuild | Dictionary: String -> String | optional | {} |
| description | Multi-line description of this package, corresponds to RPM %description. Exactly one of description or description_file must be provided. | String | optional | "" |
| description_file | File containing a multi-line description of this package, corresponds to RPM %description. | Label | optional | None |
| epoch | Optional; RPM “Epoch” tag. | String | optional | "" |
| group | 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. | String | optional | "" |
| license | RPM “License” tag. The software license for the code distributed in this package. The underlying RPM builder requires you to put something here; if your package is not going to be distributed, feel free to set this to something like “Internal”. | String | required | |
| obsoletes | List of rpm capability expressions that this package obsoletes. Corresponds to the “Obsoletes” preamble tag. See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| package_file_name | See ‘Common Attributes’ in the rules_pkg reference. If this is not provided, the package file given a NVRA-style (name-version-release.arch) output, which is preferred by most RPM repositories. | String | optional | "" |
| package_name | Optional; RPM name override. If not provided, the name attribute of this rule will be used instead.This influences values like the spec file name. | String | optional | "" |
| package_variables | See ‘Common Attributes’ in the rules_pkg reference | Label | optional | None |
| post_scriptlet | RPM %post scriptlet. Currently only allowed to be a shell script.post_scriptlet and post_scriptlet_file are mutually exclusive. | String | optional | "" |
| post_scriptlet_file | File containing the RPM %post scriptlet | Label | optional | None |
| posttrans_scriptlet | RPM %posttrans scriptlet. Currently only allowed to be a shell script.posttrans_scriptlet and posttrans_scriptlet_file are mutually exclusive. | String | optional | "" |
| posttrans_scriptlet_file | File containing the RPM %posttrans scriptlet | Label | optional | None |
| postun_scriptlet | RPM %postun scriptlet. Currently only allowed to be a shell script.postun_scriptlet and postun_scriptlet_file are mutually exclusive. | String | optional | "" |
| postun_scriptlet_file | File containing the RPM %postun scriptlet | Label | optional | None |
| pre_scriptlet | RPM %pre scriptlet. Currently only allowed to be a shell script.pre_scriptlet and pre_scriptlet_file are mutually exclusive. | String | optional | "" |
| pre_scriptlet_file | File containing the RPM %pre scriptlet | Label | optional | None |
| preun_scriptlet | RPM %preun scriptlet. Currently only allowed to be a shell script.preun_scriptlet and preun_scriptlet_file are mutually exclusive. | String | optional | "" |
| preun_scriptlet_file | File containing the RPM %preun scriptlet | Label | optional | None |
| provides | List of rpm capabilities that this package provides. Corresponds to the “Provides” preamble tag. See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| release | RPM “Release” tag Exactly one of release or release_file must be provided. | String | optional | "" |
| release_file | File containing RPM “Release” tag. | Label | optional | None |
| requires | List of rpm capability expressions that this package requires. Corresponds to the “Requires” preamble tag. See also: https://rpm-software-management.github.io/rpm/manual/dependencies.html | List of strings | optional | [] |
| requires_contextual | Contextualized requirement specifications This is a map of various properties (often scriptlet types) to capability name specifications, e.g.: {pre: [GConf2],post: [GConf2], postun: [GConf2]} Which causes the below to be added to the spec file's preamble: Requires(pre): GConf2 Requires(post): GConf2 Requires(postun): GConf2 This is most useful for ensuring that required tools exist when scriptlets are run, although there may be other valid use cases. Valid keys for this attribute may include, but are not limited to: - pre - post - preun - postun - pretrans - posttransFor capabilities that are always required by packages at runtime, use the requires attribute instead.See also: https://rpm-software-management.github.io/rpm/manual/more_dependencies.html NOTE: pkg_rpm does not check if the keys of this dictionary are acceptable to rpm(8). | Dictionary: String -> List of strings | optional | {} |
| rpmbuild_path | Path to a rpmbuild binary. Deprecated in favor of the rpmbuild toolchain | String | optional | "" |
| source_date_epoch | Value to export as SOURCE_DATE_EPOCH to facilitate reproducible builds Implicitly sets the %clamp_mtime_to_source_date_epoch in the subordinate call to rpmbuild to facilitate more consistent in-RPM file timestamps.Negative values (like the default) disable this feature. | Integer | optional | -1 |
| source_date_epoch_file | File containing the SOURCE_DATE_EPOCH value. Implicitly sets the %clamp_mtime_to_source_date_epoch in the subordinate call to rpmbuild to facilitate more consistent in-RPM file timestamps. | Label | optional | None |
| spec_template | Spec file template. Use this if you need to add additional logic to your spec files that is not available by default. In most cases, you should not need to override this attribute. | Label | optional | "@rules_pkg//pkg/rpm:template.spec.tpl" |
| subrpms | 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 | List of labels | optional | [] |
| summary | RPM “Summary” tag. One-line summary of this package. Must not contain newlines. | String | required | |
| url | RPM “URL” tag; this project/vendor's home on the Internet. | String | optional | "" |
| version | RPM “Version” tag. Exactly one of version or version_file must be provided. | String | optional | "" |
| version_file | File containing RPM “Version” tag. | Label | optional | None |
Rules for making .tar files.
load("@rules_pkg//pkg/private/tar:tar.bzl", "pkg_tar") pkg_tar(<a href="#pkg_tar-name">name</a>, <a href="#pkg_tar-deps">deps</a>, <a href="#pkg_tar-srcs">srcs</a>, <a href="#pkg_tar-out">out</a>, <a href="#pkg_tar-allow_duplicates_from_deps">allow_duplicates_from_deps</a>, <a href="#pkg_tar-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_tar-compression_level">compression_level</a>, <a href="#pkg_tar-compressor">compressor</a>, <a href="#pkg_tar-compressor_args">compressor_args</a>, <a href="#pkg_tar-create_parents">create_parents</a>, <a href="#pkg_tar-empty_dirs">empty_dirs</a>, <a href="#pkg_tar-empty_files">empty_files</a>, <a href="#pkg_tar-extension">extension</a>, <a href="#pkg_tar-files">files</a>, <a href="#pkg_tar-include_runfiles">include_runfiles</a>, <a href="#pkg_tar-mode">mode</a>, <a href="#pkg_tar-modes">modes</a>, <a href="#pkg_tar-mtime">mtime</a>, <a href="#pkg_tar-owner">owner</a>, <a href="#pkg_tar-ownername">ownername</a>, <a href="#pkg_tar-ownernames">ownernames</a>, <a href="#pkg_tar-owners">owners</a>, <a href="#pkg_tar-package_dir">package_dir</a>, <a href="#pkg_tar-package_dir_file">package_dir_file</a>, <a href="#pkg_tar-package_file_name">package_file_name</a>, <a href="#pkg_tar-package_variables">package_variables</a>, <a href="#pkg_tar-portable_mtime">portable_mtime</a>, <a href="#pkg_tar-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_tar-remap_paths">remap_paths</a>, <a href="#pkg_tar-stamp">stamp</a>, <a href="#pkg_tar-strip_prefix">strip_prefix</a>, <a href="#pkg_tar-symlinks">symlinks</a>)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| deps | tar files which will be unpacked and repacked into the archive. | List of labels | optional | [] |
| srcs | Inputs which will become part of the tar archive. | List of labels | optional | [] |
| out | - | Label | required | |
| allow_duplicates_from_deps | - | Boolean | optional | False |
| 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 |
| compression_level | Specify the numeric compression level in gzip mode; may be 0-9 or -1 (default to 6). | Integer | optional | -1 |
| compressor | External tool which can compress the archive. | Label | optional | None |
| compressor_args | Arg list for compressor. | String | optional | "" |
| create_parents | - | Boolean | optional | True |
| empty_dirs | - | List of strings | optional | [] |
| empty_files | - | List of strings | optional | [] |
| extension | - | String | optional | "tar" |
| files | Obsolete. Do not use. | Dictionary: Label -> String | optional | {} |
| 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 |
| mode | - | String | optional | "0555" |
| modes | - | Dictionary: String -> String | optional | {} |
| mtime | - | Integer | optional | -1 |
| owner | Default numeric owner.group to apply to files when not set via pkg_attributes. | String | optional | "0.0" |
| ownername | - | String | optional | "." |
| ownernames | - | Dictionary: String -> String | optional | {} |
| owners | - | Dictionary: String -> String | optional | {} |
| package_dir | Prefix to be prepend to all paths written. This is applied as a final step, while writing to the archive. Any other attributes (e.g. symlinks) which specify a path, must do so relative to package_dir. The value may contain variables. See package_file_name for examples. | String | optional | "" |
| package_dir_file | - | Label | optional | None |
| package_file_name | See Common Attributes | String | optional | "" |
| package_variables | See Common Attributes | Label | optional | None |
| portable_mtime | - | Boolean | optional | True |
| private_stamp_detect | - | Boolean | optional | False |
| remap_paths | - | Dictionary: String -> String | optional | {} |
| stamp | Enable file time stamping. Possible values: stamp = 1: Use the time of the build as the modification time of each file in the archive. stamp = 0: Use an “epoch” time for the modification time of each file. This gives good build result caching. stamp = -1: Control the chosen modification time using the --[no]stamp flag. Since 0.5.0 | Integer | optional | 0 |
| strip_prefix | (note: Use strip_prefix = “.” to strip path to the package but preserve relative paths of sub directories beneath the package.) | String | optional | "" |
| symlinks | - | Dictionary: String -> String | optional | {} |
Zip archive creation rule and associated logic.
load("@rules_pkg//pkg/private/zip:zip.bzl", "pkg_zip") pkg_zip(<a href="#pkg_zip-name">name</a>, <a href="#pkg_zip-srcs">srcs</a>, <a href="#pkg_zip-out">out</a>, <a href="#pkg_zip-allow_duplicates_with_different_content">allow_duplicates_with_different_content</a>, <a href="#pkg_zip-compression_level">compression_level</a>, <a href="#pkg_zip-compression_type">compression_type</a>, <a href="#pkg_zip-include_runfiles">include_runfiles</a>, <a href="#pkg_zip-mode">mode</a>, <a href="#pkg_zip-package_dir">package_dir</a>, <a href="#pkg_zip-package_file_name">package_file_name</a>, <a href="#pkg_zip-package_variables">package_variables</a>, <a href="#pkg_zip-private_stamp_detect">private_stamp_detect</a>, <a href="#pkg_zip-stamp">stamp</a>, <a href="#pkg_zip-strip_prefix">strip_prefix</a>, <a href="#pkg_zip-timestamp">timestamp</a>)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|---|---|---|---|
| name | A unique name for this target. | Name | required | |
| srcs | List of files that should be included in the archive. | List of labels | optional | [] |
| out | output file name. Default: name + “.zip”. | Label | required | |
| 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 |
| 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 |
| 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" |
| include_runfiles | See standard attributes. | Boolean | optional | False |
| mode | The default mode for all files in the archive. | String | optional | "0555" |
| package_dir | Prefix to be prepend to all paths written. The name may contain variables, same as package_file_name | String | optional | "/" |
| package_file_name | See Common Attributes | String | optional | "" |
| package_variables | See Common Attributes | Label | optional | None |
| private_stamp_detect | - | Boolean | optional | False |
| stamp | Enable file time stamping. Possible values: stamp = 1: Use the time of the build as the modification time of each file in the archive. stamp = 0: Use an “epoch” time for the modification time of each file. This gives good build result caching. stamp = -1: Control the chosen modification time using the --[no]stamp flag. | Integer | optional | 0 |
| strip_prefix | - | String | optional | "" |
| 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. 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 |
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 outputspkg_mkdirs describes directory structurespkg_mklink describes symbolic linkspkg_filegroup creates groupings of above to add to packagesRules that actually make use of the outputs of the above rules are not specified here.
load("@rules_pkg//pkg:mappings.bzl", "filter_directory") filter_directory(<a href="#filter_directory-name">name</a>, <a href="#filter_directory-src">src</a>, <a href="#filter_directory-excludes">excludes</a>, <a href="#filter_directory-outdir_name">outdir_name</a>, <a href="#filter_directory-prefix">prefix</a>, <a href="#filter_directory-renames">renames</a>, <a href="#filter_directory-strip_prefix">strip_prefix</a>)
Transform directories (TreeArtifacts) using pkg_filegroup-like semantics.
Effective order of operations:
excludedrenames or strip_prefix is applied.prefix is appliedIn 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 renamed 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
load("@rules_pkg//pkg:mappings.bzl", "pkg_filegroup") pkg_filegroup(<a href="#pkg_filegroup-name">name</a>, <a href="#pkg_filegroup-srcs">srcs</a>, <a href="#pkg_filegroup-prefix">prefix</a>)
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
load("@rules_pkg//pkg:mappings.bzl", "pkg_files") pkg_files(<a href="#pkg_files-name">name</a>, <a href="#pkg_files-srcs">srcs</a>, <a href="#pkg_files-attributes">attributes</a>, <a href="#pkg_files-excludes">excludes</a>, <a href="#pkg_files-include_runfiles">include_runfiles</a>, <a href="#pkg_files-prefix">prefix</a>, <a href="#pkg_files-renames">renames</a>, <a href="#pkg_files-strip_prefix">strip_prefix</a>)
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_filess 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
load("@rules_pkg//pkg:mappings.bzl", "pkg_mkdirs") pkg_mkdirs(<a href="#pkg_mkdirs-name">name</a>, <a href="#pkg_mkdirs-attributes">attributes</a>, <a href="#pkg_mkdirs-dirs">dirs</a>)
Defines creation and ownership of directories in packages
Use this if:
You need to create an empty directory in your package.
Your package needs to explicitly own a directory, even if it already owns files in those directories.
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
load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink_impl") pkg_mklink_impl(<a href="#pkg_mklink_impl-name">name</a>, <a href="#pkg_mklink_impl-attributes">attributes</a>, <a href="#pkg_mklink_impl-link_name">link_name</a>, <a href="#pkg_mklink_impl-target">target</a>)
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
load("@rules_pkg//pkg:mappings.bzl", "pkg_attributes") pkg_attributes(<a href="#pkg_attributes-mode">mode</a>, <a href="#pkg_attributes-user">user</a>, <a href="#pkg_attributes-group">group</a>, <a href="#pkg_attributes-uid">uid</a>, <a href="#pkg_attributes-gid">gid</a>, <a href="#pkg_attributes-kwargs">**kwargs</a>)
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
RETURNS
A value usable in the “attributes” attribute in package mapping rules.
load("@rules_pkg//pkg:mappings.bzl", "pkg_mklink") pkg_mklink(<a href="#pkg_mklink-name">name</a>, <a href="#pkg_mklink-link_name">link_name</a>, <a href="#pkg_mklink-target">target</a>, <a href="#pkg_mklink-attributes">attributes</a>, <a href="#pkg_mklink-src">src</a>, <a href="#pkg_mklink-kwargs">**kwargs</a>)
Create a symlink.
Wraps pkg_mklink_impl
PARAMETERS
load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") strip_prefix.files_only()
load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") strip_prefix.from_pkg(<a href="#strip_prefix.from_pkg-path">path</a>)
PARAMETERS
| Name | Description | Default Value |
|---|---|---|
| path | - | "" |
load("@rules_pkg//pkg:mappings.bzl", "strip_prefix") strip_prefix.from_root(<a href="#strip_prefix.from_root-path">path</a>)
PARAMETERS
| Name | Description | Default Value |
|---|---|---|
| path | - | "" |
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")
load("@rules_pkg//pkg/legacy:rpm.bzl", "pkg_rpm") pkg_rpm(<a href="#pkg_rpm-name">name</a>, <a href="#pkg_rpm-data">data</a>, <a href="#pkg_rpm-architecture">architecture</a>, <a href="#pkg_rpm-changelog">changelog</a>, <a href="#pkg_rpm-debug">debug</a>, <a href="#pkg_rpm-release">release</a>, <a href="#pkg_rpm-release_file">release_file</a>, <a href="#pkg_rpm-rpmbuild_path">rpmbuild_path</a>, <a href="#pkg_rpm-source_date_epoch">source_date_epoch</a>, <a href="#pkg_rpm-source_date_epoch_file">source_date_epoch_file</a>, <a href="#pkg_rpm-spec_file">spec_file</a>, <a href="#pkg_rpm-version">version</a>, <a href="#pkg_rpm-version_file">version_file</a>)
Legacy version
ATTRIBUTES