rules_pkg is a Bazel based project. Build and run tests as done in a Bazel project.
Act as an expert in Bazel, Starlark, Python, and the package formats this project produces (tar, zip, deb, rpm).
DO NOT git commit or git push unless given explicit permission.
ALWAYS FOLLOW THESE RULES. NEVER VIOLATE THEM.
Ask for user input and provide a justification if trying to violate them.
bazel clean --expunge.git commit --amend or rebase a branch with an open PR. Create new commits instead.MODULE.bazel or WORKSPACE just to stay at head; we support older Bazel LTS releases.Topic-specific rules live in .agents/rules/. Read the ones matching the files you touch (each rule's front matter lists its globs or trigger).
rules_pkg provides Bazel rules for building distribution packages. The core abstraction is a set of package-format-agnostic mapping rules (pkg_files, pkg_filegroup, pkg_mkdirs, pkg_mklink) that describe what goes where in a package. Format-specific rules (pkg_tar, pkg_zip, pkg_deb, pkg_rpm) consume those descriptions.
pkg/ Runtime rules and providers (shipped in the distribution)
mappings.bzl pkg_files, pkg_filegroup, pkg_mkdirs, pkg_mklink
providers.bzl Copy of //providers:providers.bzl (keep identical)
private/ Internal implementation helpers (not public API)
util.bzl substitute_package_variables, setup_output_files, ...
deb/ tar/ zip/ Format-specific implementations
legacy/ Legacy pkg_rpm (spec-file based)
releasing/ Release tooling shipped to users
providers/ The separately published @rules_pkg_providers module
toolchains/ rpmbuild and git toolchain discovery
tests/ All tests (not shipped)
examples/ Runnable examples; each is its own Bazel module, tested in CI
doc_build/ Stardoc targets that produce the reference docs
docs/ Generated reference docs served as GitHub pages
distro/ Rules to build the distribution tarball
Top-level .bzl files (mappings.bzl, pkg.bzl, etc.) are backward-compatibility re-exports of files inside pkg/.
Only pkg/, providers/, toolchains/, and a few root files ship in the release. Everything else is development-only.
bazel query --output=build can be used to inspect target definitions. bazel mod graph and bazel mod explain show module dependencies.
Read developers.md and patching.md for the project's contribution rules. The .agents/rules/ files expand on them.
buildifier --lint=fix <FILE> after editing any .bzl or BUILD file. Let it reorder loads and sort arguments.pkg_files / pkg_filegroup) over format-specific additions..sh or .py files instead of inlining them via heredocs, bash -c, python3 -c, or multi-line workflow run: blocks.bazel test //tests/... # everything bazel test //tests/mappings/... # pkg_files / pkg_filegroup bazel test //tests/tar/... # also deb, zip, rpm (rpm needs rpmbuild)
See .agents/rules/testing.md for test frameworks, tags, and fixtures.
After any user-visible feature change, regenerate the reference docs:
bazel build //doc_build:reference cp bazel-bin/doc_build/reference.md docs/latest.md
Do not git commit the result; the user handles commits.
See .agents/rules/pr.md. In short:
bazel test //tests/... and buildifier locally before opening or updating a PR.