[pkg-bacula-commits] [bacula] 02/04: Added script "autopostrm" to autogenerate most postrm scripts to reduce code duplication.

Carsten Leonhardt leo at moszumanska.debian.org
Wed Sep 7 14:28:13 UTC 2016


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

leo pushed a commit to branch migrate-files
in repository bacula.

commit 9fbdd12f6224e5705ff367fe56b1b534c9ee5590
Author: Carsten Leonhardt <leo at debian.org>
Date:   Wed Sep 7 15:57:21 2016 +0200

    Added script "autopostrm" to autogenerate most postrm scripts to
    reduce code duplication.
    
    Files named debian/<package>.autopostrm contain variables with
    filenames that should be deleted and/or purged in ucf during the purge
    of that package.
---
 debian/bacula-console-qt.autopostrm                |  2 +
 debian/bacula-console.autopostrm                   |  2 +
 debian/bacula-console.postrm                       | 67 ---------------------
 debian/bacula-director.autopostrm                  |  3 +
 debian/bacula-director.postrm                      | 70 ----------------------
 debian/bacula-fd.autopostrm                        |  3 +
 debian/bacula-fd.postrm                            | 70 ----------------------
 debian/bacula-sd.autopostrm                        |  3 +
 debian/bacula-sd.postrm                            | 70 ----------------------
 debian/changelog                                   |  2 +
 debian/rules                                       |  4 +-
 debian/scripts/autopostrm                          | 59 ++++++++++++++++++
 debian/scripts/libpostrm.inc.sh                    | 40 -------------
 .../template.postrm}                               | 19 +++---
 14 files changed, 87 insertions(+), 327 deletions(-)

diff --git a/debian/bacula-console-qt.autopostrm b/debian/bacula-console-qt.autopostrm
new file mode 100644
index 0000000..134ffec
--- /dev/null
+++ b/debian/bacula-console-qt.autopostrm
@@ -0,0 +1,2 @@
+# this file is handled by debian/scripts/autopostrm
+CONFFILES=/etc/bacula/bat.conf
diff --git a/debian/bacula-console.autopostrm b/debian/bacula-console.autopostrm
new file mode 100644
index 0000000..6c21458
--- /dev/null
+++ b/debian/bacula-console.autopostrm
@@ -0,0 +1,2 @@
+# this file is handled by debian/scripts/autopostrm
+CONFFILES=/etc/bacula/bconsole.conf
diff --git a/debian/bacula-console.postrm b/debian/bacula-console.postrm
deleted file mode 100644
index a1d7a97..0000000
--- a/debian/bacula-console.postrm
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-
-set -e
-
-CONFFILE=/etc/bacula/bconsole.conf
-
-# start of libpostrm.inc.sh
-#
-# helper functions to purge conffiles
-# with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
-
-# delete a list of files, also with known backup extensions
-purge_conf() {
-    local file ext
-
-    for file in $@; do
-	rm -f $file
-	for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist .dist; do
-	    rm -f $file$ext
-	done
-    done
-}
-
-# unregister a list of conffiles from ucf after deleting them
-# usage: purge_ucf_conf <packagename> <conffile ...>
-purge_ucf_conf() {
-    local package file
-
-    # save package name
-    package=$1
-    # remove first argument from list
-    shift
-
-    purge_conf $@
-    if [ -x `which ucf` ]; then
-	for file in $@; do
-	    ucf --purge $file
-	    ucfr --purge $package $file
-	done
-    fi
-}
-# end of libpostrm.inc.sh
-
-case "$1" in
-    purge)
-	purge_conf $CONFFILE
-	;;
-
-    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-	;;
-
-    *)
-	echo "postrm called with unknown argument \`$1'" >&2
-	exit 1
-	;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/bacula-director.autopostrm b/debian/bacula-director.autopostrm
new file mode 100644
index 0000000..96861de
--- /dev/null
+++ b/debian/bacula-director.autopostrm
@@ -0,0 +1,3 @@
+# this file is handled by debian/scripts/autopostrm
+CONFFILES=/etc/bacula/bacula-dir.conf
+UCF_CONFFILES="/etc/bacula/scripts/delete_catalog_backup /etc/default/bacula-dir"
diff --git a/debian/bacula-director.postrm b/debian/bacula-director.postrm
deleted file mode 100644
index cc1ec81..0000000
--- a/debian/bacula-director.postrm
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-set -e
-
-PACKAGE=bacula-director
-CONFFILE=/etc/bacula/bacula-dir.conf
-UCF_CONFFILES="/etc/bacula/scripts/delete_catalog_backup /etc/default/bacula-dir"
-
-# start of libpostrm.inc.sh
-#
-# helper functions to purge conffiles
-# with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
-
-# delete a list of files, also with known backup extensions
-purge_conf() {
-    local file ext
-
-    for file in $@; do
-	rm -f $file
-	for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist .dist; do
-	    rm -f $file$ext
-	done
-    done
-}
-
-# unregister a list of conffiles from ucf after deleting them
-# usage: purge_ucf_conf <packagename> <conffile ...>
-purge_ucf_conf() {
-    local package file
-
-    # save package name
-    package=$1
-    # remove first argument from list
-    shift
-
-    purge_conf $@
-    if [ -x `which ucf` ]; then
-	for file in $@; do
-	    ucf --purge $file
-	    ucfr --purge $package $file
-	done
-    fi
-}
-# end of libpostrm.inc.sh
-
-case "$1" in
-    purge)
-	purge_conf $CONFFILE
-	purge_ucf_conf $PACKAGE $UCF_CONFFILES
-	;;
-
-    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-	;;
-
-    *)
-	echo "postrm called with unknown argument \`$1'" >&2
-	exit 1
-	;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/bacula-fd.autopostrm b/debian/bacula-fd.autopostrm
new file mode 100644
index 0000000..440dbea
--- /dev/null
+++ b/debian/bacula-fd.autopostrm
@@ -0,0 +1,3 @@
+# this file is handled by debian/scripts/autopostrm
+CONFFILES=/etc/bacula/bacula-fd.conf
+UCF_CONFFILES=/etc/default/bacula-fd
diff --git a/debian/bacula-fd.postrm b/debian/bacula-fd.postrm
deleted file mode 100644
index a7b8df4..0000000
--- a/debian/bacula-fd.postrm
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-set -e
-
-PACKAGE=bacula-fd
-CONFFILE=/etc/bacula/bacula-fd.conf
-UCF_CONFFILES=/etc/default/bacula-fd
-
-# start of libpostrm.inc.sh
-#
-# helper functions to purge conffiles
-# with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
-
-# delete a list of files, also with known backup extensions
-purge_conf() {
-    local file ext
-
-    for file in $@; do
-	rm -f $file
-	for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist .dist; do
-	    rm -f $file$ext
-	done
-    done
-}
-
-# unregister a list of conffiles from ucf after deleting them
-# usage: purge_ucf_conf <packagename> <conffile ...>
-purge_ucf_conf() {
-    local package file
-
-    # save package name
-    package=$1
-    # remove first argument from list
-    shift
-
-    purge_conf $@
-    if [ -x `which ucf` ]; then
-	for file in $@; do
-	    ucf --purge $file
-	    ucfr --purge $package $file
-	done
-    fi
-}
-# end of libpostrm.inc.sh
-
-case "$1" in
-    purge)
-	purge_conf $CONFFILE
-	purge_ucf_conf $PACKAGE $UCF_CONFFILES
-	;;
-
-    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-	;;
-
-    *)
-	echo "postrm called with unknown argument \`$1'" >&2
-	exit 1
-	;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/bacula-sd.autopostrm b/debian/bacula-sd.autopostrm
new file mode 100644
index 0000000..551cf0f
--- /dev/null
+++ b/debian/bacula-sd.autopostrm
@@ -0,0 +1,3 @@
+# this file is handled by debian/scripts/autopostrm
+CONFFILES=/etc/bacula/bacula-sd.conf
+UCF_CONFFILES=/etc/default/bacula-sd
diff --git a/debian/bacula-sd.postrm b/debian/bacula-sd.postrm
deleted file mode 100644
index 6f5d8c3..0000000
--- a/debian/bacula-sd.postrm
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/sh
-
-set -e
-
-PACKAGE=bacula-sd
-CONFFILE=/etc/bacula/bacula-sd.conf
-UCF_CONFFILES=/etc/default/bacula-sd
-
-# start of libpostrm.inc.sh
-#
-# helper functions to purge conffiles
-# with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
-
-# delete a list of files, also with known backup extensions
-purge_conf() {
-    local file ext
-
-    for file in $@; do
-	rm -f $file
-	for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist .dist; do
-	    rm -f $file$ext
-	done
-    done
-}
-
-# unregister a list of conffiles from ucf after deleting them
-# usage: purge_ucf_conf <packagename> <conffile ...>
-purge_ucf_conf() {
-    local package file
-
-    # save package name
-    package=$1
-    # remove first argument from list
-    shift
-
-    purge_conf $@
-    if [ -x `which ucf` ]; then
-	for file in $@; do
-	    ucf --purge $file
-	    ucfr --purge $package $file
-	done
-    fi
-}
-# end of libpostrm.inc.sh
-
-case "$1" in
-    purge)
-	purge_conf $CONFFILE
-	purge_ucf_conf $PACKAGE $UCF_CONFFILES
-	;;
-
-    remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
-	;;
-
-    *)
-	echo "postrm called with unknown argument \`$1'" >&2
-	exit 1
-	;;
-esac
-
-# dh_installdeb will replace this with shell code automatically
-# generated by other debhelper scripts.
-
-#DEBHELPER#
-
-exit 0
diff --git a/debian/changelog b/debian/changelog
index 51ef4d5..bf30838 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ bacula (7.4.3+dfsg-5) unstable; urgency=medium
   * Removed obsolete check for insecure bacula-director passwords
   * Uncluttered debian/ by automating creation and cleaning of most
     maintscript files
+  * Added script "autopostrm" to autogenerate and clean up most postrm
+    scripts
 
  --
 
diff --git a/debian/rules b/debian/rules
index b84f9ff..b822ceb 100755
--- a/debian/rules
+++ b/debian/rules
@@ -143,9 +143,10 @@ override_dh_auto_install-indep:
 
 override_dh_auto_configure-arch:
 	$(foreach db,$(VARIANTS),$(call db-templates-subst,$(db)))
-	debian/scripts/generate-doc-dir-to-symlink-migration create
 	autoconf -I autoconf/ -o configure autoconf/configure.in
 	dh_auto_configure -- $(CONF_ALL)
+	debian/scripts/generate-doc-dir-to-symlink-migration create
+	debian/scripts/autopostrm create
 
 override_dh_makeshlibs:
 	dh_makeshlibs -n -Xbpipe-fd.so
@@ -157,6 +158,7 @@ override_dh_clean:
 	dh_autotools-dev_restoreconfig
 	dh_clean
 	debian/scripts/generate-doc-dir-to-symlink-migration clean
+	debian/scripts/autopostrm clean
 
 override_dh_fixperms-arch:
 	dh_fixperms -a
diff --git a/debian/scripts/autopostrm b/debian/scripts/autopostrm
new file mode 100755
index 0000000..294fd1c
--- /dev/null
+++ b/debian/scripts/autopostrm
@@ -0,0 +1,59 @@
+#!/bin/sh
+
+# This script generates the standard postrm files by fitting together
+# the package name, information from <packagename>.autopostrm and
+# scripts/template.postrm
+
+# (C) 2016 Carsten Leonhardt <leo at debian.org>
+
+# License: expat
+
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation files
+# (the "Software"), to deal in the Software without restriction,
+# including without limitation the rights to use, copy, modify, merge,
+# publish, distribute, sublicense, and/or sell copies of the Software,
+# and to permit persons to whom the Software is furnished to do so,
+# subject to the following conditions:
+
+#     The above copyright notice and this permission notice shall be
+#     included in all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+if [ ! -f debian/rules ]; then
+    echo "$0: error: must be run from the top level directory of a debian source!"
+    exit 1
+fi
+
+PACKAGES=$(cd debian; ls *autopostrm | cut -d. -f1)
+
+for pkg in $PACKAGES; do
+    case $1 in
+	create)
+	    if [ -f debian/$pkg.postrm ]; then
+		echo "$0: error: debian/$pkg.postrm already exists!"
+		exit 1
+	    fi
+	    # first insert the variables from the autopostrm files
+	    # after the marker, then replace the marker with a
+	    # variable containing the package name
+	    sed -e "/^#AUTOPOSTRM#$/r debian/$pkg.autopostrm" debian/scripts/template.postrm > debian/$pkg.postrm
+	    sed -e "s/^#AUTOPOSTRM#$/PACKAGE=$pkg/" -i debian/$pkg.postrm
+	    ;;
+	clean)
+	    rm -f debian/$pkg.postrm
+	    ;;
+	*)
+	    echo '$0: error: argument "create" or "clean" is missing'
+	    exit 1
+	    ;;
+    esac
+done
diff --git a/debian/scripts/libpostrm.inc.sh b/debian/scripts/libpostrm.inc.sh
deleted file mode 100755
index 85483e6..0000000
--- a/debian/scripts/libpostrm.inc.sh
+++ /dev/null
@@ -1,40 +0,0 @@
-# start of libpostrm.inc.sh
-#
-# helper functions to purge conffiles
-# with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
-
-# delete a list of files, also with known backup extensions
-purge_conf() {
-    local file ext
-
-    for file in $@; do
-	rm -f $file
-	for ext in '~' '%' .bak .ucf-new .ucf-old .ucf-dist .dist; do
-	    rm -f $file$ext
-	done
-    done
-}
-
-# unregister a list of conffiles from ucf after deleting them
-# usage: purge_ucf_conf <packagename> <conffile ...>
-purge_ucf_conf() {
-    local package file
-
-    # save package name
-    package=$1
-    # remove first argument from list
-    shift
-
-    purge_conf $@
-    if [ -x `which ucf` ]; then
-	for file in $@; do
-	    ucf --purge $file
-	    ucfr --purge $package $file
-	done
-    fi
-}
-# end of libpostrm.inc.sh
diff --git a/debian/bacula-console-qt.postrm b/debian/scripts/template.postrm
similarity index 77%
rename from debian/bacula-console-qt.postrm
rename to debian/scripts/template.postrm
index cc04e7c..e81adab 100644
--- a/debian/bacula-console-qt.postrm
+++ b/debian/scripts/template.postrm
@@ -2,16 +2,13 @@
 
 set -e
 
-CONFFILE=/etc/bacula/bat.conf
+# autopostrm will replace this with a variable containing the package
+# name and the contents of the debian/<package>.autopostrm files
+
+#AUTOPOSTRM#
 
-# start of libpostrm.inc.sh
-#
 # helper functions to purge conffiles
 # with and without ucf deregistration
-#
-# this file must be inserted into the postrm scripts, as there we
-# can't rely on files from our packages (they are probably already
-# deleted).
 
 # delete a list of files, also with known backup extensions
 purge_conf() {
@@ -43,11 +40,15 @@ purge_ucf_conf() {
 	done
     fi
 }
-# end of libpostrm.inc.sh
 
 case "$1" in
     purge)
-	purge_conf $CONFFILE
+	if [ -n "$CONFFILES" ]; then
+	    purge_conf $CONFFILES
+	fi
+	if [ -n "$UCF_CONFFILES" ]; then
+	    purge_ucf_conf $PACKAGE $UCF_CONFFILES
+	fi
 	;;
 
     remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-bacula/bacula.git



More information about the pkg-bacula-commits mailing list