Skip to content

Commit

Permalink
Remove ownernames and modes from @bazel_tools/build_defs/pkg%pkg_tar
Browse files Browse the repository at this point in the history
RELNOTES: None
PiperOrigin-RevId: 454629416
Change-Id: I080c08566fd7e479ea040836ea958808822502d9
  • Loading branch information
aiuto authored and copybara-github committed Jun 13, 2022
1 parent fe6b4ab commit 2454a4c
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 31 deletions.
1 change: 0 additions & 1 deletion tools/build_defs/pkg/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ genrule(
build_tar = ":build_tar",
extension = "tar%s" % ext,
mode = "0644",
modes = {"usr/titi": "0755"},
owner = "42.24",
ownername = "titi.tata",
package_dir = "/",
Expand Down
23 changes: 0 additions & 23 deletions tools/build_defs/pkg/build_tar.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,6 @@
flags.DEFINE_string('compression', None,
'Compression (`gz` or `bz2`), default is none.')

flags.DEFINE_multi_string(
'modes', None,
'Specific mode to apply to specific file (from the file argument),'
' e.g., path/to/file=0455.')

flags.DEFINE_multi_string(
'owners', None, 'Specify the numeric owners of individual files, '
'e.g. path/to/file=0.0.')

flags.DEFINE_string(
'owner', '0.0', 'Specify the numeric default owner of all files,'
' e.g., 0.0')
Expand Down Expand Up @@ -180,27 +171,13 @@ def main(unused_argv):
default_mode = int(FLAGS.mode, 8)

mode_map = {}
if FLAGS.modes:
for filemode in FLAGS.modes:
(f, mode) = unquote_and_split(filemode, '=')
if f[0] == '/':
f = f[1:]
mode_map[f] = int(mode, 8)

default_ownername = ('', '')
if FLAGS.owner_name:
default_ownername = FLAGS.owner_name.split('.', 1)

default_ids = FLAGS.owner.split('.', 1)
default_ids = (int(default_ids[0]), int(default_ids[1]))
ids_map = {}
if FLAGS.owners:
for file_owner in FLAGS.owners:
(f, owner) = unquote_and_split(file_owner, '=')
(user, group) = owner.split('.', 1)
if f[0] == '/':
f = f[1:]
ids_map[f] = (int(user), int(group))

# Add objects to the tar file
with TarFile(FLAGS.output, FLAGS.directory, FLAGS.compression,
Expand Down
2 changes: 1 addition & 1 deletion tools/build_defs/pkg/build_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function assert_content() {
./usr/
./usr/titi"
check_eq "$listing" "$(get_tar_listing $1)"
check_eq "-rwxr-xr-x" "$(get_tar_permission $1 ./usr/titi)"
check_eq "-rw-r--r--" "$(get_tar_permission $1 ./usr/titi)"
check_eq "-rw-r--r--" "$(get_tar_permission $1 ./etc/nsswitch.conf)"
check_eq "42/24" "$(get_numeric_tar_owner $1 ./usr/)"
check_eq "42/24" "$(get_numeric_tar_owner $1 ./usr/titi)"
Expand Down
6 changes: 0 additions & 6 deletions tools/build_defs/pkg/pkg.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ def _pkg_tar_impl(ctx):
fail("Each input must describe exactly one file.", attr = "files")
file_inputs += target_files
args += ["--file=%s=%s" % (_quote(target_files[0].path), f_dest_path)]
if ctx.attr.modes:
args += [
"--modes=%s=%s" % (_quote(key), ctx.attr.modes[key])
for key in ctx.attr.modes
]
if ctx.attr.extension:
dotPos = ctx.attr.extension.find(".")
if dotPos > 0:
Expand Down Expand Up @@ -112,7 +107,6 @@ _real_pkg_tar = rule(
"srcs": attr.label_list(allow_files = True),
"files": attr.label_keyed_string_dict(allow_files = True),
"mode": attr.string(default = "0555"),
"modes": attr.string_dict(),
"mtime": attr.int(default = -1),
"portable_mtime": attr.bool(default = True),
"out": attr.output(),
Expand Down

0 comments on commit 2454a4c

Please sign in to comment.