Package: devscripts
Version: 2.16.7
Followup-For: Bug #831870

Dear Maintainer,

I am attaching a patch to mk-origtargz to serve as a workaround for this issue.
I know it's not the cleanest, the general idea as well as the code (I've never 
coded in perl before),
but it seems to work so it's a good starting point in my eyes.
It seems like the actual bug might be with 'tar' itself.

-- Package-specific info:

--- /etc/devscripts.conf ---

--- ~/.devscripts ---
Not present

-- System Information:
Debian Release: stretch/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.6.0-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages devscripts depends on:
ii  dpkg-dev     1.18.10
ii  libc6        2.23-4
ii  perl         5.22.2-3
pn  python3:any  <none>

Versions of packages devscripts recommends:
ii  apt                         1.3~rc2
ii  at                          3.1.20-1
ii  curl                        7.50.1-1
ii  dctrl-tools                 2.24-2
ii  debian-keyring              2016.08.10
ii  dput                        0.9.6.4
ii  equivs                      2.0.9+nmu1
ii  fakeroot                    1.21-1
ii  file                        1:5.28-4
ii  gnupg                       2.1.14-5
ii  gnupg2                      2.1.14-5
ii  libdistro-info-perl         0.14
ii  libencode-locale-perl       1.05-1
ii  liblwp-protocol-https-perl  6.06-2
ii  libsoap-lite-perl           1.20-1
ii  liburi-perl                 1.71-1
ii  libwww-perl                 6.15-1
ii  licensecheck                3.0.22-1
ii  lintian                     2.5.46
ii  man-db                      2.7.5-1
ii  patch                       2.7.5-1
ii  patchutils                  0.3.4-1
ii  python3-debian              0.1.29
ii  python3-magic               1:5.28-4
ii  sensible-utils              0.0.9
ii  strace                      4.12-3
ii  unzip                       6.0-20
ii  wdiff                       1.2.2-1+b1
ii  wget                        1.18-2+b1
ii  xz-utils                    5.1.1alpha+20120614-2.1

Versions of packages devscripts suggests:
ii  bsd-mailx [mailx]            8.1.2-0.20160123cvs-3
ii  build-essential              12.2
pn  cvs-buildpackage             <none>
pn  devscripts-el                <none>
pn  diffoscope                   <none>
pn  dose-extra                   <none>
pn  gnuplot                      <none>
ii  gpgv                         2.1.14-5
ii  libauthen-sasl-perl          2.1600-1
ii  libfile-desktopentry-perl    0.22-1
ii  libnet-smtp-ssl-perl         1.03-1
pn  libterm-size-perl            <none>
ii  libtimedate-perl             2.3000-2
pn  libyaml-syck-perl            <none>
pn  mozilla-devscripts           <none>
ii  mutt                         1.6.2-2
ii  openssh-client [ssh-client]  1:7.3p1-1
pn  reprotest                    <none>
pn  svn-buildpackage             <none>
ii  w3m                          0.5.3-29

-- no debconf information
>From f48188e767165bb735d9642b30e1fb20794ff06e Mon Sep 17 00:00:00 2001
From: Chirayu Desai <chirayudes...@gmail.com>
Date: Thu, 25 Aug 2016 13:38:21 +0530
Subject: [PATCH] mk-origtargz: rm excluded

---
 scripts/mk-origtargz.pl | 44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

diff --git a/scripts/mk-origtargz.pl b/scripts/mk-origtargz.pl
index f09c500a55..0839aed272 100644
--- a/scripts/mk-origtargz.pl
+++ b/scripts/mk-origtargz.pl
@@ -166,6 +166,10 @@ Put the resulting file in the given directory.
 Add the extra options to use with the B<unzip> command such as B<-a>, B<-aa>,
 and B<-b>.
 
+=item B<--rm-excluded>
+
+Use rm instead of tar --delete.
+
 =back
 
 =cut
@@ -202,6 +206,7 @@ use Dpkg::Version;
 use File::Spec;
 
 use Devscripts::Compression qw/compression_is_supported compression_guess_from_file compression_get_property/;
+use Cwd;
 use Cwd 'abs_path';
 use File::Copy;
 use Dpkg::Control::Hash;
@@ -224,6 +229,7 @@ my $compression = "gzip";
 my $mode = undef; # can be symlink, rename or copy. Can internally be repacked if the file was repacked.
 my $repack = 0;
 my $suffix = '';
+my $rm_excluded = 0;
 
 my $upstream = undef;
 
@@ -255,6 +261,7 @@ GetOptions(
     'repack-suffix|S=s' => \$suffix,
     "directory|C=s" => \$destdir,
     "unzipopt=s" => \$unzipopt,
+    "rm-excluded" => \$rm_excluded,
     "help|h" => sub { pod2usage({-exitval => 0, -verbose => 1}); },
 ) or pod2usage({-exitval => 3, -verbose=>1});
 
@@ -534,11 +541,38 @@ if ($do_repack || $deletecount) {
     # We have to use piping because --delete is broken otherwise, as documented
     # at https://www.gnu.org/software/tar/manual/html_node/delete.html
     if (@to_delete) {
-	spawn(exec => ['tar', '--delete', @to_delete ],
-	      from_file => $destfiletar,
-	      to_file => $destfiletar . ".tmp",
-	      wait_child => 1) if scalar(@to_delete) > 0;
-	move ($destfiletar . ".tmp", $destfiletar);
+	if ($rm_excluded) {
+		# Setup a temporary directory and extract the tar
+		my $tempdir = tempdir ("uscanXXXX", TMPDIR => 1, CLEANUP => 1);
+		$tempdir .= '/exclude';
+		mkdir $tempdir or die("Unable to mkdir($tempdir): $!\n");
+		spawn(exec => ['tar', '--extract',
+		      '--file', "$destfiletar",
+		      '--directory', $tempdir,],
+		      wait_child => 1);
+		opendir(TMPDIR, $tempdir) || die("Can't open $tempdir $!\n");
+		my $cwd = cwd();
+		chdir TMPDIR;
+		# Remove the excluded files
+		spawn(exec => ['rm', '-r', @to_delete ], wait_child => 1);
+		chdir $cwd;
+		my @files = grep {$_ ne "." && $_ ne ".."} readdir(TMPDIR);
+		close TMPDIR;
+		# Create a tar without the excluded files
+		spawn(exec => ['tar',
+		      '--owner=root', '--group=root', '--mode=a+rX',
+		      '--create', '--file', "$destfiletar" . ".tmp",
+		      '--directory', $tempdir,
+		      @files],
+		      wait_child => 1);
+		move ($destfiletar . ".tmp", $destfiletar);
+	} else {
+		spawn(exec => ['tar', '--delete', @to_delete ],
+		      from_file => $destfiletar,
+		      to_file => $destfiletar . ".tmp",
+		      wait_child => 1) if scalar(@to_delete) > 0;
+		move ($destfiletar . ".tmp", $destfiletar);
+	}
     }
     compress_archive($destfiletar, $destfile, $compression);
 
-- 
2.9.3

_______________________________________________
devscripts-devel mailing list
devscripts-devel@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/devscripts-devel

Reply via email to