]> git.donarmstrong.com Git - debhelper.git/blob - dh_installexamples
r1655: * Added udeb support, as pioneered by di-packages-build. Understands
[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         next if is_udeb($package);
62
63         my $tmp=tmpdir($package);
64         my $file=pkgfile($package,"examples");
65         
66         my @examples;
67         
68         if ($file) {
69                 @examples=filearray($file, ".");
70         }       
71
72         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
73                 push @examples, @ARGV;
74         }
75         
76         if (@examples) {
77                 if (! -d "$tmp/usr/share/doc/$package/examples") {
78                         doit("install","-d","$tmp/usr/share/doc/$package/examples");
79                 }
80                 
81                 my $exclude = '';
82                 if ($dh{EXCLUDE_FIND}) {
83                         $exclude = ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
84                 }
85                 
86                 foreach my $example (@examples) {
87                         next if excludefile($example);
88                         if (-d $example && $exclude) {
89                                 my ($dir_basename) = basename($example);
90                                 # Pity there's no cp --exclude ..
91                                 my $pwd=`pwd`;
92                                 chomp $pwd;
93                                 complex_doit("cd $example/.. && find $dir_basename -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/usr/share/doc/$package/examples \\;");
94                         }
95                         else {
96                                 doit("cp", "-a", $example, "$tmp/usr/share/doc/$package/examples");
97                         }
98                 }
99         }
100 }
101
102 =head1 SEE ALSO
103
104 L<debhelper(7)>
105
106 This program is a part of debhelper.
107
108 =head1 AUTHOR
109
110 Joey Hess <joeyh@debian.org>
111
112 =cut