diff options
author | Kent Fredric <kentfredric@gmail.com> | 2016-04-11 21:58:36 +1200 |
---|---|---|
committer | Kent Fredric <kentnl@gentoo.org> | 2017-09-17 12:39:34 +1200 |
commit | 8d9b2b281577717bb223f50b24f57ed4eaebd56c (patch) | |
tree | 28f96cd417026d0391218d931a4346e731016b48 /eclass | |
parent | perl-module.eclass: Add DIST_EXAMPLES support to EAPI6 (diff) | |
download | perl-overlay-8d9b2b281577717bb223f50b24f57ed4eaebd56c.tar.gz perl-overlay-8d9b2b281577717bb223f50b24f57ed4eaebd56c.tar.bz2 perl-overlay-8d9b2b281577717bb223f50b24f57ed4eaebd56c.zip |
perl-functions.eclass: Add a new (not in ::gentoo) perl_check_eapi function
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/perl-functions.eclass | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/eclass/perl-functions.eclass b/eclass/perl-functions.eclass index b189ff32c..21fe60592 100644 --- a/eclass/perl-functions.eclass +++ b/eclass/perl-functions.eclass @@ -686,3 +686,57 @@ perl_domodule() { insinto "/${target#/}" doins "${doins_opts[@]}" "${files[@]}" } + +# @FUNCTION: perl_check_eapi +# @DESCRIPTION: +# Checks a blacklist of known-suspect eclass variables which can be accidentally set +# by maintainers, or may be accidentally left residual after an EAPI change. +# +# Dies if any of the suspect fields are found, and tell the user that the ebuild in question +# is broken and needs a fix. +# +# There's a workaround, but you'll have to read the code for it. +perl_check_eapi() { + local errored value; + local suspect_vars=(); + + # Secret sauce to inhibit this check + [[ -n "${_EAPI_PERL_MODULE_PERMISSIVE}" ]] && return; + + if [[ ${EAPI:-0} == 5 ]]; then + suspect_vars=( DIST_TEST DIST_VERSION DIST_NAME DIST_AUTHOR DIST_A_EXT DIST_A DIST_SECTION DIST_EXAMPLES ); + else + suspect_vars=( MY_PN MY_PV MODULE_VERSION MY_P MODULE_A MODULE_A_EXT MODULE_AUTHOR MODULE_NAME SRC_TEST MODULE_SECTION ); + fi + for i in "${suspect_vars[@]}"; do + [[ -v $i ]] || continue; + + # Add heading once and only once + if [[ ${errored:-0} == 0 ]]; then + if [[ -n "${I_KNOW_WHAT_I_AM_DOING}" ]]; then + elog "perl-module.eclass: Suspicious EAPI${EAPI:-0} eclass variables found."; + else + eerror "perl-module.eclass: Suspicious EAPI${EAPI:-0} eclass variables found."; + fi + fi + + errored=1 + # Print ENV name/value pair + if [[ -n "${I_KNOW_WHAT_I_AM_DOING}" ]]; then + elog " ${i}=\"${!i}\""; + else + eerror " ${i}=\"${!i}\""; + fi + done + # Return if there were no failures + [[ ${errored:-0} == 0 ]] && return; + + # Return if user knows what they're doing + if [[ -n "${I_KNOW_WHAT_I_AM_DOING}" ]]; then + elog "Continuing anyway, seems you know what you're doing." + return + fi + + eerror "Your ebuild/env contains eclass variables that are known invalid/legacy and indicate author oversight." + die "Please file a bug for this ebuild as per above details." +} |