From 70cce26459f26e0e1e00e737ab626fc5a65b3033 Mon Sep 17 00:00:00 2001 From: fr4nk2 Date: Fri, 14 Apr 2023 15:50:10 +0800 Subject: [PATCH] Optimise spec file --- perl-autodie.spec | 145 ++++++++++++++++++---------------------------- test.sh | 11 ++++ 2 files changed, 66 insertions(+), 90 deletions(-) create mode 100644 test.sh diff --git a/perl-autodie.spec b/perl-autodie.spec index 4f1c2e4..8f66f78 100644 --- a/perl-autodie.spec +++ b/perl-autodie.spec @@ -1,91 +1,50 @@ -%define anolis_release 1 +%define anolis_release 2 Name: perl-autodie Epoch: 1 Version: 2.36 Release: %{anolis_release}%{?dist} Summary: Replace functions with ones that succeed or die -License: GPL-1.0-or-later OR Artistic-1.0-Perl +License: GPL+ or Artistic URL: https://metacpan.org/release/autodie Source0: https://cpan.metacpan.org/authors/id/T/TO/TODDR/autodie-%{version}.tar.gz -BuildArch: noarch -BuildRequires: coreutils -BuildRequires: findutils -BuildRequires: make -BuildRequires: perl-interpreter -BuildRequires: perl-generators -BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 -BuildRequires: perl(strict) -BuildRequires: perl(warnings) -# Run-time: -BuildRequires: perl(B) -BuildRequires: perl(Carp) -BuildRequires: perl(Config) -BuildRequires: perl(constant) +Source1: test.sh + +BuildRequires: make findutils coreutils +BuildRequires: perl-generators perl-interpreter +BuildRequires: perl(B) perl(Fcntl) +BuildRequires: perl(warnings) perl(strict) +BuildRequires: perl(constant) perl(Config) perl(Carp) BuildRequires: perl(Exporter) >= 5.57 -BuildRequires: perl(Fcntl) +BuildRequires: perl(ExtUtils::MakeMaker) >= 6.76 +BuildRequires: perl(parent) perl(overload) +BuildRequires: perl(POSIX) perl(FindBin) +BuildRequires: perl(lib) perl(if) +BuildRequires: perl(open) perl(Socket) +BuildRequires: perl(IO::Handle) perl(Tie::RefHash) +BuildRequires: perl(Scalar::Util) perl(Test::More) +BuildRequires: perl(File::Temp) perl(File::Spec) perl(File::Copy) + %if !%{defined perl_bootstrap} BuildRequires: perl(IPC::System::Simple) >= 0.12 %endif -BuildRequires: perl(overload) -BuildRequires: perl(parent) -BuildRequires: perl(POSIX) -BuildRequires: perl(Scalar::Util) -# Sub::Identify is optional with a fallback -BuildRequires: perl(Tie::RefHash) -# Tests: -# English not used -BuildRequires: perl(File::Copy) -BuildRequires: perl(File::Spec) -BuildRequires: perl(File::Temp) -BuildRequires: perl(FindBin) -BuildRequires: perl(if) -BuildRequires: perl(IO::Handle) -BuildRequires: perl(lib) -BuildRequires: perl(open) -BuildRequires: perl(Socket) -BuildRequires: perl(Test::More) -Requires: perl(B) -Requires: perl(Fcntl) -Requires: perl(POSIX) -# Optional: -%if !%{defined perl_bootstrap} -# IPC::System::Simple dependency requested, bug #1183231 -Requires: perl(IPC::System::Simple) >= 0.12 -%endif -# Remove falsely detected perl(lib) -%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(lib\\)$ +Requires: perl(POSIX) perl(Fcntl) perl(B) -# Filter modules bundled for tests -%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} -%global __requires_exclude %{__requires_exclude}|^perl\\(autodie::test.*\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(autodie_.*\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(Caller_helper\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(Hints_.*\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(lethal\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(my::.*\\) -%global __requires_exclude %{__requires_exclude}|^perl\\(pujHa::ghach\\) +%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\(lib\\)$ %global __requires_exclude %{__requires_exclude}|^perl\\(Some::Module\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(pujHa::ghach\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(my::.*\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(lethal\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(Hints_.*\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(Caller_helper\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(autodie_.*\\) +%global __requires_exclude %{__requires_exclude}|^perl\\(autodie::test.*\\) -%package tests -Summary: Tests for %{name} -Requires: %{name} = %{EVR} -Requires: perl-Test-Harness -Requires: perl(lib) - -%description tests -Tests from %{name}. Execute them -with "%{_libexecdir}/%{name}/test". +%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_libexecdir} -%package doc -Summary: Doc files for %{name} -Requires: %{name} = %{EVR} BuildArch: noarch -%description doc -Doc files for %{name} - %description The "autodie" and "Fatal" pragma provides a convenient way to replace functions that normally return false on failure with equivalents that throw an @@ -94,44 +53,47 @@ exception on failure. However "Fatal" has been obsoleted by the new autodie pragma. Please use autodie in preference to "Fatal". +%package tests +Summary: Tests for %{name} +Requires: %{name} = %{EVR} +Requires: perl-Test-Harness +Requires: perl(lib) + +%description tests +Tests from %{name}. Execute them with "%{_libexecdir}/%{name}/test". + +%package doc +Summary: Documentation files for %{name} +Requires: %{name} = %{EVR} +BuildArch: noarch + +%description doc +The %{name}-doc package contains documentation files for %{name}. + %prep -%setup -q -n autodie-%{version} +%autosetup -p1 -n autodie-%{version} find -type f -exec chmod -x {} + -# Help generators to recognize Perl scripts for F in t/*.t; do perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!.*perl\b}{$Config{startperl}}' "$F" chmod +x "$F" done %build -perl Makefile.PL INSTALLDIRS=vendor NO_PACKLIST=1 NO_PERLLOCAL=1 -%{make_build} +perl Makefile.PL NO_PACKLIST=1 NO_PERLLOCAL=1 INSTALLDIRS=vendor +%make_build %install -%{make_install} +%make_install %{_fixperms} %{buildroot}/* # Install tests mkdir -p %{buildroot}%{_libexecdir}/%{name} cp -a t %{buildroot}%{_libexecdir}/%{name} -cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF' -#!/bin/bash -set -e -unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING -# Some tests write into temporary files/directories. The solution is to -# copy the tests into a writable directory and execute them from there. -DIR=$(mktemp -d) -pushd "$DIR" -cp -a %{_libexecdir}/%{name}/* ./ -prove -I . -j "$(getconf _NPROCESSORS_ONLN)" -popd -rm -rf "$DIR" -EOF -chmod +x %{buildroot}%{_libexecdir}/%{name}/test +install -m 0755 %{SOURCE1} %{buildroot}%{_libexecdir}/%{name}/test %check -unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING +unset RELEASE_TESTING PERL_CORE AUTOMATED_TESTING AUTHOR_TESTING export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}') make test @@ -144,9 +106,12 @@ make test %{_libexecdir}/%{name} %files doc -%doc AUTHORS Changes README.md +%doc README.md Changes AUTHORS %changelog +* Fri Apr 14 2023 Guyu Wang - 1:2.36-2 +- Optimise spec file + * Tue Feb 07 2023 Chunmei Xu - 1:2.36-1 - update to 2.36 diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..99aeef8 --- /dev/null +++ b/test.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +unset AUTHOR_TESTING AUTOMATED_TESTING PERL_CORE RELEASE_TESTING +# Some tests write into temporary files/directories. The solution is to +# copy the tests into a writable directory and execute them from there. +DIR=$(mktemp -d) +pushd "$DIR" +cp -a /usr/libexec/perl-autodie/* ./ +prove -I . -j "$(getconf _NPROCESSORS_ONLN)" +popd +rm -rf "$DIR" -- Gitee