544
545
and scalar(@excludes) == 0 and $use_interdiff and !$wdiff_source_control) {
545
546
# same orig tar ball, interdiff exists and not wdiffing
547
spawn(exec => ['interdiff', '-z', @diff_opts, $diffs[1], $diffs[2]],
548
to_file => $filename,
550
if ($have_diffstat and $show_diffstat) {
551
my $header = "diffstat for " . basename($diffs[1])
552
. " " . basename($diffs[2]) . "\n\n";
553
$header =~ s/\.diff\.gz//g;
555
spawn(exec => ['diffstat', $filename],
561
open( INTERDIFF, '<', $filename );
562
while( <INTERDIFF> ) {
570
# Any other situation
571
if ($origs[1] eq $origs[2] and
572
defined $diffs[1] and defined $diffs[2] and
573
scalar(@excludes) == 0 and !$wdiff_source_control) {
574
warn "Warning: You do not seem to have interdiff (in the patchutils package)\ninstalled; this program would use it if it were available.\n";
576
# possibly different orig tarballs, or no interdiff installed,
577
# or wdiffing debian/control
578
our ($sdir1, $sdir2);
548
my $tmpdir = tempdir(CLEANUP => 1);
550
spawn(exec => ['interdiff', '-z', @diff_opts, $diffs[1], $diffs[2]],
551
to_file => $filename,
553
# Make interdiff put its tempfiles in $tmpdir, so they're
554
# automatically cleaned up
555
env => { TMPDIR => $tmpdir });
558
# If interdiff fails for some reason, we'll fall back to our manual
561
if ($have_diffstat and $show_diffstat) {
562
my $header = "diffstat for " . basename($diffs[1])
563
. " " . basename($diffs[2]) . "\n\n";
564
$header =~ s/\.diff\.gz//g;
566
spawn(exec => ['diffstat', $filename],
572
open( INTERDIFF, '<', $filename );
573
while( <INTERDIFF> ) {
584
# interdiff ran and failed, or any other situation
585
if (!$use_interdiff) {
586
warn "Warning: You do not seem to have interdiff (in the patchutils package)\ninstalled; this program would use it if it were available.\n";
588
# possibly different orig tarballs, or no interdiff installed,
589
# or wdiffing debian/control
590
our ($sdir1, $sdir2);
595
push (@opts, '--skip-patches') if $dscformats[$i] eq '3.0 (quilt)';
596
my $diri = ${"dir$i"};
598
spawn(exec => ['dpkg-source', @opts, $dscs[$i]],
599
to_file => '/dev/null',
604
my $dir = dirname $dscs[1] if $i == 2;
605
$dir = dirname $dscs[2] if $i == 1;
606
cp "$dir/$origs[$i]", $diri || fatal "copy $dir/$origs[$i] $diri: $!";
607
my $dscx = basename $dscs[$i];
608
cp $diffs[$i], $diri || fatal "copy $diffs[$i] $diri: $!";
609
cp $dscs[$i], $diri || fatal "copy $dscs[$i] $diri: $!";
610
spawn(exec => ['dpkg-source', @opts, $dscx],
611
to_file => '/dev/null',
616
while ($_ = readdir(DIR)) {
617
next if $_ eq '.' || $_ eq '..' || ! -d "$diri/$_";
622
my $sdiri = ${"sdir$i"};
624
# also unpack tarballs found in the top level source directory so we can compare their contents too
625
next unless $unpack_tarballs;
626
opendir DIR,$diri.'/'.$sdiri;
629
while ($_ = readdir(DIR)) {
630
my $unpacked = "=unpacked-tar" . $tarballs . "=";
632
if ($filename =~ s/\.tar\.$compression_re_file_ext$//) {
633
my $comp = compression_guess_from_filename($_);
635
spawn(exec => ['tar', "--$comp", '-xf', $_],
636
to_file => '/dev/null',
638
chdir => "$diri/$sdiri",
640
if (-d "$diri/$sdiri/$filename") {
641
move "$diri/$sdiri/$filename", "$diri/$sdiri/$unpacked";
648
my @command = ("diff", "-Nru", @diff_opts);
649
for my $exclude (@excludes) {
650
push @command, ("--exclude", $exclude);
652
push @command, ("$dir1/$sdir1", "$dir2/$sdir2");
654
# Execute diff and remove the common prefixes $dir1/$dir2, so the patch can be used with -p1,
655
# as if when interdiff would have been used:
656
spawn(exec => \@command, to_file => $filename, wait_child => 1, nocheck => 1);
658
if ($have_diffstat and $show_diffstat) {
659
print "diffstat for $sdir1 $sdir2\n\n";
660
spawn(exec => ['diffstat', $filename],
665
if ($have_wdiff and $wdiff_source_control) {
666
# Abuse global variables slightly to create some temporary directories
667
my $tempdir1 = $dir1;
668
my $tempdir2 = $dir2;
670
our $wdiffdir1 = $dir1;
671
our $wdiffdir2 = $dir2;
675
if ($controlfiles eq 'ALL') {
678
@cf = split /,/, $controlfiles;
580
682
for my $i (1,2) {
583
push (@opts, '--skip-patches') if $dscformats[$i] eq '3.0 (quilt)';
584
my $diri = ${"dir$i"};
586
spawn(exec => ['dpkg-source', @opts, $dscs[$i]],
587
to_file => '/dev/null',
592
my $dir = dirname $dscs[1] if $i == 2;
593
$dir = dirname $dscs[2] if $i == 1;
594
cp "$dir/$origs[$i]", $diri || fatal "copy $dir/$origs[$i] $diri: $!";
595
my $dscx = basename $dscs[$i];
596
cp $diffs[$i], $diri || fatal "copy $diffs[$i] $diri: $!";
597
cp $dscs[$i], $diri || fatal "copy $dscs[$i] $diri: $!";
598
spawn(exec => ['dpkg-source', @opts, $dscx],
599
to_file => '/dev/null',
604
while ($_ = readdir(DIR)) {
605
next if $_ eq '.' || $_ eq '..' || ! -d "$diri/$_";
610
my $sdiri = ${"sdir$i"};
612
# also unpack tarballs found in the top level source directory so we can compare their contents too
613
next unless $unpack_tarballs;
614
opendir DIR,$diri.'/'.$sdiri;
617
while ($_ = readdir(DIR)) {
618
my $unpacked = "=unpacked-tar" . $tarballs . "=";
620
if ($filename =~ s/\.tar\.$compression_re_file_ext$//) {
621
my $comp = compression_guess_from_filename($_);
623
spawn(exec => ['tar', "--$comp", '-xf', $_],
624
to_file => '/dev/null',
626
chdir => "$diri/$sdiri",
628
if (-d "$diri/$sdiri/$filename") {
629
move "$diri/$sdiri/$filename", "$diri/$sdiri/$unpacked";
636
my @command = ("diff", "-Nru", @diff_opts);
637
for my $exclude (@excludes) {
638
push @command, ("--exclude", $exclude);
640
push @command, ("$dir1/$sdir1", "$dir2/$sdir2");
642
# Execute diff and remove the common prefixes $dir1/$dir2, so the patch can be used with -p1,
643
# as if when interdiff would have been used:
644
spawn(exec => \@command, to_file => $filename, wait_child => 1, nocheck => 1);
646
if ($have_diffstat and $show_diffstat) {
647
print "diffstat for $sdir1 $sdir2\n\n";
648
spawn(exec => ['diffstat', $filename],
653
if ($have_wdiff and $wdiff_source_control) {
654
# Abuse global variables slightly to create some temporary directories
655
my $tempdir1 = $dir1;
656
my $tempdir2 = $dir2;
658
our $wdiffdir1 = $dir1;
659
our $wdiffdir2 = $dir2;
663
if ($controlfiles eq 'ALL') {
666
@cf = split /,/, $controlfiles;
671
foreach my $file (@cf) {
672
cp ${"dir$i"}.'/'.${"sdir$i"}."/debian/$file", ${"wdiffdir$i"};
677
# We don't support "ALL" for source packages as that would
679
$exit_status = wdiff_control_files($wdiffdir1, $wdiffdir2, $dummyname,
680
$controlfiles eq 'ALL' ? 'control' : $controlfiles,
685
rmtree([$wdiffdir1, $wdiffdir2]);
688
if (! -f $filename) {
689
fatal "Creation of diff file $filename failed!";
690
} elsif (-s $filename) {
691
open( DIFF, '<', $filename ) or fatal "Opening diff file $filename failed!";
694
s/^--- $dir1\//--- /;
695
s/^\+\+\+ $dir2\//+++ /;
696
s/^(diff .*) $dir1\/\Q$sdir1\E/$1 $sdir1/;
697
s/^(diff .*) $dir2\/\Q$sdir2\E/$1 $sdir2/;
683
foreach my $file (@cf) {
684
cp ${"dir$i"}.'/'.${"sdir$i"}."/debian/$file", ${"wdiffdir$i"};
689
# We don't support "ALL" for source packages as that would
691
$exit_status = wdiff_control_files($wdiffdir1, $wdiffdir2, $dummyname,
692
$controlfiles eq 'ALL' ? 'control' : $controlfiles,
697
rmtree([$wdiffdir1, $wdiffdir2]);
700
if (! -f $filename) {
701
fatal "Creation of diff file $filename failed!";
702
} elsif (-s $filename) {
703
open( DIFF, '<', $filename ) or fatal "Opening diff file $filename failed!";
706
s/^--- $dir1\//--- /;
707
s/^\+\+\+ $dir2\//+++ /;
708
s/^(diff .*) $dir1\/\Q$sdir1\E/$1 $sdir1/;
709
s/^(diff .*) $dir2\/\Q$sdir2\E/$1 $sdir2/;
706
717
exit $exit_status;