fix(tar): drop truthy-string default on store_true argparse flags (#1065)

The `--preserve_mode` and `--preserve_mtime` flags in
`pkg/private/tar/build_tar.py` were declared with `default='False'` (a
string, which is truthy) combined with `action='store_true'`. When the
flags are not passed on the command line, argparse uses the default
verbatim instead of the boolean `False` that `store_true` would produce,
so `options.preserve_mode` and `options.preserve_mtime` end up as the
string `'False'` — truthy under any natural truthy check.

rules_pkg's own use happens to be safe because the check is
`if self.preserve_mode is True`, but the typo is a foot-gun for anyone
copying the pattern.

Drop the bogus default — `action='store_true'` already defaults to
boolean `False`.

Fixes #1064
1 file changed
tree: 843c9df8e406440986496cab1ec8c1ea7d5163e9
  1. .bazelci/
  2. .bcr/
  3. .claude/
  4. .github/
  5. contrib/
  6. distro/
  7. doc_build/
  8. docs/
  9. examples/
  10. pkg/
  11. providers/
  12. tests/
  13. toolchains/
  14. .bazelignore
  15. .bazelrc
  16. .gitignore
  17. .pre-commit-config.yaml
  18. .typos.toml
  19. AUTHORS
  20. BUILD
  21. CHANGELOG.md
  22. CLAUDE.md
  23. CODEOWNERS
  24. CONTRIBUTING.md
  25. CONTRIBUTORS
  26. deps.bzl
  27. developers.md
  28. LICENSE
  29. mappings.bzl
  30. MODULE.bazel
  31. patching.md
  32. pkg.bzl
  33. README.md
  34. version.bzl
  35. WORKSPACE
  36. WORKSPACE.bzlmod
README.md

Bazel package building

Bazel rules for building tar, zip, deb, and rpm for packages.

For the latest version, see Releases (with WORKSPACE setup) / Documentation

Use rules-pkg-discuss@googlegroups.com for discussion.

CI: Build status

Basic rules

Package building rules

  • pkg - Rules for building packages of various types.
  • examples - Cookbook examples for using the rules.

As of Bazel 4.x, Bazel uses this rule set for packaging its distribution. Bazel still contains a limited version of pkg_tar but its feature set is frozen. Any new capabilities will be added here.

WORKSPACE setup

Sample, but see releases for the current release.

load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
    name = "rules_pkg",
    urls = [
        "https://mirror.bazel.build/github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
        "https://github.com/bazelbuild/rules_pkg/releases/download/0.9.1/rules_pkg-0.9.1.tar.gz",
    ],
    sha256 = "8f9ee2dc10c1ae514ee599a8b42ed99fa262b757058f65ad3c384289ff70c4b8",
)
load("@rules_pkg//:deps.bzl", "rules_pkg_dependencies")
rules_pkg_dependencies()

To use pkg_rpm(), you must provide a copy of rpmbuild. You can use the system installed rpmbuild with this stanza.

load("@rules_pkg//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild")

find_system_rpmbuild(
    name = "rules_pkg_rpmbuild",
    verbose = False,
)

MODULE.bazel setup

bazel_dep(name = "rules_pkg", version = "0.0.10")

To use pkg_rpm(), you must provide a copy of rpmbuild. You can use the system installed rpmbuild with this stanza.

find_rpm = use_extension("//toolchains/rpm:rpmbuild_configure.bzl", "find_system_rpmbuild_bzlmod")
use_repo(find_rpm, "rules_pkg_rpmbuild")
register_toolchains("@rules_pkg_rpmbuild//:all")

For developers

We hold an engineering status meeting on the first Monday of every month at 10am USA East coast time. Add to calendar / meeting notes