]> git.donarmstrong.com Git - debhelper.git/blob - dh_installxfonts
version misc:Depends if necessary
[debhelper.git] / dh_installxfonts
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installxfonts - register X fonts
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 =head1 SYNOPSIS
13
14 B<dh_installxfonts> [S<I<debhelper options>>]
15
16 =head1 DESCRIPTION
17
18 dh_installxfonts is a debhelper program that is responsible for
19 registering X fonts, so their corresponding fonts.dir, fonts.alias,
20 and fonts.scale be rebuilt properly at install time.
21
22 Before calling this program, you should have installed any X fonts provided
23 by your package into the appropriate location in the package build
24 directory, and if you have fonts.alias or fonts.scale files, you should
25 install them into the correct location under etc/X11/fonts in your
26 package build directory.
27
28 Your package should depend on xfonts-utils so that the
29 update-fonts-* commands are available. (This program adds that dependency to
30 ${misc:Depends}.)
31
32 This program automatically generates the postinst and postrm commands needed
33 to register X fonts. These commands are inserted into the maintainer
34 scripts by dh_installdeb. See L<dh_installdeb(1)> for an explanation of how
35 this works.
36
37 =head1 NOTES
38
39 See L<update-fonts-alias(8)>, L<update-fonts-scale(8)>, and
40 L<update-fonts-dir(8)> for more information about X font installation.
41
42 See Debian policy, section 11.8.5. for details about doing fonts the Debian
43 way.
44
45 =cut
46
47 init();
48
49 foreach my $package (@{$dh{DOPACKAGES}}) {
50         my $tmp=tmpdir($package);
51
52         # Find all font directories in the package build directory.
53         my @fontdirs;
54         foreach my $parentdir ("$tmp/usr/share/fonts/X11/") {
55                 opendir(DIR, $parentdir) || next;
56                 @fontdirs = grep { -d "$parentdir/$_" && !/^\./ } (readdir DIR);
57                 closedir DIR;
58         }
59
60         if (@fontdirs) {
61                 # Figure out what commands the postinst and postrm will need 
62                 # to call.
63                 my @cmds;
64                 my @cmds_postinst;
65                 my @cmds_postrm;
66                 foreach my $f (@fontdirs) {
67                         # This must come before update-fonts-dir.
68                         push @cmds, "update-fonts-scale $f"
69                                 if -f "$tmp/etc/X11/fonts/$f/$package.scale";
70                         push @cmds, "update-fonts-dir --x11r7-layout $f";
71                         if (-f "$tmp/etc/X11/fonts/$f/$package.alias") {
72                                 push @cmds_postinst, "update-fonts-alias --include /etc/X11/fonts/$f/$package.alias $f";
73                                 push @cmds_postrm, "update-fonts-alias --exclude /etc/X11/fonts/$f/$package.alias $f";
74                                 addsubstvar($package, "misc:Depends", "xfonts-utils (>= 1:7.5+2)");
75                         }
76                 }
77
78                 autoscript($package, "postinst", "postinst-xfonts",
79                         "s:#CMDS#:".join(";", @cmds, @cmds_postinst).":");
80                 autoscript($package, "postrm", "postrm-xfonts",
81                         "s:#CMDS#:".join(";", @cmds, @cmds_postrm).":");
82
83                 addsubstvar($package, "misc:Depends", "xfonts-utils");
84         }
85         else {
86                 # remove
87                 addsubstvar($package, "misc:Depends", "xfonts-utils", "", 1);
88         }
89 }
90
91 =head1 SEE ALSO
92
93 L<debhelper(7)>
94
95 This program is a part of debhelper.
96
97 =head1 AUTHOR
98
99 Joey Hess <joeyh@debian.org>
100
101 =cut