mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-08-04 00:16:59 +00:00
5d9286cfb7
merge_core_repos already assembles the multi-arch core and runs the full
finalize tail (index -> sign -> final metadata -> write_release_alias, in the
required order so the xCAT-release-latest alias lands AFTER metadata and stays
out of the repo index). The preceding commit restored a separate finalize_core
sub purely to satisfy xcat_release_package.t, which grepped for
'sub finalize_core { ... $dir ... }'. That left two overlapping entry points:
--finalize-core (finalize one pre-assembled dir) and --merge-core-repos
(assemble N per-arch dirs THEN finalize) -- the former a strict subset of the
latter, with no in-tree or CI caller.
Consolidate on the single assemble+finalize path: inline the finalize tail into
merge_core_repos, drop sub finalize_core and the --finalize-core getopt/dispatch,
and update xcat_release_package.t to assert the stable alias is created after the
final metadata pass inside merge_core_repos ($out). Behaviour is unchanged (merge
already wrote the alias); only the redundant finalize_core interface is removed.
xcat_release_package.t 26/26; perl -c clean.
Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
101 lines
3.5 KiB
Perl
101 lines
3.5 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
|
|
use Digest::SHA qw(sha256_hex);
|
|
use File::Spec;
|
|
use FindBin;
|
|
use Test::More;
|
|
|
|
my $repo_root = File::Spec->rel2abs(File::Spec->catdir($FindBin::Bin, '..', '..'));
|
|
|
|
my $spec = read_file('xCAT-release/xCAT-release.spec');
|
|
like($spec, qr/^Name:\s+xCAT-release$/m, 'package has the expected name');
|
|
like($spec, qr/^Source0:\s+xCAT-release-%\{version\}\.tar\.gz$/m, 'source archive follows the package name');
|
|
like($spec, qr/^BuildArch:\s+noarch$/m, 'package is architecture independent');
|
|
like($spec, qr/^Requires:\s+dnf$/m, 'package is limited to DNF-based systems');
|
|
like($spec, qr/^%config\(noreplace\) .*xcat-core\.repo$/m, 'core repo preserves local changes');
|
|
like($spec, qr/^%config\(noreplace\) .*xcat-dep\.repo$/m, 'dependency repo preserves local changes');
|
|
like($spec, qr{RPM-GPG-KEY-xCAT}, 'package installs the signing key');
|
|
|
|
my $core = read_file('xCAT-release/xcat-core.repo');
|
|
assert_repo_security($core, 'core');
|
|
like(
|
|
$core,
|
|
qr{^baseurl=https://xcat\.org/files/xcat/repos/yum/latest/xcat-core$}m,
|
|
'core repo uses the stable HTTPS endpoint'
|
|
);
|
|
|
|
my $dep = read_file('xCAT-release/xcat-dep.repo');
|
|
assert_repo_security($dep, 'dependency');
|
|
like(
|
|
$dep,
|
|
qr{^baseurl=https://xcat\.org/files/xcat/repos/yum/latest/xcat-dep/rh\$releasever/\$basearch$}m,
|
|
'dependency repo follows the DNF release and architecture variables'
|
|
);
|
|
|
|
my $key = read_file('xCAT-release/RPM-GPG-KEY-xCAT');
|
|
like($key, qr/^-----BEGIN PGP PUBLIC KEY BLOCK-----$/m, 'signing key is ASCII armored');
|
|
is(
|
|
sha256_hex($key),
|
|
'72076f25ce4929d34a67e305327a37f89c964d3cbf1821e3afad4907c9d91249',
|
|
'packaged key matches the published xCAT signing key'
|
|
);
|
|
|
|
my $builder = read_file('buildrpms.pl');
|
|
like($builder, qr/^\s+xCAT-release\s*$/m, 'default RPM build includes xCAT-release');
|
|
like(
|
|
$builder,
|
|
qr{\$repodir/xCAT-release-latest\.noarch\.rpm},
|
|
'stable bootstrap alias follows the package name'
|
|
);
|
|
like(
|
|
$builder,
|
|
qr{\$repodir/xCAT-release-\$VERSION-\$RELEASE\.noarch\.rpm},
|
|
'stable bootstrap alias selects the xCAT-release RPM'
|
|
);
|
|
like(
|
|
$builder,
|
|
qr/unlink \$alias.*?createrepo_dir\(\$repodir/s,
|
|
'stable bootstrap alias is excluded from repository metadata'
|
|
);
|
|
like(
|
|
$builder,
|
|
qr/cp \$release_rpms\[0\], \$alias/,
|
|
'repository export creates the stable bootstrap filename'
|
|
);
|
|
my $sign_call = rindex($builder, 'sign_rpms($target)');
|
|
my $alias_call = rindex($builder, 'write_release_alias("dist/$target/rpms")');
|
|
ok(
|
|
$sign_call >= 0 && $alias_call > $sign_call,
|
|
'stable bootstrap alias is created after signed metadata is finalized'
|
|
);
|
|
like(
|
|
$builder,
|
|
qr/sub merge_core_repos \{.*?write_repo_metadata_dir\(\$out\);.*?write_release_alias\(\$out\);/s,
|
|
'assembled core repository creates the stable alias after final metadata'
|
|
);
|
|
|
|
done_testing();
|
|
|
|
sub assert_repo_security {
|
|
my ($content, $label) = @_;
|
|
like($content, qr/^enabled=1$/m, "$label repo is enabled");
|
|
like($content, qr/^gpgcheck=1$/m, "$label repo verifies packages");
|
|
like($content, qr/^repo_gpgcheck=1$/m, "$label repo verifies repository metadata");
|
|
like(
|
|
$content,
|
|
qr{^gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-xCAT$}m,
|
|
"$label repo uses the packaged signing key"
|
|
);
|
|
}
|
|
|
|
sub read_file {
|
|
my ($file) = @_;
|
|
my $path = File::Spec->catfile($repo_root, split m{/}, $file);
|
|
open(my $fh, '<', $path) or die "open $path: $!";
|
|
my $contents = do { local $/; <$fh> };
|
|
close($fh) or die "close $path: $!";
|
|
return $contents;
|
|
}
|