From babafd41040722d8a64bd0d344591852734bbe51 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 5 Jan 2009 10:52:57 -0800 Subject: [PATCH] Prevent Debian package upgrades from prompting. Before, we were using dpkg "conffiles" for our configuration. This means that if the admin has customized the configuration (as is necessary to make the switch work) and the default configuration included in the package changed, then dpkg would prompt the user interactively about what to do. Now, we take responsibility for creating, upgrading, and removing the configuration file ourselves, and do not prompt. --- debian/ofp-switch-setup | 3 ++ debian/openflow-switch.dirs | 1 + debian/openflow-switch.postinst | 46 +++++++++++++++++++ debian/openflow-switch.postrm | 43 +++++++++++++++++ ...witch.default => openflow-switch.template} | 0 debian/rules | 1 + 6 files changed, 94 insertions(+) create mode 100755 debian/openflow-switch.postinst create mode 100755 debian/openflow-switch.postrm rename debian/{openflow-switch.default => openflow-switch.template} (100%) diff --git a/debian/ofp-switch-setup b/debian/ofp-switch-setup index c21f1e05b..5a999ab45 100755 --- a/debian/ofp-switch-setup +++ b/debian/ofp-switch-setup @@ -14,6 +14,7 @@ use warnings; my $debconf_owner = 'openflow-switch'; my $default = '/etc/default/openflow-switch'; +my $template = '/usr/share/openflow/switch/default.template'; my $etc = '/etc/openflow-switch'; my $rundir = '/var/run'; my $privkey_file = "$etc/of0-privkey.pem"; @@ -62,6 +63,8 @@ if (-e $default) { local $_ = $oldconfig{$key}; &{$map{$key}}() if defined && !/^\s*$/; } +} elsif (-e $template) { + %oldconfig = load_config($template); } my $cacert_preverified = -e $cacert_file; diff --git a/debian/openflow-switch.dirs b/debian/openflow-switch.dirs index 6cf04b514..a53002fff 100644 --- a/debian/openflow-switch.dirs +++ b/debian/openflow-switch.dirs @@ -1 +1,2 @@ /etc/openflow-switch +/usr/share/openflow/switch diff --git a/debian/openflow-switch.postinst b/debian/openflow-switch.postinst new file mode 100755 index 000000000..6e75786e6 --- /dev/null +++ b/debian/openflow-switch.postinst @@ -0,0 +1,46 @@ +#!/bin/sh +# postinst script for openflow-switch +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + DEFAULT=/etc/default/openflow-switch + TEMPLATE=/usr/share/openflow/switch/default.template + if ! test -e $DEFAULT; then + cp $TEMPLATE $DEFAULT + elif ! grep DATAPATH_ID $DEFAULT; then + echo >> $DEFAULT + sed -n '/DATAPATH_ID:/,/DATAPATH_ID=/p' $TEMPLATE >> $DEFAULT + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + + diff --git a/debian/openflow-switch.postrm b/debian/openflow-switch.postrm new file mode 100755 index 000000000..20bab0e0c --- /dev/null +++ b/debian/openflow-switch.postrm @@ -0,0 +1,43 @@ +#!/bin/sh +# postrm script for openflow-switch +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `remove' +# * `purge' +# * `upgrade' +# * `failed-upgrade' +# * `abort-install' +# * `abort-install' +# * `abort-upgrade' +# * `disappear' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + purge) + rm -f /etc/default/openflow-switch + ;; + + 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/openflow-switch.default b/debian/openflow-switch.template similarity index 100% rename from debian/openflow-switch.default rename to debian/openflow-switch.template diff --git a/debian/rules b/debian/rules index fa3cea85e..539c8f3d0 100755 --- a/debian/rules +++ b/debian/rules @@ -125,6 +125,7 @@ install-arch: build-arch dh_installdirs -s $(MAKE) -C _debian DESTDIR=$(CURDIR)/debian/openflow install cp debian/openflow-switch-config.overrides debian/openflow-switch-config/usr/share/lintian/overrides/openflow-switch-config + cp debian/openflow-switch.template debian/openflow-switch/usr/share/openflow/switch/default.template dh_install -s $(ext_install_arch) -- 2.43.0