On Sun, Sep 28, 2003 at 10:06:24AM +0200, Joey Hess wrote: > Marc Haber wrote: > > ucf is a great utility to ease conffile handling where dpkg's default > > handling does not satisfy. Its use is quite easy, and the required > > changes to postinst and postrm could be made automatically. > > > > dh_ucf should > > > > (1) read a file debian/[package.]ucffiles containing pairs of NewFile > > and Destination > > (2) add the required calls to ucf to postinst and postrm > > (3) generate a dependency on ucf for conffile generation > > > > Please consider adding that feature to debhelper. > > That's a great idea! I am a little bit concerned about interactions > between ucf and debconf. It's a pity nobody has added a debconf UI to > it yet.
I believe the interactions between ucf and debconf were fixed in 2004
(by you)?
Here is a patch against the master branch that adds such a command
called dh_installucf. It also registers the conffiles with ucfr and
removes stray ucf-{new,old,dist} files on purge.
Regards,
Jeroen Schot
---
autoscripts/postinst-ucf | 4 ++
autoscripts/postrm-ucf | 12 ++++++
dh_installucf | 92 ++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 108 insertions(+), 0 deletions(-)
create mode 100644 autoscripts/postinst-ucf
create mode 100644 autoscripts/postrm-ucf
create mode 100755 dh_installucf
diff --git a/autoscripts/postinst-ucf b/autoscripts/postinst-ucf
new file mode 100644
index 0000000..633d3ff
--- /dev/null
+++ b/autoscripts/postinst-ucf
@@ -0,0 +1,4 @@
+if [ "$1" = "configure" ]; then
+ ucf #UCFSRC# #UCFDEST#
+ ucfr #PACKAGE# #UCFDEST#
+fi
diff --git a/autoscripts/postrm-ucf b/autoscripts/postrm-ucf
new file mode 100644
index 0000000..47237a4
--- /dev/null
+++ b/autoscripts/postrm-ucf
@@ -0,0 +1,12 @@
+if [ "$1" = "purge" ]; then
+ for ext in .ucf-new .ucf-old .ucf-dist ""; do
+ rm -f #UCFDEST#$ext
+ done
+
+ if [ -x `which ucf 2>/dev/null`]; then
+ ucf --purge #UCFDEST#
+ fi
+ if [ -x `which ucfr 2>/dev/null`]; then
+ ucfr --purge #PACKAGE# #UCFDEST#
+ fi
+fi
diff --git a/dh_installucf b/dh_installucf
new file mode 100755
index 0000000..caba6e8
--- /dev/null
+++ b/dh_installucf
@@ -0,0 +1,92 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_installucf - register configuration files with ucf
+
+=cut
+
+use strict;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_installucf> [S<I<debhelper options>>] [B<-n>] [S<i<source destination>
...>]
+
+=head1 DESCRIPTION
+
+B<dh_installucf> 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.
+
+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();
+
+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 <[email protected]>
+Jeroen Schot <[email protected]>
+
+=cut
--
signature.asc
Description: Digital signature

