]> git.donarmstrong.com Git - debhelper.git/blob - dh_installexamples
Typo. Closes: #653339
[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 B<dh_installexamples> is a debhelper program that is responsible for
19 installing examples into F<usr/share/doc/package/examples> in package
20 build directories.
21
22 =head1 FILES
23
24 =over 4
25
26 =item debian/I<package>.examples
27
28 Lists example files or directories to be installed.
29
30 =back
31
32 =head1 OPTIONS
33
34 =over 4
35
36 =item B<-A>, B<--all>
37
38 Install any files specified by command line parameters in ALL packages
39 acted on.
40
41 =item B<-X>I<item>, B<--exclude=>I<item>
42
43 Exclude files that contain I<item> anywhere in their filename from
44 being installed.
45
46 =item I<file> ...
47
48 Install these files (or directories) as examples into the first package
49 acted on. (Or into all packages if B<-A> is specified.)
50
51 =back
52
53 =head1 NOTES
54
55 Note that B<dh_installexamples> will happily copy entire directory hierarchies
56 if you ask it to (similar to B<cp -a>). If it is asked to install a
57 directory, it will install the complete contents of the directory.
58
59 =cut
60
61 init();
62
63 foreach my $package (@{$dh{DOPACKAGES}}) {
64         next if is_udeb($package);
65
66         my $tmp=tmpdir($package);
67         my $file=pkgfile($package,"examples");
68         
69         my @examples;
70         
71         if ($file) {
72                 @examples=filearray($file, ".");
73         }       
74
75         if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
76                 push @examples, @ARGV;
77         }
78         
79         if (@examples) {
80                 if (! -d "$tmp/usr/share/doc/$package/examples") {
81                         doit("install","-d","$tmp/usr/share/doc/$package/examples");
82                 }
83                 
84                 my $exclude = '';
85                 if ($dh{EXCLUDE_FIND}) {
86                         $exclude .= ' -and ! \( '.$dh{EXCLUDE_FIND}.' \)';
87                 }
88                 
89                 foreach my $example (@examples) {
90                         next if excludefile($example);
91                         if (-d $example && $exclude) {
92                                 my $basename = basename($example);
93                                 my $dir = ($basename eq '.') ? $example : "$example/..";
94                                 my $pwd=`pwd`;
95                                 chomp $pwd;
96                                 my $exclude2 = '-type f'.$exclude;
97                                 complex_doit("cd '$dir' && find '$basename' -type f$exclude -exec cp --parents -dp {} $pwd/$tmp/usr/share/doc/$package/examples \\;");
98                         }
99                         else {
100                                 doit("cp", "-a", $example, "$tmp/usr/share/doc/$package/examples");
101                         }
102                 }
103         }
104 }
105
106 =head1 SEE ALSO
107
108 L<debhelper(7)>
109
110 This program is a part of debhelper.
111
112 =head1 AUTHOR
113
114 Joey Hess <joeyh@debian.org>
115
116 =cut