5 dh_installcatalogs - install and register SGML Catalogs
10 use Debian::Debhelper::Dh_Lib;
12 my $sgmlbasever = "1.26+nmu2";
16 B<dh_installcatalogs> [S<I<debhelper options>>] [B<-n>]
20 B<dh_installcatalogs> is a debhelper program that installs and
21 registers SGML catalogs. It complies with the Debian XML/SGML policy.
23 Catalogs will be registered in a supercatalog, in
24 F</etc/sgml/I<package>.cat>.
26 This command automatically adds maintainer script snippets for
27 registering and unregistering the catalogs and supercatalogs (unless
28 B<-n> is used). These snippets are inserted into the maintainer scripts
29 by B<dh_installdeb>; see L<dh_installdeb(1)> for an explanation of
30 Debhelper maintainer script snippets.
32 A dependency on B<sgml-base> will be added to B<${misc:Depends}>, so be
33 sure your package uses that variable in F<debian/control>.
39 =item debian/I<package>.sgmlcatalogs
41 Lists the catalogs to be installed per package. Each line in that file
42 should be of the form C<I<source> I<dest>>, where I<source> indicates where the
43 catalog resides in the source tree, and I<dest> indicates the destination
44 location for the catalog under the package build area. I<dest> should
45 start with F</usr/share/sgml/>.
53 =item B<-n>, B<--noscripts>
55 Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
61 Note that this command is not idempotent. L<dh_prep(1)> should be
62 called between invocations of this command. Otherwise, it may cause
63 multiple instances of the same text to be added to maintainer scripts.
69 foreach my $package (@{$dh{DOPACKAGES}}) {
70 my $tmpdir = tmpdir($package);
71 my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs");
72 my @sgmlinstalled; # catalogs we've installed
74 error("extra command-line arguments");
76 if ($sgmlcatlistfile) {
77 foreach my $line (filedoublearray($sgmlcatlistfile)) {
78 my $source = $line->[0];
79 my $dest = $line->[1];
80 my $fulldest = "$tmpdir/$dest";
81 $fulldest =~ s|//|/|g; # beautification
83 if (! -d dirname($fulldest)) {
84 doit("install","-d","-m755",$tmpdir."/".dirname($dest));
87 doit("install","-p","-m644",$source,$fulldest);
89 push(@sgmlinstalled,$dest);
93 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
95 if (! -d "$tmpdir/etc/sgml") {
96 doit("install","-d","-m755","$tmpdir/etc/sgml");
99 my $centralcat = "/etc/sgml/$package.cat";
101 open(CENTRALCAT, ">", "$tmpdir$centralcat") || error("failed to write to $tmpdir$centralcat");
102 foreach my $sgmldest (@sgmlinstalled) {
103 print CENTRALCAT "CATALOG " . $sgmldest . "\n";
107 if (! $dh{NOSCRIPTS}) {
108 autoscript($package, "preinst", "preinst-sgmlcatalog",
109 "s%#CENTRALCAT#%$centralcat%g;");
110 autoscript($package, "postrm", "postrm-sgmlcatalog",
111 "s%#CENTRALCAT#%$centralcat%g;");
115 # remove the dependency
116 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
124 F</usr/share/doc/sgml-base-doc/>
128 Adam Di Carlo <aph@debian.org>