-defect 2990306 is fixed;

if two or more kernel packages are installed into $rootimg_dir/boot/,
the value of "<$rootimg_dir/boot/vmlinux-*>" will be one array, not a file, 
which can lead to one error for the copy() subroutine in File::Copy.


git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@5835 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2010-04-21 09:36:22 +00:00
parent 25cadc1e29
commit 9ed6596820

View File

@ -525,25 +525,16 @@ sub getlibs {
sub mkinitrd {
mkpath("/tmp/xcatinitrd.$$/bin");
if($basekernelver eq $kernelver) {
if (-f "$rootimg_dir/boot/vmlinuz-$kernelver") {
copy(<$rootimg_dir/boot/vmlinuz-*>,"$destdir/kernel");
} elsif (-f "$rootimg_dir/boot/vmlinux-$kernelver"){
copy(<$rootimg_dir/boot/vmlinux-*>,"$destdir/kernel");
}
}
else {
if(-r "$rootimg_dir/boot/vmlinuz-$kernelver") {
copy("$rootimg_dir/boot/vmlinuz-$kernelver","$destdir/kernel");
} elsif(-r "$rootimg_dir/boot/vmlinux-$kernelver") {
copy("$rootimg_dir/boot/vmlinux-$kernelver","$destdir/kernel");
} elsif(-r "/boot/vmlinuz-$kernelver") {
copy("/boot/vmlinuz-$kernelver","$destdir/kernel");
} elsif(-r "/boot/vmlinux-$kernelver") {#for SLES10,11
copy("/boot/vmlinux-$kernelver","$destdir/kernel");
} else {
xdie("Cannot read /boot/vmlinuz-$kernelver");
}
if(-r "$rootimg_dir/boot/vmlinuz-$kernelver") {
copy("$rootimg_dir/boot/vmlinuz-$kernelver","$destdir/kernel");
} elsif(-r "$rootimg_dir/boot/vmlinux-$kernelver") {
copy("$rootimg_dir/boot/vmlinux-$kernelver","$destdir/kernel");
} elsif(-r "/boot/vmlinuz-$kernelver") {
copy("/boot/vmlinuz-$kernelver","$destdir/kernel");
} elsif(-r "/boot/vmlinux-$kernelver") {#for SLES10,11
copy("/boot/vmlinux-$kernelver","$destdir/kernel");
} else {
xdie("Cannot read /boot/vmlinuz-$kernelver");
}
symlink("bin","/tmp/xcatinitrd.$$/sbin");
mkpath("/tmp/xcatinitrd.$$/usr/bin");
@ -1210,23 +1201,32 @@ sub generic_post { #This function is meant to leave the image in a state approxi
system("sed -i '".'s/^\(TARGETS = .*\)$/\1 gettyset/'."' $rootimg_dir/etc/init.d/.depend.start");
system("ln -s ../gettyset $rootimg_dir/etc/init.d/rc3.d/S60gettyset");
}
# is the following necesary ?
# it seems the kernel file will always be copied in the mkinitrd() subroutine
if(($osver =~ /sles11/) || ($osver =~ /sles10/)) {#for sles11,sles10
if(-e <$rootimg_dir/boot/vmlinux-*>) {
copy(<$rootimg_dir/boot/vmlinux-*>,"$destdir/kernel");
} else {
unless (-e "$destdir/kernel") {
print qq{Error: couldn't find the suitable kernel in $rootimg_dir/boot/ directory and $destdir directory};
if($kernelver) {
if(-e <$rootimg_dir/boot/vmlinux-$kernelver>) {
copy(<$rootimg_dir/boot/vmlinux-$kernelver>,"$destdir/kernel");
} else {
print qq{Error: couldn't find the suitable kernel in $rootimg_dir/boot/ for $kernelver!};
exit 1;
}
} else {
my @files = <$rootimg_dir/boot/vmlinux-*>;
copy($files[0], "$destdir/kernel") if(scalar @files > 0);
}
}else {
if(-e <$rootimg_dir/boot/vmlinuz-*>) {
copy(<$rootimg_dir/boot/vmlinuz-*>,"$destdir/kernel");
} else {
unless (-e "$destdir/kernel") {
print qq{Error: couldn't find the suitable kernel in $rootimg_dir/boot/ directory and $destdir directory};
}else { # is it necessary?
if($kernelver) {
if(-e <$rootimg_dir/boot/vmlinuz-$kernelver>) {
copy(<$rootimg_dir/boot/vmlinuz-*>,"$destdir/kernel");
} else {
print qq{Error: couldn't find the suitable kernel in $rootimg_dir/boot/ for $kernelver!};
exit 1;
}
} else {
my @files = <$rootimg_dir/boot/vmlinuz-*>;
copy($files[0], "$destdir/kernel") if (scalar @files > 0);
}
}
}