Skip to content

Commit cbd430a

Browse files
jdreedgeofft
authored andcommitted
Add documentation to dh_configpackage.
[geofft@mit.edu: Rename divert/remove to displace/hide, and mention what happens if transform scripts fail]
1 parent 170acc6 commit cbd430a

1 file changed

Lines changed: 159 additions & 5 deletions

File tree

dh_configpackage

Lines changed: 159 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,164 @@ use Dpkg::Path qw(get_control_path);
3434

3535
=head1 SYNOPSIS
3636

37-
B<dh_configpackage> [S<I<debhelper options>>] [B<-n>]
37+
B<dh_configpackage> [B<--displace> I<path>] [B<--hide> I<path>] [B<--undisplace> I<path>] [B<--unhide> I<file>] [B<--transform> I<transformation>] [S<I<debhelper options>>] [B<-n>]
3838

3939
=head1 DESCRIPTION
4040

41-
B<dh_configpackage> needs more docs.
41+
B<dh_configpackage> is a debhelper program to create "configuration
42+
packages". These packages provide an ideal way to distribute
43+
configurations to target systems while still affording local system
44+
administrators a degree of control over their workstations. The
45+
motivation and philosophy behind this style of packaging is described
46+
in detail on the config-package-dev website. Configuration packages
47+
make use of dpkg diversions and maintainer script snippets to provide
48+
three primary operations: displacing, hiding, and transforming files.
49+
50+
The I<displace> operation consists of replacing a file on the target
51+
system. The original file is renamed out of the way and diverted in the
52+
dpkg database. The replacement file is then installed by the package,
53+
and the config-package-dev maintainer script snippets create a symlink
54+
from the original name. A common use of this is to install a wrapper
55+
script for an executable.
56+
57+
The I<transform> operation is a special case of the displace operation.
58+
At build time, a "transform script" is applied to the original source,
59+
and the result is used as the replacement in the displace operation. A
60+
common use of this is to change one value in a config file without
61+
needing to re-type the entire config file (and risk bit-rot).
62+
63+
The I<hide> operation is yet another special case of the displace
64+
operation, namely that there is no replacement or symlink. Instead, the
65+
file is diverted to a unique path on the target system, thus preserving
66+
its contents. A common use of this is to suppress a snippet file in a
67+
configuration directory (e.g. /etc/foo.d), thus disabling a specific
68+
operation or configuration.
69+
70+
The I<displace extension> is a suffix appended to the diverted versions
71+
of files, and this suffix plus the string "-orig" is appended to the
72+
original versions of the files. The default value is the first word of
73+
the package name. For example, the extension for debathena-bin-example
74+
would be ".debathena". So if debathena-bin-example displaced /bin/true,
75+
the original /bin/true would be found at /bin/true.debathena-orig and
76+
the new version (installed by e.g. dh_install) found at
77+
/bin/true.debathena. /bin/true itself would become a symbolic link.
78+
(For the remainder of this documentation, ".debathena" will be used as
79+
the displace extension.)
80+
81+
=head1 FILES
82+
83+
=over 4
84+
85+
=item debian/I<package>.displace
86+
87+
List the files to displace, one per line, including the full path and
88+
displace extension. For example, to displace /usr/bin/true to
89+
/usr/bin/true.debathena, you would list "/usr/bin/true.debathena" in
90+
the file. (As with other Debhelper commands, you can omit the initial
91+
leading slash in pathnames in the package, but these examples retain
92+
it.)
93+
94+
=item debian/I<package>.hide
95+
96+
List the files to hide, one per line, including the full path and
97+
displace extension. As noted above, these files won't actually be
98+
removed, but merely diverted and renamed to a unique path below
99+
/usr/share/I<package>.
100+
101+
=item debian/I<package>.undisplace
102+
103+
List the files to undisplace, one per line, including the full path and
104+
displace extension. B<NOTE:> This is only needed when a new version of
105+
the package no longer needs to displace a file (for example, if an
106+
upstream bug was fixed). Packages automatically undo all operations
107+
upon removal or deconfiguration.
108+
109+
=item debian/I<package>.unhide
110+
111+
List the files to unhide, one per line, including the full path
112+
and displace extension. B<NOTE:> As with undisplace, this is only needed
113+
when a new version of the package no longer needs to hide a file.
114+
115+
=item debian/I<package>.transform
116+
117+
Each line in the file specifies a transformation. A transformation
118+
consists of two space-separated fields: the full path of the
119+
target file including the displace extension and the transformation
120+
command itself. The transformation can either be a single shell
121+
command, or an executable file in the debian directory. The
122+
transformation takes the original source of the file on stdin and prints
123+
its transformation on stdout. Transformations are typically performed
124+
by perl, sed, or awk, but there is no limitation on what can be used as
125+
a transformation.
126+
127+
For example, to transform /etc/school.conf by replacing all
128+
occurrences of the word 'Harvard' with the word 'MIT', you might
129+
specify the following line:
130+
131+
/etc/school.conf.debathena sed -e 's/Harvard/MIT/g'
132+
133+
Or, storing the command in a separate script:
134+
135+
/etc/school.conf.debathena debian/transform_school.conf.pl
136+
137+
If the transformation script fails, the package build fails. You can use
138+
this with e.g. Perl's C<or die> syntax to make sure that the source
139+
file of the transformation has not changed from what you expected.
140+
141+
I<Transformation sources>: Under normal operation, the source (passed
142+
on stdin) for the transformation is the name of the diversion without
143+
the divert extension. In some cases, you may wish to use a different
144+
source (e.g. a sample configuration file in /usr/share/doc). You can
145+
specify this source as an optional field between the diversion
146+
filename and the transformation. This field must begin with a '<'
147+
immediately followed by the full path to the source. Taking the
148+
example above, we might alter it as follows:
149+
150+
/etc/school.conf.debathena </usr/share/doc/school/conf.example sed -e 's/Harvard/MIT/g'
151+
152+
B<NOTE:> There is no "untransform" operation. Because a transform
153+
operation is a special case of a displace operation, the "undisplace"
154+
operation is the correct way of removing a no-longer-needed
155+
transformation in future versions of the package.
156+
157+
=item debian/I<package>.displace-extension
158+
159+
This file is used to specify the displace extension for any files
160+
diverted by this package, if you do not want to accept the default of
161+
the first word in the package name. It will not normally be present.
162+
(See L<"CAVEATS">.)
163+
164+
=back
42165

43166
=head1 OPTIONS
44167

45168
=over 4
46169

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

49-
Do not modify maintainer scripts.
172+
Do not modify maintainer scripts. This is a standard debhelper
173+
option, though you are strongly discouraged from using it except for
174+
debugging, as these operations rely heavily on the maintainer scripts.
175+
176+
=item B<--displace> I<path>
177+
178+
=item B<--hide> I<path>
179+
180+
=item B<--undisplace> I<path>
181+
182+
=item B<--unhide> I<path>
183+
184+
=item B<--transform> I<transformation>
185+
186+
These options allow for specifying an operation on the command line.
187+
The argument to the option is the same as a single line of the
188+
corresponding file, as described above. You may specify multiple
189+
occurrences of B<--displace>, or you may invoke B<dh_configpackage>
190+
repeatedly with different invocations. The most common use of this
191+
format is in a rules file when performing conditional operations, in an
192+
C<override_dh_configpackage> target in the C<rules> file. See the
193+
debathena-conffile-example-1.1 package in
194+
/usr/share/doc/config-package-dev/EXAMPLES for one such use.
50195

51196
=back
52197

@@ -279,16 +424,25 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
279424
}
280425
}
281426

427+
=head1 CAVEATS
428+
429+
Because the displace extension is automatically generated from the
430+
package name, renaming the package can have unintended consequences.
431+
If you must rename a package such that the first component of the name
432+
changes, specify the old extension using the C<displace-extension> file
433+
(see above).
434+
282435
=head1 SEE ALSO
283436

284-
L<debhelper(7)>
437+
L<debhelper(7)>, L<The config-package-dev
438+
homepage|http://debathena.mit.edu/config-package-dev>
285439

286440
This program is a part of config-package-dev.
287441

288442
=head1 AUTHOR
289443

290444
config-package-dev was written by Anders Kaseorg <andersk@mit.edu> and
291445
Tim Abbott <tabbott@mit.edu>. The debhelper port is by Geoffrey Thomas
292-
<geofft@mit.edu>.
446+
<geofft@mit.edu>. Documentation by Jonathan Reed <jdreed@mit.edu>.
293447

294448
=cut

0 commit comments

Comments
 (0)