Author: branden Date: 2003-08-19 23:51:15 -0500 (Tue, 19 Aug 2003) New Revision: 414
Modified: trunk/debian/xserver-common.preinst.in trunk/debian/xserver-xfree86.preinst.in Log: debian/xserver-{common,xfree86}.preinst.in: add more robustification to config file migration strategy; - use "lt-nl" operator instead of "lt" when invoking dpkg --compare-versions; if we know of no previous configured version of the package, don't bother attempting to migrate at all - wrap "db_get"s in if statements so that if for some reason the debconf template of interest has already been purged, the script does not fail Modified: trunk/debian/xserver-common.preinst.in =================================================================== --- trunk/debian/xserver-common.preinst.in 2003-08-20 03:59:58 UTC (rev 413) +++ trunk/debian/xserver-common.preinst.in 2003-08-20 04:51:15 UTC (rev 414) @@ -38,39 +38,41 @@ # if upgrading from < 4.2.1-10, migrate Xwrapper.config to (simplified) # ucf-style handling - if dpkg --compare-versions "$2" lt "4.2.1-10"; then + if dpkg --compare-versions "$2" lt-nl "4.2.1-10"; then # was the user letting the debconf "manage" the file? - db_get xserver-common/manage_config_with_debconf - if [ "$RET" = "true" ]; then - # yes; attempt to pre-seed the md5sum file based on the current content - # of the file - WRITE_MD5SUM=yes - # if the config file doesn't even exist, don't bother - if [ -e "$XWRAPPER_CONFIG" ]; then - # this is the preinst, so our checksum directory might not have been - # unpacked yet (in fact, if we're upgrading from < 4.2.1-10, we expect - # it not to be) - if [ ! -e "$CHECKSUM_DIR" ]; then - mkdir --mode=755 "$CHECKSUM_DIR" - else - # if the checksum pathname does exist but is not a directory, give - # up; dpkg will probably vomit on unpack anyway - if [ ! -d "$CHECKSUM_DIR" ]; then - message "Warning: cannot store MD5 checksum of $XWRAPPER_CONFIG;" \ - "$CHECKSUM_DIR exists but is not a directory." - WRITE_MD5SUM= + if db_get xserver-common/manage_config_with_debconf; then + if [ "$RET" = "true" ]; then + # yes; attempt to pre-seed the md5sum file based on the current content + # of the file + WRITE_MD5SUM=yes + # if the config file doesn't even exist, don't bother + if [ -e "$XWRAPPER_CONFIG" ]; then + # this is the preinst, so our checksum directory might not have been + # unpacked yet (in fact, if we're upgrading from < 4.2.1-10, we + # expect it not to be) + if [ ! -e "$CHECKSUM_DIR" ]; then + mkdir --mode=755 "$CHECKSUM_DIR" + else + # if the checksum pathname does exist but is not a directory, give + # up; dpkg will probably vomit on unpack anyway + if [ ! -d "$CHECKSUM_DIR" ]; then + message "Warning: cannot store MD5 checksum of" \ + "$XWRAPPER_CONFIG; $CHECKSUM_DIR exists but is not a" \ + "directory." + WRITE_MD5SUM= + fi fi + if [ -n "$WRITE_MD5SUM" ]; then + # people were letting debconf "manage" the config file even though + # they complained when it did so, so store a backup to keep people + # quiet + message "Note: migrating $XWRAPPER_CONFIG away from management" \ + "by debconf; backup stored in $XWRAPPER_CONFIG.dpkg-old" \ + "and MD5 checksum stored in $XWRAPPER_CONFIG_CHECKSUM." + md5sum "$XWRAPPER_CONFIG" > "$XWRAPPER_CONFIG_CHECKSUM" + cp "$XWRAPPER_CONFIG" "$XWRAPPER_CONFIG.dpkg-old" + fi fi - if [ -n "$WRITE_MD5SUM" ]; then - # people were letting debconf "manage" the config file even though - # they complained when it did so, so store a backup to keep people - # quiet - message "Note: migrating $XWRAPPER_CONFIG away from management" \ - "by debconf; backup stored in $XWRAPPER_CONFIG.dpkg-old" \ - "and MD5 checksum stored in $XWRAPPER_CONFIG_CHECKSUM." - md5sum "$XWRAPPER_CONFIG" > "$XWRAPPER_CONFIG_CHECKSUM" - cp "$XWRAPPER_CONFIG" "$XWRAPPER_CONFIG.dpkg-old" - fi fi fi Modified: trunk/debian/xserver-xfree86.preinst.in =================================================================== --- trunk/debian/xserver-xfree86.preinst.in 2003-08-20 03:59:58 UTC (rev 413) +++ trunk/debian/xserver-xfree86.preinst.in 2003-08-20 04:51:15 UTC (rev 414) @@ -26,7 +26,7 @@ if [ "$1" = "install" -o "$1" = "upgrade" ]; then # if upgrading from < 4.2.1-10, migrate X server symlink and XF86Config-4 # to (simplified) ucf-style handling - if dpkg --compare-versions "$2" lt "4.2.1-10"; then + if dpkg --compare-versions "$2" lt-nl "4.2.1-10"; then # do we have any configuration files to work with? if [ -e "$SERVER_SYMLINK" -o -e "$XF86CONFIG" ]; then # this is the preinst, so our checksum directory might not have been @@ -44,21 +44,22 @@ # attempt to pre-seed the md5sum file based on the current content # of the file; first, is this package selected as the one # containing the default X server? - db_get shared/default-x-server - if [ "$RET" = "$THIS_PACKAGE" ]; then - # next, does the symlink point to the server executable provided - # by this package? - CURRENT_SYMLINK_TARGET=$(readlink "$SERVER_SYMLINK") - if [ "$CURRENT_SYMLINK_TARGET" = "$THIS_SERVER" ]; then - # people were letting debconf "manage" the config file even - # though they complained when it did so, so store a backup to - # keep people quiet - message "Note: migrating $SERVER_SYMLINK away from management" \ - "by debconf; backup stored in" \ - "$SERVER_SYMLINK.dpkg-old and MD5 checksum stored in" \ - "$SERVER_SYMLINK_CHECKSUM." - echo "$CURRENT_SYMLINK_TARGET" | md5sum > "$SERVER_SYMLINK_CHECKSUM" - ln -s "$CURRENT_SYMLINK_TARGET" "$SERVER_SYMLINK.dpkg-old" + if db_get shared/default-x-server; then + if [ "$RET" = "$THIS_PACKAGE" ]; then + # next, does the symlink point to the server executable + # provided by this package? + CURRENT_SYMLINK_TARGET=$(readlink "$SERVER_SYMLINK") + if [ "$CURRENT_SYMLINK_TARGET" = "$THIS_SERVER" ]; then + # people were letting debconf "manage" the config file even + # though they complained when it did so, so store a backup to + # keep people quiet + message "Note: migrating $SERVER_SYMLINK away from" \ + "management by debconf; backup stored in" \ + "$SERVER_SYMLINK.dpkg-old and MD5 checksum stored" \ + "in $SERVER_SYMLINK_CHECKSUM." + echo "$CURRENT_SYMLINK_TARGET" | md5sum > "$SERVER_SYMLINK_CHECKSUM" + ln -s "$CURRENT_SYMLINK_TARGET" "$SERVER_SYMLINK.dpkg-old" + fi fi fi fi @@ -67,18 +68,19 @@ if [ -e "$XF86CONFIG" ]; then # attempt to pre-seed the md5sum file based on the current content # of the file - db_get xserver-xfree86/manage_config_with_debconf - if [ "$RET" = "true" ]; then - # if the config file doesn't even exist, don't bother - if [ -e "$XF86CONFIG" ]; then - # people were letting debconf "manage" the config file even - # though they complained when it did so, so store a backup to - # keep people quiet - message "Note: migrating $XF86CONFIG away from management by" \ - "debconf; backup stored in $XF86CONFIG.dpkg-old and" \ - "MD5 checksum stored in $XF86CONFIG_CHECKSUM." - md5sum "$XF86CONFIG" > "$XF86CONFIG_CHECKSUM" - cp "$XF86CONFIG" "$XF86CONFIG.dpkg-old" + if db_get xserver-xfree86/manage_config_with_debconf; then + if [ "$RET" = "true" ]; then + # if the config file doesn't even exist, don't bother + if [ -e "$XF86CONFIG" ]; then + # people were letting debconf "manage" the config file even + # though they complained when it did so, so store a backup to + # keep people quiet + message "Note: migrating $XF86CONFIG away from management" \ + "by debconf; backup stored in $XF86CONFIG.dpkg-old" \ + "and MD5 checksum stored in $XF86CONFIG_CHECKSUM." + md5sum "$XF86CONFIG" > "$XF86CONFIG_CHECKSUM" + cp "$XF86CONFIG" "$XF86CONFIG.dpkg-old" + fi fi fi fi -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]