Author: branden Date: 2003-08-23 23:40:23 -0500 (Sat, 23 Aug 2003) New Revision: 427
Modified: trunk/debian/xserver-common.postinst.in trunk/debian/xserver-xfree86.postinst.in Log: debian/xserver-{common,xfree86}.postinst.in: (cosmetic) (well, what SHOULD be cosmetic changes, anyway) - wrap all config file update logic inside the test to see if the config file aux dir is a directory; saves some time if it isn't - don't throw a warning if the config file aux dir doesn't exist, or isn't a directory; assume admin cleverness - don't mention MD5 checksums specifically in user-visible messages; it should be obvious from the checksum filenames, which end in ".md5sum" - wrap some lines that were longer than 80 chars Modified: trunk/debian/xserver-common.postinst.in =================================================================== --- trunk/debian/xserver-common.postinst.in 2003-08-24 04:30:29 UTC (rev 426) +++ trunk/debian/xserver-common.postinst.in 2003-08-24 04:40:23 UTC (rev 427) @@ -25,62 +25,60 @@ check_symlinks_and_bomb /usr/X11R6/lib/X11/xserver # now safe to remove old xserver dir -if [ -e /usr/X11R6/lib/X11/xserver.moved-by-preinst -a -L /usr/X11R6/lib/X11/xserver ]; then +if [ -e /usr/X11R6/lib/X11/xserver.moved-by-preinst -a \ + -L /usr/X11R6/lib/X11/xserver ]; then rm -r /usr/X11R6/lib/X11/xserver.moved-by-preinst fi #DEBHELPER# -# register this package as a (potential) handler of the X server wrapper config -# file -if [ ! -e "$CONFIG_AUX_DIR" ]; then - mkdir --mode=755 --parents "$CONFIG_AUX_DIR" - if ! fgrep -qsx "$THIS_PACKAGE" "$XWRAPPER_CONFIG_ROSTER" ]; then +# only mess with config files if the configuration file auxiliary directory +# exists; if it does not, assume that's the way the user wants it +if [ -d "$CONFIG_AUX_DIR" ]; then + + # register this package as a (potential) handler of the X server wrapper + # config file + if ! fgrep -qsx "$THIS_PACKAGE" "$XWRAPPER_CONFIG_ROSTER"; then echo "$THIS_PACKAGE" >> "$XWRAPPER_CONFIG_ROSTER" fi -else - # if the checksum pathname does exist but is not a directory, give up; we - # will assume the user has reasons for setting things up this way - if [ ! -d "$CONFIG_AUX_DIR" ]; then - message "Warning: cannot register $THIS_PACKAGE package as an owner of" \ - "$XWRAPPER_CONFIG; $CONFIG_AUX_DIR exists but is not a directory." - fi -fi -# only mess with config file if it exists; if it does not, assume that's the -# way the user wants it -if [ -e "$XWRAPPER_CONFIG" ]; then - # similarly, check for the existence of the checksum file; if it doesn't - # exist, assume that's the way the user wants it - if [ -e "$XWRAPPER_CONFIG_CHECKSUM" ]; then - # next, compare the current and stored checksums; if they do not match, - # assume that's the way the user wants it - if [ "$(md5sum "$XWRAPPER_CONFIG")" = "$(cat "$XWRAPPER_CONFIG_CHECKSUM")" ]; then - # they match; prepare a new version of the config file - db_get xserver-common/xwrapper/actual_allowed_users - ALLOWED_USERS="$RET" - db_get xserver-common/xwrapper/nice_value - NICE_VALUE="$RET" - NEW_XWRAPPER_CONFIG=$(tempfile) - cat > "$NEW_XWRAPPER_CONFIG" << EOF + # only mess with config file it exists; otherwise, assume that's the way the + # user wants it + if [ -e "$XWRAPPER_CONFIG" ]; then + # similarly, check for the existence of the checksum file; if it doesn't + # exist, assume that's the way the user wants it + if [ -e "$XWRAPPER_CONFIG_CHECKSUM" ]; then + # next, compare the current and stored checksums; if they do not match, + # assume that's the way the user wants it + if [ "$(md5sum "$XWRAPPER_CONFIG")" = \ + "$(cat "$XWRAPPER_CONFIG_CHECKSUM")" ]; then + # they match; prepare a new version of the config file + db_get xserver-common/xwrapper/actual_allowed_users + ALLOWED_USERS="$RET" + db_get xserver-common/xwrapper/nice_value + NICE_VALUE="$RET" + NEW_XWRAPPER_CONFIG=$(tempfile) + cat > "$NEW_XWRAPPER_CONFIG" << EOF allowed_users=$ALLOWED_USERS nice_value=$NICE_VALUE EOF - if ! cmp -s "$XWRAPPER_CONFIG" "$NEW_XWRAPPER_CONFIG"; then - cp "$NEW_XWRAPPER_CONFIG" "$XWRAPPER_CONFIG.dpkg-new" - mv "$XWRAPPER_CONFIG.dpkg-new" "$XWRAPPER_CONFIG" - md5sum "$XWRAPPER_CONFIG" > "$XWRAPPER_CONFIG_CHECKSUM" + if ! cmp -s "$XWRAPPER_CONFIG" "$NEW_XWRAPPER_CONFIG"; then + cp "$NEW_XWRAPPER_CONFIG" "$XWRAPPER_CONFIG.dpkg-new" + mv "$XWRAPPER_CONFIG.dpkg-new" "$XWRAPPER_CONFIG" + md5sum "$XWRAPPER_CONFIG" > "$XWRAPPER_CONFIG_CHECKSUM" + fi + rm -f "$NEW_XWRAPPER_CONFIG" + else + message "Note: not updating $XWRAPPER_CONFIG; file has been customized." fi - rm -f "$NEW_XWRAPPER_CONFIG" else - message "Note: not updating $XWRAPPER_CONFIG; file has been customized." + message "Note: not updating $XWRAPPER_CONFIG; no stored checksum" \ + "available." fi else - message "Note: not updating $XWRAPPER_CONFIG; no stored MD5 checksum" \ - "available." + message "Note: not updating $XWRAPPER_CONFIG; file does not exist." fi -else - message "Note: not updating $XWRAPPER_CONFIG; file does not exist." + fi exit 0 Modified: trunk/debian/xserver-xfree86.postinst.in =================================================================== --- trunk/debian/xserver-xfree86.postinst.in 2003-08-24 04:30:29 UTC (rev 426) +++ trunk/debian/xserver-xfree86.postinst.in 2003-08-24 04:40:23 UTC (rev 427) @@ -28,107 +28,103 @@ #DEBHELPER# -# register this package as a (potential) handler of the X server symlink and -# XFree86 4.x X server configuration file -if [ ! -e "$CONFIG_AUX_DIR" ]; then - mkdir --mode=755 --parents "$CONFIG_AUX_DIR" +# only mess with config files if the configuration file auxiliary directory +# exists; if it does not, assume that's the way the user wants it +if [ -d "$CONFIG_AUX_DIR" ]; then + + # register this package as a (potential) handler of the X server symlink and + # XFree86 4.x X server configuration file for ROSTER in "$SERVER_SYMLINK_ROSTER" "$XF86CONFIG_ROSTER"; do if ! fgrep -qsx "$THIS_PACKAGE" "$ROSTER"; then echo "$THIS_PACKAGE" >> "$ROSTER" fi done -else - # if the checksum pathname does exist but is not a directory, give up; we - # will assume the user has reasons for setting things up this way - if [ ! -d "$CONFIG_AUX_DIR" ]; then - message "Warning: cannot register $THIS_PACKAGE package as an owner of" \ - "$SERVER_SYMLINK or $XF86CONFIG; $CONFIG_AUX_DIR exists but is" \ - "not a directory." - fi -fi -# only mess with server symlink config file if it exists; if it does not, -# assume that's the way the user wants it -if [ -L "$SERVER_SYMLINK" ]; then - # similarly, check for the existence of the checksum file; if it doesn't - # exist, assume that's the way the user wants it - if [ -e "$SERVER_SYMLINK_CHECKSUM" ]; then - # compare the current and stored checksums; if they do not match, assume - # that's the way the user wants it - if [ "$(readlink "$SERVER_SYMLINK" | md5sum)" = "$(cat "$SERVER_SYMLINK_CHECKSUM")" ]; then - # finally, only update the symlink if this package contains the selected - # default X server - db_get shared/default-x-server - if [ -n "$RET" ]; then - SELECTED_PACKAGE="$RET" - if [ "$SELECTED_PACKAGE" = "$THIS_PACKAGE" ]; then - # prepare a new version of the config file; this is a symlink so we - # can't use the tempfile command for it (we'd have to subsequently use - # ln -sf, which is subject to race condition attacks) - NEW_SERVER_SYMLINK="$SERVER_SYMLINK.dpkg-new" - ln -sf "$THIS_SERVER" "$NEW_SERVER_SYMLINK" - if ! cmp -s "$SERVER_SYMLINK" "$NEW_SERVER_SYMLINK"; then - if [ "$(readlink "$SERVER_SYMLINK")" \ - != "$(readlink "$NEW_SERVER_SYMLINK")" ]; then - if [ ! -d "$SERVER_SYMLINK" ]; then - mv "$NEW_SERVER_SYMLINK" "$SERVER_SYMLINK" - readlink "$SERVER_SYMLINK" | md5sum > "$SERVER_SYMLINK_CHECKSUM" - else - message "Note: not updating $SERVER_SYMLINK; it is a symbolic" \ - "link to a directory." + # only mess with the server symlink file it exists and is actually a symlink; + # otherwise, assume that's the way the user wants it + if [ -L "$SERVER_SYMLINK" ]; then + # similarly, check for the existence of the checksum file; if it doesn't + # exist, assume that's the way the user wants it + if [ -e "$SERVER_SYMLINK_CHECKSUM" ]; then + # compare the current and stored checksums; if they do not match, assume + # that's the way the user wants it + if [ "$(readlink "$SERVER_SYMLINK" | md5sum)" = \ + "$(cat "$SERVER_SYMLINK_CHECKSUM")" ]; then + # finally, only update the symlink if this package contains the + # selected default X server + db_get shared/default-x-server + if [ -n "$RET" ]; then + SELECTED_PACKAGE="$RET" + if [ "$SELECTED_PACKAGE" = "$THIS_PACKAGE" ]; then + # prepare a new version of the config file; this is a symlink so we + # can't use the tempfile command for it (we'd have to subsequently + # use ln -sf, which is subject to race condition attacks) + NEW_SERVER_SYMLINK="$SERVER_SYMLINK.dpkg-new" + ln -sf "$THIS_SERVER" "$NEW_SERVER_SYMLINK" + if ! cmp -s "$SERVER_SYMLINK" "$NEW_SERVER_SYMLINK"; then + if [ "$(readlink "$SERVER_SYMLINK")" \ + != "$(readlink "$NEW_SERVER_SYMLINK")" ]; then + if [ ! -d "$SERVER_SYMLINK" ]; then + mv "$NEW_SERVER_SYMLINK" "$SERVER_SYMLINK" + readlink "$SERVER_SYMLINK" | md5sum > \ + "$SERVER_SYMLINK_CHECKSUM" + else + message "Note: not updating $SERVER_SYMLINK; it is a" \ + "symbolic link to a directory." + fi fi fi + rm -f "$NEW_SERVER_SYMLINK" fi - rm -f "$NEW_SERVER_SYMLINK" + else + message "Note: not updating $SERVER_SYMLINK; no default X server" \ + "configured; run \"dpkg-reconfigure $THIS_PACKAGE\" to" \ + "correct this." fi else - message "Note: not updating $SERVER_SYMLINK; no default X server" \ - "configured; run \"dpkg-reconfigure $THIS_PACKAGE\" to" \ - "correct this." + message "Note: not updating $SERVER_SYMLINK; file has been customized." fi else - message "Note: not updating $SERVER_SYMLINK; file has been customized." + message "Note: not updating $SERVER_SYMLINK; no stored checksum" \ + "available." fi else - message "Note: not updating $SERVER_SYMLINK; no stored MD5 checksum" \ - "available." + message "Note: not updating $SERVER_SYMLINK; file does not exist." fi -else - message "Note: not updating $SERVER_SYMLINK; file does not exist." -fi -# only mess with X server config file if it exists; if it does not, assume -# that's the way the user wants it -if [ -e "$XF86CONFIG" ]; then - # similarly, check for the existence of the checksum file; if it doesn't - # exist, assume that's the way the user wants it - if [ -e "$XF86CONFIG_CHECKSUM" ]; then - # compare the current and stored checksums; if they do not match, assume - # that's the way the user wants it - if [ "$(md5sum "$XF86CONFIG")" = "$(cat "$XF86CONFIG_CHECKSUM")" ]; then - # they match; prepare a new version of the config file - NEW_XF86CONFIG=$(tempfile) - if dexconf -o "$NEW_XF86CONFIG"; then - if ! cmp -s "$XF86CONFIG" "$NEW_XF86CONFIG"; then - cp "$NEW_XF86CONFIG" "$XF86CONFIG.dpkg-new" - mv "$XF86CONFIG.dpkg-new" "$XF86CONFIG" - md5sum "$XF86CONFIG" > "$XF86CONFIG_CHECKSUM" + # only mess with X server config file if it exists; if it does not, assume + # that's the way the user wants it + if [ -e "$XF86CONFIG" ]; then + # similarly, check for the existence of the checksum file; if it doesn't + # exist, assume that's the way the user wants it + if [ -e "$XF86CONFIG_CHECKSUM" ]; then + # compare the current and stored checksums; if they do not match, assume + # that's the way the user wants it + if [ "$(md5sum "$XF86CONFIG")" = "$(cat "$XF86CONFIG_CHECKSUM")" ]; then + # they match; prepare a new version of the config file + NEW_XF86CONFIG=$(tempfile) + if dexconf -o "$NEW_XF86CONFIG"; then + if ! cmp -s "$XF86CONFIG" "$NEW_XF86CONFIG"; then + cp "$NEW_XF86CONFIG" "$XF86CONFIG.dpkg-new" + mv "$XF86CONFIG.dpkg-new" "$XF86CONFIG" + md5sum "$XF86CONFIG" > "$XF86CONFIG_CHECKSUM" + fi + else + message "Note: error while preparing new XFree86 X server" \ + "configuration file in $NEW_XF86CONFIG; not attempting to" \ + "update existing configuration." fi + rm -f "$NEW_XF86CONFIG" else - message "Note: error while preparing new XFree86 X server" \ - "configuration file in $NEW_XF86CONFIG; not attempting to" \ - "update existing configuration." + message "Note: not updating $XF86CONFIG; file has been customized." fi - rm -f "$NEW_XF86CONFIG" else - message "Note: not updating $XF86CONFIG; file has been customized." + message "Note: not updating $XF86CONFIG; no stored checksum available." fi else - message "Note: not updating $XF86CONFIG; no stored MD5 checksum" \ - "available." + message "Note: not updating $XF86CONFIG; file does not exist." fi -else - message "Note: not updating $XF86CONFIG; file does not exist." + fi # register X server configlet -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]