1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#!/usr/bin/perl
use strict;
sub conv_file($$) {
my $d = shift;
my $f = shift;
open F, "$d/$f" or die "can't open $d/$f";
my $in_diff = 0;
my $res = "";
my @dp;
my ($line, $nextline);
while ($line = <F>) {
if ($line =~ /^#\s*DP:/) {
push @dp, $line;
next;
}
$line =~ s/^#//;
if ($line =~ /^---/) {
$nextline = <F>;
$nextline =~ s/^#//;
if ($nextline =~ /^\+\+\+\s*(\S+)/) {
my $name = $1;
while ($name && ! -e $name) {
$name =~ s/^[^\/]*\/?//;
}
if ($name) {
$line =~ s|^(---\s*)\S+(.*)$|$1a/$name$2|;
$res .= $line;
$nextline =~ s|^(\+\+\+\s*)\S+(.*)$|$1b/$name$2|;
$res .= $nextline;
$in_diff = 1;
next;
}
}
$in_diff = 0;
}
if (!($line =~ /^[-+@ ]/)) {
$in_diff = 0;
}
if ($in_diff) {
$res .= $line;
}
}
close F;
if ($res) {
$res = "# DP: This patch was converted from $f\n" .
"# DP: Original comment:\n" .
"# DP:\n" . join("", @dp) . "\n" . $res;
}
return $res;
}
my $dir = shift;
if (! -d $dir) {
die "$dir is not a directory";
}
my @patches;
if (! -d "debian/" || ! -e "debian/convert-debian-gcc-diff") {
die "Please run this script from top-level directory of gcc-*-doc-non-dfsg package.";
}
system("rm -f debian/patches/from-debian-gcc-*");
for my $file (@ARGV) {
my $converted = conv_file($dir, $file);
next if (!$converted);
my $converted_name = "from-debian-gcc-" . $file;
my $full_converted_name = "debian/patches/$converted_name";
open F, ">$full_converted_name" or die "failed to open $full_converted_name";
print F $converted;
close F;
push @patches, $converted_name;
}
open F, "debian/patches/series" or die "failed to open debian/patches/series";
while (<F>) {
chomp;
next if (/^from-debian-gcc-/);
push @patches, $_;
}
close F;
open F, ">debian/patches/series" or die "failed to open debian/patches/series";
print F $_ . "\n" for (@patches);
close F;
|