summaryrefslogtreecommitdiff
path: root/dh_ucf
blob: 811bd209611a1d6f0e90c8508ed4a25713894408 (plain)
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
#!/usr/bin/perl -w

=head1 NAME

dh_ucf - register configuration files with ucf 

=cut

use strict;
use Debian::Debhelper::Dh_Lib;

=head1 SYNOPSIS

B<dh_ucf> [S<I<debhelper options>>] [B<-n>]

=head1 DESCRIPTION

B<dh_ucf> is a debhelper program that is responsible for generating the
F<postinst> and F<postrm> commands that register files with ucf(1) and ucfr(1).

=head1 FILES

=over 4

=item debian/I<package>.ucf

List pairs of source and destination files to register with ucf. Each pair
should be put on its own line, with the source and destination separated by
whitespace. Both source and destination must be absolute paths. The source
should be a file that is provided by your package, typically in /usr/share/,
while the destination is typically a file in /etc/.

A dependency on ucf will be generated in B<${misc:Depends}>.

=back

=head1 OPTIONS

=over 4

=item B<-n>, B<--noscripts>

Do not modify F<postinst>/F<postrm> scripts. Turns this command into a no-op.

=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 ucf

foreach my $package (@{$dh{DOPACKAGES}}) {
	my $tmp=tmpdir($package);
	my $file=pkgfile($package,"ucf");

	my @ucf;
	if ($file) {
		@ucf=filedoublearray($file);
	}

	if (($package eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) {
		push @ucf, [@ARGV];
	}
	
	if (! $dh{NOSCRIPTS}) {
		if (@ucf) {
			addsubstvar($package, "misc:Depends", "ucf");
		}
		foreach my $set (@ucf) {
			my $src = $set->[0];
			my $dest = $set->[1];
			autoscript($package,"postinst","postinst-ucf","s:#UCFSRC#:$src:;s:#UCFDEST#:$dest:;s/#PACKAGE#/$package/",);
			autoscript($package,"postrm","postrm-ucf","s:#UCFDEST#:$dest:;s/#PACKAGE#/$package/");
		}
	}
}

=head1 SEE ALSO

L<debhelper(7)>

This program is a part of debhelper.

=head1 AUTHOR

Joey Hess <joeyh@debian.org>
Jeroen Schot <schot@a-eskwadraat.nl>

=cut

# Local Variables:
# indent-tabs-mode: t
# tab-width: 4
# cperl-indent-level: 4
# End: