[1082] | 1 | # Sensible Perl-specific RPM build macros.
|
---|
| 2 | #
|
---|
| 3 | # Note that these depend on the generic filtering system being in place in
|
---|
| 4 | # rpm core; but won't cause a build to fail if they're not present.
|
---|
| 5 | #
|
---|
| 6 | # Chris Weyl <cweyl@alumni.drew.edu> 2009
|
---|
| 7 | # Marcela MaÅ¡láÅová <mmaslano@redhat.com> 2011
|
---|
| 8 |
|
---|
| 9 | # This macro unsets several common vars used to control how Makefile.PL (et
|
---|
| 10 | # al) build and install packages. We also set a couple to help some of the
|
---|
| 11 | # common systems be less interactive. This was blatantly stolen from
|
---|
| 12 | # cpanminus, and helps building rpms locally when one makes extensive use of
|
---|
| 13 | # local::lib, etc.
|
---|
| 14 | #
|
---|
| 15 | # Usage, in %build, before "%{__perl} Makefile.PL ..."
|
---|
| 16 | #
|
---|
| 17 | # %{?perl_ext_env_unset}
|
---|
| 18 |
|
---|
| 19 | %perl_ext_env_unset %{expand:
|
---|
| 20 | unset PERL_MM_OPT MODULEBUILDRC PERL5INC
|
---|
| 21 | export PERL_AUTOINSTALL="--defaultdeps"
|
---|
| 22 | export PERL_MM_USE_DEFAULT=1
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | #############################################################################
|
---|
| 26 | # Filtering macro incantations
|
---|
| 27 |
|
---|
| 28 | # keep track of what "revision" of the filtering we're at. Each time we
|
---|
| 29 | # change the filter we should increment this.
|
---|
| 30 |
|
---|
| 31 | %perl_default_filter_revision 3
|
---|
| 32 |
|
---|
| 33 | # Perl provides/requeries are generated by external generators.
|
---|
| 34 | %global __perl_provides %{_rpmconfigdir}/perl.prov
|
---|
| 35 | %global __perl_requires %{_rpmconfigdir}/perl.req
|
---|
| 36 |
|
---|
| 37 | # By default, for perl packages we want to filter all files in _docdir from
|
---|
| 38 | # req/prov scanning, as well as filtering out any provides caused by private
|
---|
| 39 | # libs in vendorarch/archlib (vendor/core).
|
---|
| 40 | #
|
---|
| 41 | # Note that this must be invoked in the spec file, preferably as
|
---|
| 42 | # "%{?perl_default_filter}", before any %description block.
|
---|
| 43 |
|
---|
| 44 | %perl_default_filter %{expand: \
|
---|
| 45 | %global __provides_exclude_from %{perl_vendorarch}/auto/.*\\\\.dll$|%{perl_archlib}/.*\\\\.dll$|%{_docdir}
|
---|
| 46 | %global __requires_exclude_from %{_docdir}
|
---|
| 47 | %global __provides_exclude perl\\\\(VMS|perl\\\\(Win32|perl\\\\(DB\\\\)|perl\\\\(UNIVERSAL\\\\)
|
---|
| 48 | %global __requires_exclude perl\\\\(VMS|perl\\\\(Win32
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | #############################################################################
|
---|
| 52 | # Macros to assist with generating a "-tests" subpackage in a semi-automatic
|
---|
| 53 | # manner.
|
---|
| 54 | #
|
---|
| 55 | # The following macros are still in a highly experimental stage and users
|
---|
| 56 | # should be aware that the interface and behaviour may change.
|
---|
| 57 | #
|
---|
| 58 | # PLEASE, PLEASE CONDITIONALIZE THESE MACROS IF YOU USE THEM.
|
---|
| 59 | #
|
---|
| 60 | # See http://gist.github.com/284409
|
---|
| 61 |
|
---|
| 62 | # These macros should be invoked as above, right before the first %description
|
---|
| 63 | # section, and conditionalized. e.g., for the common case where all our tests
|
---|
| 64 | # are located under t/, the correct usage is:
|
---|
| 65 | #
|
---|
| 66 | # %{?perl_default_subpackage_tests}
|
---|
| 67 | #
|
---|
| 68 | # If custom files/directories need to be specified, this can be done as such:
|
---|
| 69 | #
|
---|
| 70 | # %{?perl_subpackage_tests:%perl_subpackage_tests t/ one/ three.sql}
|
---|
| 71 | #
|
---|
| 72 | # etc, etc.
|
---|
| 73 |
|
---|
| 74 | %perl_version %(eval "`%{__perl} -V:version`"; echo $version)
|
---|
| 75 | %perl_testdir %{_libexecdir}/perl5-tests
|
---|
| 76 | %cpan_dist_name %(eval echo %{name} | %{__sed} -e 's/^perl-//')
|
---|
| 77 |
|
---|
| 78 | # easily mark something as required by -tests and BR to the main package
|
---|
| 79 | %tests_req() %{expand:\
|
---|
| 80 | BuildRequires: %*\
|
---|
| 81 | %%tests_subpackage_requires %*\
|
---|
| 82 | }
|
---|
| 83 |
|
---|
| 84 | # fixup (and create if needed) the shbang lines in tests, so they work and
|
---|
| 85 | # rpmlint doesn't (correctly) have a fit
|
---|
| 86 | %fix_shbang_line() \
|
---|
| 87 | TMPHEAD=`mktemp`\
|
---|
| 88 | TMPBODY=`mktemp`\
|
---|
| 89 | for file in %* ; do \
|
---|
| 90 | head -1 $file > $TMPHEAD\
|
---|
| 91 | tail -n +2 $file > $TMPBODY\
|
---|
| 92 | %{__perl} -pi -e '$f = /^#!/ ? "" : "#!%{__perl}$/"; $_="$f$_"' $TMPHEAD\
|
---|
| 93 | cat $TMPHEAD $TMPBODY > $file\
|
---|
| 94 | done\
|
---|
| 95 | %{__perl} -MExtUtils::MakeMaker -e "ExtUtils::MM_Unix->fixin(qw{%*})"\
|
---|
| 96 | %{__rm} $TMPHEAD $TMPBODY\
|
---|
| 97 | %{nil}
|
---|
| 98 |
|
---|
| 99 | # additional -tests subpackage requires, if any
|
---|
| 100 | %tests_subpackage_requires() %{expand: \
|
---|
| 101 | %global __tests_spkg_req %{?__tests_spkg_req} %* \
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | # additional -tests subpackage provides, if any
|
---|
| 105 | %tests_subpackage_provides() %{expand: \
|
---|
| 106 | %global __tests_spkg_prov %{?__tests_spkg_prov} %* \
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | #
|
---|
| 110 | # Runs after the body of %check completes.
|
---|
| 111 | #
|
---|
| 112 |
|
---|
| 113 | %__perl_check_pre %{expand: \
|
---|
| 114 | %{?__spec_check_pre} \
|
---|
| 115 | pushd %{buildsubdir} \
|
---|
| 116 | %define perl_br_testdir %{buildroot}%{perl_testdir}/%{cpan_dist_name} \
|
---|
| 117 | %{__mkdir_p} %{perl_br_testdir} \
|
---|
| 118 | %{__tar} -cf - %{__perl_test_dirs} | ( cd %{perl_br_testdir} && %{__tar} -xf - ) \
|
---|
| 119 | find . -maxdepth 1 -type f -name '*META*' -exec %{__cp} -vp {} %{perl_br_testdir} ';' \
|
---|
| 120 | find %{perl_br_testdir} -type f -exec %{__chmod} -c -x {} ';' \
|
---|
| 121 | T_FILES=`find %{perl_br_testdir} -type f -name '*.t'` \
|
---|
| 122 | %fix_shbang_line $T_FILES \
|
---|
| 123 | %{__chmod} +x $T_FILES \
|
---|
| 124 | %{_fixperms} %{perl_br_testdir} \
|
---|
| 125 | popd \
|
---|
| 126 | }
|
---|
| 127 |
|
---|
| 128 | #
|
---|
| 129 | # The actual invoked macro
|
---|
| 130 | #
|
---|
| 131 |
|
---|
| 132 | %perl_subpackage_tests() %{expand: \
|
---|
| 133 | %global __perl_package 1\
|
---|
| 134 | %global __perl_test_dirs %* \
|
---|
| 135 | %global __spec_check_pre %{expand:%{__perl_check_pre}} \
|
---|
| 136 | %package tests\
|
---|
| 137 | Summary: Test suite for package %{name}\
|
---|
| 138 | Group: Development/Debug\
|
---|
| 139 | Requires: %{name} = %{?epoch:%{epoch}:}%{version}-%{release}\
|
---|
| 140 | Requires: %{_bindir}/prove \
|
---|
| 141 | %{?__tests_spkg_req:Requires: %__tests_spkg_req}\
|
---|
| 142 | %{?__tests_spkg_prov:Provides: %__tests_spkg_prov}\
|
---|
| 143 | AutoReqProv: 0 \
|
---|
| 144 | %description tests\
|
---|
| 145 | This package provides the test suite for package %{name}.\
|
---|
| 146 | %files tests\
|
---|
| 147 | %defattr(-,root,root,-)\
|
---|
| 148 | %{perl_testdir}\
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | # shortcut sugar
|
---|
| 152 | %perl_default_subpackage_tests %perl_subpackage_tests t/
|
---|
| 153 |
|
---|