| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
dh_autoreconf_clean - Clean all changes made by dh_autoreconf |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
use strict; |
| 10 |
use Debian::Debhelper::Dh_Lib; |
| 11 |
|
| 12 |
=head1 SYNOPSIS |
| 13 |
|
| 14 |
B<dh_autoreconf_clean> [S<I<debhelper options>>] |
| 15 |
|
| 16 |
=head1 DESCRIPTION |
| 17 |
|
| 18 |
dh_autoreconf_clean removes all files which have been created or changed |
| 19 |
during the autoreconf call executed by L<dh_autoreconf(1)>. It also reverts |
| 20 |
any ltmain.sh patch applied by dh_autoreconf. |
| 21 |
|
| 22 |
=cut |
| 23 |
|
| 24 |
init(); |
| 25 |
|
| 26 |
# PROMISE: DH NOOP WITHOUT autoreconf.before autoreconf.after |
| 27 |
|
| 28 |
# autoreconf failed, just remove the 'before' file. |
| 29 |
if (-r 'debian/autoreconf.before' && ! -r 'debian/autoreconf.after') { |
| 30 |
doit("rm", "debian/autoreconf.before"); |
| 31 |
exit 0; |
| 32 |
} |
| 33 |
|
| 34 |
if (! -r 'debian/autoreconf.before' || ! -r 'debian/autoreconf.after') { |
| 35 |
exit 0; |
| 36 |
} |
| 37 |
|
| 38 |
# Mapping of filename => md5sum. |
| 39 |
my %file = (); |
| 40 |
# An array of the names of the files which should be removed. |
| 41 |
my @delete = (); |
| 42 |
|
| 43 |
# Read the old files in |
| 44 |
open(FILE, 'debian/autoreconf.before') or die($!); |
| 45 |
|
| 46 |
while(<FILE>) { |
| 47 |
chomp($_); |
| 48 |
my ($checksum, $filename) = split(' ', $_, 2); |
| 49 |
|
| 50 |
$file{$filename} = $checksum; |
| 51 |
} |
| 52 |
close(FILE); |
| 53 |
|
| 54 |
# Read the new files |
| 55 |
open(FILE, 'debian/autoreconf.after') or die($!); |
| 56 |
|
| 57 |
my $ltcheck = ""; |
| 58 |
while(<FILE>) { |
| 59 |
chomp($_); |
| 60 |
my ($checksum, $filename) = split(' ', $_, 2); |
| 61 |
|
| 62 |
if ($filename eq "/usr/share/libtool/build-aux/ltmain.sh") { |
| 63 |
$ltcheck = $checksum; |
| 64 |
} elsif ($filename eq "/usr/share/libtool/config/ltmain.sh") { |
| 65 |
$ltcheck = $checksum; |
| 66 |
} elsif (!defined($file{$filename}) || $file{$filename} ne $checksum) { |
| 67 |
# Remove non-excluded, changed files |
| 68 |
push @delete, $filename; |
| 69 |
} elsif ($checksum eq $ltcheck) { |
| 70 |
# A valid ltmain.sh, reverse patch |
| 71 |
doit("patch", "-R", "-f", "--no-backup-if-mismatch", "-i", |
| 72 |
"/usr/share/dh-autoreconf/ltmain-as-needed.diff", |
| 73 |
$filename); |
| 74 |
} |
| 75 |
} |
| 76 |
close(FILE); |
| 77 |
|
| 78 |
# Cleanup |
| 79 |
doit("rm", "-f", "--", @delete) if @delete; |
| 80 |
doit("rm", "-f", "debian/autoreconf.before", "debian/autoreconf.after"); |
| 81 |
|
| 82 |
=head1 SEE ALSO |
| 83 |
|
| 84 |
L<debhelper(7)>, L<dh_autoreconf(1)>, L<dh-autoreconf(7)> |
| 85 |
|
| 86 |
=head1 AUTHOR |
| 87 |
|
| 88 |
Julian Andres Klode <[email protected]> |
| 89 |
|
| 90 |
=cut |