diff --git a/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec b/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec index 71fa9b96b7..23dc05a17b 100644 --- a/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec +++ b/xCAT-OpenStack-baremetal/xCAT-OpenStack-baremetal.spec @@ -20,8 +20,12 @@ BuildArch: noarch Provides: xCAT-OpenStack-baremetal = %{epoch}:%{version} Requires: xCAT-client -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif diff --git a/xCAT-SoftLayer/xCAT-SoftLayer.spec b/xCAT-SoftLayer/xCAT-SoftLayer.spec index a2355ddba8..3ccb508e40 100644 --- a/xCAT-SoftLayer/xCAT-SoftLayer.spec +++ b/xCAT-SoftLayer/xCAT-SoftLayer.spec @@ -15,8 +15,12 @@ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root BuildArch: noarch %endif Requires: xCAT-server -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif diff --git a/xCAT-buildkit/xCAT-buildkit.spec b/xCAT-buildkit/xCAT-buildkit.spec index 4bc6d948b1..f9ce2778d2 100644 --- a/xCAT-buildkit/xCAT-buildkit.spec +++ b/xCAT-buildkit/xCAT-buildkit.spec @@ -12,8 +12,12 @@ Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} Prefix: /opt/xcat BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif diff --git a/xCAT-client/xCAT-client.spec b/xCAT-client/xCAT-client.spec index 6c0daf8df1..942bb6ad0a 100644 --- a/xCAT-client/xCAT-client.spec +++ b/xCAT-client/xCAT-client.spec @@ -19,8 +19,12 @@ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root %define s390x %(if [ "$s390x" = "1" ];then echo 1; else echo 0; fi) %define nots390x %(if [ "$s390x" = "1" ];then echo 0; else echo 1; fi) -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif diff --git a/xCAT-test/unit/opensuse_pod_buildrequires.t b/xCAT-test/unit/opensuse_pod_buildrequires.t new file mode 100644 index 0000000000..93c29ceb8b --- /dev/null +++ b/xCAT-test/unit/opensuse_pod_buildrequires.t @@ -0,0 +1,95 @@ +#!/usr/bin/env perl +# openSUSE has no perl-generators, and its chroot carries only perl-base, which ships +# no Pod::Man and no pod2man. A spec that converts pods in %build must therefore name a +# build dependency that holds under suse_version, or the buildroot holds none by accident. +use strict; +use warnings; + +use FindBin; +use lib "$FindBin::Bin/../lib"; +use File::Spec; +use Test::More; + +use XCAT::Test::File qw(repo_path slurp_repo_file); + +#------------------------------------------------------------------------------- + +=head3 converts_pods + +Descriptions: Say whether a spec runs a pod converter in an active line. A commented +call does not count: xCAT-confluent carries one and needs no converter. + +Arguments: the spec text + +Returns: the number of converter calls + +=cut + +#------------------------------------------------------------------------------- +sub converts_pods { + my ($text) = @_; + return scalar(grep { /^\s*(\.\/xpod2man|pod2man|pod2html)\b/ } split /\n/, $text); +} + +#------------------------------------------------------------------------------- + +=head3 suse_buildrequires + +Descriptions: Collect the BuildRequires of a spec that apply when suse_version is +defined. Only the suse_version conditionals are evaluated; any other %if is entered, +because its BuildRequires can still reach a SUSE build. + +Arguments: the spec text + +Returns: the list of required package names + +=cut + +#------------------------------------------------------------------------------- +sub suse_buildrequires { + my ($text) = @_; + my @dead; # one entry per open conditional: true means the branch is not taken + my @names; + for my $line (split /\n/, $text) { + if ($line =~ /^%if\s*(!?)\s*0%\{\?suse_version\}\s*$/) { + push @dead, ($1 eq '!' ? 1 : 0); + } + elsif ($line =~ /^%if/) { + push @dead, 0; + } + elsif ($line =~ /^%else\b/) { + $dead[-1] = $dead[-1] ? 0 : 1 if @dead; + } + elsif ($line =~ /^%endif/) { + pop @dead; + } + elsif ($line =~ /^BuildRequires:\s*(.+?)\s*$/ && !grep { $_ } @dead) { + push @names, split /[,\s]+/, $1; + } + } + return @names; +} + +my %text; +for my $absolute (glob repo_path('*/*.spec')) { + my @parts = File::Spec->splitdir($absolute); + my $relative = File::Spec->catfile(@parts[-2, -1]); + $text{$relative} = slurp_repo_file($relative); +} +die "read no package spec from the checkout" unless keys %text > 10; + +my @converting = sort grep { converts_pods($text{$_}) } keys %text; +plan skip_all => 'no spec converts pods' unless @converting; +plan tests => 1 + scalar(@converting); + +cmp_ok(scalar(@converting), '>=', 4, 'several specs convert pods in %build'); + +# On Leap 15.6 perl(Pod::Man), perl(Pod::Html) and /usr/bin/pod2man are all in "perl"; +# "perl-Pod-Html" does not exist there at all. +for my $relative (@converting) { + my @required = suse_buildrequires($text{$relative}); + ok(scalar(grep { $_ eq 'perl' } @required), + "$relative build-requires perl on SUSE, which provides Pod::Man and pod2man") + or diag("BuildRequires under suse_version: " + . (@required ? join(', ', @required) : '(none)')); +} diff --git a/xCAT-test/xCAT-test.spec b/xCAT-test/xCAT-test.spec index abb562554f..57a2131f11 100644 --- a/xCAT-test/xCAT-test.spec +++ b/xCAT-test/xCAT-test.spec @@ -11,8 +11,12 @@ Vendor: IBM Corp. Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} Prefix: /opt/xcat BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif diff --git a/xCAT-vlan/xCAT-vlan.spec b/xCAT-vlan/xCAT-vlan.spec index 883f714d18..d621737f5a 100644 --- a/xCAT-vlan/xCAT-vlan.spec +++ b/xCAT-vlan/xCAT-vlan.spec @@ -11,8 +11,12 @@ Vendor: IBM Corp. Distribution: %{?_distribution:%{_distribution}}%{!?_distribution:%{_vendor}} Prefix: /opt/xcat BuildRoot: /var/tmp/%{name}-%{version}-%{release}-root -# Pod::Html ships inside the core perl package on SUSE; there is no perl-Pod-Html -%if !0%{?suse_version} +# The pod converters are in perl-Pod-Html on EL and in the core perl package on +# SUSE, which has no perl-Pod-Html. A SUSE chroot holds perl-base only, and that +# ships neither Pod::Man nor pod2man. +%if 0%{?suse_version} +BuildRequires: perl +%else BuildRequires: perl-Pod-Html %endif