defect 3369: to add the flag -g for genimage command like for sles that make rh could handle the case that the kernel version is different with the name of kernel rpm when using -k to specify a new kernel version.

This commit is contained in:
daniceexi 2013-10-24 08:05:29 -04:00
parent 2ff2cfe4e2
commit 0c5aa5d8bf
3 changed files with 10 additions and 13 deletions

View File

@ -132,7 +132,7 @@ in the install image.
=item B<-g> I<krpmver>
This flag is for SLES only. Use this flag to specify the rpm version for kernel packages in the image. It must be present if -k flag is specified in the command for SLES.
Use this flag to specify the rpm version for kernel packages in the image. It must be present if -k flag is specified in the command for SLES. Generally, the value of -g is the part after B<linux-> and before B<.rpm> in a kernel rpm name.
=item B<-m> statelite

View File

@ -270,14 +270,6 @@ sub process_request {
return 1;
}
if ($krpmver) {
if ($osfamily ne "sles") {
$krpmver="";
$callback->({error=>["-g flag is valid for Sles only."],errorcode=>[1]});
return 1;
}
}
my $cmd="cd $profDir; ./genimage";
if ($arch) { $cmd .= " -a $arch";}
if ($osver) { $cmd .= " -o $osver";}

View File

@ -48,6 +48,7 @@ my $tmplimit;
my $installroot = "/install";
my $kerneldir;
my $kernelver = ""; #`uname -r`;
my $krpmver;
my $basekernelver; # = $kernelver;
my $customdir=$fullpath;
$customdir =~ s/.*share\/xcat/$installroot\/custom/;
@ -80,6 +81,7 @@ GetOptions(
'l=s' => \$rootlimit,
't=s' => \$tmplimit,
'k=s' => \$kernelver,
'g=s' => \$krpmver,
'permission=s' => \$permission,
'kerneldir=s' => \$kerneldir,
'tempfile=s' =>\$tempfile, #internal flag
@ -266,16 +268,19 @@ unless ($onlyinitrd) {
# replace the kernel package with the name has the specific version
foreach my $p (@$pa) {
if ($p =~ /^kernel$/ && $kernelver) {
my $kernelname = "kernel-".$kernelver;
my $kernelname;
if ($krpmver) {
$kernelname = "kernel-".$krpmver;
} else {
$kernelname = "kernel-".$kernelver;
}
my $searchkern = $yumcmd . " list $kernelname -q";
my @kernpkgs = `$searchkern`;
my $found = 0;
foreach my $k (@kernpkgs) {
if ($k =~ /\s*kernel[^\s]*\s+([\w\.-]+)/) {
my $version = $1;
my $relversion = $kernelver;
$relversion =~ s/\.[^\.]+$//;
if ($version == $relversion) {
if ($kernelver =~ /$version/) {
$found++;
}
}