From 7ec7c8ba03556ce9b8daa4e5bf53fc2a7bae5330 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 28 Oct 2026 08:35:22 -0300 Subject: [PATCH] test(packaging): xCAT-server asks openSUSE for a DB_File package it has not openSUSE ships DB_File in perl-core-DB_File. The spec asks for perl-DB_File on every platform below EL10, so zypper refuses the transaction with "nothing provides 'perl-DB_File' needed by the to be installed xCAT-server" and the management node cannot install xCAT. The test reads the Requires of xCAT-server with rpmspec for openSUSE, EL9 and EL10. On openSUSE it expects the perl(DB_File) capability and no perl-DB_File package name. The EL assertions hold the existing behaviour down: EL9 keeps the hard package requirement, EL10 keeps none. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com> --- xCAT-test/unit/opensuse_db_file_requires.t | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 xCAT-test/unit/opensuse_db_file_requires.t diff --git a/xCAT-test/unit/opensuse_db_file_requires.t b/xCAT-test/unit/opensuse_db_file_requires.t new file mode 100644 index 0000000000..3957514b44 --- /dev/null +++ b/xCAT-test/unit/opensuse_db_file_requires.t @@ -0,0 +1,52 @@ +#!/usr/bin/env perl +# xCAT-server must ask for DB_File by a name that resolves on openSUSE. +# +# openSUSE ships DB_File in perl-core-DB_File. The spec asked for perl-DB_File on every +# platform below EL10, so zypper answered "nothing provides 'perl-DB_File' needed by the to +# be installed xCAT-server" and the management node could not install xCAT at all. +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; +use Test::More; + +use XCAT::Test::File qw(repo_path); + +my $rpmspec = qx(command -v rpmspec 2>/dev/null); +chomp($rpmspec); +plan skip_all => 'rpmspec is required' unless $rpmspec && -x $rpmspec; + +my $SPEC = 'xCAT-server/xCAT-server.spec'; + +# requires -- the Requires of xCAT-server for one distro +sub requires { + my ($define) = @_; + open(my $fh, '-|', $rpmspec, '-q', '--requires', '--target', 'x86_64', + '--define', 'version 2.20.0', '--define', 'release 1', + '--undefine', 'rhel', '--undefine', 'suse_version', '--undefine', 'openEuler', + '--define', $define, repo_path($SPEC)) or die "run rpmspec: $!"; + my @requires = <$fh>; + close($fh) or die "rpmspec failed for $define"; + chomp @requires; + return @requires; +} + +my @suse = requires('suse_version 1500'); +# The capability, not the package name: openSUSE calls the package perl-core-DB_File. +is(scalar(grep { $_ eq 'perl(DB_File)' } @suse), 1, + 'xCAT-server requires the perl(DB_File) capability on openSUSE'); +is(scalar(grep { $_ eq 'perl-DB_File' } @suse), 0, + 'xCAT-server does not ask openSUSE for the EL package name perl-DB_File'); + +# EL9 keeps the hard requirement under the name EPEL publishes. +my @el9 = requires('rhel 9'); +is(scalar(grep { $_ eq 'perl-DB_File' } @el9), 1, + 'xCAT-server keeps perl-DB_File on EL9'); + +# EL10 asks weakly, because riscv64 has no EPEL to provide it. +my @el10 = requires('rhel 10'); +is(scalar(grep { /DB_File/ } @el10), 0, + 'xCAT-server has no hard DB_File requirement on EL10'); + +done_testing();