Hi,

Here are 2 patches to fix kernel detection in built client image.

Problem fixed here:
- rhel6 now uses initramfs.img instead of initrd.img
- Kernel_ia.pm thought rhel6 x86_64 was an itanium distro as it found /boot/efi 
in client image.
  => used OS_Detect on Images/Kernel_*.pm to correctly detect client image arch.
   => IMHO we should use the architecture stored in the Images table of the 
oscar database. No need to redetect something we have previously decided. 
(anyway, for now it fixes stufs).
- Image.pm & OS_Detect updated to take into account ia64 and ppc64.

now we have more than 2 lines in the following command (a kernel is found)
scconf_kernel -i  /var/lib/systemimager/images/oscarimage
DEFAULTBOOT : 5148
Label                   Kernel
2.6.32-220.23.1.el6.x86_64    /boot/vmlinuz-2.6.32-220.23.1.el6.x86_64

Regards,

--
   Olivier LAHAYE
   CEA DRT/LIST/DCSI/DIR
Index: oscar/lib/OSCAR/OCA/OS_Detect.pm
===================================================================
--- oscar/lib/OSCAR/OCA/OS_Detect.pm	(révision 9443)
+++ oscar/lib/OSCAR/OCA/OS_Detect.pm	(copie de travail)
@@ -146,6 +146,10 @@
 	    $arch = "i386";
 	} elsif ($arch =~ m/x86-64/) {
 	    $arch = "x86_64";
+	} elsif ($arch =~ m/IA-64/) {
+	    $arch = "ia64";
+	} elsif ($arch =~ m/PowerPC/) { # OL: May need tunning. (iSeries)
+	    $arch = "ppc64";
 	}
     }
     # DIKIM added this for YDL5
Index: pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image.pm
===================================================================
--- pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image.pm	(révision 9443)
+++ pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image.pm	(copie de travail)
@@ -54,9 +54,13 @@
 $VERSION = sprintf("%d", q$Revision$ =~ /(\d+)/);
 
 my @MODS=qw(Kernel_ia64 Kernel_iseries Kernel_x86);
+# OL: Kernel detection is using OS_Detect on $imagepath/bin/ach file in
+# order to guess the image architecture. This is stupid as we have the info
+# in OSCAR database. There are no possible reasons to find a different arch
+# from what is stated in the database...
 use SystemInstaller::Image::Kernel_x86;
 use SystemInstaller::Image::Kernel_ia64;
-use SystemInstaller::Image::Kernel_iseries;
+use SystemInstaller::Image::Kernel_iseries; # Should be Kernel_ppc64;
 
 use SystemInstaller::Log qw(verbose get_verbose);
 
@@ -71,7 +75,7 @@
 	mkpath(["$root/etc/systemimager/partitionschemes"]);
 	mkpath(["$root/etc/systemconfig"]);
 	# Check that something worked.
-	unless (-d "$root/usr/lib" ){
+	unless (-d "$root/etc/systemconfig" ){
 		return 1;
 	}
 	return 0;
@@ -138,7 +142,8 @@
     opendir (DIR, "$imagepath/boot")
         or (carp "ERROR: Could not read directory $imagepath!", return undef);
     for my $f (readdir DIR) {
-        if ($f =~ /initrd(.*)$label(.*)/) {
+	# OL:initrd or initramfs must be matched.
+        if ($f =~ /initr(.*)$label(.*)/) {
             closedir (DIR);
             return "/boot/$f";
         }
Index: pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_x86.pm
===================================================================
--- pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_x86.pm	(révision 9443)
+++ pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_x86.pm	(copie de travail)
@@ -40,9 +40,13 @@
 	my $class=shift;
         my $imgdir=shift;
 
-        if (-e "$imgdir/boot/") {
-                return 1;
-        }
+	my $arch = main::OSCAR::OCA::OS_Detect::detect_arch_file($imgdir,"/bin/arch");
+	if ($arch =~ m/(x86_64|i386)/) {
+		return 1;
+	}
+	#if (-e "$imgdir/boot/") { # Bad test; dir also exists on other systems.
+	#        return 1;
+	#}
         return 0;
 
 } #footprint
Index: pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_ia64.pm
===================================================================
--- pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_ia64.pm	(révision 9443)
+++ pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_ia64.pm	(copie de travail)
@@ -40,10 +40,15 @@
 # Input:        Package path, image path
 # Returns:      Boolean of match
 	my $class=shift;
-        my $imgpath=shift;
-        if (-e "$imgpath/boot/efi") {
-                        return 1;
-        }
+        my $imgdir=shift;
+	# determine architecture (using OS_Detect)
+	my $arch = main::OSCAR::OCA::OS_Detect::detect_arch_file($imgdir,"/bin/arch");
+        # if (-e "$imgpath/boot/efi") { # OL:bad test: efi is also available on x86_64 systems.
+        #                return 1;
+        #}
+        if ($arch eq "ia64") {
+		return 1;
+	}
         return 0;
 
 } #footprint
Index: pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_iseries.pm
===================================================================
--- pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_iseries.pm	(révision 9443)
+++ pkgsrc/systeminstaller-oscar/trunk/lib/SystemInstaller/Image/Kernel_iseries.pm	(copie de travail)
@@ -41,9 +41,13 @@
 	my $class=shift;
         my $imgdir=shift;
 
-        if (-d "/proc/iSeries") {
-                return 1;
-        }
+	my $arch = main::OSCAR::OCA::OS_Detect::detect_arch_file($imgdir,"/bin/arch");
+	if ($arch eq "ppc64") {
+		return 1;
+	}
+        #if (-d "/proc/iSeries") { # OL:Bad test: if head is an iSeries, doesn't iplies image is iSeries as well
+        #        return 1;
+        #}
         return 0;
 
 } #footprint
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Oscar-devel mailing list
Oscar-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oscar-devel

Reply via email to