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