Browse code

* unified mktemp handling across platforms * add libexec to build PATH, for the benefits of scripts (regression)

Nat! authored on 10-10-2017 15:03:04
Showing 6 changed files
... ...
@@ -31,7 +31,7 @@
31 31
 #
32 32
 MULLE_EXECUTABLE_VERSION_MAJOR=3
33 33
 MULLE_EXECUTABLE_VERSION_MINOR=13
34
-MULLE_EXECUTABLE_VERSION_PATCH=5
34
+MULLE_EXECUTABLE_VERSION_PATCH=6
35 35
 
36 36
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
37 37
 
... ...
@@ -229,24 +229,24 @@ resolve_symlinks()
229 229
 
230 230
 bootstrap_libexec_path()
231 231
 {
232
-   local path="$1"
232
+   local executablepath="$1"
233 233
 
234 234
    local exedir
235 235
    local exedirpath
236 236
    local prefix
237 237
    local libexecpath
238 238
 
239
-   case "${path}" in
239
+   case "${executablepath}" in
240 240
       \.*|/*|~*)
241 241
       ;;
242 242
 
243 243
       *)
244
-         path="`command -v "${path}"`"
244
+         executablepath="`command -v "${executablepath}"`"
245 245
       ;;
246 246
    esac
247 247
 
248
-   path="`resolve_symlinks "${path}"`"
249
-   exedirpath="`dirname "${path}"`"
248
+   executablepath="`resolve_symlinks "${executablepath}"`"
249
+   exedirpath="`dirname "${executablepath}"`"
250 250
    prefix="`dirname "${exedirpath}"`"
251 251
    libexecpath="${prefix}/libexec/mulle-bootstrap"
252 252
 
... ...
@@ -273,16 +273,14 @@ bootstrap_libexec_path()
273 273
 
274 274
 bootstrap_init()
275 275
 {
276
-   local libexecpath
277
-
278
-   libexecpath="`bootstrap_libexec_path "$0"`"
279
-   if [ -z "${libexecpath}" ]
276
+   MULLE_LIBEXEC_PATH="`bootstrap_libexec_path "$0"`"
277
+   if [ -z "${MULLE_LIBEXEC_PATH}" ]
280 278
    then
281 279
       echo "Fatal Error: Could not find libexec for ${MULLE_EXECUTABLE} ($PWD)" >&2
282 280
       exit 1
283 281
    fi
284 282
 
285
-   PATH="${libexecpath}:$PATH"
283
+   PATH="${MULLE_LIBEXEC_PATH}:$PATH"
286 284
    export PATH
287 285
 
288 286
    if [ ! -z "${MULLE_BOOTSTRAP_LIBEXEC_TRACE}" ]
... ...
@@ -296,7 +294,7 @@ bootstrap_init()
296 294
    #
297 295
    case "${1}" in
298 296
       library-path)
299
-         echo "${libexecpath}"
297
+         echo "${MULLE_LIBEXEC_PATH}"
300 298
          exit 0
301 299
       ;;
302 300
 
... ...
@@ -729,8 +727,6 @@ MULLE_EXECUTABLE_PID="$$"
729 727
 export MULLE_EXECUTABLE_PID
730 728
 
731 729
 
732
-
733
-
734 730
 bootstrap_init "$@" # needs params
735 731
 
736 732
 
... ...
@@ -70,7 +70,7 @@ _bootstrap_auto_copy()
70 70
    #
71 71
    # this first stage folds platform specific files
72 72
    #
73
-   tmpdir="`mktemp -d /tmp/mulle-bootstrap.XXXXXXXX`"
73
+   tmpdir="`make_tmp_directory "bootstrap"`"
74 74
    inherit_files "${tmpdir}" "${src}"
75 75
    inherit_scripts "${tmpdir}" "${src}"
76 76
 
... ...
@@ -175,6 +175,9 @@ build_complete_environment()
175 175
    BUILDPATH="`prepend_to_search_path_if_missing "${MULLE_EXECUTABLE_ENV_PATH}" \
176 176
                                                  "${ADDICTIONS_DIR}/bin"`"
177 177
 
178
+   # for scripts
179
+   BUILDPATH="${BUILDPATH}:${MULLE_LIBEXEC_PATH}"
180
+
178 181
    #
179 182
    # dont export stuff for scripts
180 183
    # if scripts want it, they should source this file
... ...
@@ -186,7 +189,7 @@ build_complete_environment()
186 189
          setup_mingw_buildenvironment
187 190
 
188 191
          BUILDPATH="`mingw_buildpath "${BUILDPATH}"`"
189
-         # if mulle-bootstrap is not properly installed pickup .bat path 
192
+         # if mulle-bootstrap is not properly installed pickup .bat path
190 193
          # this way
191 194
          local pretty
192 195
 
... ...
@@ -1188,6 +1188,35 @@ remove_file_if_present()
1188 1188
    fi
1189 1189
 }
1190 1190
 
1191
+
1192
+_make_tmp()
1193
+{
1194
+   local name="${1:-mctmp}"
1195
+   local type="${2}"
1196
+
1197
+   case "${UNAME}" in
1198
+      darwin|freebsd)
1199
+         exekutor mktemp ${type} "/tmp/${name}.XXXXXX"
1200
+      ;;
1201
+
1202
+      *)
1203
+         exekutor mktemp ${type} -t "${name}.XXXXXX"
1204
+      ;;
1205
+   esac
1206
+}
1207
+
1208
+
1209
+make_tmp_file()
1210
+{
1211
+   _make_tmp "$1"
1212
+}
1213
+
1214
+
1215
+make_tmp_directory()
1216
+{
1217
+   _make_tmp "$1" "-d"
1218
+}
1219
+
1191 1220
 # ####################################################################
1192 1221
 #                        Symbolic Links
1193 1222
 # ####################################################################
... ...
@@ -1015,7 +1015,7 @@ tar_unpack()
1015 1015
    esac
1016 1016
 
1017 1017
    rmdir_safer "${name}.tmp"
1018
-   tmpdir="`exekutor mktemp -d "${name}.XXXXXXXX"`" || return 1
1018
+   tmpdir="`make_tmp_directory "${name}"`" || return 1
1019 1019
    (
1020 1020
       exekutor cd "${tmpdir}" || return 1
1021 1021
 
... ...
@@ -1051,7 +1051,7 @@ zip_unpack()
1051 1051
    archivename="`extension_less_basename "${download}"`"
1052 1052
 
1053 1053
    rmdir_safer "${name}.tmp"
1054
-   tmpdir="`exekutor mktemp -d "${name}.XXXXXXXX"`" || exit 1
1054
+   tmpdir="`make_tmp_directory "${name}"`" || exit 1
1055 1055
    (
1056 1056
       exekutor cd "${tmpdir}" || return 1
1057 1057
 
... ...
@@ -171,7 +171,7 @@ force_rebuild()
171 171
    #
172 172
    local tmpfile
173 173
 
174
-   tmpfile="`exekutor mktemp "mulle-bootstrap.XXXXXXXX"`" || exit 1
174
+   tmpfile="`make_tmp_file "bootstrap"`" || exit 1
175 175
 
176 176
    redirect_exekutor "${tmpfile}" snip_from_to_file "${from}" "${to}" "${REPOS_DIR}/.build_done"
177 177
    exekutor mv "${tmpfile}" "${REPOS_DIR}/.build_done"