[Pkg-bugzilla-commits] r80 - trunk/bugzilla-2.18/debian
Alexis Sukrieh
sukria-guest@costa.debian.org
Mon, 25 Apr 2005 12:17:13 +0000
Author: sukria-guest
Date: 2005-04-25 12:17:12 +0000 (Mon, 25 Apr 2005)
New Revision: 80
Added:
trunk/bugzilla-2.18/debian/bugzilla.preinst
Modified:
trunk/bugzilla-2.18/debian/bugzilla.postinst
Log:
Added bugzilla.preinst to hande the "params" file migration from 2.16 or 2.18 packages.
Updated bugzilla.postinst.
Modified: trunk/bugzilla-2.18/debian/bugzilla.postinst
===================================================================
--- trunk/bugzilla-2.18/debian/bugzilla.postinst 2005-04-24 19:54:27 UTC (rev 79)
+++ trunk/bugzilla-2.18/debian/bugzilla.postinst 2005-04-25 12:17:12 UTC (rev 80)
@@ -53,36 +53,10 @@
params_218_dest="/etc/bugzilla/params"
params_218_new="/usr/share/bugzilla/debian/params.new"
- # manage the upgrade for 2.16 packages
- if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.16.7-6; then
- debug "Upgrading $2 "
- params="/var/lib/bugzilla/data/params"
-
- # the 2.16 params file is found, move it for an upgrade...
- if [ -f $params ]; then
- debug "2.16 params file found, moving it"
- # We are upgrading from 2.16, then $params_218_dest is only our
- # package's version, we can safely remove it and use the old 2.16 file
- replace_file $params $params_218_dest
- fi
- fi
-
- # manage the upgrade for 2.18 packages before 2.18-4
- if [ -n "$2" ] && dpkg --compare-versions "$2" lt 2.18-4; then
- debug "Upgrading $2 "
- params="/usr/share/bugzilla/web/data/params"
-
- # the 2.16 params file is found, move it for an upgrade...
- if [ -f $params ]; then
- debug "2.18 params file found, moving it"
- # We are upgrading from 2.16, then $params_218_dest is only our
- # package's version, we can safely remove it and use the old 2.16 file
- replace_file $params $params_218_dest
- fi
- fi
-
# If there's no $params_218_dest yet, let's move our package version
- if [ ! -f $params_218_dest ]; then
+ # Note that if we upgraded a previous package, we might have already
+ # moved the previous params file to the right place.
+ if [ ! -e $params_218_dest ]; then
replace_file $params_218_src $params_218_dest
fi
Added: trunk/bugzilla-2.18/debian/bugzilla.preinst
===================================================================
--- trunk/bugzilla-2.18/debian/bugzilla.preinst 2005-04-24 19:54:27 UTC (rev 79)
+++ trunk/bugzilla-2.18/debian/bugzilla.preinst 2005-04-25 12:17:12 UTC (rev 80)
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+# Summary of how this script is called:
+# . new-preinst install
+# . new-preinst install old-version
+# . new-preinst upgrade old-version
+
+debug()
+{
+ if [ -n "$DEBIAN_BUGZILLA_DEBUG" ]; then
+ echo "$1" >&2
+ fi
+}
+
+# Use the same order as for mv
+replace_file()
+{
+ file_source="$1"
+ file_dest="$2"
+
+ if [ ! -e $file_source ]; then
+ debug "$file_source has already been moved"
+ else
+ if [ ! -e $file_dest ]; then
+ mv $file_source $file_dest || exit 10
+ debug "mv $file_source $file_dest"
+ else
+ cp $file_dest ${file_dest}.old
+ debug "ucf $file_source $file_dest"
+ ucf $file_source $file_dest || exit 11
+ fi
+ chown www-data:www-data $file_dest
+ #rm -f $file_source
+ fi
+}
+
+upgrade_params_file()
+{
+ file="$1"
+ if [ -e $file ]; then
+ debug "Moving $file"
+ replace_file $file /etc/bugzilla/params
+ fi
+}
+
+
+##############################################################
+# Main
+#############################################################
+
+set -e
+mode="$1"
+version="$2"
+
+if [ "$mode" = "upgrade" ]; then
+
+ # Upgrade the 2.16 packages and older
+ params_216="/var/lib/bugzilla/data/params"
+ if [ -n "$version" ] && dpkg --compare-versions $version lt 2.16.7-6; then
+ debug "Upgrading $version"
+ upgrade_params_file $params_216
+ fi
+
+ # Upgrade previous 2.18 packages
+ params_218="/usr/share/bugzilla/web/data/params"
+ if [ -n "$version" ] && dpkg --compare-versions "$version" lt 2.18-4; then
+ debug "Upgrading $version"
+ upgrade_params_file $params_218
+ fi
+fi
+
+