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
This commit is contained in:
mxi1 2010-09-27 09:09:50 +00:00
parent 43824e8111
commit 152777a64e
2 changed files with 30 additions and 32 deletions

View File

@ -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.";
}
}

View File

@ -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");