|
|
683572 |
# Sensible Perl-specific RPM build macros.
|
|
|
683572 |
#
|
|
|
683572 |
# Note that these depend on the generic filtering system being in place in
|
|
|
683572 |
# rpm core; but won't cause a build to fail if they're not present.
|
|
|
683572 |
#
|
|
|
683572 |
# Chris Weyl <cweyl@alumni.drew.edu> 2009
|
|
|
683572 |
# Marcela Mašláňová <mmaslano@redhat.com> 2011
|
|
|
683572 |
|
|
|
683572 |
# This macro unsets several common vars used to control how Makefile.PL (et
|
|
|
683572 |
# al) build and install packages. We also set a couple to help some of the
|
|
|
683572 |
# common systems be less interactive. This was blatantly stolen from
|
|
|
683572 |
# cpanminus, and helps building rpms locally when one makes extensive use of
|
|
|
683572 |
# local::lib, etc.
|
|
|
683572 |
#
|
|
|
683572 |
# Usage, in %build, before "%{__perl} Makefile.PL ..."
|
|
|
683572 |
#
|
|
|
683572 |
# %{?perl_ext_env_unset}
|
|
|
683572 |
|
|
|
683572 |
%perl_ext_env_unset %{expand:
|
|
|
683572 |
unset PERL_MM_OPT MODULEBUILDRC PERL5INC
|
|
|
683572 |
export PERL_AUTOINSTALL="--defaultdeps"
|
|
|
683572 |
export PERL_MM_USE_DEFAULT=1
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
#############################################################################
|
|
|
683572 |
# Perl specific macros, no longer part of rpm >= 4.15
|
|
|
683572 |
%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
|
|
|
683572 |
%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
|
|
|
683572 |
%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
|
|
|
683572 |
%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
|
|
|
683572 |
|
|
|
683572 |
#############################################################################
|
|
|
683572 |
# Filtering macro incantations
|
|
|
683572 |
|
|
|
683572 |
# keep track of what "revision" of the filtering we're at. Each time we
|
|
|
683572 |
# change the filter we should increment this.
|
|
|
683572 |
|
|
|
683572 |
%perl_default_filter_revision 3
|
|
|
683572 |
|
|
|
683572 |
# By default, for perl packages we want to filter all files in _docdir from
|
|
|
683572 |
# req/prov scanning.
|
|
|
683572 |
# Filtering out any provides caused by private libs in vendorarch/archlib
|
|
|
683572 |
# (vendor/core) is done by rpmbuild since Fedora 20
|
|
|
683572 |
# <https://fedorahosted.org/fpc/ticket/353>.
|
|
|
683572 |
#
|
|
|
683572 |
# Note that this must be invoked in the spec file, preferably as
|
|
|
683572 |
# "%{?perl_default_filter}", before any %description block.
|
|
|
683572 |
|
|
|
683572 |
%perl_default_filter %{expand: \
|
|
|
683572 |
%global __provides_exclude_from %{?__provides_exclude_from:%__provides_exclude_from|}^%{_docdir}
|
|
|
683572 |
%global __requires_exclude_from %{?__requires_exclude_from:%__requires_exclude_from|}^%{_docdir}
|
|
|
683572 |
%global __provides_exclude %{?__provides_exclude:%__provides_exclude|}^perl\\\\(VMS|^perl\\\\(Win32|^perl\\\\(DB\\\\)|^perl\\\\(UNIVERSAL\\\\)
|
|
|
683572 |
%global __requires_exclude %{?__requires_exclude:%__requires_exclude|}^perl\\\\(VMS|^perl\\\\(Win32
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
#############################################################################
|
|
|
683572 |
# Macros to assist with generating a "-tests" subpackage in a semi-automatic
|
|
|
683572 |
# manner.
|
|
|
683572 |
#
|
|
|
683572 |
# The following macros are still in a highly experimental stage and users
|
|
|
683572 |
# should be aware that the interface and behaviour may change.
|
|
|
683572 |
#
|
|
|
683572 |
# PLEASE, PLEASE CONDITIONALIZE THESE MACROS IF YOU USE THEM.
|
|
|
683572 |
#
|
|
|
683572 |
# See http://gist.github.com/284409
|
|
|
683572 |
|
|
|
683572 |
# These macros should be invoked as above, right before the first %description
|
|
|
683572 |
# section, and conditionalized. e.g., for the common case where all our tests
|
|
|
683572 |
# are located under t/, the correct usage is:
|
|
|
683572 |
#
|
|
|
683572 |
# %{?perl_default_subpackage_tests}
|
|
|
683572 |
#
|
|
|
683572 |
# If custom files/directories need to be specified, this can be done as such:
|
|
|
683572 |
#
|
|
|
683572 |
# %{?perl_subpackage_tests:%perl_subpackage_tests t/ one/ three.sql}
|
|
|
683572 |
#
|
|
|
683572 |
# etc, etc.
|
|
|
683572 |
|
|
|
683572 |
%perl_version %(eval "`%{__perl} -V:version`"; echo $version)
|
|
|
683572 |
%perl_testdir %{_libexecdir}/perl5-tests
|
|
|
683572 |
%cpan_dist_name %(eval echo %{name} | %{__sed} -e 's/^perl-//')
|
|
|
683572 |
|
|
|
683572 |
# easily mark something as required by -tests and BR to the main package
|
|
|
683572 |
%tests_req() %{expand:\
|
|
|
683572 |
BuildRequires: %*\
|
|
|
683572 |
%%tests_subpackage_requires %*\
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
# fixup (and create if needed) the shbang lines in tests, so they work and
|
|
|
683572 |
# rpmlint doesn't (correctly) have a fit
|
|
|
683572 |
%fix_shbang_line() \
|
|
|
683572 |
TMPHEAD=`mktemp`\
|
|
|
683572 |
TMPBODY=`mktemp`\
|
|
|
683572 |
for file in %* ; do \
|
|
|
683572 |
head -1 $file > $TMPHEAD\
|
|
|
683572 |
tail -n +2 $file > $TMPBODY\
|
|
|
683572 |
%{__perl} -pi -e '$f = /^#!/ ? "" : "#!%{__perl}$/"; $_="$f$_"' $TMPHEAD\
|
|
|
683572 |
cat $TMPHEAD $TMPBODY > $file\
|
|
|
683572 |
done\
|
|
|
683572 |
%{__perl} -MExtUtils::MakeMaker -e "ExtUtils::MM_Unix->fixin(qw{%*})"\
|
|
|
683572 |
%{__rm} $TMPHEAD $TMPBODY\
|
|
|
683572 |
%{nil}
|
|
|
683572 |
|
|
|
683572 |
# additional -tests subpackage requires, if any
|
|
|
683572 |
%tests_subpackage_requires() %{expand: \
|
|
|
683572 |
%global __tests_spkg_req %{?__tests_spkg_req} %* \
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
# additional -tests subpackage provides, if any
|
|
|
683572 |
%tests_subpackage_provides() %{expand: \
|
|
|
683572 |
%global __tests_spkg_prov %{?__tests_spkg_prov} %* \
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
#
|
|
|
683572 |
# Runs after the body of %check completes.
|
|
|
683572 |
#
|
|
|
683572 |
|
|
|
683572 |
%__perl_check_pre %{expand: \
|
|
|
683572 |
%{?__spec_check_pre} \
|
|
|
683572 |
pushd %{buildsubdir} \
|
|
|
683572 |
%define perl_br_testdir %{buildroot}%{perl_testdir}/%{cpan_dist_name} \
|
|
|
683572 |
%{__mkdir_p} %{perl_br_testdir} \
|
|
|
683572 |
%{__tar} -cf - %{__perl_test_dirs} | ( cd %{perl_br_testdir} && %{__tar} -xf - ) \
|
|
|
683572 |
find . -maxdepth 1 -type f -name '*META*' -exec %{__cp} -vp {} %{perl_br_testdir} ';' \
|
|
|
683572 |
find %{perl_br_testdir} -type f -exec %{__chmod} -c -x {} ';' \
|
|
|
683572 |
T_FILES=`find %{perl_br_testdir} -type f -name '*.t'` \
|
|
|
683572 |
%fix_shbang_line $T_FILES \
|
|
|
683572 |
%{__chmod} +x $T_FILES \
|
|
|
683572 |
%{_fixperms} %{perl_br_testdir} \
|
|
|
683572 |
popd \
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
#
|
|
|
683572 |
# The actual invoked macro
|
|
|
683572 |
#
|
|
|
683572 |
|
|
|
683572 |
%perl_subpackage_tests() %{expand: \
|
|
|
683572 |
%global __perl_package 1\
|
|
|
683572 |
%global __perl_test_dirs %* \
|
|
|
683572 |
%global __spec_check_pre %{expand:%{__perl_check_pre}} \
|
|
|
683572 |
%package tests\
|
|
|
683572 |
Summary: Test suite for package %{name}\
|
|
|
683572 |
Group: Development/Debug\
|
|
|
683572 |
Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}\
|
|
|
683572 |
Requires: /usr/bin/prove \
|
|
|
683572 |
%{?__tests_spkg_req:Requires: %__tests_spkg_req}\
|
|
|
683572 |
%{?__tests_spkg_prov:Provides: %__tests_spkg_prov}\
|
|
|
683572 |
AutoReqProv: 0 \
|
|
|
683572 |
%description tests\
|
|
|
683572 |
This package provides the test suite for package %{name}.\
|
|
|
683572 |
%files tests\
|
|
|
683572 |
%defattr(-,root,root,-)\
|
|
|
683572 |
%{perl_testdir}\
|
|
|
683572 |
}
|
|
|
683572 |
|
|
|
683572 |
# shortcut sugar
|
|
|
683572 |
%perl_default_subpackage_tests %perl_subpackage_tests t/
|
|
|
683572 |
|