for defect 3203276 and 3170932,

added a new attribute ("kerneldir") in linuximage table;
    The 3rd-party kernel rpm package should be installed into the kerneldir.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9175 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
mxi1 2011-03-28 07:39:59 +00:00
parent 02a1175afb
commit dd26e8d03f
3 changed files with 47 additions and 58 deletions

View File

@ -602,7 +602,7 @@ osimage => {
},
},
linuximage => {
cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir nodebootif otherifce netdrivers kernelver permission dump comments disable)],
cols => [qw(imagename template pkglist pkgdir otherpkglist otherpkgdir exlist postinstall rootimgdir kerneldir nodebootif otherifce netdrivers kernelver permission dump comments disable)],
keys => [qw(imagename)],
table_desc => 'Information about a Linux operating system image that can be used to deploy cluster nodes.',
descriptions => {
@ -615,6 +615,7 @@ linuximage => {
exlist => 'The fully qualified name of the file that stores the file names and directory names that will be excluded from the image during packimage command. It is used for diskless image only.',
postinstall => 'The fully qualified name of the script file that will be run at the end of the packimage command. It is used for diskless image only.',
rootimgdir => 'The directory name where the image is stored. It is used for diskless image only.',
kerneldir => 'The directory name where the 3rd-party kernel is stored. It is used for diskless image only.',
nodebootif => 'The network interface the stateless/statelite node will boot over (e.g. eth0)',
otherifce => 'Other network interfaces (e.g. eth1) in the image that should be configured via DHCP',
netdrivers => 'the ethernet device drivers of the nodes which will use this linux image, at least the device driver for the nodes\' installnic should be included',
@ -1891,6 +1892,11 @@ push(@{$defspec{node}->{'attrs'}}, @nodeattrs);
tabentry => 'linuximage.rootimgdir',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'kerneldir',
only_if => 'imagetype=linux',
tabentry => 'linuximage.kerneldir',
access_tabentry => 'linuximage.imagename=attr:imagename',
},
{attr_name => 'nodebootif',
only_if => 'imagetype=linux',
tabentry => 'linuximage.nodebootif',

View File

@ -41,6 +41,7 @@ if ($name =~ /geninitrd/) {
my $rootlimit;
my $tmplimit;
my $installroot = "/install";
my $kerneldir;
my $kernelver = ""; #`uname -r`;
my $basekernelver; # = $kernelver;
my $customdir=$fullpath;
@ -119,7 +120,7 @@ if (@ARGV > 0 and $needUpdateTable eq 1) {
exit 1;
}
($ref_linuximage_tab) = $linuximagetab->getAttribs({imagename => $imagename}, 'pkglist', 'pkgdir', 'otherpkglist', 'otherpkgdir', 'postinstall', 'rootimgdir', 'nodebootif', 'otherifce', 'kernelver', 'netdrivers', 'permission');
($ref_linuximage_tab) = $linuximagetab->getAttribs({imagename => $imagename}, 'pkglist', 'pkgdir', 'otherpkglist', 'otherpkgdir', 'postinstall', 'rootimgdir', 'kerneldir', 'nodebootif', 'otherifce', 'kernelver', 'netdrivers', 'permission');
unless ($ref_linuximage_tab) {
print "Cannot find $imagename from the linuximage table\n";
exit 1;
@ -151,6 +152,7 @@ if (@ARGV > 0 and $needUpdateTable eq 1) {
$otherpkglist = $ref_linuximage_tab->{'otherpkglist'};
$postinstall_filename = $ref_linuximage_tab->{'postinstall'};
$destdir = $ref_linuximage_tab->{'rootimgdir'};
$kerneldir = $ref_linuximage_tab->{'kerneldir'};
# TODO: how can we do if the user specifies one wrong value to the following attributes?
# currently, one message is output to indicate the users there will be some updates
@ -216,6 +218,9 @@ $updates{'rootimgdir'} = $destdir if ($needUpdateTable);
$rootimg_dir="$destdir/rootimg";
$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels";
$updates{'kerneldir'} = $kerneldir if ($needUpdateTable);
# Get the subchannels of the given interface
my $subchn;
my $readChn;
@ -455,22 +460,20 @@ $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");
}
# the files in the entire kernel rpm package must be put in ${linuximage.kerneldir},
# the default value for ${linuximage.kerneldir} is "$installroot/kernels";
if ( -e "/lib/modules/$kernelver" ) {
system("cp -r -a /lib/modules/$kernelver $rootimg_dir/lib/modules/");
} else {
xdie("couldn't find /lib/modules/$kernelver");
if ( -d "$kerneldir/$kernelver" ) {
# return one error if the directory is empty
my @kernelfiles = <$kerneldir/$kernelver/*>;
if (scalar @kernelfiles) {
# remove the kernel files for the basekernelver
unlink <$rootimg_dir/boot/*$basekernelver*>;
system("rm -rf $rootimg_dir/lib/modules/$basekernelver");
system("cp -r -a $kerneldir/$kernelver/* $rootimg_dir/");
} else {
xdie("couldnot find the kernel files matched $kernelver in $kerneldir/$kernelver !");
}
}
}
@ -744,7 +747,7 @@ sub mkinitrd_dracut {
}
system("chroot $rootimg_dir dracut -f /tmp/initrd.$$.gz $kernelver");
print "the initial ramdisk is generated successfully.\n";
print "the initial ramdisk for $mode is generated successfully.\n";
move("$rootimg_dir/tmp/initrd.$$.gz", "$destdir/initrd-$mode.gz");
}
@ -1270,16 +1273,6 @@ EOMS
}
push @filestoadd,keys %libhash;
if($basekernelver ne $kernelver) {
system("rm -rf $rootimg_dir/lib/modules/$basekernelver");
unless (-d "$rootimg_dir/lib/modules/$kernelver") {
if(-d "/lib/modules/$kernelver") {
system("cd /lib/modules;cp -r $kernelver $rootimg_dir/lib/modules/");
} else {
xdie("Cannot read /lib/modules/$kernelver");
}
}
}
find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>);
foreach (@filestoadd) {

View File

@ -40,6 +40,7 @@ if ($name =~ /geninitrd/) {
my $rootlimit;
my $tmplimit;
my $installroot = "/install";
my $kerneldir;
my $kernelver = "";
my $basekernelver;
my $customdir=$fullpath;
@ -136,7 +137,7 @@ if (@ARGV > 0 and $needUpdateTable eq 1) {
exit 1;
}
(my $ref_linuximage_tab) = $linuximagetab->getAttribs({imagename => $imagename}, 'pkglist', 'pkgdir', 'otherpkglist', 'otherpkgdir', 'postinstall', 'rootimgdir', 'nodebootif', 'otherifce', 'kernelver', 'netdrivers', 'permission');
(my $ref_linuximage_tab) = $linuximagetab->getAttribs({imagename => $imagename}, 'pkglist', 'pkgdir', 'otherpkglist', 'otherpkgdir', 'postinstall', 'rootimgdir', 'kerneldir', 'nodebootif', 'otherifce', 'kernelver', 'netdrivers', 'permission');
unless ($ref_linuximage_tab) {
print "Cannot find $imagename from the linuximage table\n";
exit 1;
@ -168,6 +169,7 @@ if (@ARGV > 0 and $needUpdateTable eq 1) {
$otherpkglist = $ref_linuximage_tab->{'otherpkglist'};
$postinstall_filename = $ref_linuximage_tab->{'postinstall'};
$destdir = $ref_linuximage_tab->{'rootimgdir'};
$kerneldir = $ref_linuximage_tab->{'kerneldir'};
# TODO: how can we do if the user specifies one wrong value to the following attributes?
# currently, one message is output to indicate the users there will be some updates
@ -236,6 +238,8 @@ $destdir="$installroot/netboot/$osver/$arch/$profile" unless ($destdir);
$updates{'rootimgdir'} = $destdir if ($needUpdateTable);
$rootimg_dir="$destdir/rootimg";
$kerneldir = "$installroot/kernels" unless ($kerneldir); # the default directory for 3rd-party kernel is "$installroot/kernels";
$updates{'kerneldir'} = $kerneldir if ($needUpdateTable);
unless ($osver and $profile) {
print 'Usage: genimage -i <nodebootif> -n <nodenetdrivers> [-r <otherifaces>] -k <KERNELVER> -o <OSVER> -p <PROFILE> [-a <ARCH>] [-l rootlimitsize] [-t tmplimitsize] [--permission <permission>]'."\n";
@ -534,25 +538,21 @@ $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/");
} 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!";
# the files in the entire kernel rpm package must be put in ${linuximage.kerneldir},
# the default value for ${linuximage.kerneldir} is "$installroot/kernels";
if ( -d "$kerneldir/$kernelver" ) {
# return one error if the directory is empty
my @kernelfiles = <$kerneldir/$kernelver/*>;
if (scalar @kernelfiles) {
# remove the kernel files for the basekernelver
unlink <$rootimg_dir/boot/*$basekernelver*>;
system("rm -rf $rootimg_dir/lib/modules/$basekernelver");
system("cp -r -a $kerneldir/$kernelver/* $rootimg_dir/");
} else {
xdie("couldnot find the kernel files matched $kernelver in $kerneldir/$kernelver !");
}
}
}
@ -1240,17 +1240,7 @@ END
push @filestoadd,keys %libhash;
if($basekernelver ne $kernelver) {
system("rm -rf $rootimg_dir/lib/modules/$basekernelver");
unless (-d "$rootimg_dir/lib/modules/$kernelver") {
if(-d "/lib/modules/$kernelver") {
system("cd /lib/modules;cp -r $kernelver $rootimg_dir/lib/modules/");
}
else {
xdie("Cannot read /lib/modules/$kernelver");
}
}
}
find(\&isnetdriver, <$rootimg_dir/lib/modules/$kernelver/*>);
foreach (@filestoadd) {
if (ref($_)) {