[libconfig-model-perl] 05/09: added cme-postinst and cme-purge option

dod at debian.org dod at debian.org
Fri Jan 17 18:03:50 UTC 2014


This is an automated email from the git hooks/post-receive script.

dod pushed a commit to branch master
in repository libconfig-model-perl.

commit dec8c19ddb1afe02ebc67331fe6f59f53effc38b
Author: Dominique Dumont <dod at debian.org>
Date:   Thu Jan 2 19:44:21 2014 +0100

    added cme-postinst and cme-purge option
---
 debian/dh/cme_upgrade.pm            |  2 +-
 debian/dh/dh_cme_upgrade            | 28 ++++++++++++++++++++++++++--
 debian/dh/postrm-cme                |  7 +++++++
 debian/libconfig-model-perl.install |  1 +
 4 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/debian/dh/cme_upgrade.pm b/debian/dh/cme_upgrade.pm
index 044decf..fab551b 100644
--- a/debian/dh/cme_upgrade.pm
+++ b/debian/dh/cme_upgrade.pm
@@ -10,8 +10,8 @@ use strict;
 use Debian::Debhelper::Dh_Lib;
 
 # see /usr/share/doc/debhelper/PROGRAMMING.gz
-insert_before("dh_install", "dh_cme_upgrade");
 insert_before("dh_install","dh_install_debconf") ;
+insert_after("dh_install_debconf", "dh_cme_upgrade");
 
 
 1;
diff --git a/debian/dh/dh_cme_upgrade b/debian/dh/dh_cme_upgrade
index 764e413..3a5f0d5 100644
--- a/debian/dh/dh_cme_upgrade
+++ b/debian/dh/dh_cme_upgrade
@@ -48,7 +48,7 @@ unless (@do_packages) {
 }
 
 my @mandatory  = qw/cme-app-name cme-model-package/;
-my @legal_list = ( @mandatory, qw/cme-model-version cme-options/ );
+my @legal_list = ( @mandatory, qw/cme-model-version cme-options cme-purge/ );
 my %legal      = map { ( $_ => 1 ) } @legal_list;
 
 # debian/config file: foo.config-model
@@ -91,11 +91,13 @@ foreach my $package (@do_packages) {
 
     addsubstvar( $package, 'misc:Depends', $dep );
 
+    my $purge = $cm_config{'cme-purge'};
     my $munge_sub = sub {
         s/%APPNAME%/$cm_config{'cme-app-name'}/g;
         s/%PACKAGE%/$package/g;
         no warnings 'uninitialized';
         s/%OPTION%/$cm_config{'cme-options'}/g;
+        s/%PURGE%/$purge/g;
     };
 
     # calls autoscript to update pkg.postinst with cme command
@@ -103,6 +105,13 @@ foreach my $package (@do_packages) {
     autoscript( $package, postinst  => 'postinst-cme',      $munge_sub );
     autoscript( $package, config    => 'config-script-cme', $munge_sub );
 
+    if ($purge) {
+        die "Error: cme-purge is not safe ('$purge'). Expected something like /etc/foo"
+            unless $purge =~ m!^/etc/\w+!;
+        autoscript( $package, postrm  => 'postrm-cme', $munge_sub );
+
+    }
+
     autotemplate( $package, 'template-cme',      $munge_sub );
 
 }
@@ -177,12 +186,20 @@ For this program to work, package maintainer must make sure that:
 
 =item *
 
-C<*.postinst> and C<*.config> have a C<#DEBHELPER#>  line (if these files exist)
+C<*.postinst>, C<*.postrm> and C<*.config> have a C<#DEBHELPER#>  line (if these files exist)
 
 =item *
 
 C<control> file has a dependency on C<${misc:Depends}>
 
+=item *
+
+Configuration files upgraded by C<cme> must not be conffiles. Any
+default configuration file provided by upstream must not be installed
+directly in C</etc>. They should be installed in C</usr/share/doc/> for
+reference. C<cme> will create a default configuration file during package
+installation.
+
 =back
 
 =head1 OPTIONS
@@ -226,6 +243,12 @@ Specifies the minimal version of the package that provides the model.
 Specify a list of options or command that will be passed verbatim to
 L<cme> during upgrade. (optional)
 
+=item cme-purge
+
+Specify the configuration files or directory to be removed when purging the package. E.g
+C</etc/LCDd.conf*> or C</etc/java/>. Several files or directory can be purged by using a shell glob.
+If this option is empty, configuration files handled by cme will be left as-is after a purge.
+
 =back
 
 =head1 Examples
@@ -245,6 +268,7 @@ For lcdproc:
  cme-model-version: 2.040
  # required to upgrade LCDd.conf from upstream configuration
  cme-options: -force
+ cme-purge: /etc/LCDd.conf*
 
 For Popcon:
 
diff --git a/debian/dh/postrm-cme b/debian/dh/postrm-cme
new file mode 100644
index 0000000..a5b1798
--- /dev/null
+++ b/debian/dh/postrm-cme
@@ -0,0 +1,7 @@
+# Purge configuration files handled by cme
+
+if [ "$1" = purge ]
+then
+    echo "Purging cme files: '%PURGE%'"
+    rm -rf "%PURGE%"
+fi
diff --git a/debian/libconfig-model-perl.install b/debian/libconfig-model-perl.install
index 6a12bfc..a64a6a2 100644
--- a/debian/libconfig-model-perl.install
+++ b/debian/libconfig-model-perl.install
@@ -1,4 +1,5 @@
 debian/dh/cme_upgrade.pm            usr/share/perl5/Debian/Debhelper/Sequence/
 debian/dh/template-cme              usr/share/debhelper/autoscripts/
 debian/dh/postinst-cme              usr/share/debhelper/autoscripts/
+debian/dh/postrm-cme                usr/share/debhelper/autoscripts/
 debian/dh/config-script-cme         usr/share/debhelper/autoscripts/

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libconfig-model-perl.git



More information about the Pkg-perl-cvs-commits mailing list