Mailing List Archive

perl-module.class review
Attached is a diff of the current and the prospective perl-module.class.
Please review.

Thanks.


--- perl-module.eclass
+++ perl-module.eclass
@@ -1,4 +1,4 @@
-# Copyright 1999-2004 Gentoo Foundation
+# Copyright 1999-2009 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/perl-module.eclass,v 1.116 2009/03/29 17:32:31 tove Exp $
#
@@ -13,13 +13,18 @@
# modules, and their incorporation into the Gentoo Linux system.

inherit eutils base
+[[ ${CATEGORY} == "perl-core" ]] && inherit alternatives
+
+EXPORTED_FUNCTIONS="src_unpack src_compile src_test src_install"

case "${EAPI:-0}" in
0|1)
- EXPORT_FUNCTIONS pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm src_compile src_install src_test src_unpack
+ EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} pkg_setup pkg_preinst pkg_postinst pkg_prerm pkg_postrm"
;;
2)
- EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_test src_install
+ EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} src_prepare src_configure"
+ [[ ${CATEGORY} == "perl-core" ]] && \
+ EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS} pkg_postinst pkg_postrm"

case "${GENTOO_DEPEND_ON_PERL:-yes}" in
yes)
@@ -30,6 +35,8 @@
;;
esac

+EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
+
DESCRIPTION="Based on the $ECLASS eclass"

LICENSE="${LICENSE:-|| ( Artistic GPL-2 )}"
@@ -56,7 +63,7 @@

perl-module_src_unpack() {
base_src_unpack unpack
- has "${EAPI:-0}" 0 1 && perl-module_src_prepare
+ has src_prepare ${EXPORTED_FUNCTIONS} || perl-module_src_prepare
}

perl-module_src_prepare() {
@@ -110,7 +117,7 @@
perl-module_src_compile() {
${perlinfo_done} || perlinfo

- has "${EAPI:-0}" 0 1 && perl-module_src_prep
+ has src_configure ${EXPORTED_FUNCTIONS} || perl-module_src_prep

if [[ -f Build ]] ; then
./Build build \
@@ -124,13 +131,38 @@
fi
}

+# For testers:
+# This code attempts to work out your threadingness from MAKEOPTS
+# and apply them to Test::Harness.
+#
+# If you want more verbose testing, set TEST_VERBOSE=1
+# in your bashrc | /etc/make.conf | ENV
+#
+# For ebuild writers:
+# If you wish to enable default tests w/ 'make test' ,
+#
+# SRC_TEST="do"
+#
+# If you wish to have threads run in parallel ( using the users makeopts )
+# all of the following have been tested to work.
+#
+# SRC_TEST="do parallel"
+# SRC_TEST="parallel"
+# SRC_TEST="parallel do"
+# SRC_TEST=parallel
+#
+
perl-module_src_test() {
- if [[ "${SRC_TEST}" == "do" ]] ; then
+ if has 'do' ${SRC_TEST} || has 'parallel' ${SRC_TEST} ; then
+ if has "${TEST_VERBOSE:-0}" 0 && has 'parallel' ${SRC_TEST} ; then
+ export HARNESS_OPTIONS=j$(echo -j1 ${MAKEOPTS} | sed -r "s/.*(-j\s*|--jobs=)([0-9]+).*/\2/" )
+ einfo "Test::Harness Jobs=${HARNESS_OPTIONS}"
+ fi
${perlinfo_done} || perlinfo
if [[ -f Build ]] ; then
- ./Build test || die "test failed"
+ ./Build test verbose=${TEST_VERBOSE:-0} || die "test failed"
elif [[ -f Makefile ]] ; then
- emake test || die "test failed"
+ emake test TEST_VERBOSE=${TEST_VERBOSE:-0} || die "test failed"
fi
fi
}
@@ -162,7 +194,7 @@

fixlocalpod

- for f in Change* CHANGES README* ${mydoc}; do
+ for f in Change* CHANGES README* TODO ${mydoc}; do
[[ -s "${f}" ]] && dodoc ${f}
done

@@ -174,10 +206,12 @@

find "${D}" -type f -not -name '*.so' -print0 | while read -rd '' f ; do
if file "${f}" | grep -q -i " text" ; then
-if grep -q "${D}" "${f}" ; then ewarn "QA: File contains a temporary path ${f}" ;fi
+ grep -q "${D}" "${f}" && ewarn "QA: File contains a temporary path ${f}"
sed -i -e "s:${D}:/:g" "${f}"
fi
done
+
+ linkduallifescripts
}

perl-module_pkg_setup() {
@@ -188,20 +222,21 @@
${perlinfo_done} || perlinfo
}

-perl-module_pkg_postinst() { : ; }
-# einfo "Man pages are not installed for most modules now."
-# einfo "Please use perldoc instead."
-#}
+perl-module_pkg_postinst() {
+ linkduallifescripts
+}

-perl-module_pkg_prerm() { : ; }
+perl-module_pkg_postrm() {
+ linkduallifescripts
+}

-perl-module_pkg_postrm() { : ; }
+perl-module_pkg_prerm() { : ; }

perlinfo() {
perlinfo_done=true

- local f version install{site{arch,lib},archlib,vendor{arch,lib}}
- for f in version install{site{arch,lib},archlib,vendor{arch,lib}} ; do
+ local f version install{{site,vendor}{arch,lib},archlib}
+ for f in version install{{site,vendor}{arch,lib},archlib} ; do
eval "$(perl -V:${f} )"
done
PERL_VERSION=${version}
@@ -216,3 +251,29 @@
find "${D}" -type f -name perllocal.pod -delete
find "${D}" -depth -mindepth 1 -type d -empty -delete
}
+
+linkduallifescripts() {
+ if [[ ${CATEGORY} != "perl-core" ]] || ! has_version ">=dev-lang/perl-5.10.1" ; then
+ return 0
+ fi
+
+ local i ff
+ if has "${EBUILD_PHASE:-none}" "postinst" "postrm" ; then
+ for i in "${DUALLIFESCRIPTS[@]}" ; do
+ alternatives_auto_makesym "/usr/bin/${i}" "/usr/bin/${i}-[0-9]*"
+ ff=`echo "${ROOT}"/usr/share/man/man1/${i}-${PV}-${P}.1*`
+ ff=${ff##*.1}
+ alternatives_auto_makesym "/usr/share/man/man1/${i}.1${ff}" "/usr/share/man/man1/${i}-[0-9]*"
+ done
+ else
+ pushd "${D}" > /dev/null
+ for i in $(find usr/bin -maxdepth 1 -type f 2>/dev/null) ; do
+ mv ${i}{,-${PV}-${P}} || die
+ DUALLIFESCRIPTS[${#DUALLIFESCRIPTS[*]}]=${i##*/}
+ if [[ -f usr/share/man/man1/${i##*/}.1 ]] ; then
+ mv usr/share/man/man1/${i##*/}{.1,-${PV}-${P}.1} || die
+ fi
+ done
+ popd > /dev/null
+ fi
+}
Re: perl-module.class review [ In reply to ]
On Sun, 20 Sep 2009 20:28:54 +0200
Torsten Veller <tove@gentoo.org> wrote:
> +EXPORTED_FUNCTIONS="src_unpack src_compile src_test src_install"

You're probably not the only one using this trick, so it might be wise
to use PERL_EXPORTED_FUNCTIONS or somesuch to avoid name collisions
with other eclasses.

--
Ciaran McCreesh
Re: perl-module.class review [ In reply to ]
* Ciaran McCreesh <ciaran.mccreesh@googlemail.com>:
> Torsten Veller <tove@gentoo.org> wrote:
> > +EXPORTED_FUNCTIONS="src_unpack src_compile src_test src_install"
>
> You're probably not the only one using this trick, so it might be wise
> to use PERL_EXPORTED_FUNCTIONS or somesuch to avoid name collisions
> with other eclasses.

git and x-modular use EXPORTED_FUNCTIONS and
cmake and xfconf use EXPF.

| eclass/git.eclass:EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
| eclass/x-modular.eclass:EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
|
| eclass/cmake-utils.eclass:EXPORT_FUNCTIONS ${EXPF}
| eclass/xfconf.eclass:EXPORT_FUNCTIONS ${EXPF}

I'll use PERL_EXPORTED_FUNCTIONS in the perl eclass.

Thanks :)
Re: Re: perl-module.class review [ In reply to ]
Dne pondělí 21 Září 2009 17:29:26 Torsten Veller napsal(a):
> * Ciaran McCreesh <ciaran.mccreesh@googlemail.com>:
> > Torsten Veller <tove@gentoo.org> wrote:
> > > +EXPORTED_FUNCTIONS="src_unpack src_compile src_test src_install"
> >
> > You're probably not the only one using this trick, so it might be wise
> > to use PERL_EXPORTED_FUNCTIONS or somesuch to avoid name collisions
> > with other eclasses.
>
> git and x-modular use EXPORTED_FUNCTIONS and
> cmake and xfconf use EXPF.
>
> | eclass/git.eclass:EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
> | eclass/x-modular.eclass:EXPORT_FUNCTIONS ${EXPORTED_FUNCTIONS}
> |
> | eclass/cmake-utils.eclass:EXPORT_FUNCTIONS ${EXPF}
> | eclass/xfconf.eclass:EXPORT_FUNCTIONS ${EXPF}
>
> I'll use PERL_EXPORTED_FUNCTIONS in the perl eclass.
>
> Thanks :)
>
I think it is not required
EXPF="src_compile src_test src_install" <- definition, also nulls anything
what was in it before :]
case ${EAPI:-0} in
2) EXPF="${EXPF} src_configure" ;;
1|0) ;;
*) die "Unknown EAPI, Bug eclass maintainers." ;;
esac
EXPORT_FUNCTIONS ${EXPF} <- export

i used expf cause it was shorter
and in git eclass i was too lazy for adjusting for the shorter name :]
Re: perl-module.class review [ In reply to ]
* TomᨠChvátal <scarabeus@gentoo.org>:
> I think it is not required
> EXPF="src_compile src_test src_install" <- definition, also nulls anything
> what was in it before :]
> case ${EAPI:-0} in
> 2) EXPF="${EXPF} src_configure" ;;
> 1|0) ;;
> *) die "Unknown EAPI, Bug eclass maintainers." ;;
> esac
> EXPORT_FUNCTIONS ${EXPF} <- export

And later in cmake-utils_src_compile you use:
| has src_configure ${EXPF} || cmake-utils_src_configure

What will happen if an EAPI=2 ebuild inherits cmake-utils and another eclass
also using EXPF that does not EXPORT_FUNCTIONS src_configure and the
ebuild uses cmake-utils_src_compile?

It will call cmake-utils_src_configure during src_configure and later in
cmake-utils_src_compile it will run cmake-utils_src_configure again,
won't it?
Re: Re: perl-module.class review [ In reply to ]
Dne pondělí 21 Září 2009 18:03:56 Torsten Veller napsal(a):
> * Tomáš Chvátal <scarabeus@gentoo.org>:
> > I think it is not required
> > EXPF="src_compile src_test src_install" <- definition, also nulls
> > anything what was in it before :]
> > case ${EAPI:-0} in
> > 2) EXPF="${EXPF} src_configure" ;;
> > 1|0) ;;
> > *) die "Unknown EAPI, Bug eclass maintainers." ;;
> > esac
> > EXPORT_FUNCTIONS ${EXPF} <- export
>
> And later in cmake-utils_src_compile you use:
> | has src_configure ${EXPF} || cmake-utils_src_configure
>
> What will happen if an EAPI=2 ebuild inherits cmake-utils and another
> eclass also using EXPF that does not EXPORT_FUNCTIONS src_configure and
> the ebuild uses cmake-utils_src_compile?
>
> It will call cmake-utils_src_configure during src_configure and later in
> cmake-utils_src_compile it will run cmake-utils_src_configure again,
> won't it?
>
You dont do this magic before inherits, so you are safe, if you inherit in
middle of your eclass code, then you probably deserve the breakage for
writting such horrible thing ;]


A - inherit B
EXPF - value from B
A - define our own export_functions
EXPF - value from A
Re: Re: perl-module.class review [ In reply to ]
On Monday 21 of September 2009 17:38:53 Tomáš Chvátal wrote:

> I think it is not required
> EXPF="src_compile src_test src_install" <- definition, also nulls anything
> what was in it before :]
> case ${EAPI:-0} in
> 2) EXPF="${EXPF} src_configure" ;;
> 1|0) ;;
> *) die "Unknown EAPI, Bug eclass maintainers." ;;
> esac
> EXPORT_FUNCTIONS ${EXPF} <- export

How about unsetting variables after use in first place so that they no longer
pollute global env.

--
regards
MM

----------------------------------------------------------------------
Rudi Schuberth odkrywa kulisy swojego odchudzania. Ile schudnie?
Sprawdz >>> http://link.interia.pl/f236a
Re: perl-module.class review [ In reply to ]
* Tomáš Chvátal <scarabeus@gentoo.org>:
> Dne pondělí 21 Září 2009 18:03:56 Torsten Veller napsal(a):
> > * Tomáš Chvátal <scarabeus@gentoo.org>:
> > > I think it is not required
> > > EXPF="src_compile src_test src_install" <- definition, also nulls
> > > anything what was in it before :]
> > > case ${EAPI:-0} in
> > > 2) EXPF="${EXPF} src_configure" ;;
> > > 1|0) ;;
> > > *) die "Unknown EAPI, Bug eclass maintainers." ;;
> > > esac
> > > EXPORT_FUNCTIONS ${EXPF} <- export
> >
> > And later in cmake-utils_src_compile you use:
> > | has src_configure ${EXPF} || cmake-utils_src_configure
> >
> > What will happen if an EAPI=2 ebuild inherits cmake-utils and another
> > eclass also using EXPF that does not EXPORT_FUNCTIONS src_configure and
> > the ebuild uses cmake-utils_src_compile?
> >
> > It will call cmake-utils_src_configure during src_configure and later in
> > cmake-utils_src_compile it will run cmake-utils_src_configure again,
> > won't it?
> >
> You dont do this magic before inherits, so you are safe, if you inherit in
> middle of your eclass code, then you probably deserve the breakage for
> writting such horrible thing ;]

I'am trying to give an example:

,----- test.eclass
EXPF=pkg_postinst
EXPORT_FUNCTIONS ${EXPF}

test_pkg_postinst() {
einfo test_pkg_postinst
}
'----- test.eclass

,----- another_test.eclass
EXPF="src_configure src_compile"
EXPORT_FUNCTIONS ${EXPF}

another_test_src_configure() {
einfo another_test_src_configure
}
another_test_src_compile() {
einfo another_test_src_compile
has src_configure ${EXPF} || another_test_src_configure
}
'----- another_test.eclass

,----- test.ebuild
EAPI=2
inherit another_test test

DESCRIPTION=""
HOMEPAGE=""
SRC_URI=""

LICENSE=""
SLOT="0"
KEYWORDS="~amd64"
IUSE=""

'----- test.ebuild

It outputs:

* another_test_src_configure
* another_test_src_compile
* another_test_src_configure
* test_pkg_postinst

if s/EXPF/TEST_EXPF/ in test.eclass, it does:

* another_test_src_configure
* another_test_src_compile
* test_pkg_postinst
Re: perl-module.class review [ In reply to ]
* Maciej Mrozowski <reavertm@poczta.fm>:
> How about unsetting variables after use in first place so that they no longer
> pollute global env.

It's probably too late as it is used in functions like
cmake-utils_src_compile:
| has src_configure ${EXPF} || cmake-utils_src_configure
Re: Re: perl-module.class review [ In reply to ]
On Mon, Sep 21, 2009 at 11:55 AM, Torsten Veller <ml-en@veller.net> wrote:
<snip>
> if s/EXPF/TEST_EXPF/ in test.eclass, it does:
>
>  * another_test_src_configure
>  * another_test_src_compile
>  * test_pkg_postinst

Although I don't anticipate xfconf and cmake being used together, we
changed xfconf.eclass. ;) Thanks for your time to test there.

sed -i -e 's/EXPF/XFCONF_EXPF/g' xfconf.eclass

-Jeremy