]> git.donarmstrong.com Git - debhelper.git/blob - dh_installexamples
r513: * Fixed dh_installdocs and dh_installexamples to support multiple -X's.
[debhelper.git] / dh_installexamples
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installexamples - install example files into package build directories
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installexamples> [S<I<debhelper options>>] [B<-A>] [B<-X>I<item>] [S<I<file ...>>]
15
16 =head1 DESCRIPTION
17
18 dh_installexamples is a debhelper program that is responsible for
19 installing examples into usr/share/doc/package/examples in package
20 build directories.
21
22 Any file names specified as parameters will be installed into the first
23 package dh_installexamples is told to act on. By default, this is the first
24 binary package in debian/control, but if you use -p, -i, or -a flags, it
25 will be the first package specified by those flags.
26
27 Files named debian/package.examples can list other files to be installed.
28
29 =head1 OPTIONS
30
31 =over 4
32
33 =item B<-A>, B<--all>
34
35 Install any files specified by command line parameters in ALL packages
36 acted on.
37
38 =item I<file ...>
39
40 Install these files as examples into the first package acted on. (Or into
41 all packages if -A is specified.)
42
43 =item B<-Xitem>, B<--exclude=item>
44
45 Exclude files that contain "item" anywhere in their filename from
46 being installed.
47
48 =back
49
50 =head1 NOTES
51
52 Note that dh_installexamples will happily copy entire directory hierarchies
53 if you ask it to (similar to cp -a). If it is asked to install a
54 directory, it will install the complete contents of the directory.
55
56 =cut
57
58 init();
59
60 foreach my $package (@{$dh{DOPACKAGES}}) {
61         my $tmp=tmpdir($package);
62         my $file=pkgfile($package,"examples");
63         
64         my @examples;
65         
66         if ($file) {
67                 @examples=filearray($file, ".");
68         }       
69
70         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
71                 push @examples, @ARGV;
72         }
73         
74         if (@examples) {
75                 if (! -d "$tmp/usr/share/doc/$package/examples") {
76                         doit("install","-d","$tmp/usr/share/doc/$package/examples");
77                 }
78                 
79                 my $exclude = '';
80                 if ($dh{EXCLUDE_FIND}) {
81                         $exclude = ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
82                 }
83                 
84                 foreach my $example (@examples) {
85                         next if excludefile($example);
86                         if (-d $example && $exclude) {
87                                 my ($dir_basename) = basename($example);
88                                 # Pity there's no cp --exclude ..
89                                 my $pwd=`pwd`;
90                                 chomp $pwd;
91                                 complex_doit("cd $example/.. && find $dir_basename -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/usr/share/doc/$package/examples \\;");
92                         }
93                         else {
94                                 doit("cp", "-a", $example, "$tmp/usr/share/doc/$package/examples");
95                         }
96                 }
97         }
98 }
99
100 =head1 SEE ALSO
101
102 L<debhelper(1)>
103
104 This program is a part of debhelper.
105
106 =head1 AUTHOR
107
108 Joey Hess <joeyh@debian.org>
109
110 =cut