| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
=head1 NAME |
| 4 |
|
| 5 |
dh_clistrip - strips CLI debug symbols from package build directories |
| 6 |
|
| 7 |
=cut |
| 8 |
|
| 9 |
use strict; |
| 10 |
use File::Find; |
| 11 |
use Debian::Debhelper::Dh_Lib; |
| 12 |
|
| 13 |
=head1 SYNOPSIS |
| 14 |
|
| 15 |
B<dh_clistrip> [S<I<debhelper options>>] [B<-X>I<item>] [--dbg-package=package] |
| 16 |
|
| 17 |
=head1 DESCRIPTION |
| 18 |
|
| 19 |
dh_clistrip is a debhelper program that removes debug symbols from |
| 20 |
CLI libraries and applications. |
| 21 |
|
| 22 |
dh_clistrip deletes all *.pdb, *.exe.mdb and *.dll.mdb files. |
| 23 |
|
| 24 |
=head1 OPTIONS |
| 25 |
|
| 26 |
=over 4 |
| 27 |
|
| 28 |
=item B<-X>I<item>, B<--exclude=>I<item> |
| 29 |
|
| 30 |
Exclude files that contain "item" anywhere in their filename from being |
| 31 |
deleted. You may use this option multiple times to build up a list of things |
| 32 |
to exclude. |
| 33 |
|
| 34 |
=item B<--dbg-package=>I<package> |
| 35 |
|
| 36 |
Moves the debug symbols to the specified package. |
| 37 |
|
| 38 |
=back |
| 39 |
|
| 40 |
=cut |
| 41 |
|
| 42 |
init(); |
| 43 |
|
| 44 |
my $pwd = `pwd`; |
| 45 |
chomp $pwd; |
| 46 |
|
| 47 |
# This variable can be used to turn off stripping (see Policy). |
| 48 |
if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) { |
| 49 |
exit; |
| 50 |
} |
| 51 |
|
| 52 |
foreach my $package (@{$dh{DOPACKAGES}}) { |
| 53 |
my $tmp = tmpdir($package); |
| 54 |
|
| 55 |
my $debug_pkg = ''; |
| 56 |
if (defined($dh{DEBUGPACKAGES})) { |
| 57 |
$debug_pkg = @{$dh{DEBUGPACKAGES}}[0]; |
| 58 |
verbose_print("debug_pkg: $debug_pkg"); |
| 59 |
} |
| 60 |
|
| 61 |
if ($package eq $debug_pkg) { |
| 62 |
# skip debug package |
| 63 |
next; |
| 64 |
} |
| 65 |
|
| 66 |
# find debug symbols |
| 67 |
find (sub { |
| 68 |
foreach my $exclude (@{$dh{EXCLUDE}}) { |
| 69 |
return if /$exclude/; |
| 70 |
} |
| 71 |
return unless -f && /\.(((exe|dll)\.mdb)|pdb)$/; |
| 72 |
|
| 73 |
my $file = $_; |
| 74 |
my $dir = $File::Find::dir; |
| 75 |
|
| 76 |
if ($debug_pkg ne '') { |
| 77 |
my $debug_dir = $dir; |
| 78 |
verbose_print("dir: $dir"); |
| 79 |
$debug_dir =~ s!$tmp!!; |
| 80 |
verbose_print("debug_dir: $debug_dir"); |
| 81 |
$debug_dir = $pwd . "/debian/$debug_pkg/" . $debug_dir; |
| 82 |
verbose_print("debug_dir: $debug_dir"); |
| 83 |
if (! -d $debug_dir) { |
| 84 |
doit("install", "-d", $debug_dir); |
| 85 |
} |
| 86 |
verbose_print("moving $file to $debug_dir"); |
| 87 |
doit("mv", $file, $debug_dir); |
| 88 |
} else { |
| 89 |
verbose_print("deleting $file"); |
| 90 |
doit("rm", $file); |
| 91 |
} |
| 92 |
}, $tmp); |
| 93 |
} |
| 94 |
|
| 95 |
=head1 SEE ALSO |
| 96 |
|
| 97 |
L<debhelper(7)> |
| 98 |
|
| 99 |
This program is a part of cli-common. |
| 100 |
|
| 101 |
=head1 AUTHOR |
| 102 |
|
| 103 |
Mirco Bauer <[email protected]> |
| 104 |
|
| 105 |
=cut |