mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-12-04 08:07:04 +00:00
test(packaging): copy standalone Debian sources without repair
This commit is contained in:
@@ -26,23 +26,12 @@ sub checked {
|
||||
return $out;
|
||||
}
|
||||
|
||||
sub stage_deb_source {
|
||||
my ($package, $source, $work) = @_;
|
||||
checked('tar', '-cf', "$work/source.tar", '-C', $source, $package);
|
||||
checked('tar', '-xpf', "$work/source.tar", '-C', $work);
|
||||
my $live_root = "$package/debian/xcat-live-root-functions";
|
||||
if (-l "$work/$live_root") {
|
||||
unlink "$work/$live_root" or die "unlink $live_root: $!";
|
||||
copy("$source/$live_root", "$work/$live_root") or die "copy $live_root: $!";
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
sub build_deb {
|
||||
my ($package, $source) = @_;
|
||||
$source //= repo_path('.');
|
||||
my $work = tempdir(CLEANUP => 1);
|
||||
stage_deb_source($package, $source, $work);
|
||||
checked('tar', '-cf', "$work/source.tar", '-C', $source, $package);
|
||||
checked('tar', '-xpf', "$work/source.tar", '-C', $work);
|
||||
if ($package eq 'perl-xCAT') {
|
||||
for my $name (qw(Version Gitinfo)) {
|
||||
next unless -f "$source/$name";
|
||||
|
||||
@@ -15,7 +15,7 @@ plan skip_all => 'Run as an ordinary user on Debian or Ubuntu'
|
||||
unless $^O eq 'linux' && $< != 0 && -f '/etc/debian_version';
|
||||
my $work = tempdir(CLEANUP => 1);
|
||||
make_path(map { "$work/$_" } qw(source home bin capture));
|
||||
for my $entry (qw(builddebs.pl build-utils Version Release perl-xCAT xCAT-server xCATsn)) {
|
||||
for my $entry (qw(builddebs.pl build-utils Version Release xCAT-server)) {
|
||||
XCAT::Test::Lifecycle::checked('cp', '-a', repo_path($entry), "$work/source/");
|
||||
}
|
||||
write_binary("$work/bin/dpkg-buildpackage", <<'SH');
|
||||
@@ -31,13 +31,14 @@ chmod oct('0755'), "$work/bin/dpkg-buildpackage" or die "chmod wrapper: $!";
|
||||
local %ENV = (%ENV, HOME => "$work/home", SOURCE_DATE_EPOCH => 1750000000,
|
||||
PATH => "$work/bin:/usr/bin:/bin", LC_ALL => 'C', XCAT_SOURCE_CAPTURE => "$work/capture");
|
||||
my ($status, $output) = run_command($^X, "$work/source/builddebs.pl",
|
||||
'--package', 'perl-xCAT', '--package', 'xCAT-server', '--package', 'xCATsn',
|
||||
'--package', 'xCAT-server',
|
||||
'--dist', 'noble', '--release', 'test1', '--dest', "$work/output");
|
||||
is($status, 0, 'builds all three packages through the production Debian builder') or diag $output;
|
||||
is($status, 0, 'builds the server through the production Debian builder') or diag $output;
|
||||
die 'package build failed' if $status;
|
||||
}
|
||||
|
||||
for my $package (qw(xCAT-server xCATsn)) {
|
||||
{
|
||||
my $package = 'xCAT-server';
|
||||
subtest "$package standalone source export" => sub {
|
||||
my @sources = glob "$work/capture/$package/*.dsc";
|
||||
is(scalar @sources, 1, 'captures one source package') or return;
|
||||
@@ -48,43 +49,25 @@ for my $package (qw(xCAT-server xCATsn)) {
|
||||
my $root = XCAT::Test::Lifecycle->new;
|
||||
$root->{live} = $live;
|
||||
$root->write('/calls', '');
|
||||
my ($script, @args);
|
||||
if ($package eq 'xCAT-server') {
|
||||
$script = 'prerm';
|
||||
@args = ('remove');
|
||||
local $root->{deb} = $rebuilt;
|
||||
my @unpack = $root->run('/bin/sh', '-ec',
|
||||
'dpkg-deb -x /package.deb /unpacked; mkdir -p /opt/xcat/share/xcat; ' .
|
||||
'cp -a /unpacked/opt/xcat/share/xcat/scripts /opt/xcat/share/xcat/');
|
||||
is($unpack[0], 0, 'stage the rebuilt runtime helpers') or diag "$unpack[1]$unpack[2]";
|
||||
$root->record_command('/test-bin/systemctl');
|
||||
$root->write('/etc/os-release', "ID=ubuntu\nVERSION_ID=24.04\n");
|
||||
$root->write('/run/systemd/system/.fixture', '') if $live;
|
||||
} else {
|
||||
$script = 'postinst';
|
||||
@args = ('configure');
|
||||
$root->record_command('/test-bin/update-rc.d');
|
||||
$root->record_command('/etc/init.d/apache2');
|
||||
$root->record_command('/etc/init.d/xcatd');
|
||||
$root->record_command('/test-bin/a2enmod');
|
||||
$root->write('/etc/apache2/conf-enabled/.fixture', '');
|
||||
}
|
||||
my ($status, $out, $err) = $root->deb_script($rebuilt, $script, @args);
|
||||
local $root->{deb} = $rebuilt;
|
||||
my @unpack = $root->run('/bin/sh', '-ec',
|
||||
'dpkg-deb -x /package.deb /unpacked; mkdir -p /opt/xcat/share/xcat; ' .
|
||||
'cp -a /unpacked/opt/xcat/share/xcat/scripts /opt/xcat/share/xcat/');
|
||||
is($unpack[0], 0, 'stage the rebuilt runtime helpers') or diag "$unpack[1]$unpack[2]";
|
||||
$root->record_command('/test-bin/systemctl');
|
||||
$root->write('/etc/os-release', "ID=ubuntu\nVERSION_ID=24.04\n");
|
||||
$root->write('/run/systemd/system/.fixture', '');
|
||||
my ($status, $out, $err) = $root->deb_script($rebuilt, 'prerm', 'remove');
|
||||
is($status, 0, 'rebuilt control script executes without a sibling source helper') or diag "$out$err";
|
||||
unlike("$out$err", qr/not found/, 'the rebuilt script has no missing command');
|
||||
if (!$live) {
|
||||
unlike($root->read('/calls'), qr/(?:<start>|<stop>|<reload>|<--now>)/,
|
||||
'the rebuilt script performs no live service action in an offline root');
|
||||
} elsif ($package eq 'xCAT-server') {
|
||||
} else {
|
||||
like($root->read('/calls'), qr/^systemctl <stop> <xcatd\.service>$/m,
|
||||
'rebuilt removal stops xcatd in a live root');
|
||||
like($root->read('/calls'), qr/^systemctl <disable> <--now> <xcat-uftp-listener\.service>$/m,
|
||||
'rebuilt removal stops the live UFTP listener');
|
||||
} else {
|
||||
like($root->read('/calls'), qr/^xcatd <start>$/m,
|
||||
'rebuilt service-node configuration starts xcatd in a live root');
|
||||
like($root->read('/calls'), qr/^apache2 <reload>$/m,
|
||||
'rebuilt service-node configuration reloads Apache in a live root');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -74,7 +74,7 @@ if (!-f '/etc/debian_version') {
|
||||
check_assets($reduced, 'reduced RPM: ', glob "$share/netboot/rocky/*.riscv64.*");
|
||||
} else {
|
||||
my $fixture = tempdir(CLEANUP => 1);
|
||||
XCAT::Test::Lifecycle::stage_deb_source('xCAT-server', repo_path('.'), $fixture);
|
||||
XCAT::Test::Lifecycle::checked('cp', '-a', repo_path('xCAT-server'), "$fixture/xCAT-server");
|
||||
my $profiles = "$fixture/xCAT-server/share/xcat";
|
||||
XCAT::Test::Lifecycle::checked('chmod', '-R', 'g+w', "$profiles/install", "$profiles/netboot");
|
||||
my $data = 'install/rh/compute.rhels10.riscv64.pkglist';
|
||||
|
||||
Reference in New Issue
Block a user