From ae06a1edcb01c06ea6006a856be9abf2c21cb6bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Mon, 24 Aug 2026 12:00:11 -0300 Subject: [PATCH] fix(anaconda): read the CentOS Linux minor version from the release package Every CentOS Linux 8 medium gives the same description, "CentOS Linux 8". The description gives no minor version. The .treeinfo file on the medium gives no minor version. Thus copycds gave the name centos8 to all of these media. Two CentOS Linux 8 media then wrote into the same /install/centos8 directory and made osimage definitions with the same names. The discinfo identifier table gives the minor version, but it contains only 8.1 and 8.5. The identifiers of an expanded tree are also different from the identifiers of the DVD. The release package in BaseOS/Packages is the only other record of the minor version on the medium. Read the version from the name of that package. CentOS changed the name of the package to centos-linux-release in 8.3, thus accept the two names. Accept only a major.minor version, because other packages start with the same centos-release prefix. Accept only the major version that the description gives, because a package for a different major version does not describe this medium. Accept the minor version only when the medium names one, because a medium that names more than one does not pin a minor version. Keep the version from the description in the other conditions. A medium that names no minor version keeps the name centos8, which is the behaviour before this change and the correct name for media that do not pin a minor version. CentOS Stream, Rocky Linux, AlmaLinux and Red Hat Enterprise Linux keep their own branches. CentOS Linux 7 gives a different description and has no BaseOS directory, thus it does not use this path. Recovered from the lenovobuild branch. Reimplemented against master: the original reads only centos-release, which CentOS renamed in 8.3, and its expression is not anchored. --- xCAT-server/lib/xcat/plugins/anaconda.pm | 32 ++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 87ec419cc..06a32cb6b 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -56,6 +56,34 @@ sub _oracle_linux_distname } +sub _centos_linux_distname +{ + my ($desc, $mntpath) = @_; + + return unless defined($desc) and $desc =~ /CentOS Linux (.*)/; + + my $version = $1; + my ($major) = $version =~ /^(\d+)/; + + if (defined($major) + and defined($mntpath) + and opendir(my $pkgdir, "$mntpath/BaseOS/Packages")) + { + my %candidate; + foreach my $rpm (readdir($pkgdir)) { + $candidate{$1} = 1 + if $rpm =~ /^centos(?:-linux)?-release-(\Q$major\E\.\d+)-.+\.rpm$/; + } + closedir($pkgdir); + + my @minor = keys %candidate; + $version = $minor[0] if scalar(@minor) == 1; + } + + return "centos$version"; +} + + sub handled_commands { return { @@ -2115,8 +2143,8 @@ sub copycd { $distname = $xCAT::data::discinfo::distnames{$did}; } - } elsif ($desc and $desc =~ /CentOS Linux (.*)/) { - $distname = "centos" . $1; + } elsif (my $centos_distname = _centos_linux_distname($desc, $mntpath)) { + $distname = $centos_distname; } elsif ($desc and $desc =~ /CentOS Stream (.*)/) { $distname = "centos-stream" . $1; } elsif ($desc and $desc =~ /Rocky Linux (.*)/) {