]> git.donarmstrong.com Git - debhelper.git/blob - dh_installexamples
* dh_installdocs/examples: Don't unnecessarily use the exclude code path.
[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 use Cwd q{abs_path};
12
13 =head1 SYNOPSIS
14
15 B<dh_installexamples> [S<I<debhelper options>>] [B<-A>] [B<-X>I<item>] [S<I<file ...>>]
16
17 =head1 DESCRIPTION
18
19 dh_installexamples is a debhelper program that is responsible for
20 installing examples into usr/share/doc/package/examples in package
21 build directories.
22
23 Any file names specified as parameters will be installed into the first
24 package dh_installexamples is told to act on. By default, this is the first
25 binary package in debian/control, but if you use -p, -i, or -a flags, it
26 will be the first package specified by those flags.
27
28 Files named debian/package.examples can list other files to be installed.
29
30 =head1 OPTIONS
31
32 =over 4
33
34 =item B<-A>, B<--all>
35
36 Install any files specified by command line parameters in ALL packages
37 acted on.
38
39 =item I<file ...>
40
41 Install these files as examples into the first package acted on. (Or into
42 all packages if -A is specified.)
43
44 =item B<-Xitem>, B<--exclude=item>
45
46 Exclude files that contain "item" anywhere in their filename from
47 being installed.
48
49 =back
50
51 =head1 NOTES
52
53 Note that dh_installexamples will happily copy entire directory hierarchies
54 if you ask it to (similar to cp -a). If it is asked to install a
55 directory, it will install the complete contents of the directory.
56
57 =cut
58
59 init();
60
61 foreach my $package (@{$dh{DOPACKAGES}}) {
62         next if is_udeb($package);
63
64         my $tmp=tmpdir($package);
65         my $file=pkgfile($package,"examples");
66         
67         my @examples;
68         
69         if ($file) {
70                 @examples=filearray($file, ".");
71         }       
72
73         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
74                 push @examples, @ARGV;
75         }
76         
77         if (@examples) {
78                 if (! -d "$tmp/usr/share/doc/$package/examples") {
79                         doit("install","-d","$tmp/usr/share/doc/$package/examples");
80                 }
81                 
82                 my $exclude = '';
83                 if ($dh{EXCLUDE_FIND}) {
84                         $exclude .= ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
85                 }
86                 
87                 foreach my $example (@examples) {
88                         next if excludefile($example);
89                         if (-d $example && $exclude) {
90                                 my ($dir_basename) = basename(abs_path($example));
91                                 my $pwd=`pwd`;
92                                 chomp $pwd;
93                                 $exclude = '-type f'.$exclude;
94                                 complex_doit("cd '$example/..' && find '$dir_basename' $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