for defect 3072164,

move the code related with kernel selection out of "unless($onlyinitrd)" block.

    the code for sles and redhat  is all udpated.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7639 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2010-09-25 09:54:06 +00:00
parent 28ec23dc21
commit 9ce6102a4a
2 changed files with 117 additions and 118 deletions

View File

@ -426,54 +426,55 @@ unless ($onlyinitrd) {
$rc = system("$yumcmd_update");
# ignore any return code
# Default to the first kernel found in the install image if nothing specified explicitly.
# A more accurate guess than whatever the image build server happens to be running
# If specified, that takes precedence.
# if image has one, that is used
# if all else fails, resort to uname -r like this script did before
# Kernel name for s390x should be the same: vmlinuz-2.6.18-164.el5
my @KVERS= <$rootimg_dir/boot/vmlinuz-*>;
foreach (@KVERS) {
s/vmlinuz-//;
}
@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);
if ($kernelver ne $basekernelver) {
# the kernelver is specified by "-k",
# the kernel file should be in /boot
# the moudles should be in /lib/modules/$kernelver
if ( -e "/boot/vmlinux-$kernelver") {
copy("/boot/vmlinux-$kernelver", "$rootimg_dir/boot/");
} elsif ( -e "/boot/vmlinuz-$kernelver") {
copy("/boot/vmlinuz-$kernelver", "$rootimg_dir/boot/");
} elsif ( -e "/boot/image-$kernelver" ) {
copy("/boot/image-$kernelver", "$rootimg_dir/boot/");
} else {
xdie("couldn't find the kernel file matched $kernelver in /boot");
}
if ( -e "/lib/modules/$kernelver" ) {
system("cp -r -a /lib/modules/$kernelver $rootimg_dir/lib/modules/");
} else {
xdie("couldn't find /lib/modules/$kernelver");
}
}
postscripts(); #run 'postscripts'
}
# Default to the first kernel found in the install image if nothing specified explicitly.
# A more accurate guess than whatever the image build server happens to be running
# If specified, that takes precedence.
# if image has one, that is used
# if all else fails, resort to uname -r like this script did before
# Kernel name for s390x should be the same: vmlinuz-2.6.18-164.el5
my @KVERS= <$rootimg_dir/boot/vmlinuz-*>;
foreach (@KVERS) {
s/vmlinuz-//;
}
@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);
if ($kernelver ne $basekernelver) {
# the kernelver is specified by "-k",
# the kernel file should be in /boot
# the moudles should be in /lib/modules/$kernelver
if ( -e "/boot/vmlinux-$kernelver") {
copy("/boot/vmlinux-$kernelver", "$rootimg_dir/boot/");
} elsif ( -e "/boot/vmlinuz-$kernelver") {
copy("/boot/vmlinuz-$kernelver", "$rootimg_dir/boot/");
} elsif ( -e "/boot/image-$kernelver" ) {
copy("/boot/image-$kernelver", "$rootimg_dir/boot/");
} else {
xdie("couldn't find the kernel file matched $kernelver in /boot");
}
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");
}
}
# Load driver update disk, and copy them to the root image
my @dd_drivers = &load_dd();
@ -635,11 +636,9 @@ if ($dracutmode) {
# before mkinitrd, run depmod to generate modules.dep
system("chroot $rootimg_dir depmod $kernelver");
# TODO: for the genimage-enchement, need to create two initial ramdisks,
# for the genimage-enchement, need to create two initial ramdisks,
# one is for stateless
# the other one is for statelite
# move the load_dd() and @ndrivers-related code here
if ($dracutmode) {
mkinitrd_dracut("statelite");

View File

@ -164,7 +164,6 @@ if (@ARGV > 0 and $needUpdateTable eq 1) {
$pkglist = $ref_linuximage_tab->{'pkglist'};
$srcdir = $ref_linuximage_tab->{'pkgdir'};
$srcdir = "$srcdir/1" if ($srcdir);
$srcdir_otherpkgs = $ref_linuximage_tab->{'otherpkgdir'};
$otherpkglist = $ref_linuximage_tab->{'otherpkglist'};
$postinstall_filename = $ref_linuximage_tab->{'postinstall'};
@ -471,80 +470,81 @@ unless ($onlyinitrd) {
$rc = system("$yumcmd_update");
# ignore any return code
#$kernelver = $basekernelver unless($kernelver);
#$updates{'kernelver'} = $kernelver if ($needUpdateTable);
if ($kernelver) {
# 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") {
copy("/boot/image-$kernelver", "$rootimg_dir/boot/");
} 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/");
} else {
xdie "couldnot find /lib/modules/$kernelver!";
}
} else {
# default to the first kernel found in the install image if nothing specified explicitly.
# A more accurate guess than whatever the image build server happens to be running
# If specified, that takes precedence.
# If image has one, that is used
# If all else fails, resort to uname -r like this script did before
if ( -e "$rootimg_dir/boot/vmlinux" ) {
$basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux");
if ($basekernelver eq "vmlinux") {
$basekernelver = "";
} else {
$basekernelver =~ s/vmlinu.-//;
$basekernelver =~ s/image-//;
}
}
unless ($basekernelver) {
my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>;
# The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default
@KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x";
foreach (@KVERS) {
s/vmlinu.-//;
s/image-//;
}
unless (scalar @KVERS) {
@KVERS = <$rootimg_dir/lib/modules/*>;
}
if (scalar @KVERS) {
foreach my $kver (@KVERS) {
unless ($kver =~ m/.gz$/) {
$basekernelver = basename($kver);
last;
}
}
}
unless($basekernelver) {
xdie "couldnot find the kernel file in root image, please make sure kernel package is in your pkglist!";
}
}
chomp $basekernelver;
$kernelver = $basekernelver;
$updates{kernelver} = $kernelver if ($needUpdateTable);
}
postscripts(); #run 'postscripts'
}
unlink "/tmp/genimage.$$.yum.conf";
# default to the first kernel found in the install image if nothing specified explicitly.
# A more accurate guess than whatever the image build server happens to be running
# If specified, that takes precedence.
# If image has one, that is used
# If all else fails, resort to uname -r like this script did before
if ( -e "$rootimg_dir/boot/vmlinux" ) {
$basekernelver = basename(readlink "$rootimg_dir/boot/vmlinux");
if ($basekernelver eq "vmlinux") {
$basekernelver = "";
} else {
$basekernelver =~ s/vmlinu.-//;
$basekernelver =~ s/image-//;
}
}
unless ($basekernelver) {
my @KVERS = <$rootimg_dir/boot/vmlinu[xz]-*>;
# The kernel name is different on s390x, e.g. image-2.6.32.9-0.5-default
@KVERS = <$rootimg_dir/boot/image-*> if $arch eq "s390x";
foreach (@KVERS) {
s/vmlinu.-//;
s/image-//;
}
unless (scalar @KVERS) {
@KVERS = <$rootimg_dir/lib/modules/*>;
}
if (scalar @KVERS) {
foreach my $kver (@KVERS) {
unless ($kver =~ m/.gz$/) {
$basekernelver = basename($kver);
last;
}
}
}
@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);
}
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") {
copy("/boot/image-$kernelver", "$rootimg_dir/boot/");
} 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!";
}
}
#-- run postinstall script
unless ($imagename) {
$postinstall_filename= imgutils::get_profile_def_filename($osver, $profile, $arch, $customdir, "postinstall");