bazel icon indicating copy to clipboard operation
bazel copied to clipboard

Provide a tiny tar utility for use in tests

Open aiuto opened this issue 4 years ago • 2 comments

Proposal: Create a rule(s) that can create a zip/tar archives from a set of sources. This would not be available at Bazel runtime as part of @tools (even though the source might go in //tools for lack of a better place). The capabilities would be to bundle up a list of sources and rename some files along the way. It would be stripped down version of the rules from pkg_tar.

Need:

  1. Some workspace tests often require building a tar archive as part of the test. These currently depend on pkg_tar from @tools/build_defs/pkg, which is going away (#8857 ). https://github.com/bazelbuild/bazel/search?q=bazel_tools/tools/build_defs/pkg&unscoped_q=pkg_tar Rewriting them to depend on the rules_pkg distribution is possible, but introduces an external dependency buried in code. The package checksum ends up appearing in Java test code that is writing a WORKSPACE file. This is extremely ugly.
  2. Building the Bazel distribution makes frequent use of pkg_tar to bundle up some things. We currently depend on bazelbuild/rules_pkg for this. It looks like we could use the mini tool to eliminate an upstream dependency.

As an alternative, we could minimize chance of drift between rules_pkg in the build and tests by reusing the imported repo.

  • re-export the rules_pkg.tar.gz that we import into the Bazel WORKSPACE. (maybe an http_file duplicating the http_archive)
  • tests which need to import @rules_pkg into the WORKSPACE files they write will add a dep on this tarball.

aiuto avatar Apr 22 '20 03:04 aiuto

My thinking as of late is to remove all the extra features from the internal pkg_tar and let it become the mini-tar. Users of the esoteric ones will have to do the easy migration to rules_pkg

aiuto avatar Jun 03 '21 14:06 aiuto

I picked this up again for now. Rough plan:

  • PR 1: create mini_tar using the remains of pkg_tar. Same build_tar, but few attributes.
  • migrate google off of bazel's pkg_tar to rules_pkg.pkg_tar
  • PR 2: drop more attributes from pkg_tar
  • PR 3: delete pkg.bzl
  • PR 4: consolidate archive.py into build_tar.py
  • PR 5: get rid of the shell tests.

It is very back burner, so it may take a few months.

aiuto avatar Mar 02 '22 19:03 aiuto

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 90 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

github-actions[bot] avatar Nov 25 '23 01:11 github-actions[bot]