tree: df240179b3199fcab56a600d213c4a1965de45af [path history] [tgz]
  1. testdata/
  2. archive.py
  3. archive_test.py
  4. BUILD
  5. build_tar.py
  6. build_test.sh
  7. make_deb.py
  8. pkg.bzl
  9. README.md
  10. testenv.py
  11. testenv.sh
tools/build_defs/pkg/README.md

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:


load("@bazel_tools//tools/build_defs/pkg:pkg.bzl", "pkg_tar", "pkg_deb") pkg_tar( name = "bazel-bin", data_path = "/src", directory = "/usr/bin", files = ["//src:bazel"], mode = "0755", ) pkg_tar( name = "bazel-tools", data_path = "/", directory = "/usr/share/lib/bazel/tools", files = ["//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.io", 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.

Future work

  • Support more format, especially pkg_zip.
  • Maybe a bit more integration with the docker_build rule.

pkg_tar

pkg_tar(name, extension, data_path, directory, files, mode, modes, deps, symlinks)

Creates a tar file from a list of inputs.

pkg_deb

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, predepends, recommends)

Create a debian package. See http://www.debian.org/doc/debian-policy/ch-controlfields.html for more details on this.