Browse code

fix PATH generation for homebrew

Nat! authored on 11-11-2016 19:13:45
Showing 4 changed files
... ...
@@ -1,12 +1,13 @@
1 1
 2.4.2
2 2
 ===
3 3
 
4
-Exit with 0 when printing version.
4
+Make PATH generation compatible with homebrew shims
5 5
 
6 6
 
7 7
 2.4.1
8 8
 ===
9 9
 
10
+Exit with 0 when printing version.
10 11
 Emit better .gitignore code for symlinked embedded repos
11 12
 
12 13
 2.4.0
... ...
@@ -30,7 +30,7 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 MULLE_BOOTSTRAP_VERSION_MAJOR=2
32 32
 MULLE_BOOTSTRAP_VERSION_MINOR=4
33
-MULLE_BOOTSTRAP_VERSION_PATCH=1
33
+MULLE_BOOTSTRAP_VERSION_PATCH=2
34 34
 
35 35
 MULLE_BOOTSTRAP_VERSION="${MULLE_BOOTSTRAP_VERSION_MAJOR}.${MULLE_BOOTSTRAP_VERSION_MINOR}.${MULLE_BOOTSTRAP_VERSION_PATCH}"
36 36
 MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap"
... ...
@@ -197,7 +197,7 @@ bootstrap_main()
197 197
 
198 198
    BOOTSTRAP_SUBDIR=.bootstrap
199 199
 
200
-   PATH="/usr/local/libexec/mulle-bootstrap:`pwd -P`/dependencies/bin:`pwd -P`/addictions/bin:$PATH"
200
+   PATH="/usr/local/libexec/mulle-bootstrap:$PATH"
201 201
    export PATH
202 202
 
203 203
    #
... ...
@@ -223,7 +223,7 @@ bootstrap_main()
223 223
    # logging and UNAME
224 224
 
225 225
    . mulle-bootstrap-logging.sh
226
-   . mulle-bootstrap-local-environment.sh
226
+   . mulle-bootstrap-local-environment.sh || fail "not loaded"
227 227
 
228 228
    trap trap_fail INT
229 229
 
... ...
@@ -390,6 +390,11 @@ bootstrap_main()
390 390
 
391 391
    local_environment_main
392 392
 
393
+   PATH="`make_executable_search_path "$PATH"`"
394
+   export PATH
395
+
396
+   log_verbose "PATH set to: $PATH"
397
+
393 398
    #
394 399
    # some commands only run when we have a .bootstrap folder
395 400
    #
... ...
@@ -504,7 +509,7 @@ bootstrap_main()
504 509
 
505 510
       library-path)
506 511
          echo "$PATH" | tr ':' '\012' | head -1
507
-         exit 0
512
+         return 0
508 513
       ;;
509 514
 
510 515
       refresh)
... ...
@@ -548,7 +553,7 @@ bootstrap_main()
548 553
 
549 554
       version)
550 555
          echo "${MULLE_BOOTSTRAP_VERSION}"
551
-         exit 0
556
+         return 0
552 557
       ;;
553 558
 
554 559
       *)
... ...
@@ -559,3 +564,6 @@ bootstrap_main()
559 564
 }
560 565
 
561 566
 bootstrap_main "$@"
567
+
568
+trap - TERM EXIT
569
+
... ...
@@ -218,31 +218,6 @@ add_cmake_path()
218 218
 }
219 219
 
220 220
 
221
-add_path()
222
-{
223
-   local line
224
-   local path
225
-
226
-   [ -z "${PATH_SEPARATOR}" ] && fail "PATH_SEPARATOR is undefined"
227
-
228
-   line="$1"
229
-   path="$2"
230
-
231
-   case "${UNAME}" in
232
-      mingw)
233
-         path="`echo "${path}" | tr '/' '\\' 2> /dev/null`"
234
-      ;;
235
-   esac
236
-
237
-   if [ -z "${line}" ]
238
-   then
239
-      echo "${path}"
240
-   else
241
-      echo "${line}${PATH_SEPARATOR}${path}"
242
-   fi
243
-}
244
-
245
-
246 221
 add_line()
247 222
 {
248 223
    local lines
... ...
@@ -313,6 +288,7 @@ expand_environment_variables()
313 288
 }
314 289
 
315 290
 
291
+
316 292
 # ####################################################################
317 293
 #                             Path handling
318 294
 # ####################################################################
... ...
@@ -82,6 +82,78 @@ get_core_count()
82 82
 }
83 83
 
84 84
 
85
+add_path()
86
+{
87
+   local line
88
+   local path
89
+
90
+   [ -z "${PATH_SEPARATOR}" ] && fail "PATH_SEPARATOR is undefined"
91
+
92
+   line="$1"
93
+   path="$2"
94
+
95
+   case "${UNAME}" in
96
+      mingw)
97
+         path="`echo "${path}" | tr '/' '\\' 2> /dev/null`"
98
+      ;;
99
+   esac
100
+
101
+   if [ -z "${line}" ]
102
+   then
103
+      echo "${path}"
104
+   else
105
+      echo "${line}${PATH_SEPARATOR}${path}"
106
+   fi
107
+}
108
+
109
+
110
+make_executable_search_path()
111
+{
112
+   local path
113
+
114
+   path="$1"
115
+   #
116
+   #
117
+   #
118
+   local new_path
119
+   local tail_path
120
+   local directory
121
+
122
+   tail_path=""
123
+   new_path=""
124
+   directory="`pwd -P`"
125
+
126
+   tail_path="`add_path "${tail_path}" "${directory}/addictions/bin"`"
127
+   tail_path="`add_path "${tail_path}" "${directory}/dependencies/bin"`"
128
+
129
+   local i
130
+   local oldifs
131
+
132
+   oldifs="$IFS"
133
+   IFS=":"
134
+
135
+   for i in $path
136
+   do
137
+      IFS="${oldifs}"
138
+
139
+      # shims stay in front (homebrew)
140
+      case "$i" in
141
+         */shims/*)
142
+            new_path="`add_path "${new_path}" "$i"`"
143
+         ;;
144
+
145
+         *)
146
+            tail_path="`add_path "${tail_path}" "$i"`"
147
+         ;;
148
+      esac
149
+   done
150
+
151
+   IFS="${oldifs}"
152
+
153
+   add_path "${new_path}" "${tail_path}"
154
+}
155
+
156
+
85 157
 # figure out if we need to run refresh
86 158
 build_needed()
87 159
 {