From 5101337a65f67f81df872f05362fadbda12ec068 Mon Sep 17 00:00:00 2001 From: Tim Orling Date: Sat, 5 Jul 2014 20:46:11 -0700 Subject: cpanm.bbclass * Use cpanm (App::cpanminus, libapp-cpanminus-perl) to get, unpack, build and install perl modules from CPAN Signed-off-by: Tim Orling --- meta/classes/cpanm.bbclass | 58 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 meta/classes/cpanm.bbclass diff --git a/meta/classes/cpanm.bbclass b/meta/classes/cpanm.bbclass new file mode 100644 index 0000000000..77aa854b0a --- /dev/null +++ b/meta/classes/cpanm.bbclass @@ -0,0 +1,58 @@ +# +# This is for perl modules that use cpanm (App::cpanminus) +# +inherit cpan-base perlnative + +# Env var which tells perl if it should use host (no) or target (yes) settings +export PERLCONFIGTARGET = "${@is_target(d)}" +export PERL_ARCHLIB = "${STAGING_LIBDIR}${PERL_OWN_DIR}/perl/${@get_perl_version(d)}" +export LD = "${CCLD}" + +# Env var which tells cpanm where to download files +export PERL_CPANM_HOME = "${DL_DIR}/.cpanm" +# Env vars which would be set by local::lib +export PERL_MB_OPT = "--install_base ${PERL_ARCHLIB}" +export PERL_MM_OPT = "INSTALL_BASE=${PERL_ARCHLIB}" +export PERL5LIB = "${PERL_ARCHLIB}:${STAGING_LIBDIR}/perl/" +export PERL_LOCAL_LIB_ROOT = "${libdir}/perl" + +# +# We also need to have built libapp-cpanminus-perl-native for +# everything except libapp-cpanminus-perl-native itself (which uses +# this class, but uses itself as the provider of +# libapp-cpanminus-perl) +# +def cpanm_dep_prepend(d): + if d.getVar('CPANM_DEPS', True): + return '' + pn = d.getVar('PN', True) + if pn in ['libapp-cpanminus-perl', 'libapp-cpanminus-perl-native']: + return '' + return 'libapp-cpanminus-perl-native ' + +DEPENDS_prepend = "${@cpanm_dep_prepend(d)}" + +cpanm_do_configure () { + if [ "${@is_target(d)}" = "yes" ]; then + # build for target + . ${STAGING_LIBDIR}/perl/config.sh + fi + + perl Build.PL --installdirs vendor \ + --destdir ${D} \ + --install_path arch="${libdir}/perl" \ + --install_path script=${bindir} \ + --install_path bin=${bindir} \ + --install_path bindoc=${mandir}/man1 \ + --install_path libdoc=${mandir}/man3 \ +} + +cpanm_do_compile () { + cpanm perl Build +} + +cpanm_do_install () { + cpanm perl Build install +} + +EXPORT_FUNCTIONS do_configure do_compile do_install -- cgit 1.2.3-korg