]> git.donarmstrong.com Git - debhelper.git/blob - dh_installcatalogs
r1914: * dh_installcatalogs: Make sure that /etc/sgml exists. Closes: #364946
[debhelper.git] / dh_installcatalogs
1 #!/usr/bin/perl -w
2
3 =head1 NAME
4
5 dh_installcatalogs - install and register SGML Catalogs
6
7 =cut
8
9 use strict;
10 use Debian::Debhelper::Dh_Lib;
11
12 my $sgmlbasever = "1.17";
13
14 =head1 SYNOPSIS
15
16 B<dh_installcatalogs> [S<I<debhelper options>>] [B<-n>]
17
18 =head1 DESCRIPTION
19
20 dh_installcatalogs is a debhelper program that installs and
21 registers SGML catalogs. (Note: it will be extended for XML catalog
22 registration when xml-core is available.)  It complies with the Debian
23 XML/SGML policy.
24
25 The file F<debian/I<package>.sgmlcatalogs> contains the catalogs to be
26 installed per package.  Each line in that file should be of the form
27 C<source dest>, where C<source> indicates where the catalog resides in
28 the source tree, and C<dest> indicates the destination location for
29 the catalog under the package build area.  C<dest> should start with
30 F</usr/share/sgml/>.
31
32 Catalogs will be registered in a supercatalog, in
33 F</etc/sgml/I<package>.cat>.
34
35 This command automatically adds maintainer script snippets for
36 registering and unregistering the catalogs and "supercatalogs" (unless
37 B<-n> is used).  A dependency on B<sgml-base> will be added to
38 C<${misc:Depends}>, so be sure your package uses that variable in
39 F<debian/control>.  See L<dh_installdeb(1)> for an explanation of
40 Debhelper maintainer script snippets.
41
42 =head1 OPTIONS
43
44 =over 4
45
46 =item B<-n>, B<--noscripts>
47
48 Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
49
50 =back
51
52 =head1 NOTES
53
54 Note that this command is not idempotent. "dh_clean -k" should be
55 called between invocations of this command. Otherwise, it may cause
56 multiple instances of the same text to be added to maintainer scripts.
57
58 =cut
59
60 init();
61
62 foreach my $package (@{$dh{DOPACKAGES}}) {
63         my $tmpdir = tmpdir($package);
64         my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs");
65         my @sgmlinstalled; # catalogs we've installed
66         if ($#ARGV >= 0) {
67                 error("extra command-line arguments");
68         }
69         if ($sgmlcatlistfile) {
70                 foreach my $line (filedoublearray($sgmlcatlistfile)) {
71                         my $source = $line->[0];
72                         my $dest = $line->[1];
73                         my $fulldest = "$tmpdir/$dest"; 
74                         $fulldest =~ s|//|/|g; # beautification
75         
76                         if (! -d dirname($fulldest)) {
77                                 doit("install","-d","-m755",$tmpdir."/".dirname($dest));
78                         }
79
80                         doit("install","-p","-m644",$source,$fulldest);
81         
82                         push(@sgmlinstalled,$dest);
83                 }
84         }
85         if (@sgmlinstalled) {
86                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
87
88                 if (! -d "$tmpdir/etc/sgml") {
89                         doit("install","-d","-m755","$tmpdir/etc/sgml");
90                 }
91
92                 if (! $dh{NOSCRIPTS}) {
93                         my $ordcats = join(" ", @sgmlinstalled);
94                         my $centralcat = "/etc/sgml/$package.cat";
95                         autoscript($package, "postinst", "postinst-sgmlcatalog",
96                                    "s%#CENTRALCAT#%$centralcat%g; s%#ORDCATS#%$ordcats%g;");
97                         autoscript($package, "prerm", "prerm-sgmlcatalog",
98                                    "s%#CENTRALCAT#%$centralcat%g;");
99                         autoscript($package, "postrm", "postrm-sgmlcatalog",
100                                    "s%#CENTRALCAT#%$centralcat%g;");
101                 }
102         }
103         else {
104                 # remove the dependency
105                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
106         }
107 }
108
109 =head1 SEE ALSO
110
111 L<debhelper(7)>
112
113 F</usr/share/doc/sgml-base-doc/>
114
115 =head1 AUTHOR
116
117 Adam Di Carlo <aph@debian.org>
118
119 =cut