]> git.donarmstrong.com Git - debhelper.git/blobdiff - dh_installcatalogs
r572: * Added dh_installcatalogs, for sgml (and later xml) catalogs. By
[debhelper.git] / dh_installcatalogs
diff --git a/dh_installcatalogs b/dh_installcatalogs
new file mode 100755 (executable)
index 0000000..16bab81
--- /dev/null
@@ -0,0 +1,115 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_installcatalog - install and register SGML Catalogs
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+my $sgmlbasever = "1.17";
+
+=head1 SYNOPSIS
+
+B<dh_installcatalog> [S<I<debhelper options>>] [B<-n>]
+
+=head1 DESCRIPTION
+
+dh_registersgmlcatalog is a debhelper program that installs and
+registers SGML catalogs. (Note: it will be extended for XML catalog
+registration when xml-core is available.)  It complies with the Debian
+XML/SGML policy.
+
+The file F<debian/I<package>.sgmlcatalogs> contains the catalogs to be
+installed per package.  Each line in that file should be of the form
+C<source dest>, where C<source> indicates where the catalog resides in
+the source tree, and C<dest> indicates the destination location for
+the catalog under the package build area.  C<dest> should start with
+F</usr/share/sgml/>.
+
+Catalogs will be registered in a supercatalog, in
+F</etc/sgml/I<package>.cat>.
+
+This script automatically adds maintainer script snippets for
+registering and unregistering the catalogs and "supercatalogs" (unless
+B<-n> is used).  A dependancy on B<sgml-base> will be added to
+C<${misc:Depends}>, so be sure your package uses that variable in
+F<debian/control>.  See L<dh_installdeb(1)> for an explantion of
+Debhelper maintainer script snippets.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-n>, B<--noscripts>
+
+Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
+
+=back
+
+=head1 NOTES
+
+Note that this command is not idempotent. "dh_clean -k" should be
+called between invocations of this command. Otherwise, it may cause
+multiple instances of the same text to be added to maintainer scripts.
+
+=cut
+
+init();
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+       my $tmpdir = tmpdir($package);
+       my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs");
+       my @sgmlinstalled; # catalogs we've installed
+       if ($#ARGV >= 0) {
+               error("extra command-line arguments");
+       }
+       if ($sgmlcatlistfile) {
+               foreach my $line (filedoublearray($sgmlcatlistfile)) {
+                       my $source = $line->[0];
+                       my $dest = $line->[1];
+                       my $fulldest = "$tmpdir/$dest"; 
+                       $fulldest =~ s|//|/|g; # beautification
+       
+                       if (! -d dirname($fulldest)) {
+                               doit("install","-d","-m755",dirname($dest));
+                       }
+
+                       doit("install","-p","-m644",$source,$fulldest);
+       
+                       push(@sgmlinstalled,$dest);
+               }
+       }
+       if (@sgmlinstalled) {
+               addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
+
+               if (! $dh{NOSCRIPTS}) {
+                       my $ordcats = join(" ", @sgmlinstalled);
+                       my $centralcat = "/etc/sgml/$package.cat";
+                       autoscript($package, "postinst", "postinst-sgmlcatalog",
+                                  "s%#CENTRALCAT#%$centralcat%g; s%#ORDCATS#%$ordcats%g;");
+                       autoscript($package, "prerm", "prerm-sgmlcatalog",
+                                  "s%#CENTRALCAT#%$centralcat%g;");
+                       autoscript($package, "postrm", "postrm-sgmlcatalog",
+                                  "s%#CENTRALCAT#%$centralcat%g;");
+               }
+       }
+       else {
+               # remove the dependency
+               addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
+       }
+}
+
+=head1 SEE ALSO
+
+L<debhelper(1)>
+
+F</usr/share/doc/sgml-base-doc/>
+
+=head1 AUTHOR
+
+Adam Di Carlo <aph@debian.org>
+
+=cut