From 2f9518f7eda67efc78bc1241ed403fd405d73c5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20Ferr=C3=A3o?= <2031761+viniciusferrao@users.noreply.github.com> Date: Tue, 1 Dec 2026 21:29:26 -0300 Subject: [PATCH] test(packaging): copy standalone Debian sources without repair --- xCAT-test/lib/XCAT/Test/Lifecycle.pm | 15 +------ xCAT-test/native/debian_live_root_delivery.t | 47 +++++++------------- xCAT-test/native/profile_package_payload.t | 2 +- 3 files changed, 18 insertions(+), 46 deletions(-) diff --git a/xCAT-test/lib/XCAT/Test/Lifecycle.pm b/xCAT-test/lib/XCAT/Test/Lifecycle.pm index 7d417b1444..9bbc4d64ea 100644 --- a/xCAT-test/lib/XCAT/Test/Lifecycle.pm +++ b/xCAT-test/lib/XCAT/Test/Lifecycle.pm @@ -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"; diff --git a/xCAT-test/native/debian_live_root_delivery.t b/xCAT-test/native/debian_live_root_delivery.t index 2dc4a38292..0007ab9dc8 100644 --- a/xCAT-test/native/debian_live_root_delivery.t +++ b/xCAT-test/native/debian_live_root_delivery.t @@ -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/(?:|||<--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 $/m, 'rebuilt removal stops xcatd in a live root'); like($root->read('/calls'), qr/^systemctl <--now> $/m, 'rebuilt removal stops the live UFTP listener'); - } else { - like($root->read('/calls'), qr/^xcatd $/m, - 'rebuilt service-node configuration starts xcatd in a live root'); - like($root->read('/calls'), qr/^apache2 $/m, - 'rebuilt service-node configuration reloads Apache in a live root'); } } }; diff --git a/xCAT-test/native/profile_package_payload.t b/xCAT-test/native/profile_package_payload.t index a3af37f730..a97a0da1e7 100644 --- a/xCAT-test/native/profile_package_payload.t +++ b/xCAT-test/native/profile_package_payload.t @@ -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';