bazelbuild / rules_pkg

Bazel rules for creating packages of many types (zip, tar, deb, rpm, ...)
Apache License 2.0
212 stars 166 forks source link

Dangling archive paths are not supported by pkg_tar #832

Open eejayes opened 3 months ago

eejayes commented 3 months ago

Common tar utilities allow inclusion of file paths with some depth to them, where the resulting archive does not include records for the parent directories and their corresponding file permissions. On the other hand, when pkg_tar is presented with a path where an explicit specification of a path's parent directories is not provided, records will automatically be created with a default set of file permissions. While fine-grained control of directory permission levels is available through pkg_mkdirs, it is not possible to instruct pkg_tar to refrain from creating file permission records for parents of a dangling path.

The common use case for a tar archive with a fragmented file structure, is one where extraction is being performed on top of a pre-existing file structure where only the paths specified in the archive should be subject to change. A work around of pkg_tars behavior with limited applicability could be to ensure that declared directory permissions for parent directories match the state of the pre-existing structure on the extraction target. Some more specialized use cases are:

  1. Parent directory records that a user doesn't want to specify correspond to paths on the extraction target that are not mounted as writable file systems. In this case an error will occur during extraction.
  2. Other expected factors on the extraction target can cause it's file system state to change that is not synchronized with the subject 'pkg_tar' specification.
aiuto commented 3 months ago

This seems like a reasonable feature if anyone would like to implement it.