]> git.donarmstrong.com Git - debhelper.git/blob - dh_installcatalogs
Updated French man page translation. Closes: #685560
[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.26+nmu2";
13
14 =head1 SYNOPSIS
15
16 B<dh_installcatalogs> [S<I<debhelper options>>] [B<-n>]
17
18 =head1 DESCRIPTION
19
20 B<dh_installcatalogs> is a debhelper program that installs and
21 registers SGML catalogs. It complies with the Debian XML/SGML policy.
22
23 Catalogs will be registered in a supercatalog, in
24 F</etc/sgml/I<package>.cat>.
25
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.
31
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>.
34
35 =head1 FILES
36
37 =over 4
38
39 =item debian/I<package>.sgmlcatalogs
40
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/>.
46
47 =back
48
49 =head1 OPTIONS
50
51 =over 4
52
53 =item B<-n>, B<--noscripts>
54
55 Do not modify F<postinst>/F<postrm>/F<prerm> scripts.
56
57 =back
58
59 =head1 NOTES
60
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.
64
65 =cut
66
67 init();
68
69 foreach my $package (@{$dh{DOPACKAGES}}) {
70         my $tmpdir = tmpdir($package);
71         my $sgmlcatlistfile = pkgfile($package, "sgmlcatalogs");
72         my @sgmlinstalled; # catalogs we've installed
73         if ($#ARGV >= 0) {
74                 error("extra command-line arguments");
75         }
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
82         
83                         if (! -d dirname($fulldest)) {
84                                 doit("install","-d","-m755",$tmpdir."/".dirname($dest));
85                         }
86
87                         doit("install","-p","-m644",$source,$fulldest);
88         
89                         push(@sgmlinstalled,$dest);
90                 }
91         }
92         if (@sgmlinstalled) {
93                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
94
95                 if (! -d "$tmpdir/etc/sgml") {
96                         doit("install","-d","-m755","$tmpdir/etc/sgml");
97                 }
98
99                 my $centralcat = "/etc/sgml/$package.cat";
100
101                 open(CENTRALCAT, ">", "$tmpdir$centralcat") || error("failed to write to $tmpdir$centralcat");
102                 foreach my $sgmldest (@sgmlinstalled) {
103                         print CENTRALCAT "CATALOG " . $sgmldest . "\n";
104                 }
105                 close CENTRALCAT;
106
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;");
112                 }
113         }
114         else {
115                 # remove the dependency
116                 addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
117         }
118 }
119
120 =head1 SEE ALSO
121
122 L<debhelper(7)>
123
124 F</usr/share/doc/sgml-base-doc/>
125
126 =head1 AUTHOR
127
128 Adam Di Carlo <aph@debian.org>
129
130 =cut