2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-08-16 16:20:22 +00:00

Ensure the requested kernel version and associated packages are installed (#2018)

If a specific version of the kernel was requested, make sure any other
kernel-related packages requested in a package list get the same version.
Note, packages that get pulled in due to dependencies are NOT checked.
Also avoid updating the kernel packages when the requested version has already
been installed.
This commit is contained in:
Matt Ezell
2016-10-25 02:21:06 -04:00
committed by yangsong
parent ee8b418aaf
commit 0c84550441

View File

@@ -367,20 +367,20 @@ unless ($onlyinitrd) {
my $pa = $pkg_hash{$pass}{$_};
my @npa = ();
# replace the kernel package with the name has the specific version
# replace the kernel package (and headers, tools, etc) with the specific version
foreach my $p (@$pa) {
if ($p =~ /^kernel$/ && $kernelver) {
if ($kernelver && $p =~ /^kernel(-headers|-devel|-bootwrapper|-tools)?$/) {
my $kernelname;
if ($krpmver) {
$kernelname = "kernel-" . $krpmver;
$kernelname = $p . "-" . $krpmver;
} else {
$kernelname = "kernel-" . $kernelver;
$kernelname = $p . "-" . $kernelver;
}
my $searchkern = $yumcmd . " list $kernelname -q";
my @kernpkgs = `$searchkern`;
my $found = 0;
foreach my $k (@kernpkgs) {
if ($k =~ /\s*kernel[^\s]*\s+([\w\.-]+)/) {
if ($k =~ /\s*$p\.[^\s]*\s+([\w\.-]+)/) {
my $version = $1;
if ($kernelver =~ /$version/) {
$found++;
@@ -388,7 +388,7 @@ unless ($onlyinitrd) {
}
}
if ($found eq 0) {
print "Cannot find the kernel with version $kernelver.\n";
print "Cannot find the $p package with version $kernelver.\n";
umount_chroot($rootimg_dir);
exit 1;
}
@@ -546,7 +546,9 @@ unless ($onlyinitrd) {
# run yum update to update any installed rpms
# needed when running genimage again after updating software in repositories
my $yumcmd_update = $yumcmd_base . " update ";
# exclude updating the kernel if a specific version was specified
my $excludecmd = $kernelver ? " --exclude=kernel\*" : "";
my $yumcmd_update = $yumcmd_base . $excludecmd . " update ";
$rc = system("$yumcmd_update");
}
}