Currently, the multilib_toolchain_setup function does not distinguish
between unset and empty variables. Therefore, variables which were unset
before calling it are restored as empty and exported. This breaks some
packages, e.g. libdbusmenu.

This patch 'disables' saving variables which were unset, therefore
making the saved variants unset. Then, restoring exports only those
variables which were set in the saved variants and unsets remaining
ones.

Fixes: https://bugs.gentoo.org/show_bug.cgi?id=461682
---
 gx86/eclass/multilib.eclass | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gx86/eclass/multilib.eclass b/gx86/eclass/multilib.eclass
index 13583d0..dd78d38 100644
--- a/gx86/eclass/multilib.eclass
+++ b/gx86/eclass/multilib.eclass
@@ -397,7 +397,8 @@ multilib_toolchain_setup() {
        if [[ ${__DEFAULT_ABI_SAVED} == "true" ]] ; then
                for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH} ; do
                        vv="__abi_saved_${v}"
-                       export ${v}="${!vv}"
+                       unset ${v}
+                       [[ ${!vv+1} ]] && export ${v}="${!vv}"
                        unset ${vv}
                done
                unset __DEFAULT_ABI_SAVED
@@ -408,7 +409,9 @@ multilib_toolchain_setup() {
        if [[ ${ABI} != ${DEFAULT_ABI} ]] ; then
                # Back that multilib-ass up so we can restore it later
                for v in CHOST CBUILD AS CC CXX LD PKG_CONFIG_{LIBDIR,PATH} ; do
-                       export __abi_saved_${v}="${!v}"
+                       vv=__abi_saved_${v}
+                       unset ${vv}
+                       [[ ${!v+1} ]] && export ${vv}="${!v}"
                done
                export __DEFAULT_ABI_SAVED="true"
 
-- 
1.8.1.5


Reply via email to