[Dbconfig-common-changes] [dbconfig-common] r242 - in trunk: debian dpkg

Sean Finney seanius at costa.debian.org
Sun Jun 4 17:03:43 UTC 2006


Author: seanius
Date: 2006-06-04 17:03:42 +0000 (Sun, 04 Jun 2006)
New Revision: 242

Modified:
   trunk/debian/changelog
   trunk/dpkg/postinst
Log:
fix for #370252


Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog	2006-05-30 21:22:25 UTC (rev 241)
+++ trunk/debian/changelog	2006-06-04 17:03:42 UTC (rev 242)
@@ -1,8 +1,13 @@
-dbconfig-common (1.8.15) UNRELEASED; urgency=low
+dbconfig-common (1.8.15) unstable; urgency=low
 
-  * NOT RELEASED YET
+  [sean finney]
+  * Michael Ablassmeier noticed the the various upgrade files were
+    not being applied in "version" sorted order (and were instead in
+    "sort -n" sorted order).  fixed with an O(n^2) chunk of code that
+    would make any computer scientist cry, if only it were used for
+    sorting more than a small number of files :) closes: #370252.
 
- -- sean finney <sean at localhost.localdomain>  Tue, 30 May 2006 23:22:09 +0200
+ -- sean finney <seanius at debian.org>  Sun, 04 Jun 2006 19:03:00 +0200
 
 dbconfig-common (1.8.14) unstable; urgency=low
 

Modified: trunk/dpkg/postinst
===================================================================
--- trunk/dpkg/postinst	2006-05-30 21:22:25 UTC (rev 241)
+++ trunk/dpkg/postinst	2006-06-04 17:03:42 UTC (rev 242)
@@ -179,7 +179,7 @@
 ## upgrades are provided in-order regardless of which methods are used.
 ##
 _dbc_find_upgrades(){
-	local f sqldir admsqldir scriptdir upgradedirs upgrades_pending
+	local f s sqldir admsqldir scriptdir upgradedirs pending sorted placed tlist
 	# check for new upgrades in these three locations
 	sqldir=$dbc_share/data/$dbc_package/upgrade/$dbc_dbtype
 	admsqldir=$dbc_share/data/$dbc_package/upgrade-dbadmin/$dbc_dbtype
@@ -196,11 +196,44 @@
 	for f in `find $upgradedirs -type f -print0 | \
               xargs --no-run-if-empty -0 -n1 basename | sort -n | uniq`; do
 		if dpkg --compare-versions $dbc_oldversion lt $f; then
-			upgrades_pending="$upgrades_pending $f"
+			pending="$pending $f"
 		fi
 	done
 
-	echo $upgrades_pending
+	# for each pending update
+	for f in $pending; do
+		# if the sorted list is empty
+		if [ ! "$sorted" ]; then
+			sorted="$f"
+		else
+			# a scratch list for a sorted insert of the next version
+			tlist=""
+			# for each already sorted version
+			for s in $sorted; do
+				# if we haven't already placed it
+				if [ ! "$placed" ]; then
+					# if the this version is less than the next sorted one
+					if dpkg --compare-versions $f lt $s; then
+						# insert it here
+						tlist="$tlist $f $s"
+						placed="yes"
+					else
+						# it's not less, so append the sorted one and continue
+						tlist="$tlist $s"
+					fi
+				fi
+			done
+			# if we still haven't placed it, tack it on to the end of the list
+			if [ ! "$placed" ]; then
+				tlist="$tlist $f"
+			fi
+			# and now reset the placed variable, and update the sorted list
+			placed=""
+			sorted="$tlist"
+		fi
+	done
+
+	echo $sorted
 }
 
 ##




More information about the Dbconfig-common-changes mailing list