These build rules are used for building various packaging such as tarball and debian package.
This example is a simplification of the debian packaging of Bazel:
load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar", "pkg_deb") pkg_tar( name = "bazel-bin", strip_prefix = "/src", package_dir = "/usr/bin", srcs = ["//src:bazel"], mode = "0755", ) pkg_tar( name = "bazel-tools", strip_prefix = "/", package_dir = "/usr/share/lib/bazel/tools", srcs = ["//tools:package-srcs"], mode = "0644", ) pkg_tar( name = "debian-data", extension = "tar.gz", deps = [ ":bazel-bin", ":bazel-tools", ], ) pkg_deb( name = "bazel-debian", architecture = "amd64", built_using = "unzip (6.0.1)", data = ":debian-data", depends = [ "zlib1g-dev", "unzip", ], description_file = "debian/description", homepage = "http://bazel.build", maintainer = "The Bazel Authors <bazel-dev@googlegroups.com>", package = "bazel", version = "0.1.1", )
Here, the Debian package is built from three pkg_tar targets:
bazel-bin creates a tarball with the main binary (mode 0755) in /usr/bin,bazel-tools create a tarball with the base workspace (mode 0644) to /usr/share/bazel/tools ; the modes attribute let us specifies executable files,debian-data creates a gzip-compressed tarball that merge the three previous tarballs.debian-data is then used for the data content of the debian archive created by pkg_deb.
pkg_zip.docker_build rule.pkg_tar(name, extension, strip_prefix, package_dir, srcs, mode, modes, deps, symlinks)
Creates a tar file from a list of inputs.
pkg_deb(name, data, package, architecture, maintainer, preinst, postinst, prerm, postrm, version, version_file, description, description_file, built_using, built_using_file, priority, section, homepage, depends, suggests, enhances, conflicts, predepends, recommends)
Create a debian package. See http://www.debian.org/doc/debian-policy/ch-controlfields.html for more details on this.
<tr>
<td><code>conffiles</code>, <code>conffiles_file</code></td>
<td>
<code>String list or File, optional</code>
<p>
The list of conffiles or a file containing one conffile per
line. Each item is an absolute path on the target system
where the deb is installed.
</p>
<p>
See <a href="https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-conffile">https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html#s-conffile</a>.
</p>
</td>
</tr>
<tr>
<td><code>version</code>, <code>version_file</code></td>
<td>
<code>String or File, required</code>
<p>
The package version provided either inline (with <code>version</code>)
or from a file (with <code>version_file</code>).
</p>
</td>
</tr>
<tr>
<td><code>description</code>, <code>description_file</code></td>
<td>
<code>String or File, required</code>
<p>
The package description provided either inline (with <code>description</code>)
or from a file (with <code>description_file</code>).
</p>
</td>
</tr>
<tr>
<td><code>built_using</code>, <code>built_using_file</code></td>
<td>
<code>String or File</code>
<p>
The tool that were used to build this package provided either inline
(with <code>built_using</code>) or from a file (with <code>built_using_file</code>).
</p>
</td>
</tr>
<tr>
<td><code>priority</code></td>
<td>
<code>String, default to 'optional'</code>
<p>The priority of the package.</p>
<p>
See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities">http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities</a>.
</p>
</td>
</tr>
<tr>
<td><code>section</code></td>
<td>
<code>String, default to 'contrib/devel'</code>
<p>The section of the package.</p>
<p>
See <a href="http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections</a>.
</p>
</td>
</tr>
<tr>
<td><code>homepage</code></td>
<td>
<code>String, optional</code>
<p>The homepage of the project.</p>
</td>
</tr>
<tr>
<td>
<code>depends</code>, <code>suggests</code>, <code>enhances</code>,
<code>conflicts</code>, <code>predepends</code> and <code>recommends</code>.
</td>
<td>
<code>String list, optional</code>
<p>The list of dependencies in the project.</p>
<p>
See <a href="http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps">http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps</a>.
</p>
</td>
</tr>
pkg_rpm(name, spec_file, architecture, version, version_file, changelog, data)
Create an RPM package. See http://rpm.org/documentation.html for more details on this.