diff --git a/xCAT-server-2.0/share/xcat/netboot/rh/genimage b/xCAT-server-2.0/share/xcat/netboot/rh/genimage index 01a646e12..47c2e5a4c 100755 --- a/xCAT-server-2.0/share/xcat/netboot/rh/genimage +++ b/xCAT-server-2.0/share/xcat/netboot/rh/genimage @@ -29,11 +29,12 @@ if ($name =~ /geninitrd/) { } my $rootlimit; my $tmplimit; -my $kernelver = `uname -r`; -my $basekernelver = $kernelver; +my $installroot = "/install"; +my $kernelver = ""; #`uname -r`; +my $basekernelver; # = $kernelver; GetOptions( - #'a=s' => \$architecture, + 'a=s' => \$arch, 'p=s' => \$profile, 'o=s' => \$osver, 'n=s' => \$netdriver, @@ -43,6 +44,21 @@ GetOptions( 't=s' => \$tmplimit, 'k=s' => \$kernelver ); +#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 +my @KVERS= <$installroot/netboot/$osver/$arch/$profile/rootimg/lib/modules/*>; +if (scalar(@KVERS)) { + $basekernelver = basename($KVERS[0]); +} +unless ($basekernelver) { + $basekernelver = `uname -r`; +} +unless ($kernelver) { + $kernelver=$basekernelver; +} chomp($kernelver); unless ($osver and $profile and $netdriver and $prinic) { print 'Usage: genimage -i -n [-r ] -o -p -k '."\n"; @@ -62,7 +78,6 @@ foreach (split /,/,$netdriver) { push @ndrivers,$_; } -my $installroot = "/install"; unless ($onlyinitrd) { my $srcdir = "$installroot/$osver/$arch"; @yumdirs=();