Blame SOURCES/macros.perl

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