Drop ownernames from pkg_tar.

The package is deprecated and we do not use this feature.  Removing it helps prevent backsliding.

RELNOTES: None
PiperOrigin-RevId: 433481373
diff --git a/tools/build_defs/pkg/BUILD b/tools/build_defs/pkg/BUILD
index b573850..533b284 100644
--- a/tools/build_defs/pkg/BUILD
+++ b/tools/build_defs/pkg/BUILD
@@ -81,7 +81,6 @@
     modes = {"usr/titi": "0755"},
     owner = "42.24",
     ownername = "titi.tata",
-    ownernames = {"etc/nsswitch.conf": "tata.titi"},
     owners = {"etc/nsswitch.conf": "24.42"},
     package_dir = "/",
     strip_prefix = ".",
diff --git a/tools/build_defs/pkg/README.md b/tools/build_defs/pkg/README.md
index 9888d02..26d8057 100644
--- a/tools/build_defs/pkg/README.md
+++ b/tools/build_defs/pkg/README.md
@@ -245,28 +245,6 @@
       </td>
     </tr>
     <tr>
-      <td><code>ownernames</code></td>
-      <td>
-        <code>Dictionary, default to '{}'</code>
-        <p>
-          A string dictionary to change default owner of specific files from
-          <code>files</code>. Each key should be a path to a file before
-          appending the prefix <code>package_dir</code> and the corresponding
-          value the <code>username.groupname</code> string for the owner of the
-          file. When determining ownernames, this attribute is looked first then
-          <code>ownername</code>.
-        </p>
-        <p>
-          <code>
-          owners = {
-           "tools/py/2to3.sh": "leeroy.jenkins",
-           ...
-          },
-          </code>
-        </p>
-      </td>
-    </tr>
-    <tr>
       <td><code>deps</code></td>
       <td>
         <code>List of labels, optional</code>
diff --git a/tools/build_defs/pkg/build_tar.py b/tools/build_defs/pkg/build_tar.py
index 12e4b80..91aca12 100644
--- a/tools/build_defs/pkg/build_tar.py
+++ b/tools/build_defs/pkg/build_tar.py
@@ -68,10 +68,6 @@
 flags.DEFINE_string('owner_name', None,
                     'Specify the owner name of all files, e.g. root.root.')
 
-flags.DEFINE_multi_string(
-    'owner_names', None, 'Specify the owner names of individual files, e.g. '
-    'path/to/file=root.root.')
-
 flags.DEFINE_string('root_directory', './',
                     'Default root directory is named "."')
 
@@ -214,14 +210,6 @@
   default_ownername = ('', '')
   if FLAGS.owner_name:
     default_ownername = FLAGS.owner_name.split('.', 1)
-  names_map = {}
-  if FLAGS.owner_names:
-    for file_owner in FLAGS.owner_names:
-      (f, owner) = unquote_and_split(file_owner, '=')
-      (user, group) = owner.split('.', 1)
-      if f[0] == '/':
-        f = f[1:]
-      names_map[f] = (user, group)
 
   default_ids = FLAGS.owner.split('.', 1)
   default_ids = (int(default_ids[0]), int(default_ids[1]))
@@ -244,7 +232,7 @@
       return {
           'mode': mode_map.get(filename, default_mode),
           'ids': ids_map.get(filename, default_ids),
-          'names': names_map.get(filename, default_ownername),
+          'names': default_ownername,
       }
 
     for f in FLAGS.file:
diff --git a/tools/build_defs/pkg/build_test.sh b/tools/build_defs/pkg/build_test.sh
index ddaeb53..aad8d32 100755
--- a/tools/build_defs/pkg/build_test.sh
+++ b/tools/build_defs/pkg/build_test.sh
@@ -71,8 +71,8 @@
   check_eq "42/24" "$(get_numeric_tar_owner $1 ./usr/)"
   check_eq "42/24" "$(get_numeric_tar_owner $1 ./usr/titi)"
   if [ -z "${2-}" ]; then
-    check_eq "tata/titi" "$(get_tar_owner $1 ./etc/)"
-    check_eq "tata/titi" "$(get_tar_owner $1 ./etc/nsswitch.conf)"
+    check_eq "titi/tata" "$(get_tar_owner $1 ./etc/)"
+    check_eq "titi/tata" "$(get_tar_owner $1 ./etc/nsswitch.conf)"
     check_eq "titi/tata" "$(get_tar_owner $1 ./usr/)"
     check_eq "titi/tata" "$(get_tar_owner $1 ./usr/titi)"
   fi
diff --git a/tools/build_defs/pkg/pkg.bzl b/tools/build_defs/pkg/pkg.bzl
index 2386786..6de44b7 100644
--- a/tools/build_defs/pkg/pkg.bzl
+++ b/tools/build_defs/pkg/pkg.bzl
@@ -87,11 +87,6 @@
             "--owners=%s=%s" % (_quote(key), ctx.attr.owners[key])
             for key in ctx.attr.owners
         ]
-    if ctx.attr.ownernames:
-        args += [
-            "--owner_names=%s=%s" % (_quote(key), ctx.attr.ownernames[key])
-            for key in ctx.attr.ownernames
-        ]
     if ctx.attr.extension:
         dotPos = ctx.attr.extension.find(".")
         if dotPos > 0:
@@ -133,7 +128,6 @@
         "owner": attr.string(default = "0.0"),
         "ownername": attr.string(default = "."),
         "owners": attr.string_dict(),
-        "ownernames": attr.string_dict(),
         "extension": attr.string(default = "tar"),
         "symlinks": attr.string_dict(),
         "include_runfiles": attr.bool(),