--- perl-module.eclass 2015-03-15 12:49:17.976368033 +1300 +++ perl-module.eclass 2015-03-15 13:40:12.750005314 +1300 @@ -114,6 +114,8 @@ [[ ${SRC_PREP} = yes ]] && return 0 SRC_PREP="yes" + perl_check_env + perl_set_version [[ -z ${pm_echovar} ]] && export PERL_MM_USE_DEFAULT=1 @@ -548,3 +550,44 @@ popd > /dev/null fi } + +# @FUNCTION: perl_check_env +# @USAGE: perl_check_env +# @DESCRIPTION: +# Checks a blacklist of known-suspect ENV values that can be accidentally set by users +# doing personal perl work, which may accidentally leak into portage and break the +# system perl installaton. +# Dies if any of the suspect fields are found, and tells users the circumvention options +# for the problem, whether it be unsetting the bad fields, or setting +# I_KNOW_WHAT_IM_DOING=1 +perl_check_env() { + local warned value; + + for i in PERL_MM_OPT PERL5LIB PERL5OPT PERL_MB_OPT PERL_CORE PERLPREFIX; do + # Next Loop unless match + [ -v $i ] || continue; + + # Warn only once, and warn only when one of the bad values are set. + # record failure here. + if [ ${warned:-0} == 0 ]; then + if [ ${I_KNOW_WHAT_IM_DOING:-0} == 1 ]; then + ewarn "Potentially bad ENV values found but I_KNOW_WHAT_IM_DOING=1"; + else + ewarn "Bad ENV values found. Please unset from ENV ( ~/.bashrc, package.env, etc ) or set I_KNOW_WHAT_IM_DOING=1" + fi + warned=1 + fi + + # Read ENV Value + eval "value=\$$i"; + + # Print ENV name/value pair + ewarn " $i=\"$value\""; + done + + # If any failures occurred, die unless I_KNOW_WHAT_IM_DOING + if [ ${warned:-0} == 1 ] && [ ${I_KNOW_WHAT_IM_DOING:-0} != 1 ]; then + die; + fi +} +