diff --git a/build-utils/lib/XCAT/BuildUtils.pm b/build-utils/lib/XCAT/BuildUtils.pm index 36571f5fdf..512e70d087 100644 --- a/build-utils/lib/XCAT/BuildUtils.pm +++ b/build-utils/lib/XCAT/BuildUtils.pm @@ -813,17 +813,29 @@ sub cancel_build { # or chronyd_manage_pid_files(). m4 leaves an undefined interface name in its # output, and checkmodule stops on it. openEuler 24.03sp4 carries # selinux-policy 40.7 and does compile the module, and is excluded too, so no -# openEuler release ships a package the other releases cannot build. +# openEuler release ships a package the other releases cannot build. openSUSE +# Leap ships no selinux-policy-devel at all. my %EL_ONLY_PACKAGES = ( 'xCAT-selinux' => 'SELinux support is EL only', ); -# Why $pkg is not built for $target, or undef when the pair is built. openEuler -# is the one non-EL family buildrpms.pl targets. +# The EL build targets, named positively: alma+epel-- for the three EL +# releases, and the suffixed rocky target mock cross-builds riscv64 through. +my $EL_TARGET = qr/\A(?:alma|rocky|centos|rhel)(?:\+epel)?-/; + +# Why $pkg is not built for $target, or undef when the pair is built. The test is +# on EL rather than on the families that are not EL, so a family added later +# skips an EL-only package instead of trying to build it. openSUSE was added +# after this guard and matched neither arm of a /\Aopeneuler-/ test, so +# xcat-core-build-opensuse #42 spent three attempts on "No matching package to +# install: selinux-policy-devel" and failed the whole openSUSE family. sub package_skip_reason { my ($pkg, $target) = @_; my $reason = $EL_ONLY_PACKAGES{ $pkg // '' } or return undef; - return undef unless defined($target) && $target =~ /\Aopeneuler-/; + # No target names no platform. buildrpms.pl always has one; a caller that + # does not is asking about the package, not about a pair. + return undef unless defined($target) && length($target); + return undef if $target =~ $EL_TARGET; return $reason; } diff --git a/xCAT-test/unit/selinux_el_only_scope.t b/xCAT-test/unit/selinux_el_only_scope.t index 296c88d7d2..98f9ff22d9 100644 --- a/xCAT-test/unit/selinux_el_only_scope.t +++ b/xCAT-test/unit/selinux_el_only_scope.t @@ -23,6 +23,15 @@ my @openeuler_targets = qw( openeuler-24.03sp4-x86_64 openeuler-24.03-ppc64le ); +# openSUSE Leap ships no selinux-policy-devel at all, so the module has nothing +# to compile against. The guard this test was written with named openEuler, and +# openSUSE was enabled afterwards: xcat-core-build-opensuse #42 spent three +# attempts on "No matching package to install: selinux-policy-devel" and took +# the whole openSUSE family down with it. +my @opensuse_targets = qw( + opensuse-leap-15.6-x86_64 + opensuse-leap-42.3-x86_64 +); my @el_targets = qw( alma+epel-8-x86_64 alma+epel-9-x86_64 @@ -34,9 +43,9 @@ my $decides = XCAT::BuildUtils->can('package_skip_reason'); ok($decides, 'BuildUtils decides which packages a target builds'); SKIP: { - skip 'BuildUtils has no build-plan decision', 17 unless $decides; + skip 'BuildUtils has no build-plan decision', 20 unless $decides; - foreach my $target (@openeuler_targets) { + foreach my $target (@openeuler_targets, @opensuse_targets) { ok($decides->('xCAT-selinux', $target), "xCAT-selinux is not built for $target"); } @@ -51,6 +60,8 @@ SKIP: { xCAT-genesis-scripts xCAT-test xCAT-release)) { is($decides->($pkg, 'openeuler-22.03sp4-x86_64'), undef, "$pkg is built for openEuler"); + is($decides->($pkg, 'opensuse-leap-15.6-x86_64'), undef, + "$pkg is built for openSUSE"); } }