]> git.donarmstrong.com Git - debhelper.git/blob - dh_installcatalogs
dh_prep: New program, does the same as dh_clean -k (which will be deprecated later).
[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). These snippets are inserted into the maintainer scripts
38 by dh_installdeb; see L<dh_installdeb(1)> for an explanation of
39 Debhelper maintainer script snippets.
40
41 A dependency on B<sgml-base> will be added to C<${misc:Depends}>, so be
42 sure your package uses that variable in F<debian/control>.
43
44 =head1 OPTIONS
45
46 =over 4
47
48 =item B<-n>, B<--noscripts>
49
50 Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
51
52 =back
53
54 =head1 NOTES
55
56 Note that this command is not idempotent. L<dh_prep(1)> should be
57 called between invocations of this command. Otherwise, it may cause
58 multiple instances of the same text to be added to maintainer scripts.
59
60 =cut
61
62 init();
63
64 foreach my $package (@{$dh{DOPACKAGES}}) {
65         my $tmpdir = tmpdir($package);
66         my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs");
67         my @sgmlinstalled; # catalogs we've installed
68         if ($#ARGV >= 0) {
69                 error("extra command-line arguments");
70         }
71         if ($sgmlcatlistfile) {
72                 foreach my $line (filedoublearray($sgmlcatlistfile)) {
73                         my $source = $line->[0];
74                         my $dest = $line->[1];
75                         my $fulldest = "$tmpdir/$dest"; 
76                         $fulldest =~ s|//|/|g; # beautification
77         
78                         if (! -d dirname($fulldest)) {
79                                 doit("install","-d","-m755",$tmpdir."/".dirname($dest));
80                         }
81
82                         doit("install","-p","-m644",$source,$fulldest);
83         
84                         push(@sgmlinstalled,$dest);
85                 }
86         }
87         if (@sgmlinstalled) {
88                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
89
90                 if (! -d "$tmpdir/etc/sgml") {
91                         doit("install","-d","-m755","$tmpdir/etc/sgml");
92                 }
93
94                 if (! $dh{NOSCRIPTS}) {
95                         my $ordcats = join(" ", @sgmlinstalled);
96                         my $centralcat = "/etc/sgml/$package.cat";
97                         autoscript($package, "postinst", "postinst-sgmlcatalog",
98                                    "s%#CENTRALCAT#%$centralcat%g; s%#ORDCATS#%$ordcats%g;");
99                         autoscript($package, "prerm", "prerm-sgmlcatalog",
100                                    "s%#CENTRALCAT#%$centralcat%g;");
101                         autoscript($package, "postrm", "postrm-sgmlcatalog",
102                                    "s%#CENTRALCAT#%$centralcat%g;");
103                 }
104         }
105         else {
106                 # remove the dependency
107                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
108         }
109 }
110
111 =head1 SEE ALSO
112
113 L<debhelper(7)>
114
115 F</usr/share/doc/sgml-base-doc/>
116
117 =head1 AUTHOR
118
119 Adam Di Carlo <aph@debian.org>
120
121 =cut