Control: tag -1 + patch

On Mon, May 14, 2018 at 11:07:50AM -0700, Bdale Garbee wrote:
> Paul Eggert <egg...@cs.ucla.edu> writes:
> 
> > On 05/14/2018 07:56 AM, Antonio Terceiro wrote:
> >> I still need to study the  > code a bit further to try to come up with a 
> >> better suggestion.
> > Sorry, the only suggestion I can make is that you should just use the 
> > new GNU tar. The old one was obviously busted and it generated busted 
> > tarballs.
> 
> Antonio, given this, I wonder if maybe the right approach might be to
> come up with a work-around so that pristine-tar can collaborate with tar
> to successfully extract older tarballs from git repos?  I could imagine
> a Debian-specific patch that adds a long-form command-line option to do
> the equivalent of reverting that one patch, and a mod to pristine-tar to
> try that option if reproducing the tarball fails before giving up
> entirely?  
> 
> In this way, Debian developers could continue to be able to rebuild and
> work on packages with older tarballs captured using pristine-tar, but
> all new work would be in the correct format.  This means all developers
> would want to get to tar 1.30 or later as soon as possible, but at least
> we wouldn't lose access to all our existing work.
> 
> What do you think?

Yes. Attached you will find a patch against the Debian tar packaging
repository that adds this new work-around to the existing
Debian-specific pristine-tar patch. I tested it locally and it works.

The accompanying pristine-tar change is this:
https://salsa.debian.org/debian/pristine-tar/commit/dd332ffb672ce27dcacdeec712419683f36c59c8

Thanks
From fdb28a41aac7627baaf405dc28e3328dcacb84a6 Mon Sep 17 00:00:00 2001
From: Antonio Terceiro <terce...@debian.org>
Date: Tue, 15 May 2018 08:36:12 -0300
Subject: [PATCH 1/2] pristine-tar: add support to force using user and group
 names

---
 debian/patches/pristine-tar.diff | 33 +++++++++++++++++++++++---------
 1 file changed, 24 insertions(+), 9 deletions(-)

diff --git a/debian/patches/pristine-tar.diff b/debian/patches/pristine-tar.diff
index 26e0268f..4f7826ea 100644
--- a/debian/patches/pristine-tar.diff
+++ b/debian/patches/pristine-tar.diff
@@ -1,26 +1,28 @@
 --- a/src/common.h
 +++ b/src/common.h
-@@ -980,4 +980,7 @@
+@@ -980,4 +980,8 @@ void group_map_read (char const *file);
  int group_map_translate (gid_t gid, gid_t *new_gid, char const **new_name);
  
  
 +GLOBAL int debian_longlink_hack;
++GLOBAL int debian_broken_numeric_owner;
 +GLOBAL int pristine_tar_compat;
 +
  _GL_INLINE_HEADER_END
 --- a/src/create.c
 +++ b/src/create.c
-@@ -28,6 +28,9 @@
+@@ -28,6 +28,10 @@
  #include "common.h"
  #include <hash.h>
  
 +extern int debian_longlink_hack;
++extern int debian_broken_numeric_owner;
 +extern int pristine_tar_compat;
 +
  /* Error number to use when an impostor is discovered.
     Pretend the impostor isn't there.  */
  enum { IMPOSTOR_ERRNO = ENOENT };
-@@ -535,6 +538,11 @@
+@@ -535,6 +539,11 @@ write_short_name (struct tar_stat_info *
    return header;
  }
  
@@ -32,18 +34,20 @@
  /* Write a GNUTYPE_LONGLINK or GNUTYPE_LONGNAME block.  */
  static void
  write_gnu_long_link (struct tar_stat_info *st, const char *p, char type)
-@@ -544,6 +552,10 @@
+@@ -544,7 +553,11 @@ write_gnu_long_link (struct tar_stat_inf
    union block *header;
  
    header = start_private_header ("././@LongLink", size, 0);
+-  if (! numeric_owner_option)
 +  if (pristine_tar_compat) {
 +         FILL (header->header.mtime, '0');
 +         FILL (header->header.mode, '0');
 +  }
-   if (! numeric_owner_option)
++  if ((pristine_tar_compat && debian_broken_numeric_owner) || ! numeric_owner_option)
      {
        static char *uname, *gname;
-@@ -729,7 +741,7 @@
+       if (!uname)
+@@ -729,7 +742,7 @@ write_header_name (struct tar_stat_info
        return write_short_name (st);
      }
    else if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
@@ -52,7 +56,7 @@
      return write_long_name (st);
    else
      return write_short_name (st);
-@@ -1502,7 +1514,7 @@
+@@ -1502,7 +1515,7 @@ dump_hard_link (struct tar_stat_info *st
  	  block_ordinal = current_block_ordinal ();
  	  assign_string (&st->link_name, link_name);
  	  if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT)
@@ -63,7 +67,7 @@
  	  st->stat.st_size = 0;
 --- a/src/tar.c
 +++ b/src/tar.c
-@@ -1204,6 +1204,26 @@
+@@ -1204,6 +1204,36 @@ expand_pax_option (struct tar_args *targ
    return res;
  }
  
@@ -77,6 +81,16 @@
 +	 debian_longlink_hack=0;
 +}
 +
++/* Debian specific environment variable used by pristine-tar to enable use of
++ * user and group names even when --numeric-owner is passed. */
++void debian_broken_numeric_owner_init (void) {
++ char *s=getenv ("TAR_BROKEN_NUMERIC_OWNER");
++ if (s && strcmp(s, "1") == 0)
++	 debian_broken_numeric_owner=1;
++ else
++	 debian_broken_numeric_owner=0;
++}
++
 +/* pristine-tar sets this environment variable to force fields in longlinks
 + * to be zeroed as was the case in tar 1.26. */
 +void pristine_tar_compat_init (void) {
@@ -90,11 +104,12 @@
  
  static uintmax_t
  parse_owner_group (char *arg, uintmax_t field_max, char const **name_option)
-@@ -2677,6 +2697,9 @@
+@@ -2677,6 +2707,10 @@ main (int argc, char **argv)
  
    set_quoting_style (0, DEFAULT_QUOTING_STYLE);
  
 +  debian_longlink_hack_init ();
++  debian_broken_numeric_owner_init ();
 +  pristine_tar_compat_init ();
 +
    /* Make sure we have first three descriptors available */
-- 
2.17.0

Attachment: signature.asc
Description: PGP signature

Reply via email to