]> git.donarmstrong.com Git - debhelper.git/blob - dh_installexamples
releasing version 6.0.2
[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 $basename = basename($example);
90                                 my $dir = ($basename eq '.') ? $example : "$example/..";
91                                 my $pwd=`pwd`;
92                                 chomp $pwd;
93                                 my $exclude2 = '-type f'.$exclude;
94                                 complex_doit("cd '$dir' && find '$basename' -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/usr/share/doc/$package/examples \\;");
95                         }
96                         else {
97                                 doit("cp", "-a", $example, "$tmp/usr/share/doc/$package/examples");
98                         }
99                 }
100         }
101 }
102
103 =head1 SEE ALSO
104
105 L<debhelper(7)>
106
107 This program is a part of debhelper.
108
109 =head1 AUTHOR
110
111 Joey Hess <joeyh@debian.org>
112
113 =cut