From 7fdb9cac79e6008c5862b173517fbbbe90eabd0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Fri, 27 Nov 2026 01:02:58 -0300 Subject: [PATCH] test(genesis): restore native openEuler build fixtures Use the current Genesis source directory and stage the payload verifier with its Perl module through the existing build helper. Supply the OpenSSL configuration and native awk required by the module. Keep private Perl libraries available with ownership the build namespace can preserve. --- xCAT-test/native/genesis_openeuler.t | 11 ++++-- xCAT-test/native/genesis_openeuler_release.t | 40 +++++++++++--------- 2 files changed, 30 insertions(+), 21 deletions(-) diff --git a/xCAT-test/native/genesis_openeuler.t b/xCAT-test/native/genesis_openeuler.t index 80ae195080..1e134324e2 100644 --- a/xCAT-test/native/genesis_openeuler.t +++ b/xCAT-test/native/genesis_openeuler.t @@ -11,8 +11,8 @@ plan skip_all => 'Linux native RPM and user namespace tools required' unless $^O eq 'linux' && system('sh', '-c', 'command -v rpmspec >/dev/null && command -v unshare >/dev/null') == 0; my $root = abs_path("$RealBin/../.."); -my $spec = $ENV{XCAT_GENESIS_SPEC} // "$root/xCAT-genesis-builder/xCAT-genesis-base.spec"; -my $module = $ENV{XCAT_GENESIS_MODULE} // "$root/xCAT-genesis-builder/dracut_105/el/module-setup.sh"; +my $spec = $ENV{XCAT_GENESIS_SPEC} // "$root/xCAT-genesis-base/xCAT-genesis-base.spec"; +my $module = $ENV{XCAT_GENESIS_MODULE} // "$root/xCAT-genesis-base/dracut_105/el/module-setup.sh"; my $tmp = tempdir(CLEANUP => 1); my $sequence = 0; @@ -47,13 +47,14 @@ for my $arch (qw(x86_64 ppc64le)) { SKIP: { my ($probe_status) = run('unshare', '--user', '--map-root-user', '--mount', 'true'); skip 'Unprivileged user/mount namespaces unavailable', 25 if $probe_status; - make_path("$tmp/native-etc", "$tmp/legacy-etc", "$tmp/zones/Etc", "$tmp/zones/Native", "$tmp/modules/fixture", "$tmp/empty-zones"); + make_path("$tmp/native-etc/ssl", "$tmp/legacy-etc/ssl", "$tmp/zones/Etc", "$tmp/zones/Native", "$tmp/modules/fixture", "$tmp/empty-zones"); make_path("$tmp/locales/C.utf8/LC_MESSAGES", "$tmp/missing-locales", "$tmp/empty-locales/C.utf8", "$tmp/missing-ctype/C.utf8", "$tmp/empty-ctype/C.utf8"); write_file("$tmp/native-etc/openEuler-release", "openEuler release 24.03 (LTS-SP3)\n"); write_file("$tmp/native-etc/os-release", "ID=openEuler\n"); write_file("$tmp/legacy-etc/redhat-release", "Rocky Linux release 10\n"); write_file("$tmp/legacy-etc/os-release", "ID=rocky\n"); + write_file("$tmp/$_/ssl/openssl.cnf", '') for qw(native-etc legacy-etc); write_file("$tmp/zones/Etc/UTC", "native UTC fixture\n"); write_file("$tmp/zones/Native/Fixture", "native timezone fixture\n"); symlink('Etc/UTC', "$tmp/zones/UTC") or die $!; @@ -75,6 +76,10 @@ mount --bind "$4" /lib/modules || exit mount --bind "$6" /usr/lib/locale || exit source "$1" moddir=${1%/*} +openssl() { + [[ $* == 'version -d' ]] || return 99 + printf 'OPENSSLDIR: "/etc/ssl"\n' +} dracut_install() { [[ ${FAIL_MKTEMP:-0} == 1 && $1 == mktemp ]] && return 77 printf 'file\t%s\n' "$@" diff --git a/xCAT-test/native/genesis_openeuler_release.t b/xCAT-test/native/genesis_openeuler_release.t index cdcda7910b..d921070730 100644 --- a/xCAT-test/native/genesis_openeuler_release.t +++ b/xCAT-test/native/genesis_openeuler_release.t @@ -2,12 +2,11 @@ use strict; use warnings; use Cwd qw(abs_path); -use File::Basename qw(dirname); -use File::Copy qw(copy); -use File::Find qw(find); use File::Path qw(make_path); use File::Temp qw(tempdir); use FindBin qw($RealBin); +use lib "$RealBin/../../build-utils/lib"; +use XCAT::BuildUtils qw(stage_genesis_base_sources); use Test::More; plan skip_all => 'requires native openEuler, an unprivileged user, rpmbuild and user namespaces' @@ -16,20 +15,12 @@ plan skip_all => 'requires native openEuler, an unprivileged user, rpmbuild and local $ENV{PATH} = "$ENV{PATH}:/usr/sbin:/sbin"; my $root = abs_path("$RealBin/../.."); -my $spec = $ENV{XCAT_GENESIS_RELEASE_SPEC} // "$root/xCAT-genesis-builder/xCAT-genesis-base.spec"; +my $spec = $ENV{XCAT_GENESIS_RELEASE_SPEC} // "$root/xCAT-genesis-base/xCAT-genesis-base.spec"; my $tmp = tempdir(CLEANUP => 1); -my $support = "$tmp/build/xCAT-genesis-base-build-support"; -make_path("$support/dracut_105/el", "$tmp/bin"); -find({ no_chdir => 1, wanted => sub { - return unless -f $_; - my $relative = substr($_, length("$root/xCAT-genesis-builder/dracut_105/el/")); - my $target = "$support/dracut_105/el/$relative"; - make_path(dirname($target)); - copy($_, $target) or die "copy $_: $!"; -} }, "$root/xCAT-genesis-builder/dracut_105/el"); -copy("$root/xCAT-genesis-builder/80-net-name-slot.rules", "$support/80-net-name-slot.rules") or die $!; -copy("$root/xCAT-genesis-builder/verify-genesis-payload", "$support/verify-genesis-payload") or die $!; -chmod 0755, "$support/verify-genesis-payload" or die $!; +make_path("$tmp/build", "$tmp/bin"); +stage_genesis_base_sources($root, "$tmp/support.tar.bz2", 1700000000); +system('tar', '-xjf', "$tmp/support.tar.bz2", '-C', "$tmp/build") == 0 + or die "extract Genesis build support: $?"; write_file("$tmp/bin/dracut", <<'SH'); #!/bin/bash set -eu @@ -54,6 +45,8 @@ dracut_install() { mkdir -p "$(dirname "$tree$destination")" || exit if [[ -d "$item" ]]; then mkdir -p "$tree$destination" || exit + elif [[ $item == /usr/bin/awk ]]; then + cp -L "$item" "$tree$destination" || exit else printf 'fixture\n' > "$tree$destination" || exit fi @@ -63,6 +56,10 @@ inst() { :; } inst_script() { :; } inst_dir() { :; } inst_hook() { :; } +openssl() { + [[ $* == 'version -d' ]] || return 99 + printf 'OPENSSLDIR: "%s"\n' "$GENESIS_RELEASE_BUILD/ssl" +} ( set +eu moddir="$GENESIS_RELEASE_BUILD/xCAT-genesis-base-build-support/dracut_105/el" @@ -101,9 +98,13 @@ if [[ -d /usr/share/dracut ]]; then mount --bind "$GENESIS_RELEASE_CASE/dracut" /usr/share/dracut fi mount --bind "$GENESIS_RELEASE_CASE/run" /run +# Private Perl libraries let the verifier run and RPM preserve ownership in the namespace. for directory in /usr/share/perl5 /usr/lib64/perl5 /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/share/ntp/lib; do if [[ -d $directory ]]; then - mount --bind "$GENESIS_RELEASE_CASE/empty" "$directory" + runtime="$GENESIS_RELEASE_CASE/runtime$directory" + mkdir -p "$runtime" + cp -R "$directory/." "$runtime/" + mount --bind "$runtime" "$directory" fi done platform=() @@ -119,9 +120,12 @@ exec rpmbuild -bi --short-circuit --nodeps --target x86_64 \ "$GENESIS_RELEASE_SPEC" SH +make_path("$tmp/build/ssl"); +write_file("$tmp/build/ssl/openssl.cnf", ''); + for my $failure (qw(none ID VERSION_ID mktemp dhclient legacy-none legacy-zone legacy-release)) { my $case = "$tmp/$failure"; - make_path("$case/dracut/modules.d", "$case/run", "$case/rpm", "$case/empty"); + make_path("$case/dracut/modules.d", "$case/run", "$case/rpm"); if ($failure =~ /^legacy-/) { make_path("$case/etc/ssh"); write_file("$case/etc/os-release", "ID=rocky\nVERSION_ID=9.6\n");