tag 322510 patch
thanks
Hi,
Here's a patch that converts watchdog to debconf. Let me know whether
to NMU...
Thanks!
Matej
diff -ruN watchdog-5.2.4.dist/debian/changelog watchdog-5.2.4/debian/changelog
--- watchdog-5.2.4.dist/debian/changelog 2005-09-08 01:54:12.000000000
+0200
+++ watchdog-5.2.4/debian/changelog 2005-09-08 03:10:21.000000000 +0200
@@ -1,3 +1,11 @@
+watchdog (5.2.4-4.1) unstable; urgency=low
+
+ * Non-maintainer upload.
+ * Prompt via debconf. Store configuration in /etc/default/watchdog
+ (not a conffile). Closes: #180094, #242214, #299629, #322510.
+
+ -- Matej Vela <[EMAIL PROTECTED]> Thu, 8 Sep 2005 03:10:21 +0200
+
watchdog (5.2.4-4) unstable; urgency=medium
* Check for local changes to startup links before changing them
diff -ruN watchdog-5.2.4.dist/debian/config watchdog-5.2.4/debian/config
--- watchdog-5.2.4.dist/debian/config 1970-01-01 01:00:00.000000000 +0100
+++ watchdog-5.2.4/debian/config 2005-09-08 02:58:15.000000000 +0200
@@ -0,0 +1,53 @@
+#!/bin/sh
+set -e
+
+. /usr/share/debconf/confmodule
+db_capb backup
+
+parse_default() {
+ case `sed -n 's/^run_watchdog=//p' "$@"` in
+ 0) db_set watchdog/run false;;
+ 1) db_set watchdog/run true;;
+ *) return 1;;
+ esac
+}
+
+if dpkg --compare-versions "$2" le-nl 5.2.4-4
+then
+ # Upgrade quietly from pre-debconf days (<= 5.2.4-4).
+ if parse_default /etc/init.d/watchdog; then
+ db_fset watchdog/run seen true
+ fi
+elif [ -f /etc/default/watchdog ]
+then
+ # Load previous value (may have been changed manually).
+ parse_default /etc/default/watchdog || true
+fi
+
+# Use a state machine to allow jumping back.
+state=1
+while true
+do
+ case $state in
+ 1)
+ db_input medium watchdog/run || true
+ ;;
+ 2)
+ db_get watchdog/run
+ [ "$RET" = false ] || db_input medium watchdog/restart || true
+ ;;
+ *)
+ break
+ ;;
+ esac
+
+ if db_go
+ then
+ state=$(($state + 1))
+ else
+ state=$(($state - 1))
+ fi
+done
+
+# Check if the user backed up from the first question.
+[ $state -gt 0 ] || exit 10
diff -ruN watchdog-5.2.4.dist/debian/control watchdog-5.2.4/debian/control
--- watchdog-5.2.4.dist/debian/control 2005-09-08 01:54:12.000000000 +0200
+++ watchdog-5.2.4/debian/control 2005-09-08 01:58:55.000000000 +0200
@@ -7,7 +7,7 @@
Package: watchdog
Architecture: any
-Depends: ${shlibs:Depends}, makedev (>= 2.3.1-24) | devfsd
+Depends: ${shlibs:Depends}, ${misc:Depends}, makedev (>= 2.3.1-24) | devfsd
Description: software watchdog
The watchdog program writes to /dev/watchdog every ten seconds.
If the device is open but not written to within a minute the machine
diff -ruN watchdog-5.2.4.dist/debian/postinst watchdog-5.2.4/debian/postinst
--- watchdog-5.2.4.dist/debian/postinst 2005-09-08 01:54:12.000000000 +0200
+++ watchdog-5.2.4/debian/postinst 2005-09-08 03:02:13.000000000 +0200
@@ -1,6 +1,8 @@
#!/bin/sh
set -e
+. /usr/share/debconf/confmodule
+
# do we have to create the device?
if [ ! -c /dev/watchdog ]
then
@@ -19,69 +21,43 @@
chmod 750 /var/log/watchdog
fi
-wd=0
-if grep "run_watchdog=0" /etc/init.d/watchdog > /dev/null 2>&1 \
- && [ "$1" = "configure" ]
-then
-
- if test -z "$2" -o "$2" = "<unknown>"
- then
- # The package has not ever been configured on this system, or was
- # purged since it was last configured.
-
- cat << EOF
+default_format="\
+# Start watchdog at boot time? 0 or 1
+run_watchdog=%s
+"
-I can set up the system so that at boot-time \`watchdog' is
-automatically started.
-
-EOF
- while true
- do
- echo -n "Should I do this (y/n) [y]? "
- read input
- if [ $input = "y" ]
- then
- wd=1
- break
- elif [ $input = "n" ]
- then
- wd=0
- break
- elif [ ! $input ]
- then
- wd=1
- break
- else
- echo "Please answer \`Y' or \`N'."
- fi 2>/dev/null
- done
-
- if [ $wd = 1 ]
- then
- echo -n "Okay, now enabling \`watchdog'... "
- sed 's:^run_watchdog=0:run_watchdog=1:' /etc/init.d/watchdog \
- > /etc/init.d/watchdog.new.$$
- mv /etc/init.d/watchdog.new.$$ /etc/init.d/watchdog
- chmod 755 /etc/init.d/watchdog
- echo "done."
- echo
- echo -n "The next time you reboot the system, \`watchdog' will "
- echo "automatically start."
- else
- echo "Okay, not enabling \`watchdog'."
- fi
- fi
+if [ "$1" = configure ]
+then
+ # Determine whether to start watchdog at boot time.
+ db_get watchdog/run
+ case $RET in
+ false) run_watchdog=0;;
+ *) run_watchdog=1;;
+ esac
+
+ # Create an up-to-date copy of the default file.
+ {
+ # If it already exists, preserve everything except our comment
+ # and $run_watchdog.
+ if [ -f /etc/default/watchdog ]
+ then
+ printf "$default_format" '.*' \
+ | grep -vxf - /etc/default/watchdog || true
+ fi
- if [ $wd = 1 ]
+ # Append our comment and the current value.
+ printf "$default_format" "$run_watchdog"
+ } > /etc/default/watchdog.dpkg-new
+
+ # Replace the original atomically.
+ mv /etc/default/watchdog.dpkg-new /etc/default/watchdog
+
+ # Restart if so configured.
+ db_get watchdog/restart
+ if [ "$RET" = true ]
then
- echo -n "Do you want to start \`watchdog' now? (y/n) [n] "
- read input
- if [ "$input" = "y" ] ; then
- /etc/init.d/watchdog stop > /dev/null 2>&1
- /etc/init.d/watchdog start
- else
- echo "You may start \`watchdog' later by typing
'/etc/init.d/watchdog start'."
- fi
+ /etc/init.d/watchdog stop > /dev/null 2>&1
+ /etc/init.d/watchdog start
fi
fi
diff -ruN watchdog-5.2.4.dist/debian/postrm watchdog-5.2.4/debian/postrm
--- watchdog-5.2.4.dist/debian/postrm 2005-09-08 01:54:12.000000000 +0200
+++ watchdog-5.2.4/debian/postrm 2005-09-08 01:34:04.000000000 +0200
@@ -1,5 +1,10 @@
#!/bin/sh -e
+# Remove generated default file.
+if [ "$1" = "purge" ]; then
+ rm -f /etc/default/watchdog
+fi
+
# Not automatically added by dh_installinit (--noscripts)
if [ "$1" = "purge" ] ; then
update-rc.d watchdog remove >/dev/null
diff -ruN watchdog-5.2.4.dist/debian/rules watchdog-5.2.4/debian/rules
--- watchdog-5.2.4.dist/debian/rules 2005-09-08 01:54:12.000000000 +0200
+++ watchdog-5.2.4/debian/rules 2005-09-08 01:37:26.000000000 +0200
@@ -44,6 +44,7 @@
include/watch_err.h
dh_installexamples examples/*
dh_installchangelogs ChangeLog
+ dh_installdebconf
$(MAKE) install prefix=$$(pwd)/debian/tmp/usr \
CONFIG_FILENAME=$$(pwd)/debian/tmp/etc/watchdog.conf
# Do not install wd_keepalive as it is work in progress
diff -ruN watchdog-5.2.4.dist/debian/templates watchdog-5.2.4/debian/templates
--- watchdog-5.2.4.dist/debian/templates 1970-01-01 01:00:00.000000000
+0100
+++ watchdog-5.2.4/debian/templates 2005-09-08 03:04:41.000000000 +0200
@@ -0,0 +1,14 @@
+Template: watchdog/run
+Type: boolean
+Default: true
+Description: Start watchdog at boot time?
+ Please specify whether watchdog should be started as part of the boot
+ process. This can be changed later by editing /etc/default/watchdog.
+
+Template: watchdog/restart
+Type: boolean
+Default: false
+Description: Restart watchdog on upgrades?
+ If your kernel is configured with the CONFIG_WATCHDOG_NOWAYOUT option,
+ restarting watchdog will cause a spurious reboot (the kernel will think
+ the watchdog daemon crashed).
diff -ruN watchdog-5.2.4.dist/rc.watchdog.debian
watchdog-5.2.4/rc.watchdog.debian
--- watchdog-5.2.4.dist/rc.watchdog.debian 1997-11-14 15:14:26.000000000
+0100
+++ watchdog-5.2.4/rc.watchdog.debian 2005-09-08 01:32:23.000000000 +0200
@@ -2,9 +2,9 @@
#/etc/init.d/watchdog: start watchdog daemon.
test -x /usr/sbin/watchdog || exit 0
+test -f /etc/default/watchdog || exit 0
-# Set run_watchdog to 1 to start watchdog or 0 to disable it.
-run_watchdog=1
+. /etc/default/watchdog
# Used by debmake as an argument to update-rc.d.
FLAGS="defaults 10"