2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-09-28 08:10:53 +00:00

fix(genesis): close consumer review gaps

This commit is contained in:
Vinícius Ferrão
2026-08-24 22:54:48 -03:00
parent f853d52b98
commit 719e5aecab
4 changed files with 108 additions and 15 deletions
+27 -5
View File
@@ -68,6 +68,31 @@ sub handled_commands
};
}
sub _find_genesis_boot_files
{
my ($tftpdir, $arch) = @_;
return unless defined($arch) && $arch =~ /\A[A-Za-z0-9_]+\z/;
my $directory = "$tftpdir/xcat";
my $kernel = "genesis.kernel.$arch";
return unless -r "$directory/$kernel";
my $lzma = "genesis.fs.$arch.lzma";
my $gzip = "genesis.fs.$arch.gz";
my $initrd;
if (-r "$directory/$lzma" && -r "$directory/$gzip") {
$initrd = -C "$directory/$lzma" > -C "$directory/$gzip"
? $gzip
: $lzma;
} elsif (-r "$directory/$lzma") {
$initrd = $lzma;
} elsif (-r "$directory/$gzip") {
$initrd = $gzip;
}
return unless defined($initrd);
return ($kernel, $initrd);
}
sub preprocess_request
{
my $req = shift;
@@ -1854,12 +1879,9 @@ sub mksysclone
=cut
my $ramdisk_size = 200000;
my $kernpath = `ls -l $tftpdir/xcat/|grep "genesis.kernel.$arch"|awk '{print \$9}'`;
chomp($kernpath);
my $initrdpath = `ls -l $tftpdir/xcat/|grep "genesis.fs.$arch"| awk '{print \$9}'`;
chomp($initrdpath);
my ($kernpath, $initrdpath) = _find_genesis_boot_files($tftpdir, $arch);
if ($kernpath ne '' and $initrdpath ne '')
if (defined($kernpath) && defined($initrdpath))
{
#We have a shot...
my $ent = $rents{$node}->[0];
+46
View File
@@ -270,6 +270,29 @@ sub _install_prebuilt_genesis {
return ("$destination_dir/genesis.fs.$arch.gz", undef);
}
sub _remove_openembedded_genesis {
my ($tftpdir, $requested_arch) = @_;
return (0, 'Missing Genesis architecture') unless defined($requested_arch);
my $arch = $requested_arch eq 'ppc64el' ? 'ppc64le' : $requested_arch;
return (0, "Unsupported Genesis architecture: $requested_arch")
unless $GENESIS_ARCHITECTURES{$arch};
my $directory = "$tftpdir/xcat";
my @artifacts = (
"$directory/genesis.kernel.$arch",
"$directory/genesis.fs.$arch.gz",
"$directory/genesis.fs.$arch.lzma",
);
my $removed = 0;
foreach my $artifact (@artifacts) {
next unless -e $artifact || -l $artifact;
return ($removed, "Unable to remove Genesis artifact: $artifact")
unless unlink($artifact);
$removed++;
}
return ($removed, undef);
}
sub genesis_lzma_command {
my ($have_lzma, $have_xz) = @_;
return 'lzma -C crc32 -9' if $have_lzma;
@@ -371,6 +394,29 @@ sub process_request {
return;
}
my $canonical_arch = $requested_arch eq 'ppc64el'
? 'ppc64le'
: $requested_arch;
if (($request->{arg}->[1] // '') eq '--remove-openembedded') {
unless ($GENESIS_ARCHITECTURES{$canonical_arch}) {
$callback->({ error => "Unsupported Genesis architecture: $requested_arch", errorcode => [1] });
return;
}
my $source = "$::XCATROOT/share/xcat/netboot/genesis-openembedded/$canonical_arch";
if (-d $source || -l $source) {
$callback->({ error => "Cannot remove boot artifacts while OpenEmbedded Genesis $canonical_arch is installed", errorcode => [1] });
return;
}
my ($removed, $remove_error) =
_remove_openembedded_genesis($tftpdir, $canonical_arch);
if ($remove_error) {
$callback->({ error => $remove_error, errorcode => [1] });
return;
}
$callback->({ data => "Removed $removed OpenEmbedded Genesis artifacts for $canonical_arch" });
return;
}
my ($genesis_dir, $arch, $genesis_type) =
_select_genesis_source($::XCATROOT, $requested_arch);
unless (defined($genesis_dir) && -d $genesis_dir) {
+2 -1
View File
@@ -2007,7 +2007,7 @@ sub _installed_genesis_architectures
while (my $entry = readdir($dh)) {
next unless $supported{$entry};
my $path = "$openembedded/$entry";
$installed{$entry} = 1 if -d $path;
$installed{$entry} = 1 if -d $path && !-l $path;
}
closedir($dh);
}
@@ -2029,6 +2029,7 @@ sub _genesis_architectures_to_build
return grep {
-d "$xcatroot/share/xcat/netboot/genesis-openembedded/$_"
&& !-l "$xcatroot/share/xcat/netboot/genesis-openembedded/$_"
} @installed;
}
+33 -9
View File
@@ -1345,6 +1345,7 @@ function add_repo_by_url_yum_or_zypper()
[[ "$1" = "-y" ]] && yes=("-y") && shift
local url="$1"
local repo_id="$2"
local policy="${3:-}"
local tmp=""
local install_path="${GO_XCAT_DEFAULT_INSTALL_PATH}"
case "${url%%://*}" in
@@ -1361,7 +1362,8 @@ function add_repo_by_url_yum_or_zypper()
;;
*) # assume it is the base url of the repo
tmp="${TMP_DIR}/tmp_repo.repo"
while read -r ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF
{
while read -r ; do echo "${REPLY}" ; done <<-EOF
[${repo_id}]
name=${repo_id}
baseurl=${url%/}
@@ -1369,6 +1371,11 @@ function add_repo_by_url_yum_or_zypper()
gpgcheck=1
gpgkey=${url%/}/repodata/repomd.xml.key
EOF
if [[ "${policy}" = "optional" ]]; then
echo "repo_gpgcheck=1"
echo "skip_if_unavailable=1"
fi
} >"${tmp}"
add_repo_by_file "${tmp}" "${repo_id}"
return "$?"
;;
@@ -1397,15 +1404,22 @@ function add_repo_by_url_yum_or_zypper()
[[ "${url:0:1}" = "/" ]] || url="${PWD}/${url}"
# directory
tmp="${TMP_DIR}/tmp_repo.repo"
while read -r ; do echo "${REPLY}" ; done >"${tmp}" <<-EOF
{
while read -r ; do echo "${REPLY}" ; done <<-EOF
[${repo_id}]
name=${repo_id}
baseurl=file://${url%/}
enabled=1
EOF
if [[ "${policy}" = "optional" ]]; then
echo "skip_if_unavailable=1"
fi
} >"${tmp}"
if [ -f "${url%/}/repodata/repomd.xml.asc" ]
then
echo "gpgcheck=1" >>"${tmp}"
[[ "${policy}" != "optional" ]] \
|| echo "repo_gpgcheck=1" >>"${tmp}"
else
echo "gpgcheck=0" >>"${tmp}"
fi
@@ -1614,7 +1628,6 @@ function add_xcat_dep_common_repo_yum_or_zypper()
local ver="$2"
local common_url=""
local metadata=""
local repo_id=""
[[ -z "${ver}" ]] && ver="latest"
[[ -z "${url}" ]] &&
@@ -1645,12 +1658,22 @@ function add_xcat_dep_common_repo_yum_or_zypper()
;;
esac
add_repo_by_url_yum_or_zypper "${common_url}" "xcat-dep-common" || return 0
for repo_id in "${GO_XCAT_DEP_REPOSITORY_IDS[@]}"
do
[[ "${repo_id}" == "xcat-dep-common" ]] && return 0
done
GO_XCAT_DEP_REPOSITORY_IDS+=(xcat-dep-common)
add_repo_by_url_yum_or_zypper \
"${common_url}" "xcat-dep-common" optional || return 0
}
function xcat_dep_common_repo_configured()
{
[[ -f /etc/yum.repos.d/xcat-dep-common.repo \
|| -f /etc/zypp/repos.d/xcat-dep-common.repo ]]
}
function refresh_xcat_dep_repository_ids()
{
GO_XCAT_DEP_REPOSITORY_IDS=(xcat-dep)
xcat_dep_common_repo_configured \
&& GO_XCAT_DEP_REPOSITORY_IDS+=(xcat-dep-common)
:
}
function add_xcat_dep_repo_yum_or_zypper()
@@ -2521,6 +2544,7 @@ then
boo_boo_if_bad "${RET}"
fi
echo "done"
refresh_xcat_dep_repository_ids
case "${GO_XCAT_ACTION}" in
"check")