Re: cleanup config handling in xlibs
Hello Denis.
On Sat, 6 Aug 2005 00:39:07 +0200
you wrote:
> On Sat, Aug 06, 2005 at 06:25:59AM +0800, Eugene Konev wrote:
> > * Remove /etc/X11/xkb/rules/xfree86.lst and
> > /etc/X11/xkb/rules/xfree86-it.lst as we don't ship them anymore.
> Why won't we ship xfree86.lst anymore? Does that mean that a config
> script replaces
> Option "XkbRules" "xfree86"
> by
> Option "XkbRules" "xorg"
> in XF86Config-4?
Yep. You are right, it doesn't. Fixed patch attached.
Changes (to the previous patch):
* Introduce replace_conffile_with_symlink_{prepare,commit,rollback}
functions to debian/shell-lib.sh. Switch handling of symlinks to
them.
* Add link from /etc/X11/xkb/rules/xorg.lst to
/etc/X11/xkb/rules/xfree86.lst in xlibs.links. Add it to symlink
handling.
* Add /etc/X11/xkb/rules/xfree86.xml symlink to symlink handling.
* Check old version of package in postrm in case of abort-install or
abort-upgrade so we do not remove new config in the case of failed
install/upgrade from not so old version.
diff -Nru debian.orig/shell-lib.sh debian/shell-lib.sh
--- debian.orig/shell-lib.sh 2005-07-28 11:31:19.000000000 +0800
+++ debian/shell-lib.sh 2005-08-06 14:43:48.000000000 +0800
@@ -461,7 +461,7 @@
exit $SHELL_LIB_USAGE_ERROR
fi
- conffile="$1"
+ _conffile="$1"
shift
# does the _conffile even exist?
@@ -535,6 +535,99 @@
fi
}
+replace_conffile_with_symlink_prepare () {
+ # syntax: replace_conffile_with_symlink_prepare oldfilename newfilename \
+ # official_md5sum ...
+ #
+ # Check a conffile "oldfilename" against a list of canonical MD5 checksums.
+ # If the file's current MD5 checksum matches one of the "official_md5sum"
+ # operands provided, then prepare the conffile for removal from the system.
+ # We defer actual deletion until the package is configured so that we can
+ # roll this operation back if package installation fails. Otherwise copy it
+ # to newfilename and let dpkg handle it through conffiles mechanism.
+ #
+ # Call this function from a preinst script in the event $1 is "upgrade" or
+ # "install" and verify $2 to ensure the package is being upgraded from a
+ # version (or installed over a version removed-but-not-purged) prior to the
+ # one in which the conffile was obsoleted.
+
+ #local conffile current_checksum
+
+ # validate arguments
+ if [ $# -lt 3 ]; then
+ usage_error "replace_conffile_with_symlink_prepare() called with wrong" \
+ " number of arguments; expected at least 3, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ _oldconffile="$1"
+ shift
+ _newconffile="$1"
+ shift
+
+ remove_conffile_prepare "$_oldconffile" "$@"
+ # If $_oldconffile still exists, then md5sums didn't match.
+ # Copy it to new one.
+ if [ -f "$_oldconffile" ]; then
+ cp "$_oldconffile" "$_newconffile"
+ fi
+
+}
+
+replace_conffile_with_symlink_commit () {
+ # syntax: replace_conffile_with_symlink_commit oldfilename
+ #
+ # Complete the removal of a conffile "oldfilename" that has been
+ # replaced by a symlink.
+ #
+ # Call this function from a postinst script after having used
+ # replace_conffile_with_symlink_prepare() in the preinst.
+
+ #local conffile
+
+ # validate arguments
+ if [ $# -ne 1 ]; then
+ usage_error "replace_conffile_with_symlink_commit() called with wrong" \
+ "number of arguments; expected 1, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ _conffile="$1"
+
+ remove_conffile_commit "$_conffile"
+}
+
+remove_conffile_rollback () {
+ # syntax: replace_conffile_with_symlink_rollback oldfilename newfilename
+ #
+ # Roll back the replacing of a conffile "oldfilename" with symlink to
+ # "newfilename"
+ #
+ # Call this function from a postrm script in the event $1 is "abort-upgrade"
+ # or "abort-install" and verify $2 to ensure the package failed to upgrade
+ # from a version (or install over a version removed-but-not-purged) prior
+ # to the one in which the conffile was obsoleted.
+ # You should have used replace_conffile_with_symlink_prepare() in the
+ # preinst.
+
+ #local conffile
+
+ # validate arguments
+ if [ $# -ne 2 ]; then
+ usage_error "replace_conffile_with_symlink_rollback() called with wrong" \
+ "number of arguments; expected 2, got $#"
+ exit $SHELL_LIB_USAGE_ERROR
+ fi
+
+ _oldconffile="$1"
+ _newconffile="$2"
+
+ remove_conffile_rollback "$_oldconffile"
+ if [ -f "$_newconffile" ]; then
+ rm "$_newconffile"
+ fi
+}
+
run () {
# syntax: run command [ argument ... ]
#
diff -Nru debian.orig/xlibs.links debian/xlibs.links
--- debian.orig/xlibs.links 2005-05-11 10:43:02.000000000 +0800
+++ debian/xlibs.links 2005-08-06 14:44:01.000000000 +0800
@@ -1,3 +1,4 @@
etc/X11/xkb/symbols/dvorak etc/X11/xkb/symbols/macintosh/dvorak
etc/X11/xkb/rules/xorg.xml etc/X11/xkb/rules/xfree86.xml
+etc/X11/xkb/rules/xorg.lst etc/X11/xkb/rules/xfree86.lst
etc/X11/xkb/rules/xorg etc/X11/xkb/rules/xfree86
diff -Nru debian.orig/xlibs.postinst.in debian/xlibs.postinst.in
--- debian.orig/xlibs.postinst.in 2005-06-11 08:04:27.000000000 +0800
+++ debian/xlibs.postinst.in 2005-08-06 14:44:07.000000000 +0800
@@ -17,5 +17,9 @@
remove_conffile_commit /etc/X11/xkb/geometry/omnibook
remove_conffile_commit /etc/X11/xkb/symbols/ru_yawerty
-
+remove_conffile_commit /etc/X11/xkb/rules/xfree86-it.lst
+replace_conffile_with_symlink_commit /etc/X11/xkb/rules/xfree86
+replace_conffile_with_symlink_commit /etc/X11/xkb/rules/xfree86.lst
+replace_conffile_with_symlink_commit /etc/X11/xkb/rules/xfree86.xml
+
# vim:set ai et sts=2 sw=2 tw=80:
diff -Nru debian.orig/xlibs.postrm.in debian/xlibs.postrm.in
--- debian.orig/xlibs.postrm.in 2005-06-11 08:04:27.000000000 +0800
+++ debian/xlibs.postrm.in 2005-08-06 14:44:07.000000000 +0800
@@ -15,8 +15,17 @@
#INCLUDE_SHELL_LIB#
if [ "$1" = "abort-install" ] || [ "$1" = "abort-upgrade" ]; then
- remove_conffile_rollback /etc/X11/xkb/geometry/omnibook
- remove_conffile_rollback /etc/X11/xkb/symbols/ru_yawerty
+ if dpkg --compare-versions "$2" lt "6.8.1-0.3"; then
+ remove_conffile_rollback /etc/X11/xkb/geometry/omnibook
+ remove_conffile_rollback /etc/X11/xkb/symbols/ru_yawerty
+ remove_conffile_rollback /etc/X11/xkb/rules/xfree86-it.lst
+ replace_conffile_with_symlink_rollback /etc/X11/xkb/rules/xfree86 \
+ /etc/X11/xkb/rules/xorg
+ replace_conffile_with_symlink_rollback /etc/X11/xkb/rules/xfree86.lst \
+ /etc/X11/xkb/rules/xorg.lst
+ replace_conffile_with_symlink_rollback /etc/X11/xkb/rules/xfree86.xml \
+ /etc/X11/xkb/rules/xorg.xml
+ fi
fi
#DEBHELPER#
diff -Nru debian.orig/xlibs.preinst.in debian/xlibs.preinst.in
--- debian.orig/xlibs.preinst.in 2005-06-11 08:04:27.000000000 +0800
+++ debian/xlibs.preinst.in 2005-08-06 14:44:07.000000000 +0800
@@ -20,6 +20,14 @@
99647d0d78564ac821c558d2bb7da714
remove_conffile_prepare /etc/X11/xkb/symbols/ru_yawerty \
b554dadb4877cfeb2cb38dd2531b3eb2
+ remove_conffile_prepare /etc/X11/xkb/rules/xfree86-it.lst \
+ 4261329d61ba59549df77ff3734d086c
+ replace_conffile_with_symlink_prepare /etc/X11/xkb/rules/xfree86 \
+ /etc/X11/xkb/rules/xorg 82a80c3162b2254d69d84cbe3dfa9de6
+ replace_conffile_with_symlink_prepare /etc/X11/xkb/rules/xfree86.lst \
+ /etc/X11/xkb/rules/xorg.lst 72bb740887679a6c61530f49a52e0ec4
+ replace_conffile_with_symlink_prepare /etc/X11/xkb/rules/xfree86.xml \
+ /etc/X11/xkb/rules/xorg.xml d2cba1c74edbd1a3bce26e23fafcec9d
fi
fi
Reply to: