2
0
mirror of https://github.com/xcat2/xcat-dep.git synced 2026-10-17 01:00:35 +00:00

fix(xcat-dep): the OpenEmbedded Genesis build cannot find the builder in xcat-core master

Every OpenEmbedded Genesis build fails against xcat-core master:

    xcat-core source is missing xCAT-genesis-builder/oe/build

xcat-core 2a7364476 renamed xCAT-genesis-builder to xCAT-genesis-base and
updated the readers inside xcat-core. genesis-openembedded/build names the old
directory in four places, so it rejects the checkout before it builds anything.
The build jobs for EL and for Ubuntu both exit 2 on it.

A dep build serves two kinds of checkout at once. A released core still carries
the old name, and master carries the new one, so neither name can replace the
other. XCAT::GenesisRelease::oe_source_dir takes whichever directory holds a
complete pair of build and export scripts, prefers the new name when a checkout
has both, and names every path it looked for when a checkout has neither. The
script resolves the directory once and uses it for the architecture probe, the
build and the export.

Half a directory is not a directory. The build runs both scripts, so a prefix
that carries only one is skipped here instead of failing later at the second
run_command, with a message that names the wrong thing.

t/genesis_oe_source_dir.t covers both names, a checkout with both, a checkout
with neither, an incomplete pair and a caller that needs one script. Against the
directory list before this change, four of its ten assertions fail.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
Daniel Hilst
2026-10-13 11:12:03 -03:00
parent 774b592df7
commit c0af7aeffb
3 changed files with 93 additions and 6 deletions
+6 -6
View File
@@ -22,6 +22,7 @@ use XCAT::BuildUtils qw(
);
use XCAT::GenesisRelease qw(
architectures
oe_source_dir
deb_package_name
minimum_release_version
rpm_package_name
@@ -62,9 +63,8 @@ my %requested = map { $_ => 1 } @requested_architectures;
umask(0022);
$xcat_source = abs_path($xcat_source) or die "Cannot resolve xcat-core source\n";
for my $path (qw(Version xCAT-genesis-builder/oe/build xCAT-genesis-builder/oe/export)) {
die "xcat-core source is missing $path\n" unless -f "$xcat_source/$path";
}
die "xcat-core source is missing Version\n" unless -f "$xcat_source/Version";
my $oe_dir = oe_source_dir($xcat_source);
die "xcat-core checkout is not clean\n"
if capture_command('git', '-C', $xcat_source, 'status', '--porcelain') ne '';
@@ -79,7 +79,7 @@ if ($xcat_ref ne '') {
unless $revision eq $expected;
}
if ($requested{s390x}) {
my $architecture_reporter = "$xcat_source/xCAT-genesis-builder/oe/build";
my $architecture_reporter = "$xcat_source/$oe_dir/build";
my $probe_work = tempdir('xcat-genesis-capabilities.XXXXXX', TMPDIR => 1, CLEANUP => 1);
my $supported_output;
{
@@ -133,7 +133,7 @@ local $ENV{XCAT_GENESIS_WORK_DIR} = $oe_work;
{
local $ENV{TMPDIR} = $oe_tmp;
make_path($oe_tmp);
run_command("$xcat_source/xCAT-genesis-builder/oe/build", @requested_architectures);
run_command("$xcat_source/$oe_dir/build", @requested_architectures);
}
my $effective_deploy = "$oe_tmp/deploy";
die "Invalid OpenEmbedded deploy directory: $effective_deploy\n"
@@ -143,7 +143,7 @@ for my $architecture (@requested_architectures) {
my $export = "$work/exports/$architecture";
make_path(dirname($export));
run_command(
"$xcat_source/xCAT-genesis-builder/oe/export",
"$xcat_source/$oe_dir/export",
$architecture, $effective_deploy, $export,
);
+20
View File
@@ -8,6 +8,7 @@ use XCAT::BuildUtils qw(digest_file read_lines relative_files);
our @EXPORT_OK = qw(
architectures
oe_source_dir
deb_package_prefix
deb_package_name
minimum_release_version
@@ -35,6 +36,25 @@ my %RELEASE_ARCHITECTURES = (
2 => \@RELEASE_V2_ARCHITECTURES,
);
# xcat-core 2a7364476 renamed xCAT-genesis-builder to xCAT-genesis-base. A dep build
# serves both: the released core still carries the old name, and master carries the new
# one. Take whichever the checkout has, and name both when it has neither.
my @OE_SOURCE_DIRS = qw(xCAT-genesis-base/oe xCAT-genesis-builder/oe);
sub oe_source_dir {
my ($xcat_source, @required) = @_;
@required = qw(build export) unless @required;
my @missing;
foreach my $dir (@OE_SOURCE_DIRS) {
my @absent = grep { !-f "$xcat_source/$dir/$_" } @required;
return $dir unless @absent;
push(@missing, map { "$dir/$_" } @absent);
}
die "xcat-core source has no OpenEmbedded Genesis builder: missing "
. join(', ', @missing) . "\n";
}
sub architectures {
return @ARCHITECTURES;
}
+67
View File
@@ -0,0 +1,67 @@
#!/usr/bin/env perl
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use File::Path qw(make_path);
use File::Temp qw(tempdir);
use Test::More;
use XCAT::GenesisRelease qw(oe_source_dir);
# xcat-core 2a7364476 renamed xCAT-genesis-builder to xCAT-genesis-base. A dep build
# serves a released core that still carries the old name and a master that carries the
# new one, so it must take either.
# oe_source_dir dies when it resolves nothing. Report that as a failed assertion rather
# than letting it abort the file: a die emits no TAP, so prove reports "no plan found" and
# names nothing, which reads as a harness problem instead of the defect it is.
sub resolved {
my @args = @_;
my $dir = eval { oe_source_dir(@args) };
return defined($dir) ? $dir : "died: $@";
}
sub core_with {
my (@paths) = @_;
my $root = tempdir(CLEANUP => 1);
foreach my $path (@paths) {
my ($dir) = $path =~ m{^(.*)/[^/]+$};
make_path("$root/$dir");
open(my $fh, '>', "$root/$path") or die "cannot create $path: $!";
close($fh);
}
return $root;
}
is(resolved(core_with(qw(xCAT-genesis-base/oe/build xCAT-genesis-base/oe/export))),
'xCAT-genesis-base/oe', 'a renamed checkout resolves to the new directory');
is(resolved(core_with(qw(xCAT-genesis-builder/oe/build xCAT-genesis-builder/oe/export))),
'xCAT-genesis-builder/oe', 'a checkout from before the rename still resolves');
is(resolved(core_with(qw(
xCAT-genesis-base/oe/build xCAT-genesis-base/oe/export
xCAT-genesis-builder/oe/build xCAT-genesis-builder/oe/export))),
'xCAT-genesis-base/oe', 'a checkout carrying both prefers the new directory');
# Half a directory is not a directory: the build runs both scripts, so one without the
# other must fail here rather than at the second run_command.
is(resolved(core_with(qw(xCAT-genesis-base/oe/build xCAT-genesis-builder/oe/build
xCAT-genesis-builder/oe/export))),
'xCAT-genesis-builder/oe', 'a new directory missing export falls back to the complete one');
my $half = core_with(qw(xCAT-genesis-base/oe/build));
ok(!eval { oe_source_dir($half); 1 }, 'a checkout with no complete directory dies');
like($@, qr{xCAT-genesis-base/oe/export}, 'the error names what the new directory lacks');
like($@, qr{xCAT-genesis-builder/oe/build}, 'the error names the old directory too');
my $empty = core_with();
ok(!eval { oe_source_dir($empty); 1 }, 'a checkout with neither directory dies');
like($@, qr{no OpenEmbedded Genesis builder}, 'the error says what is missing');
# The caller asks for the two scripts it runs; a caller that needs one gets one.
is(resolved(core_with(qw(xCAT-genesis-base/oe/build)), 'build'),
'xCAT-genesis-base/oe', 'a caller may require a subset');
done_testing();