1 |
commit: 84ba7d0ccde1869bed07f9d9b9c2fac09f48c13a |
2 |
Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Sep 8 08:35:51 2019 +0000 |
4 |
Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Sep 8 08:35:51 2019 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/gcc-config.git/commit/?id=84ba7d0c |
7 |
|
8 |
gcc-config: consolidate profiles sourcing logic in a single function |
9 |
|
10 |
Bug: https://bugs.gentoo.org/174422 |
11 |
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org> |
12 |
|
13 |
gcc-config | 29 +++++++++++------------------ |
14 |
1 file changed, 11 insertions(+), 18 deletions(-) |
15 |
|
16 |
diff --git a/gcc-config b/gcc-config |
17 |
index 9965449..dd11c71 100755 |
18 |
--- a/gcc-config |
19 |
+++ b/gcc-config |
20 |
@@ -80,16 +80,15 @@ show_var() { |
21 |
echo "${!1}" |
22 |
} |
23 |
|
24 |
-# Compatibility with profile files created before 2019-09-05. |
25 |
-# These profile files were setting PATH variable. |
26 |
-# Sourcing them without restoring previous PATH value breaks gcc-config. |
27 |
-source_profile_pre() { |
28 |
- __PATH__=${PATH} |
29 |
-} |
30 |
+source_profile() { |
31 |
+ # Compatibility with profile files created before 2019-09-05. |
32 |
+ # These profile files were setting PATH variable. |
33 |
+ # Sourcing them without restoring previous PATH value breaks gcc-config. |
34 |
+ local backup_PATH=${PATH} |
35 |
+ |
36 |
+ source "$1" |
37 |
|
38 |
-source_profile_post() { |
39 |
- PATH=${__PATH__} |
40 |
- unset __PATH__ |
41 |
+ PATH=${backup_PATH} |
42 |
} |
43 |
|
44 |
try_real_hard_to_find_CHOST() { |
45 |
@@ -545,9 +544,7 @@ prefix_copy_gcc_libs() { |
46 |
for x in ${GCC_PROFILES} ; do |
47 |
unset GCC_PATH LDPATH |
48 |
eval $( |
49 |
- source_profile_pre |
50 |
- source "${x}" |
51 |
- source_profile_post |
52 |
+ source_profile "${x}" |
53 |
echo "GCC_PATH='${GCC_PATH}'" |
54 |
echo "LDPATH='${LDPATH%%:*}'" |
55 |
) |
56 |
@@ -613,9 +610,7 @@ switch_profile() { |
57 |
|
58 |
# Setup things properly again for this profile |
59 |
unset GCC_SPECS LDPATH MULTIOSDIRS |
60 |
- source_profile_pre |
61 |
- source "${GCC_ENV_D}/${CC_COMP}" |
62 |
- source_profile_post |
63 |
+ source_profile "${GCC_ENV_D}/${CC_COMP}" |
64 |
# Support older configs that did not setup MULTIOSDIRS for us. |
65 |
: ${MULTIOSDIRS:=../${GENTOO_LIBDIR}} |
66 |
|
67 |
@@ -830,9 +825,7 @@ list_profiles() { |
68 |
if [[ ${x} == ${CURRENT_NATIVE} ]] ; then |
69 |
x="${x} ${GOOD}*${NORMAL}" |
70 |
elif [[ -e ${GCC_ENV_D}/config-${target} ]] ; then |
71 |
- source_profile_pre |
72 |
- source "${GCC_ENV_D}/config-${target}" |
73 |
- source_profile_post |
74 |
+ source_profile "${GCC_ENV_D}/config-${target}" |
75 |
[[ ${x} == ${CURRENT} ]] && x="${x} ${HILITE}*${NORMAL}" |
76 |
fi |
77 |
echo " [${i}] ${x}" |