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