# Packaging for Bazel
## Overview These build rules are used for building various packaging such as tarball and debian package. ## Basic Example This example is a simplification of the debian packaging of Bazel: ```python 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", modes = {"tools/build_defs/docker/build_test.sh": "0755"}, ) pkg_tar( name = "debian-data", extension = "tar.gz", deps = [ ":bazel-bin", ":bazel-tools", ], ) pkg_deb( name = "bazel-debian", architecture = "amd64", built_using = "bazel (0.1.1)", data = ":debian-data", depends = [ "zlib1g-dev", "unzip", ], description_file = "debian/description", homepage = "http://bazel.build", maintainer = "The Bazel AuthorsAttributes | |
---|---|
name |
Name, required
A unique name for this rule. |
extension |
String, default to 'tar'
The extension for the resulting tarball. The output
file will be 'name.extension'. This extension
also decide on the compression: if set to |
strip_prefix |
String, optional
Root path of the files.
The directory structure from the files is preserved inside the
tarball but a prefix path determined by |
package_dir |
String, optional
Target directory. The directory in which to expand the specified files, defaulting to '/'. Only makes sense accompanying files. |
srcs |
List of files, optional
File to add to the layer. A list of files that should be included in the docker image. |
mode |
String, default to 0555
Set the mode of files added by the |
modes |
Dictionary, default to '{}'
A string dictionary to change default mode of specific files from
|
owner |
String, default to '0.0'
|
owners |
Dictionary, default to '{}'
A string dictionary to change default owner of specific files from
|
ownername |
String, optional
|
ownernames |
Dictionary, default to '{}'
A string dictionary to change default owner of specific files from
|
deps |
List of labels, optional
Tar files to extract and include in this tar package. A list of tarball labels to merge into the output tarball. |
symlinks |
Dictionary, optional
Symlinks to create in the output tarball.
|
Attributes | |
---|---|
name |
Name, required
A unique name for this rule. |
data |
File, required
A tar file that contains the data for the debian package (basically the list of files that will be installed by this package). |
package |
String, required
The name of the package. |
architecture |
String, default to 'all'
The architecture that this package target. |
maintainer |
String, required
The maintainer of the package. |
preinst , postinst , prerm and postrm |
Files, optional
Respectively, the pre-install, post-install, pre-remove and post-remove scripts for the package. See http://www.debian.org/doc/debian-policy/ch-maintainerscripts.html. |
conffiles , conffiles_file |
String list or File, optional
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/manuals/debian-faq/ch-pkg_basics.en.html#s-conffile. |
version , version_file |
String or File, required
The package version provided either inline (with |
description , description_file |
String or File, required
The package description provided either inline (with |
built_using , built_using_file |
String or File, default to 'Bazel'
The tool that were used to build this package provided either inline
(with |
priority |
String, default to 'optional'
The priority of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-priorities. |
section |
String, default to 'contrib/devel'
The section of the package. See http://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections. |
homepage |
String, optional
The homepage of the project. |
depends , suggests , enhances ,
conflicts , predepends and recommends .
|
String list, optional
The list of dependencies in the project. See http://www.debian.org/doc/debian-policy/ch-relationships.html#s-binarydeps. |
Attributes | |
---|---|
name |
Name, required
A unique name for this rule. Used to name the output package. |
spec_file |
File, required
The RPM specification file used to generate the package. See http://ftp.rpm.org/max-rpm/s1-rpm-build-creating-spec-file.html. |
architecture |
String, default to 'all'
The architecture that this package target. |
version , version_file |
String or File, required
The package version provided either inline (with |
data |
Files, required
Files to include in the generated package. |