summaryrefslogtreecommitdiff
path: root/dh_clistrip
blob: 209c83444d151fa6302f2bb62f24960a9c9c052f (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/perl -w

=head1 NAME

dh_clistrip - strips CLI debug symbols from package build directories

=cut

use strict;
use File::Find;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_clistrip> [S<I<debhelper options>>] [B<-X>I<item>] [--dbg-package=package]

=head1 DESCRIPTION

dh_clistrip is a debhelper program that removes debug symbols from
CLI libraries and applications.

dh_clistrip deletes all *.pdb, *.exe.mdb and *.dll.mdb files.

=head1 OPTIONS

=over 4

=item B<-X>I<item>, B<--exclude=>I<item>

Exclude files that contain "item" anywhere in their filename from being
deleted. You may use this option multiple times to build up a list of things
to exclude.

=item B<--dbg-package=>I<package>

Moves the debug symbols to the specified package.

=back

=cut

init();

my $pwd = `pwd`;
chomp $pwd;

# This variable can be used to turn off stripping (see Policy).
if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
	exit;
}
        
foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp = tmpdir($package);

	my $debug_pkg = '';
	if (defined($dh{DEBUGPACKAGES})) {
		$debug_pkg = @{$dh{DEBUGPACKAGES}}[0];
		verbose_print("debug_pkg: $debug_pkg");
	}
	
	if ($package eq $debug_pkg) {
		# skip debug package
		next;
	}
	
	# find debug symbols
	find (sub {
		foreach my $exclude (@{$dh{EXCLUDE}}) {  
			return if /$exclude/;
		}
		return unless -f && /\.(((exe|dll)\.mdb)|pdb)$/;
        	
		my $file = $_;
		my $dir = $File::Find::dir;
		
		if ($debug_pkg ne '') {
			my $debug_dir = $dir;
			verbose_print("dir: $dir");
			$debug_dir =~ s!$tmp!!;
			verbose_print("debug_dir: $debug_dir");
			$debug_dir = $pwd . "/debian/$debug_pkg/" . $debug_dir;
			verbose_print("debug_dir: $debug_dir");
			install_dir($debug_dir);
			verbose_print("moving $file to $debug_dir");
			doit("mv", $file, $debug_dir);
		} else {
			verbose_print("deleting $file");
			rm_files($file);
		}
	}, $tmp);
}

=head1 SEE ALSO

L<debhelper(7)>

This program is part of cli-common-dev.

=head1 AUTHOR

Mirco Bauer <meebey@meebey.net>

=cut