-
Notifications
You must be signed in to change notification settings - Fork 0
/
dh_installcatalogs
executable file
·138 lines (95 loc) · 3.33 KB
/
dh_installcatalogs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/perl
=head1 NAME
dh_installcatalogs - install and register SGML Catalogs
=cut
use strict;
use warnings;
use Debian::Debhelper::Dh_Lib;
our $VERSION = DH_BUILTIN_VERSION;
my $sgmlbasever = "1.28";
=head1 SYNOPSIS
B<dh_installcatalogs> [S<I<debhelper options>>] [B<-n>]
=head1 DESCRIPTION
B<dh_installcatalogs> is a debhelper program that installs and
registers SGML catalogs. It complies with the Debian XML/SGML policy.
Catalogs will be registered in a supercatalog, in
F</etc/sgml/I<package>.cat>.
This command automatically adds maintainer script snippets for
registering and unregistering the catalogs and supercatalogs (unless
B<-n> is used). These snippets are inserted into the maintainer
scripts and the B<triggers> file by B<dh_installdeb>; see
L<dh_installdeb(1)> for an explanation of Debhelper maintainer script
snippets.
A dependency on B<sgml-base> will be added to B<${misc:Depends}>, so be
sure your package uses that variable in F<debian/control>.
=head1 FILES
=over 4
=item debian/I<package>.sgmlcatalogs
Lists the catalogs to be installed per package. Each line in that file
should be of the form C<I<source> I<dest>>, where I<source> indicates where the
catalog resides in the source tree, and I<dest> indicates the destination
location for the catalog under the package build area. I<dest> should
start with F</usr/share/sgml/>.
Supports substitution variables in compat 13 and later as
documented in L<debhelper(7)>.
=back
=head1 OPTIONS
=over 4
=item B<-n>, B<--no-scripts>
Do not modify F<postinst>/F<postrm>/F<prerm> scripts nor add an
activation trigger.
=back
=head1 NOTES
Note that this command is not idempotent. L<dh_prep(1)> 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();
# PROMISE: DH NOOP WITHOUT sgmlcatalogs cli-options()
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)) {
# Ensure the parent exist
install_dir($tmpdir."/".dirname($dest));
}
install_file($source,$fulldest);
push(@sgmlinstalled,$dest);
}
}
if (@sgmlinstalled) {
addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever");
install_dir("$tmpdir/etc/sgml");
my $centralcat = "/etc/sgml/$package.cat";
open(my $fd, ">", "$tmpdir$centralcat") || error("failed to write to $tmpdir$centralcat");
foreach my $sgmldest (@sgmlinstalled) {
print {$fd} "CATALOG " . $sgmldest . "\n";
}
close($fd) or error("close $tmpdir$centralcat: $!");
if (! $dh{NOSCRIPTS}) {
autotrigger($package, "activate-await", "update-sgmlcatalog");
autoscript($package, "postrm", "postrm-sgmlcatalog",
{ 'CENTRALCAT' => $centralcat });
}
}
else {
# remove the dependency
addsubstvar($package, "misc:Depends", "sgml-base", ">= $sgmlbasever", 1);
}
}
=head1 SEE ALSO
L<debhelper(7)>
F</usr/share/doc/sgml-base-doc/>
=head1 AUTHOR
Adam Di Carlo <[email protected]>
=cut