[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#339482: patch to fix dpkg usage in glibc when /usr isnt mounted yet



Hi

tested in debian mips, works fine in my machines

replaced all (but one already commented) dpkg call with plain and old
if tests

in the end, checking if the machine is running the correct architecture
is hard to check and should be extremely rare, so i tweak it up and
comment it

thanks
-- 
Naturally the common people don't want war... but after all it is the
leaders of a country who determine the policy, and it is always a 
simple matter to drag the people along, whether it is a democracy, or
a fascist dictatorship, or a parliament, or a communist dictatorship.
Voice or no voice, the people can always be brought to the bidding of
the leaders. That is easy. All you have to do is tell them they are 
being attacked, and denounce the pacifists for lack of patriotism and
exposing the country to danger.  It works the same in every country.
           -- Hermann Goering, Nazi and war criminal, 1883-1946
--- glibc.sh	2006-01-03 02:39:45.000000000 +0000
+++ glibc-new.sh	2006-01-03 03:25:40.000000000 +0000
@@ -11,6 +11,19 @@
 # This script is existed for detecting depreciated kernel version to
 # check glibc incompatibility.
 
+
+a=0;
+for i in `uname -r | sed 's/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)\(.*\)/\1 \2 \3 \4/'`; do 
+	ver[$a]=$i
+	a=$((a+1)) 
+done
+
+K_MAJOR=${ver[0]}
+K_MINOR=${ver[1]}
+K_REV=${ver[2]}
+K_EXTRA=${ver[3]}
+
+
 if [ "`uname -s`" = Linux ]; then
     # glibc kernel version check: KERNEL_VERSION_CHECK
 exit_check () {
@@ -20,8 +33,7 @@
 
     # Test to make sure z < 255, in x.y.z-n form of kernel version
     # Also make sure we don't trip on x.y.zFOO-n form
-    #kernel_rev=$(uname -r | tr -- - . | cut -d. -f3 | tr -d '[:alpha:]')
-    kernel_rev=$(uname -r | sed 's/\([0-9]*\.[0-9]*\.\)\([0-9]*\)\(.*\)/\2/')
+    kernel_rev=$K_REV
     if [ "$kernel_rev" -ge 255 ]
     then
         echo WARNING: Your kernel version indicates a revision number
@@ -36,7 +48,6 @@
 
     # sanity checking for the appropriate kernel on each architecture.
     realarch=`uname -m`
-    kernel_ver=`uname -r`
 
     # intel i386 requires a recent kernel
     if [ "$realarch" = i386 ]
@@ -62,8 +73,11 @@
 
 	if [ "$cputype" != "" ]
 	then
-	    if dpkg --compare-versions "$kernel_ver" lt 2.4.21
-	    then
+	    # check < 2.4.21
+	    if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 4 ] \
+		|| [ ${K_REV} -lt 21 ]
+            then 
 		echo WARNING: You have a cpu which requires kernel 2.4.21
 		echo or greater in order to install this version of glibc.
 		echo Please upgrade the kernel before installing this package.
@@ -75,7 +89,9 @@
 		exit_check
 	    fi
 	else
-	    if dpkg --compare-versions "$kernel_ver" lt 2.2.0 #should be safe
+	    # check < 2.2.0 , should be safe
+	    if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 2 ]
 	    then
 		echo WARNING: This version of glibc suggests atleast a
 		echo 2.2.0 kernel in order to work properly. 2.0.x kernels
@@ -92,7 +108,10 @@
     # HPPA boxes require latest fixes in the kernel to function properly.
     if [ "$realarch" = parisc ]
     then
-	if dpkg --compare-versions "$kernel_ver" lt 2.4.17
+        # check < 2.4.17
+        if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 4 ] \
+		|| [ ${K_REV} -lt 17 ]
 	then
 		echo WARNING: This version of glibc requires that you be running
 		echo atleast a 2.4.17 kernel in order to work properly. Earlier
@@ -109,7 +128,11 @@
 	kernel_ver_pa=$(echo "$kernel_ver" | sed 's/pa//')
 	if [ "$kernel_ver" = "$kernel_ver_pa" ]
 	then
-	    if dpkg --compare-versions "$kernel_ver" lt 2.4.19-64
+            # check < 2.4.19-64
+            if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 4 ] \
+		|| [ ${K_REV} -lt 19 ] \
+		|| [ "${L_EXTRA}" == "-64" ] 
 	    then
 		echo WARNING: This version of glibc requires that you be
 		echo running at least a 2.4.19-64 to work properly.
@@ -118,7 +141,11 @@
 		exit_check
 	    fi
 	else
-	    if dpkg --compare-versions "$kernel_ver" lt 2.4.19-pa17
+            # check < 2.4.19-pa17
+            if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 4 ] \
+		|| [ ${K_REV} -lt 19 ] \
+		|| [ "${ver[4]}" == "-pa17" ] 
 	    then
 		echo WARNING: This version of glibc requires that you be
 		echo running at least a 2.4.19-pa17 in \(2.4\) or 2.5.53-pa3 
@@ -130,11 +157,14 @@
 	fi
     fi
 
-    if [ "$realarch" = mips ] \
-	&& [ "`dpkg --print-architecture`" = mips ]
-    then
+    if [ "$realarch" = mips ] ; then
+# removed, /var, /proc and /usr may not be mounted
+#	&& [ "`dpkg --print-architecture`" = mips ] ; then
 	# MIPS (but not mipsel) require a kernel update for the msq fixes.
-	if dpkg --compare-versions "$kernel_ver" lt 2.4.22
+        # check < 2.4.22
+        if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 4 ] \
+		|| [ ${K_REV} -lt 22 ] 
 	then
 		echo WARNING: System V message queues require kernel 2.4.22 to
 		echo work correctly on this architecture.  Some programs
@@ -144,10 +174,12 @@
     fi
 
     # amd64 requires 2.6 kernel because we drop to support linuxthreads
-    if [ "$realarch" = x86_64 ] \
-	&& [ "`dpkg --print-architecture`" = amd64 ]
-    then
-	if dpkg --compare-versions "$kernel_ver" lt 2.6.0
+    if [ "$realarch" = x86_64 ] ; then 
+# removed, /var, /proc and /usr may not be mounted
+#	&& [ "`dpkg --print-architecture`" = amd64 ]; then
+        # check < 2.6.0
+        if [ ${K_MAJOR} -lt 2 ] \
+		|| [ ${K_MINOR} -lt 6 ]
 	then
 	    echo WARNING: POSIX threads library NPTL requires 2.6 and
 	    echo later kernel on amd64.  If you use 2.4 kernel, please

Attachment: signature.asc
Description: PGP signature


Reply to: