General-purpose rule to create tar archives.

Unlike pkg_tar from rules_pkg this:

  • Does not depend on any Python interpreter setup
  • Does not have any custom program to produce the output, instead we rely on a well-known C++ program called “tar”. Specifically, we use the BSD variant of tar since it provides a means of controlling mtimes, uid, symlinks, etc.

We also provide full control for tar'ring binaries including their runfiles.

tar_rule

Rule that executes BSD tar. Most users should use the tar macro, rather than load this directly.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
compressCompress the archive file with a supported algorithm.Stringoptional""
mtreeAn mtree specification fileLabeloptionalNone
outResulting tar file to writeLabeloptional
srcsFiles that are placed into the tarList of labelsrequired

tar

Wrapper macro around tar_rule.

Allows the mtree to be supplied as an array literal of lines, in addition to a separate file, e.g.

mtree =[
    "usr/bin uid=0 gid=0 mode=0755 type=dir",
    "usr/bin/ls uid=0 gid=0 mode=0755 time=0 type=file content={}/a".format(package_name()),
],

For the format of a line, see “There are four types of lines in a specification” on the man page for BSD mtree, https://man.freebsd.org/cgi/man.cgi?mtree(8)

PARAMETERS

NameDescriptionDefault Value
namename of resulting tar_rulenone
mtreeeither an array of specification lines, or a label of a file that contains the lines.None
kwargsadditional named parameters to pass to tar_rulenone