Pull in upstream tar-1.32.

BUG=b:131301432,chromium:956531
TEST=emerge-lakitu tar

Change-Id: I15825b311aa661bce88f5a3463d117d98df5fe44
Reviewed-on: https://chromium-review.googlesource.com/1589129
Commit-Ready: Xuewei Zhang <xueweiz@google.com>
Tested-by: Xuewei Zhang <xueweiz@google.com>
Tested-by: Mattias Nissler <mnissler@chromium.org>
Reviewed-by: Mattias Nissler <mnissler@chromium.org>
(cherry picked from commit c44b2b98f210f201eeba0edef8d875ed225e8c11)
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/1591465
Commit-Queue: Xuewei Zhang <xueweiz@google.com>
diff --git a/app-arch/tar/Manifest b/app-arch/tar/Manifest
index e16fce7..64c7c86 100644
--- a/app-arch/tar/Manifest
+++ b/app-arch/tar/Manifest
@@ -1 +1 @@
-DIST tar-1.29.tar.bz2 2715993 SHA256 236b11190c0a3a6885bdb8d61424f2b36a5872869aa3f7f695dea4b4843ae2f2 SHA512 d2cea9892892dfa0c8efd390303b75dccc085c4895e07ced684074592d69729916d6ea12475aa6aff873d076a729bb7dc2499c233edcfb9c7e8e8995481eef3b WHIRLPOOL fa5f66a7bb7698c35ad842bc4900a62997da5eb2f3cd6154391b88505a581078a64a8399bb5976d4723d90951d34c084e00d17908d90792bb5139184e8b92a94
+DIST tar-1.32.tar.bz2 2947264 BLAKE2B 4e380a9a2f84a2af5130464e1b298ae6acf02ee459cbca20dd0991c2859785e5aac789d57b87b32e8b45d89985b6414af9dd37161385da9568d6030c5aa42c0e SHA512 3139e87112123269ee0600243b3ea081687cc93667bef5832bfe3c785c1be622f520f00fcfbdf44ad1d3247866d0ecfe347a85bbfec38eb38fa1014baef566f6
diff --git a/app-arch/tar/files/tar-1.29-add-files.patch b/app-arch/tar/files/tar-1.29-add-files.patch
deleted file mode 100644
index 8ab15ac..0000000
--- a/app-arch/tar/files/tar-1.29-add-files.patch
+++ /dev/null
@@ -1,194 +0,0 @@
-From 3a283cfe9f8f1f127e8dc5597a5ea1d249985a54 Mon Sep 17 00:00:00 2001
-From: Sergey Poznyakoff <gray@gnu.org>
-Date: Sat, 12 Nov 2016 11:20:47 +0200
-Subject: [PATCH] Fix the --add-file option.
-
-* src/common.h (name_more_files): New proto.
-(files_from_option): Remove.
-* src/names.c (name_more_files): New file.
-(names_options): Fix declaration of the
-add-file option.
-(names_parse_opt): Handle --add-file.
-* src/tar.c (struct tar_args): Remove the input_files member.
-Change all uses: use name_more_files() instead.
-* tests/Makefile.am: Add new test.
-* tests/add-file.at: New testcase.
-* tests/testsuite.at: Add new test.
----
- src/common.h       |  4 +---
- src/names.c        | 24 ++++++++++++-------
- src/tar.c          | 16 ++++---------
- tests/Makefile.am  |  3 ++-
- tests/add-file.at  | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
- tests/testsuite.at |  1 +
- 6 files changed, 92 insertions(+), 23 deletions(-)
- create mode 100644 tests/add-file.at
-
-diff --git a/src/common.h b/src/common.h
-index 50c34cc7c09b..6fdb6225f18b 100644
---- a/src/common.h
-+++ b/src/common.h
-@@ -414,9 +414,6 @@ GLOBAL bool show_transformed_names_option;
-    timestamps from archives with an unusual member order. It is automatically
-    set for incremental archives. */
- GLOBAL bool delay_directory_restore_option;
--
--/* When set, tar will not refuse to create empty archives */
--GLOBAL bool files_from_option;
- 
- /* Declarations for each module.  */
- 
-@@ -738,6 +735,7 @@ void uid_to_uname (uid_t uid, char **uname);
- int uname_to_uid (char const *uname, uid_t *puid);
- 
- void name_init (void);
-+bool name_more_files (void);
- void name_add_name (const char *name);
- void name_term (void);
- const char *name_next (int change_dirs);
-diff --git a/src/names.c b/src/names.c
-index 219aa77a4356..1a9465667cd3 100644
---- a/src/names.c
-+++ b/src/names.c
-@@ -32,7 +32,8 @@ static void name_add_file (const char *name);
- 
- enum
-   {
--    EXCLUDE_BACKUPS_OPTION = 256,
-+    ADD_FILE_OPTION = 256,
-+    EXCLUDE_BACKUPS_OPTION,
-     EXCLUDE_CACHES_OPTION,
-     EXCLUDE_CACHES_UNDER_OPTION,
-     EXCLUDE_CACHES_ALL_OPTION,
-@@ -67,7 +68,7 @@ static struct argp_option names_options[] = {
-   {NULL, 0, NULL, 0,
-    N_("Local file name selection:"), GRID },
- 
--  {"add-file", ARGP_KEY_ARG, N_("FILE"), 0,
-+  {"add-file", ADD_FILE_OPTION, N_("FILE"), 0,
-    N_("add given FILE to the archive (useful if its name starts with a dash)"), GRID+1 },
-   {"directory", 'C', N_("DIR"), 0,
-    N_("change to directory DIR"), GRID+1 },
-@@ -190,10 +191,10 @@ names_parse_opt (int key, char *arg, struct argp_state *state)
- 
-     case 'T':
-       name_add_file (arg);
--      /* Indicate we've been given -T option. This is for backward
--	 compatibility only, so that `tar cfT archive /dev/null will
--	 succeed */
--      files_from_option = true;
-+      break;
-+
-+    case ADD_FILE_OPTION:
-+      name_add_name (arg);
-       break;
- 
-     default:
-@@ -651,8 +652,8 @@ struct name_elt        /* A name_array element. */
-   } v;
- };
- 
--static struct name_elt *name_head;  /* store a list of names */
--size_t name_count;	 	    /* how many of the entries are names? */
-+static struct name_elt *name_head;/* store a list of names */
-+size_t name_count;	 	  /* how many of the entries are file names? */
- 
- static struct name_elt *
- name_elt_alloc (void)
-@@ -784,6 +785,12 @@ name_list_advance (void)
-     }
- }
- 
-+/* Return true if there are names or options in the list */
-+bool
-+name_more_files (void)
-+{
-+  return name_count > 0;
-+}
- 
- /* Add to name_array the file NAME with fnmatch options MATFLAGS */
- void
-@@ -823,6 +830,7 @@ name_add_file (const char *name)
-   ep->v.file.name = name;
-   ep->v.file.line = 0;
-   ep->v.file.fp = NULL;
-+  name_count++;
- }
- 
- /* Names from external name file.  */
-diff --git a/src/tar.c b/src/tar.c
-index 35bac38c2793..a361fc2c607f 100644
---- a/src/tar.c
-+++ b/src/tar.c
-@@ -813,7 +813,6 @@ struct tar_args        /* Variables used during option parsing */
-   bool pax_option;                 /* True if --pax-option was given */
-   char const *backup_suffix_string;   /* --suffix option argument */
-   char const *version_control_string; /* --backup option argument */
--  bool input_files;                /* True if some input files where given */
-   int compress_autodetect;         /* True if compression autodetection should
- 				      be attempted when creating archives */
- };
-@@ -1322,7 +1321,6 @@ parse_opt (int key, char *arg, struct argp_state *state)
-     case ARGP_KEY_ARG:
-       /* File name or non-parsed option, because of ARGP_IN_ORDER */
-       name_add_name (arg);
--      args->input_files = true;
-       break;
- 
-     case 'A':
-@@ -2179,7 +2177,7 @@ more_options (int argc, char **argv, struct option_locus *loc)
-   args.loc = loc;
-   if (argp_parse (&argp, argc, argv, ARGP_IN_ORDER|ARGP_NO_EXIT, &idx, &args))
-     abort (); /* shouldn't happen */
--  if (loc->source == OPTS_ENVIRON && args.input_files)
-+  if (loc->source == OPTS_ENVIRON && name_more_files ())
-     USAGE_ERROR ((0, 0, _("non-option arguments in %s"), loc->name));
- }
- 
-@@ -2221,7 +2219,6 @@ decode_options (int argc, char **argv)
-   args.pax_option = false;
-   args.backup_suffix_string = getenv ("SIMPLE_BACKUP_SUFFIX");
-   args.version_control_string = 0;
--  args.input_files = false;
-   args.compress_autodetect = false;
- 
-   subcommand_option = UNKNOWN_SUBCOMMAND;
-@@ -2340,10 +2337,7 @@ decode_options (int argc, char **argv)
- 
-   /* Handle operands after any "--" argument.  */
-   for (; idx < argc; idx++)
--    {
--      name_add_name (argv[idx]);
--      args.input_files = true;
--    }
-+    name_add_name (argv[idx]);
- 
-   /* Derive option values and check option consistency.  */
- 
-@@ -2365,7 +2359,7 @@ decode_options (int argc, char **argv)
- 
-   if (occurrence_option)
-     {
--      if (!args.input_files)
-+      if (!name_more_files ())
- 	USAGE_ERROR ((0, 0,
- 		      _("--occurrence is meaningless without a file list")));
-       if (!IS_SUBCOMMAND_CLASS (SUBCL_OCCUR))
-@@ -2569,7 +2563,7 @@ decode_options (int argc, char **argv)
-     {
-       /* --test-label is silent if the user has specified the label name to
- 	 compare against. */
--      if (!args.input_files)
-+      if (!name_more_files ())
- 	verbose_option++;
-     }
-   else if (utc_option)
-@@ -2598,7 +2592,7 @@ decode_options (int argc, char **argv)
-   switch (subcommand_option)
-     {
-     case CREATE_SUBCOMMAND:
--      if (!args.input_files && !files_from_option)
-+      if (!name_more_files ())
- 	USAGE_ERROR ((0, 0,
- 		      _("Cowardly refusing to create an empty archive")));
-       if (args.compress_autodetect && archive_names
diff --git a/app-arch/tar/files/tar-1.29-extract-pathname-bypass-upstream.patch b/app-arch/tar/files/tar-1.29-extract-pathname-bypass-upstream.patch
deleted file mode 100644
index 2030ca6..0000000
--- a/app-arch/tar/files/tar-1.29-extract-pathname-bypass-upstream.patch
+++ /dev/null
@@ -1,60 +0,0 @@
-https://bugs.gentoo.org/598334
-
-From 7340f67b9860ea0531c1450e5aa261c50f67165d Mon Sep 17 00:00:00 2001
-From: Paul Eggert <eggert@Penguin.CS.UCLA.EDU>
-Date: Sat, 29 Oct 2016 21:04:40 -0700
-Subject: [PATCH] When extracting, skip ".." members
-
-* NEWS: Document this.
-* src/extract.c (extract_archive): Skip members whose names
-contain "..".
----
- NEWS          | 8 +++++++-
- src/extract.c | 8 ++++++++
- 2 files changed, 15 insertions(+), 1 deletion(-)
-
---- a/NEWS
-+++ b/NEWS
-@@ -1,6 +1,16 @@
- GNU tar NEWS - User visible changes. 2016-05-16
- Please send GNU tar bug reports to <bug-tar@gnu.org>
- 
-+
-+
-+version 1.29-r2+ Gentoo
-+
-+* Member names containing '..' components are now skipped when extracting.
-+
-+This fixes tar's behavior to match its documentation, and is a bit
-+safer when extracting untrusted archives over old files (an unsafe
-+practice that the tar manual has long recommended against).
-+
- 
- version 1.29 - Sergey Poznyakoff, 2016-05-16
- 
---- a/src/extract.c
-+++ b/src/extract.c
-@@ -1629,12 +1629,20 @@
- {
-   char typeflag;
-   tar_extractor_t fun;
-+  bool skip_dotdot_name;
- 
-   fatal_exit_hook = extract_finish;
- 
-   set_next_block_after (current_header);
- 
-+  skip_dotdot_name = (!absolute_names_option
-+		      && contains_dot_dot (current_stat_info.orig_file_name));
-+  if (skip_dotdot_name)
-+    ERROR ((0, 0, _("%s: Member name contains '..'"),
-+	    quotearg_colon (current_stat_info.orig_file_name)));
-+
-   if (!current_stat_info.file_name[0]
-+      || skip_dotdot_name
-       || (interactive_option
- 	  && !confirm ("extract", current_stat_info.file_name)))
-     {
--- 
-2.11.0.rc2
-
diff --git a/app-arch/tar/files/tar-1.29-extract-pathname-bypass.patch b/app-arch/tar/files/tar-1.29-extract-pathname-bypass.patch
deleted file mode 100644
index 6470fe0..0000000
--- a/app-arch/tar/files/tar-1.29-extract-pathname-bypass.patch
+++ /dev/null
@@ -1,27 +0,0 @@
---- a/lib/paxnames.c	2016-04-06 00:04:47.314860045 +0300
-+++ b/lib/paxnames.c	2016-04-06 02:08:44.962297881 +0300
-@@ -18,6 +18,7 @@
- #include <system.h>
- #include <hash.h>
- #include <paxlib.h>
-+#include <quotearg.h>
- 
- 
- /* Hash tables of strings.  */
-@@ -114,7 +115,15 @@
-       for (p = file_name + prefix_len; *p; )
- 	{
-           if (p[0] == '.' && p[1] == '.' && (ISSLASH (p[2]) || !p[2]))
--	    prefix_len = p + 2 - file_name;
-+            {
-+	      static char const *const diagnostic[] =
-+	      {
-+		N_("%s: Member name contains '..'"),
-+		N_("%s: Hard link target contains '..'")
-+	      };
-+	      ERROR ((0, 0, _(diagnostic[link_target]),
-+	              quotearg_colon (file_name)));
-+	    }
- 
- 	  do
- 	    {
diff --git a/app-arch/tar/tar-1.29-r3.ebuild b/app-arch/tar/tar-1.32.ebuild
similarity index 66%
rename from app-arch/tar/tar-1.29-r3.ebuild
rename to app-arch/tar/tar-1.32.ebuild
index be70033..68facce 100644
--- a/app-arch/tar/tar-1.29-r3.ebuild
+++ b/app-arch/tar/tar-1.32.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2017 Gentoo Foundation
+# Copyright 1999-2019 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
-EAPI="5"
+EAPI=6
 
-inherit flag-o-matic eutils
+inherit flag-o-matic
 
 DESCRIPTION="Use this to make tarballs :)"
 HOMEPAGE="https://www.gnu.org/software/tar/"
@@ -15,20 +15,17 @@
 KEYWORDS="*"
 IUSE="acl elibc_glibc minimal nls selinux static userland_GNU xattr"
 
-RDEPEND="acl? ( virtual/acl )
+LIB_DEPEND="acl? ( virtual/acl[static-libs(+)] )"
+
+RDEPEND="!static? ( ${LIB_DEPEND//\[static-libs(+)]} )
 	selinux? ( sys-libs/libselinux )"
 DEPEND="${RDEPEND}
 	nls? ( >=sys-devel/gettext-0.10.35 )
+	static? ( ${LIB_DEPEND} )
 	xattr? ( elibc_glibc? ( sys-apps/attr ) )"
 
-PATCHES=(
-	"${FILESDIR}/${P}-extract-pathname-bypass-upstream.patch" #598334
-	"${FILESDIR}/${P}-add-files.patch"
-)
-
 src_prepare() {
-	epatch "${PATCHES[@]}"
-	epatch_user
+	default
 
 	if ! use userland_GNU ; then
 		sed -i \
@@ -40,16 +37,17 @@
 
 src_configure() {
 	use static && append-ldflags -static
-	FORCE_UNSAFE_CONFIGURE=1 \
-	econf \
-		--enable-backup-scripts \
-		--bindir="${EPREFIX}"/bin \
-		--libexecdir="${EPREFIX}"/usr/sbin \
-		$(usex userland_GNU "" "--program-prefix=g") \
-		$(use_with acl posix-acls) \
-		$(use_enable nls) \
-		$(use_with selinux) \
+	local myeconfargs=(
+		--bindir="${EPREFIX%/}"/bin
+		--enable-backup-scripts
+		--libexecdir="${EPREFIX%/}"/usr/sbin
+		$(usex userland_GNU "" "--program-prefix=g")
+		$(use_with acl posix-acls)
+		$(use_enable nls)
+		$(use_with selinux)
 		$(use_with xattr xattrs)
+	)
+	FORCE_UNSAFE_CONFIGURE=1 econf "${myeconfargs[@]}"
 }
 
 src_install() {
@@ -70,11 +68,11 @@
 		dosym tar /bin/gtar
 	fi
 
-	mv "${ED}"/usr/sbin/${p}backup{,-tar} || die
-	mv "${ED}"/usr/sbin/${p}restore{,-tar} || die
+	mv "${ED%/}"/usr/sbin/${p}backup{,-tar} || die
+	mv "${ED%/}"/usr/sbin/${p}restore{,-tar} || die
 
 	if use minimal ; then
-		find "${ED}"/etc "${ED}"/*bin/ "${ED}"/usr/*bin/ \
+		find "${ED%/}"/etc "${ED%/}"/*bin/ "${ED%/}"/usr/*bin/ \
 			-type f -a '!' '(' -name tar -o -name ${p}tar ')' \
 			-delete || die
 	fi