commit:     0f2a105de5c407a2fa0113d0815d54e0067bbb4b
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 21 18:42:28 2021 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Mon Jun 21 18:42:28 2021 +0000
URL:        https://gitweb.gentoo.org/proj/crossdev.git/commit/?id=0f2a105d

crossdev: fail eval when multilib.eclass sourcing fails

Before the change failure to source 'multilib.eclass' resuled in
a fallback mode to be used instead of hard failure.

It was caused by two expansion layers of 'eval $(...)'.

After the change falure to source 'mmultilib.eclass' hard fails early:

```
$ PORTAGE_CONFIGROOT=$(pwd)/foo EPREFIX=$(pwd)/foo PORT_LOGDIR=$(pwd)/foo 
./crossdev -t mmix -P -p
 * error: : EAPI 0 not supported
 *
 * If you file a bug, please attach the following logfiles:
 * /home/slyfox/dev/git/crossdev/foo/cross--info.log
 *
 * error: could not load multilib settings for 'HCHOST'
 *
 * If you file a bug, please attach the following logfiles:
 * /home/slyfox/dev/git/crossdev/foo/cross-mmix-info.log
```

Reported-by: Marco Scardovi (scardracs)
Bug: https://bugs.gentoo.org/797367
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 crossdev | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/crossdev b/crossdev
index 1a2b030..619603f 100755
--- a/crossdev
+++ b/crossdev
@@ -968,6 +968,9 @@ fi
 # parse multilib settings until profiles are sane
 load_multilib_env() {
        local var=$1
+       # TODO: avoid eval+subshell and use subshell only. It will make error
+       # handling simpler.
+       local eval_result=failed
        eval $(
        # see what target to parse
        CTARGET=${!var}
@@ -1016,7 +1019,9 @@ load_multilib_env() {
                        echo ${_v}=\'${!d}\'
                done
        done
+       echo "eval_result='succeeded'"
        )
+       [[ $eval_result = succeeded ]] || die "could not load multilib settings 
for '${var}'"
 }
 # Load settings for the host.
 MULTILIB_ABIS=${HOST_ABI} load_multilib_env HCHOST

Reply via email to