-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
tags 397214 patch
thanks
On Tue, 14 Nov 2006, Matthew Johnson wrote:
It's not clear that the automatic generation should happen more than
once; I think it should happen only if the config file doesn't exist.
I've attached a patch which does this. Basically, the test for the
config file existing is extended to around the whole block. Also,
TMPFILE isn't ever deleted, so we do that too.
- --
Matthew Johnson
http://www.matthew.ath.cx/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Made with pgp4pine 1.76
iD8DBQFFWlVepldmHVvob7kRAnbYAJ0WWspGs8UYl5ImF/6e7WDrog6gYwCdHFXj
A3lv93kNqHiu14zi3RSb2q0=
=zsl1
-----END PGP SIGNATURE-----
diff -u uswsusp-0.3~cvs20060928/debian/uswsusp.postinst
uswsusp-0.3~cvs20060928.new/debian/uswsusp.postinst
--- uswsusp-0.3~cvs20060928/debian/uswsusp.postinst 2006-11-14
23:29:08.000000000 +0000
+++ uswsusp-0.3~cvs20060928.new/debian/uswsusp.postinst 2006-11-14
23:28:39.464412500 +0000
@@ -34,47 +34,51 @@
# db_get uswsusp/resume_device
#if [ -n "$RET" ]; then exit(0); fi
+ # Don't upgrade config file if one exists!
+ #
if [ ! -f $CONFIGFILE -o ! -s $CONFIGFILE ]; then
echo "# $CONFIGFILE(8) -- Configuration file for s2disk/s2both " >
$CONFIGFILE
- fi
- TMPFILE=`mktemp`
- cp -a -f $CONFIGFILE $TMPFILE
+ TMPFILE=`mktemp`
+ cp -a -f $CONFIGFILE $TMPFILE
+
+ SEDCMD=""
+
+ for I in $MEDQ $LOWQ $HIGHQ $CRYPTQ; do
+ db_get uswsusp/$I
+ VAL=$RET
+
+ db_metaget uswsusp/$I type
+ TYPE=$RET
+
+ if [ "boolean" = "$TYPE" ]; then
+ if [ "$VAL" = "true" ]; then
+ VAL="y";
+ else
+ VAL=
+ fi
+ fi
+
+ PATRN="^[[:space:]]*${I//_/ }[[:space:]]*[:=]"
+
+ # If we didn't got a value, we want the hardcoded default, so del
+ if [ -z "$VAL" ]; then
+ SEDCMD="$SEDCMD -e '/$PATRN/ d'"
+ # Else, rewrite the value
+ elif eval grep -q -e "'$PATRN'" $CONFIGFILE; then
+ SEDCMD="$SEDCMD -e 's/$PATRN.*$/${I//_/ } = ${VAL//\//\\/}/'"
+ # Or add it
+ else
+ SEDCMD="$SEDCMD -e '$ a ${I//_/ } = $VAL'"
+ fi
+
+ done
+
+ eval sed $SEDCMD < $CONFIGFILE > $TMPFILE
+ mv -f $TMPFILE $CONFIGFILE
- SEDCMD=""
-
- for I in $MEDQ $LOWQ $HIGHQ $CRYPTQ; do
- db_get uswsusp/$I
- VAL=$RET
-
- db_metaget uswsusp/$I type
- TYPE=$RET
-
- if [ "boolean" = "$TYPE" ]; then
- if [ "$VAL" = "true" ]; then
- VAL="y";
- else
- VAL=
- fi
- fi
-
- PATRN="^[[:space:]]*${I//_/ }[[:space:]]*[:=]"
-
- # If we didn't got a value, we want the hardcoded default, so del
- if [ -z "$VAL" ]; then
- SEDCMD="$SEDCMD -e '/$PATRN/ d'"
- # Else, rewrite the value
- elif eval grep -q -e "'$PATRN'" $CONFIGFILE; then
- SEDCMD="$SEDCMD -e 's/$PATRN.*$/${I//_/ } = ${VAL//\//\\/}/'"
- # Or add it
- else
- SEDCMD="$SEDCMD -e '$ a ${I//_/ } = $VAL'"
- fi
-
- done
-
- eval sed $SEDCMD < $CONFIGFILE > $TMPFILE
- mv -f $TMPFILE $CONFIGFILE
+ rm $TMPFILE
+ fi
db_get uswsusp/create_RSA_key
VAL=$RET