Package: tardiff
Version: 0.1-5
Severity: normal
Tags: patch

Hi,

Perhaps I'm not using this utility in the way it was intended to be
used, but it falsely reports tarballs to be identical if the top-level
directories are identical. This is because the tarballs get extracted
to the same location, and therefore files are always compared to
themselves. This is the case with Debian tarballs, since the top-level
directory will always be debian/.

I have attached a patch which fixes this.

I also detected a minor fault in its error messages. 'Too much arguments'
should be changed to "Too many arguments'.

Best regards,

Carlos

-- System Information:
Debian Release: buster/sid
  APT prefers unstable
  APT policy: (990, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

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

Versions of packages tardiff depends on:
ii  libtext-diff-perl  1.44-1
ii  perl               5.26.0-5

tardiff recommends no packages.

tardiff suggests no packages.

-- no debconf information
>From 7ff1a7d462dbd48e634aba4c1181b187310b667b Mon Sep 17 00:00:00 2001
From: Carlos Maddela <e7ap...@gmail.com>
Date: Tue, 29 Aug 2017 23:24:57 +1000
Subject: [PATCH] Handle tarballs with the same top-level directory.

---
 tardiff | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/tardiff b/tardiff
index 2577b8f..000e9b1 100755
--- a/tardiff
+++ b/tardiff
@@ -67,6 +67,10 @@ sub arguments{
 
 sub untar{
        my $tarball = shift(@_);
+    my $prefix = shift(@_);
+
+    my $tardir = "$tempdir/$prefix";
+    mkdir $tardir or die "Couldn't create $tardir";
 
        my $flag = "";
        if($tarball =~ /\.gz$/){
@@ -75,7 +79,7 @@ sub untar{
                $flag = "-j";
        }
 
-       open(TARLIST, '-|', qw(tar -C), $tempdir, $flag, qw(-xvf), $tarball)
+       open(TARLIST, '-|', qw(tar -C), $tardir, $flag, qw(-xvf), $tarball)
            or die "Can't call tar as expected: $!";
        local $/ = undef; # slurp mode
        my $list = <TARLIST> or die "Couldn't read from tar";
@@ -174,8 +178,8 @@ sub autofile{
 sub tardiff{
        my $error = 0;
 
-       my $filelist1 = untar($tarball1) or die "Error: Could not unpack 
$tarball1.";
-       my $filelist2 = untar($tarball2) or die "Error: Could not unpack 
$tarball2.";
+       my $filelist1 = untar($tarball1, 1) or die "Error: Could not unpack 
$tarball1.";
+       my $filelist2 = untar($tarball2, 2) or die "Error: Could not unpack 
$tarball2.";
 
        my %files;
 
@@ -189,7 +193,7 @@ sub tardiff{
                        next if $opt_autoskip and autofile($file);
                        my $modified = 0;
                        if($opt_modified){
-                               $modified = comparefile($base1, $base2, $file);
+                               $modified = comparefile("1/$base1", "2/$base2", 
$file);
                                if($modified){
                                        if($opt_stats){
                                                print "/ $file $modified\n";
-- 
2.14.1

Reply via email to