From 152777a64e27aaeca1d424ba5cb94345c1e313a8 Mon Sep 17 00:00:00 2001 From: mxi1 Date: Mon, 27 Sep 2010 09:09:50 +0000 Subject: [PATCH] update the code to handle the kernel in genimage git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7667 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/share/xcat/netboot/rh/genimage | 20 +++++----- xCAT-server/share/xcat/netboot/sles/genimage | 42 +++++++++----------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/xCAT-server/share/xcat/netboot/rh/genimage b/xCAT-server/share/xcat/netboot/rh/genimage index e8e177a3a..ff4e50780 100755 --- a/xCAT-server/share/xcat/netboot/rh/genimage +++ b/xCAT-server/share/xcat/netboot/rh/genimage @@ -468,14 +468,22 @@ if ($kernelver ne $basekernelver) { if ( -e "/lib/modules/$kernelver" ) { system("cp -r -a /lib/modules/$kernelver $rootimg_dir/lib/modules/"); - if ($basekernelver) { - system("rm -rf $rootimg_dir/lib/modules/$basekernelver/"); - } } else { xdie("couldn't find /lib/modules/$kernelver"); } } +# copy the kernel to $destdir +if ( -e "$rootimg_dir/boot/vmlinux-$kernelver") { + cp("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); +} elsif ( -e "$rootimg_dir/boot/vmlinuz-$kernelver") { + cp("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); +} elsif ( -e "$rootimg_dir/boot/image-$kernelver") { + cp("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); +} else { + xdie("couldn't find the kernel file matched $kernelver in $rootimg_dir/boot"); +} + # Load driver update disk, and copy them to the root image my @dd_drivers = &load_dd(); @@ -1454,12 +1462,6 @@ sub generic_post { #This function is meant to leave the image in a state approxi system("cd $rootimg_dir/etc/rc3.d; ln -sf ../init.d/xcatpostinit S61xcatpostinit"); } - if ( -e "$rootimg_dir/boot/vmlinuz-$kernelver" ) { - copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); - } else { - xdie "couldn't find vmlinuz-$kernelver under $rootimg/boot."; - } - } diff --git a/xCAT-server/share/xcat/netboot/sles/genimage b/xCAT-server/share/xcat/netboot/sles/genimage index 58ec9c98f..88de76666 100755 --- a/xCAT-server/share/xcat/netboot/sles/genimage +++ b/xCAT-server/share/xcat/netboot/sles/genimage @@ -9,7 +9,7 @@ use lib "../imgutils"; use File::Basename; use File::Path; -use File::Copy; +use File::Copy qw/copy cp mv move/; use File::Find; use Getopt::Long; use Cwd qw(realpath); @@ -514,20 +514,19 @@ unless ($basekernelver) { @KVERS=<$rootimg_dir/lib/modules/*> unless (scalar @KVERS); $basekernelver = basename(pop @KVERS) if (scalar @KVERS); $basekernelver = `uname -r` unless ($basekernelver); - - $kernelver = $basekernelver unless ($kernelver); - chomp $kernelver; - $updates{kernelver} = $kernelver if ($needUpdateTable); - } +$kernelver = $basekernelver unless ($kernelver); +chomp $kernelver; +$updates{kernelver} = $kernelver if ($needUpdateTable); + + if ($kernelver ne $basekernelver) { # if "-k" is specified, the kernel file should be in the "/boot" directory (not in the rootimg chroot environment) # the modules should be in /lib/modules/$kernelver if ( -e "/boot/vmlinux-$kernelver") { copy("/boot/vmlinux-$kernelver", "$rootimg_dir/boot/"); - system("cp -r /lib/modules/$kernelver $rootimg_dir/lib/modules/"); } elsif ( -e "/boot/vmlinuz-$kernelver") { copy("/boot/vmlinuz-$kernelver", "$rootimg_dir/boot/"); } elsif ( -e "/boot/image-$kernelver") { @@ -535,16 +534,25 @@ if ($kernelver ne $basekernelver) { } else { xdie "couldnot find the kernel file matched $kernelver in /boot!"; } + if ( -e "/lib/modules/$kernelver" ) { system("cp -r /lib/modules/$kernelver $rootimg_dir/lib/modules/"); - if($basekernelver) { - system("rm -rf $rootimg_dir/lib/modules/$basekernelver/"); - } } else { xdie "couldnot find /lib/modules/$kernelver!"; } } +# copy the kernel to $destdir +if ( -e "$rootimg_dir/boot/vmlinux-$kernelver") { + copy("$rootimg_dir/boot/vmlinux-$kernelver", "$destdir/kernel"); +} elsif ( -e "$rootimg_dir/boot/vmlinuz-$kernelver") { + copy("$rootimg_dir/boot/vmlinuz-$kernelver", "$destdir/kernel"); +} elsif ( -e "$rootimg_dir/boot/image-$kernelver") { + copy("$rootimg_dir/boot/image-$kernelver", "$destdir/kernel"); +} else { + xdie "couldn't find the kernel file matched $kernelver in $rootimg_dir/boot !"; +} + #-- run postinstall script unless ($imagename) { $postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall"); @@ -572,7 +580,7 @@ if ($needUpdateTable) { # now, update the linuximage and osimage tables # TODO: do statelite and stateless share the same attributes? currently, I will update both of them if ($imagename) { - $keychain{'imagename'} = $imagename; + $keyhash{'imagename'} = $imagename; $linuximagetab->setAttribs(\%keyhash, \%updates); $linuximagetab->commit; } else { @@ -720,18 +728,6 @@ sub mkinitrd { } - if(-r "$rootimg_dir/boot/vmlinux-$kernelver") { # SLES use vmlinux-* as its name - copy("$rootimg_dir/boot/vmlinux-$kernelver","$destdir/kernel"); - } elsif(-r "$rootimg_dir/boot/vmlinuz-$kernelver") { # OpenSuSE maight use vmlinuz-* as its name - copy("$rootimg_dir/boot/vmlinuz-$kernelver","$destdir/kernel"); - } elsif(-r "$rootimg_dir/boot/image-$kernelver") { # SLES on s390x use image-* as its name - copy("$rootimg_dir/boot/image-$kernelver","$destdir/kernel"); - } else { - xdie("Cannot find suitable kernel file for $kernelver"); - } - - - mkpath("/tmp/xcatinitrd.$$/bin"); symlink("bin","/tmp/xcatinitrd.$$/sbin"); mkpath("/tmp/xcatinitrd.$$/usr/bin");