Browse code

don't use symlinks except if the platform supports it. This affects existing installations (dist clean them). Improve mulle-bootstrap main command file. Improve assoc_array code

Nat! authored on 02-09-2016 16:02:39
Showing 12 changed files
... ...
@@ -1,7 +1,7 @@
1 1
 2.0
2 2
 ===
3 3
 
4
-* Add pre-build.sh script phase for libcurl
4
+* Add pre-build.sh script phase (for libcurl really)
5 5
 * Brew formulas are now installed locally into "addictions". A folder which
6 6
 lies besides "dependencies". This is a pretty huge change. By removing pips and
7 7
 gems, mulle-bootstrap can now claim to do only project relative installs.
... ...
@@ -10,13 +10,16 @@ gems, mulle-bootstrap can now claim to do only project relative installs.
10 10
  more proper way, didn't work with cmake generated xcode projects.
11 11
 * reorganized repository structure a bit
12 12
 * You can now specify ALL (always YES) or NONE (always NO) at the y/n prompt.
13
-* Support for MINGW (Windows) for cmake (experimental)
13
+* Support for MINGW on Windows for cmake and configure (experimental)
14 14
 * Finally added a proper dependency resolver
15 15
 * -f option now recognized by build and fetch
16 16
 * rewrote mulle-bootstrap so that the files in libexec are included and not
17
-executed, which is nicer for less environment pollution and ever so slightly 
17
+executed, which is nicer for less environment pollution and ever so slightly
18 18
 better performance.
19
-
19
+* rewrote mulle-bootstrap so that it works on systems, which do not have
20
+symlinks available.  This meant that I had to redo the whole settings
21
+inheritance scheme.
22
+* -v is now more interesting to watch
20 23
 
21 24
 1.1
22 25
 ===
... ...
@@ -119,7 +119,7 @@ do
119 119
          export MULLE_BOOTSTRAP_ANSWER  # override settings with environment
120 120
       ;;
121 121
 
122
-      -f) 
122
+      -f)
123 123
          MULLE_BOOTSTRAP_DIRTY_HARRY="NO"
124 124
       ;;
125 125
 
... ...
@@ -207,133 +207,148 @@ done
207 207
 
208 208
 bootstrap()
209 209
 {
210
-   if [ "$1" = "-h" -o "$1" = "--help" ]
211
-   then
212
-      cat <<EOF >&2
213
-usage: bootstrap
214
-   There is nothing more to it.
210
+   case "$1" in
211
+      -h|--help)
212
+         cat <<EOF >&2
213
+usage: bootstrap <dstprefix>
214
+
215
+   dstprefix : like /usr/local
215 216
 EOF
216
-      exit 1
217
-   fi
217
+         exit 1
218
+      ;;
219
+   esac
218 220
 
219 221
    #
220 222
    # this is run when checking mulle-project itself out
221 223
    #
222 224
    if [ -f "src/mulle-bootstrap-local-environment.sh" -a -x install.sh ]
223 225
    then
224
-      . install.sh "$@"
225
-      exit 0
226
-   else
227
-      . mulle-bootstrap-warn-scripts.sh 
228
-
229
-      warn_scripts_main "${BOOTSTRAP_SUBDIR}" || exit 1
226
+      exec install.sh "$@"
230 227
    fi
228
+}
229
+
231 230
 
232
-   . mulle-bootstrap-refresh.sh 
233
-   . mulle-bootstrap-fetch.sh  
234
-   . mulle-bootstrap-build.sh 
231
+ensure_consistency()
232
+{
233
+   local owd
234
+
235
+   owd="`pwd -P`"
235 236
 
236
-   if [ "${DONT_RECURSE}" = "" ]
237
+   if [ -f "${CLONESFETCH_SUBDIR}/.fetch_update_started" ]
237 238
    then
238
-      refresh_main                 || exit 1
239
-      fetch_main install "$@"      || exit 1
240
-   else
241
-      refresh_main nonrecursive    || exit 1
242
-      fetch_main nonrecursive "$@" || exit 1
243
-      refresh_main nonrecursive    || exit 1
239
+      log_error "A previous fetch or update was incomplete.
240
+Suggested resolution (in $owd):
241
+    ${C_RESET_BOLD}mulle-bootstrap clean dist${C_ERROR}
242
+    ${C_RESET_BOLD}mulle-bootstrap${C_ERROR}
243
+
244
+Or do you feel lucky ?
245
+   ${C_RESET_BOLD}rm $owd/${CLONESFETCH_SUBDIR}/.fetch_update_started${C_ERROR}
246
+and try again. But you've gotta ask yourself one question: Do I feel lucky ?
247
+Well, do ya, punk?
248
+(Same difference: if you are in \"${owd}\", ${C_RESET_BOLD}mulle-bootstrap fetch -f${C_ERROR})"
249
+      exit 1
244 250
    fi
245
-
246
-   # do it again now!
247
-   build_main "$@" || exit 1
248 251
 }
249 252
 
250 253
 
251
-main()
254
+
255
+bootstrap_main()
252 256
 {
253 257
    local command
254 258
 
255 259
    command=${1:-"bootstrap"}
256 260
    [ $# -eq 0 ] || shift
257 261
 
262
+   [ -z "${MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH}" ] && . mulle-bootstrap-local-environment.sh
263
+   [ -z "${MULLE_BOOTSTRAP_REFRESH_SH}" ] && . mulle-bootstrap-refresh.sh
264
+
258 265
    #
259 266
    # some commands only run when we have a .bootstrap folder
260 267
    #
261 268
    if [ ! -d "${BOOTSTRAP_SUBDIR}" ]
262 269
    then
263 270
       case "${command}" in
264
-         bootstrap|nomagic|build|ibuild|refresh)
265
-            echo "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue" >&2
266
-            exit 1
267
-         ;;
268
-         dist-clean|fetch|update|setup-xcode|xcode|tag)
269
-            echo "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue" >&2
270
-            exit 1
271
-         ;;
271
+         bootstrap|nomagic|build|ibuild|refresh|dist-clean|fetch|update|setup-xcode|xcode|tag)
272
+            fail "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue"
272 273
       esac
273 274
    fi
274 275
 
276
+   [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" != "NO" ] && ensure_consistency
277
+
275 278
    case "${command}" in
276
-      bootstrap)
277
-         bootstrap "$@" || exit 1
278
-      ;;
279
+      bootstrap|nomagic)
280
+         if [ "${command}" = "nomagic" ]
281
+         then
282
+            DONT_RECURSE=YES
283
+         fi
279 284
 
280
-      nomagic)
281
-         DONT_RECURSE=YES bootstrap "$@" || exit 1
285
+         . mulle-bootstrap-fetch.sh
286
+         . mulle-bootstrap-build.sh
287
+         . mulle-bootstrap-warn-scripts.sh
288
+
289
+         if [ "${DONT_RECURSE}" = "" ]
290
+         then
291
+            refresh_main                 || exit 1
292
+            fetch_main install "$@"      || exit 1
293
+         else
294
+            refresh_main nonrecursive    || exit 1
295
+            fetch_main nonrecursive "$@" || exit 1
296
+            refresh_main nonrecursive    || exit 1
297
+         fi
298
+
299
+         warn_scripts_main "${BOOTSTRAP_SUBDIR}" || exit 1
300
+
301
+         # do it again now!
302
+         build_main "$@" || exit 1
282 303
       ;;
283 304
 
284 305
       # experimental stuff
285 306
       project)
286
-         . mulle-bootstrap-project.sh 
307
+         . mulle-bootstrap-project.sh
287 308
 
288 309
          project_main "$@" || exit 1
289 310
       ;;
290 311
 
291 312
       install)
292
-         . mulle-bootstrap-install.sh 
313
+         . mulle-bootstrap-install.sh
293 314
 
294 315
          install_main "$@" || exit 1
295 316
       ;;
296 317
 
297 318
       build)
298
-         . mulle-bootstrap-refresh.sh 
299
-         . mulle-bootstrap-build.sh 
319
+         . mulle-bootstrap-build.sh
300 320
 
301 321
          refresh_main || exit 1
302 322
          build_main "$@" || exit 1
303 323
       ;;
304 324
 
305 325
       refresh)
306
-         . mulle-bootstrap-refresh.sh 
307
-
308 326
          refresh_main "$@" || exit 1
309 327
       ;;
310 328
 
311 329
       clean)
312
-         . mulle-bootstrap-refresh.sh 
313
-         . mulle-bootstrap-clean.sh 
330
+         . mulle-bootstrap-clean.sh
314 331
 
315 332
          refresh_main || exit 1
316 333
          clean_main "$@" || exit 1
317 334
       ;;
318 335
 
319 336
       dist-clean)
320
-         . mulle-bootstrap-refresh.sh 
321
-         . mulle-bootstrap-clean.sh 
337
+         . mulle-bootstrap-clean.sh
322 338
 
323 339
          refresh_main || exit 1
324 340
          clean_main "dist" || exit 1
325 341
       ;;
326 342
 
327 343
       fetch)
328
-         . mulle-bootstrap-refresh.sh 
329
-         . mulle-bootstrap-fetch.sh 
344
+         . mulle-bootstrap-fetch.sh
330 345
 
331 346
          refresh_main || exit 1
332 347
          DONT_ASK_AFTER_WARNING=YES fetch_main "install" "$@" || exit 1
333 348
       ;;
334 349
 
335 350
       update)
336
-         . mulle-bootstrap-fetch.sh 
351
+         . mulle-bootstrap-fetch.sh
337 352
 
338 353
          fetch_main "${command}" "$@" || exit 1
339 354
       ;;
... ...
@@ -345,16 +360,14 @@ main()
345 360
       ;;
346 361
 
347 362
       setup-xcode|xcode)
348
-         . mulle-bootstrap-refresh.sh 
349
-         . mulle-bootstrap-xcode.sh 
363
+         . mulle-bootstrap-xcode.sh
350 364
 
351 365
          refresh_main || exit 1
352 366
          xcode_main "$@" || exit 1
353 367
       ;;
354 368
 
355 369
       tag)
356
-         . mulle-bootstrap-refresh.sh 
357
-         . mulle-bootstrap-tag.sh 
370
+         . mulle-bootstrap-tag.sh
358 371
 
359 372
          refresh_main || exit 1
360 373
          tag_main "$@" || exit 1
... ...
@@ -368,7 +381,28 @@ main()
368 381
          log_error "Unknown command \"${command}\""
369 382
          usage
370 383
       ;;
371
-      esac
384
+   esac
385
+}
386
+
387
+
388
+main()
389
+{
390
+   local command
391
+
392
+   command=${1:-"bootstrap"}
393
+   [ $# -eq 0 ] || shift
394
+
395
+   case "${command}" in
396
+      bootstrap)
397
+         bootstrap "$@"
398
+      ;;
399
+   esac
400
+
401
+   #
402
+   # now setup an environment
403
+   #
404
+
405
+   bootstrap_main "$@"
372 406
 }
373 407
 
374
-main "$@"
408
+main
... ...
@@ -34,18 +34,6 @@ MULLE_BOOTSTRAP_ARRAY_SH="included"
34 34
 # declare "fail" outside
35 35
 # array contents can contain any characters except newline
36 36
 
37
-array_key_check()
38
-{
39
-   local n
40
-
41
-   n=`echo "$1" | wc -l`
42
-   [ $n -eq 0 ] && fail "empty key"
43
-   [ $n -ne 1 ] && fail "key \"$1\" has linebreaks"
44
-
45
-   echo "$1" | tr '>' '|'
46
-}
47
-
48
-
49 37
 array_value_check()
50 38
 {
51 39
    local n
... ...
@@ -96,25 +84,6 @@ array_index_check()
96 84
 }
97 85
 
98 86
 
99
-#
100
-# currently escaping is provided for code "outside" of array, but it really
101
-# should be done within the functions (slow though)
102
-#
103
-array_escape_value()
104
-{
105
-   local text
106
-
107
-   text="`echo "$@" | sed -e 's/|/\\|/g'`"
108
-   /bin/echo -n "${text}" | tr '\012' '|'
109
-}
110
-
111
-
112
-array_unescape_value()
113
-{
114
-   echo "$@" | tr '|' '\012' | sed -e 's/\\$/|/g' -e '/^$/d'
115
-}
116
-
117
-
118 87
 
119 88
 array_add()
120 89
 {
... ...
@@ -249,6 +218,25 @@ array_contains()
249 218
 # but be careful, that > chars are translated to |, so
250 219
 # get 'a|' and get 'a>' match
251 220
 #
221
+#
222
+# currently escaping is provided for code "outside" of array, but it really
223
+# should be done within the functions (slow though)
224
+#
225
+_assoc_array_key_check()
226
+{
227
+   local n
228
+
229
+   n=`echo "$1" | wc -w`
230
+   [ $n -eq 0 ] && fail "empty value"
231
+   [ $n -ne 1 ] && fail "key \"$1\" has spaces"
232
+
233
+   #
234
+   # escape charactes
235
+   # keys can't contain grep characters or '=''
236
+   #
237
+   echo "$1" | sed -e 's/[][\\.*^$=]/_/g'
238
+}
239
+
252 240
 
253 241
 _assoc_array_add()
254 242
 {
... ...
@@ -257,18 +245,18 @@ _assoc_array_add()
257 245
    local value
258 246
 
259 247
    array="$1"
260
-   key="`array_key_check "$2"`"
248
+   key="`_assoc_array_key_check "$2"`"
261 249
    value="`array_value_check "$3"`"
262 250
 
263
-   local value
251
+   local line
264 252
 
265
-   value="<${key}>${value}"
253
+   line="${key}=${value}"
266 254
    if [ -z "${array}" ]
267 255
    then
268
-       echo "${value}"
256
+       echo "${line}"
269 257
    else
270 258
        echo "${array}
271
-${value}"
259
+${line}"
272 260
    fi
273 261
 }
274 262
 
... ...
@@ -282,8 +270,8 @@ _assoc_array_remove()
282 270
 
283 271
    if [ ! -z "${array}" ]
284 272
    then
285
-       key="`array_key_check "$2"`"
286
-       echo "${array}" | fgrep -v "<${key}>"
273
+       key="`_assoc_array_key_check "$2"`"
274
+       echo "${array}" | grep -v "^${key}="
287 275
    fi
288 276
 }
289 277
 
... ...
@@ -294,9 +282,9 @@ assoc_array_get()
294 282
    local key
295 283
 
296 284
    array="$1"
297
-   key="`array_key_check "$2"`"
285
+   key="`_assoc_array_key_check "$2"`"
298 286
 
299
-   echo "${array}" | fgrep "<${key}>" | sed -n 's/^<.*>\(.*\)$/\1/p'
287
+   echo "${array}" | grep "^${key}=" | sed -n 's/^[^=]*=\(.*\)$/\1/p'
300 288
 }
301 289
 
302 290
 
... ...
@@ -306,7 +294,7 @@ assoc_array_get_last()
306 294
 
307 295
    array="$1"
308 296
 
309
-   echo "${array}" | tail -1 | sed -n 's/^<.*>\(.*\)$/\1/p'
297
+   echo "${array}" | tail -1 | sed -n 's/^[^=]*=\(.*\)$/\1/p'
310 298
 }
311 299
 
312 300
 
... ...
@@ -337,3 +325,41 @@ assoc_array_set()
337 325
 
338 326
    _assoc_array_add "${array}" "${key}" "${value}"
339 327
 }
328
+
329
+
330
+#
331
+# merge second array into first array
332
+# meaning if key in second array exists it overwrites
333
+# the value in the first array
334
+#
335
+assoc_array_merge_array()
336
+{
337
+   local array1
338
+   local array2
339
+
340
+   array="$1"
341
+   array="$2"
342
+
343
+   echo "${array2}" "${array1}" | sort -u -t'=' -k1,1
344
+}
345
+
346
+#
347
+# add second array into first array
348
+# meaning only keys in second array that don't exists in the
349
+# first are added
350
+#
351
+assoc_array_add_array()
352
+{
353
+   local array1
354
+   local array2
355
+
356
+   array="$1"
357
+   array="$2"
358
+
359
+   echo "${array1}" "${array2}" | sort -u -t'=' -k1,1
360
+}
361
+
362
+
363
+
364
+
365
+
... ...
@@ -113,8 +113,6 @@ bootstrap_auto_update()
113 113
 
114 114
       # now move it
115 115
       exekutor mv "${BOOTSTRAP_SUBDIR}.tmp" "${BOOTSTRAP_SUBDIR}.auto" || exit 1
116
-
117
-      # leave .scm files behind
118 116
    fi
119 117
 
120 118
    #
... ...
@@ -159,37 +157,31 @@ bootstrap_auto_update()
159 157
    done
160 158
    IFS="${old}"
161 159
 
162
-   # link scm files over, that we find
163
-   local relative
164
-
165
-   relative="`compute_relative "${BOOTSTRAP_SUBDIR}"`"
166
-   exekutor find "${directory}/.bootstrap" -xdev -mindepth 1 -maxdepth 1 -name "*.scm" -type f -print0 | \
167
-         exekutor xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/${name}"
168
-
169 160
    #
170
-   # link up other non-inheriting settings
161
+   # copy up other non-inheriting settings, if there aren't already settings there
171 162
    #
172
-   if dir_has_files "${directory}/.bootstrap/settings"
163
+   local srcsettingsdir
164
+
165
+   srcsettingsdir="${directory}/.bootstrap/settings"
166
+
167
+   if dir_has_files "${srcsettingsdir}"
173 168
    then
174
-      local relative
169
+      local dstdir
170
+      local dstsettingsdir
175 171
 
176
-      log_verbose "Link up build settings of \"${name}\" to \"${BOOTSTRAP_SUBDIR}.auto/settings/${name}\""
172
+      dstsettingsdir="${BOOTSTRAP_SUBDIR}.auto/settings"
173
+      dstdir="${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
177 174
 
178
-      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings"
179
-      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type f -print0 | \
180
-         exekutor xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}/%"
175
+      log_verbose "Copy build settings of \"${name}\" to \"${dstdir}\""
181 176
 
182
-      if [ -e "${directory}/.bootstrap/settings/bin"  ]
183
-      then
184
-         exekutor ln -s -f "${relative}/../../${directory}/.bootstrap/settings/bin" "${BOOTSTRAP_SUBDIR}.auto/settings/${name}/bin"
185
-      fi
177
+      mkdir_if_missing "${dstdir}"
178
+
179
+      local entry
186 180
 
187
-      #
188
-      # flatten other folders into our own settings
189
-      # don't force though, keep first
190
-      #
191
-      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type d -print0 | \
192
-         exekutor xargs -0 -I % ln -s "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings/%"
181
+      for entry in "${srcsettingsdir}"/*
182
+      do
183
+         exekutor cp -Ran "${entry}" "${dstdir}/"
184
+      done
193 185
    fi
194 186
 
195 187
    log_fluff "Acquisition of ${directory} .bootstrap settings finished"
... ...
@@ -679,7 +679,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
679 679
       cmakemodulepath="\${CMAKE_MODULE_PATH}"
680 680
       if [ ! -z "${CMAKE_MODULE_PATH}" ]
681 681
       then
682
-         cmakemodulepath="${CMAKE_MODULE_PATH}${PATH_SEPARATOR}${cmakemodulepath}"   # prepend    
682
+         cmakemodulepath="${CMAKE_MODULE_PATH}${PATH_SEPARATOR}${cmakemodulepath}"   # prepend
683 683
       fi
684 684
 
685 685
       local frameworkprefix
... ...
@@ -692,7 +692,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
692 692
 
693 693
       case "${UNAME}" in
694 694
          Darwin)
695
-            frameworkprefix="-F"         
695
+            frameworkprefix="-F"
696 696
          ;;
697 697
 
698 698
          MINGW*)
... ...
@@ -952,7 +952,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
952 952
       DEPENDENCIES_DIR="'${dependenciesdir}'" \
953 953
       CFLAGS="${other_cflags}" \
954 954
       CPPFLAGS="${other_cflags} ${other_cppflags}" \
955
-      LDFLAGS="${other_ldflags}" \ 
955
+      LDFLAGS="${other_ldflags}" \
956 956
       logging_exekutor "${owd}/${srcdir}/configure" ${configureflags} \
957 957
           --prefix "${prefixbuild}" >> "${logfile1}" \
958 958
       || build_fail "${logfile1}" "configure"
... ...
@@ -1582,7 +1582,7 @@ build()
1582 1582
    [ "${name}" != "${CLONES_SUBDIR}" ] || internal_fail "missing repo argument (${srcdir})"
1583 1583
 
1584 1584
    log_verbose "Building ${name} ..."
1585
-   
1585
+
1586 1586
    local preferences
1587 1587
 
1588 1588
    #
... ...
@@ -2032,7 +2032,7 @@ build_main()
2032 2032
             CLEAN_BEFORE_BUILD=
2033 2033
          ;;
2034 2034
 
2035
-         -f) 
2035
+         -f)
2036 2036
             MULLE_BOOTSTRAP_DIRTY_HARRY="NO"
2037 2037
          ;;
2038 2038
 
... ...
@@ -2080,8 +2080,6 @@ build_main()
2080 2080
       return 0
2081 2081
    fi
2082 2082
 
2083
-   [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" != "NO" ] && ensure_consistency
2084
-
2085 2083
    if [ $# -eq 0 ]
2086 2084
    then
2087 2085
       log_fluff "Setting up dependencies directory as \"${DEPENDENCY_SUBDIR}\""
... ...
@@ -52,7 +52,7 @@ _dependency_resolve()
52 52
    local dependencies
53 53
 
54 54
    escaped_dependencies="`assoc_array_get "${map}" "${name}"`"
55
-   dependencies="`array_unescape_value "${escaped_dependencies}"`"
55
+   dependencies="`unescape_linefeeds "${escaped_dependencies}"`"
56 56
 
57 57
    UNRESOLVED_DEPENDENCIES="`array_add "${UNRESOLVED_DEPENDENCIES}" "${name}"`"
58 58
 
... ...
@@ -103,7 +103,7 @@ dependency_add()
103 103
    local dependencies
104 104
 
105 105
    escaped_dependencies="`assoc_array_get "${map}" "${name}"`"
106
-   dependencies="`array_unescape_value "${escaped_dependencies}"`"
106
+   dependencies="`unescape_linefeeds "${escaped_dependencies}"`"
107 107
 
108 108
    if array_contains "${dependencies}" "${sub_name}"
109 109
    then
... ...
@@ -115,7 +115,7 @@ dependency_add()
115 115
    fi
116 116
 
117 117
    dependencies="`array_add "${dependencies}" "${sub_name}"`"
118
-   escaped_dependencies="`array_escape_value "${dependencies}"`"
118
+   escaped_dependencies="`escape_linefeeds "${dependencies}"`"
119 119
 
120 120
    assoc_array_set "${map}" "${name}" "${escaped_dependencies}"
121 121
 }
... ...
@@ -889,8 +889,9 @@ clone_embedded_repository()
889 889
       mkdir_if_missing "${symlinkdir}"
890 890
       symlinkcontent="${symlinkrelative}/${dstdir}"
891 891
 
892
+      # dont't use symlinks anymore
892 893
       log_fluff "Remember embedded repository \"${name}\" via \"${symlinkdir}/${name}\""
893
-      exekutor ln -s "${symlinkcontent}" "${symlinkdir}/${name}"
894
+      exekutor echo "${symlinkcontent}" > "${symlinkdir}/${name}"
894 895
 
895 896
       run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
896 897
    else
... ...
@@ -1352,8 +1353,6 @@ fetch_main()
1352 1353
       fi
1353 1354
    fi
1354 1355
 
1355
-   [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" != "NO" ] && ensure_consistency
1356
-
1357 1356
    #
1358 1357
    # Run prepare scripts if present
1359 1358
    #
... ...
@@ -122,10 +122,13 @@ log_trace2()
122 122
 fail()
123 123
 {
124 124
    log_error "$@"
125
-   kill -INT "${MULLE_BOOTSTRAP_PID}"  # kill myself (especially, if executing in subshell)
126
-   if [ $$ -ne ${MULLE_BOOTSTRAP_PID} ]
125
+   if [ ! -z "${MULLE_BOOTSTRAP_PID}" ]
127 126
    then
128
-      kill -INT $$  # actually useful
127
+      kill -INT "${MULLE_BOOTSTRAP_PID}"  # kill myself (especially, if executing in subshell)
128
+      if [ $$ -ne ${MULLE_BOOTSTRAP_PID} ]
129
+      then
130
+         kill -INT $$  # actually useful
131
+      fi
129 132
    fi
130 133
    exit 1        # paranoia
131 134
    # don't ask me why the fail message is printed twice
... ...
@@ -298,7 +301,7 @@ _canonicalize_file_path()
298 301
 {
299 302
     local dir file
300 303
 
301
-    dir="` dirname "$1"`"
304
+    dir="`dirname -- "$1"`"
302 305
     file="`basename -- "$1"`"
303 306
     (cd "${dir}" 2>/dev/null && echo "`pwd -P`/${file}")
304 307
 }
... ...
@@ -894,10 +897,10 @@ run_script()
894 897
       then
895 898
          echo "ARGV=" "$@" >&2
896 899
          echo "DIRECTORY=$PWD/$3" >&2
897
-         echo "ENVIRONMENT=" >&2 
898
-         echo "{" >&2 
900
+         echo "ENVIRONMENT=" >&2
901
+         echo "{" >&2
899 902
          env | sed 's/^\(.\)/   \1/' >&2
900
-         echo "}" >&2 
903
+         echo "}" >&2
901 904
       fi
902 905
       exekutor "${script}" "$@" || fail "script \"${script}\" did not run successfully"
903 906
    else
... ...
@@ -966,29 +969,6 @@ ensure_clones_directory()
966 969
 }
967 970
 
968 971
 
969
-ensure_consistency()
970
-{
971
-   local owd
972
-
973
-   owd="`pwd -P`"
974
-
975
-   if [ -f "${CLONESFETCH_SUBDIR}/.fetch_update_started" ]
976
-   then
977
-      log_error "A previous fetch or update was incomplete.
978
-Suggested resolution (in $owd):
979
-    ${C_RESET_BOLD}mulle-bootstrap clean dist${C_ERROR}
980
-    ${C_RESET_BOLD}mulle-bootstrap${C_ERROR}
981
-
982
-Or do you feel lucky ?
983
-   ${C_RESET_BOLD}rm $owd/${CLONESFETCH_SUBDIR}/.fetch_update_started${C_ERROR}
984
-and try again. But you've gotta ask yourself one question: Do I feel lucky ?
985
-Well, do ya, punk?
986
-(Same difference: if you are in \"${owd}\", ${C_RESET_BOLD}mulle-bootstrap fetch -f${C_ERROR})"
987
-      exit 1
988
-   fi
989
-}
990
-
991
-
992 972
 get_core_count()
993 973
 {
994 974
     count="`nproc 2> /dev/null`"
... ...
@@ -1053,7 +1033,7 @@ add_path()
1053 1033
 {
1054 1034
    local line
1055 1035
    local path
1056
-  
1036
+
1057 1037
    [ -z "${PATH_SEPARATOR}" ] && fail "PATH_SEPARATOR is undefined"
1058 1038
    [ -z "${UNAME}" ] && fail "UNAME is undefined"
1059 1039
 
... ...
@@ -1065,7 +1045,7 @@ add_path()
1065 1045
          path="`echo "${path}" | tr '/' '\\' 2> /dev/null`"
1066 1046
       ;;
1067 1047
    esac
1068
-  
1048
+
1069 1049
    if [ -z "${line}" ]
1070 1050
    then
1071 1051
       echo "${path}"
... ...
@@ -1092,3 +1072,19 @@ add_line()
1092 1072
 ${line}"
1093 1073
    fi
1094 1074
 }
1075
+
1076
+
1077
+escape_linefeeds()
1078
+{
1079
+   local text
1080
+
1081
+   text="`echo "$@" | sed -e 's/|/\\|/g'`"
1082
+   /bin/echo -n "${text}" | tr '\012' '|'
1083
+}
1084
+
1085
+
1086
+unescape_linefeeds()
1087
+{
1088
+   echo "$@" | tr '|' '\012' | sed -e 's/\\$/|/g' -e '/^$/d'
1089
+}
1090
+
... ...
@@ -60,7 +60,7 @@ main_project()
60 60
 
61 61
    if [ "$1" = "" -o "$1" = "-h" -o "$1" = "--help" ]
62 62
    then
63
-      project_usage 
63
+      project_usage
64 64
    fi
65 65
 
66 66
    command="$1"
... ...
@@ -77,7 +77,7 @@ main_project()
77 77
    clone)
78 78
       set -e
79 79
       git clone "$1"
80
-      cd "`basename "$1"`"
80
+      cd "`basename -- "$1"`"
81 81
       mulle-bootstrap-fetch.sh || exit 1
82 82
       if [ -x "./build.sh" ]
83 83
       then
... ...
@@ -122,7 +122,7 @@ ${clone}"
122 122
                   sub_repos="`_read_setting "${filename}"`"
123 123
                   if [ ! -z "${sub_repos}" ]
124 124
                   then
125
-                     dependency_map="`dependency_add "${dependency_map}" "**ROOT**" "${url}"`"
125
+                     dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${url}"`"
126 126
                      dependency_map="`dependency_add_array "${dependency_map}" "${url}" "${sub_repos}"`"
127 127
                      if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
128 128
                      then
... ...
@@ -152,7 +152,7 @@ ${clone}"
152 152
    #
153 153
    local repositories
154 154
 
155
-   repositories="`dependency_resolve "${dependency_map}" "**ROOT**" | fgrep -v -x "**ROOT**"`"
155
+   repositories="`dependency_resolve "${dependency_map}" "__ROOT__" | fgrep -v -x "__ROOT__"`"
156 156
    if [ ! -z "${repositories}" ]
157 157
    then
158 158
       if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
... ...
@@ -328,8 +328,8 @@ mark_all_embedded_repositories_zombies()
328 328
 
329 329
       for symlink in `ls -1d "${path}/"*`
330 330
       do
331
-         i="`readlink "$symlink"`"
332
-         name="`basename "$i"`"
331
+         i="`cat "$symlink"`"
332
+         name="`basename -- "$i"`"
333 333
          exekutor touch "${zombiepath}/${name}"
334 334
       done
335 335
    else
... ...
@@ -117,7 +117,7 @@ _read_setting()
117 117
          local os
118 118
          local name
119 119
 
120
-         os="`uname`"
120
+         os="${UNAME:-`uname`}"
121 121
          name="`basename -- "${file}" ".${os}"`"
122 122
          log_fluff "${C_MAGENTA}${C_BOLD}`basename -- "${file}" ".${os}"`${C_FLUFF} found as \"${file}\""
123 123
       fi
... ...
@@ -129,7 +129,7 @@ _read_setting()
129 129
          local os
130 130
          local name
131 131
 
132
-         os="`uname`"
132
+         os="${UNAME:-`uname`}"
133 133
          name="`basename -- "${file}" ".${os}"`"
134 134
          if [ "${name}" = "repositories" -o "${name}" = "repositories.tmp" -o  "${name}" = "embedded_repositories" ]
135 135
          then
... ...
@@ -236,10 +236,10 @@ _read_bootstrap_setting()
236 236
    name="$1"
237 237
    shift
238 238
 
239
-   [ $# -gt 0 ]      || internal_fail "parameterization error"
240
-   [ ! -z "${name}" ] || internal_fail "missing parameters in _read_bootstrap_setting"
239
+   [ $# -eq 0 ]     && internal_fail "parameterization error"
240
+   [ -z "${name}" ] && internal_fail "missing parameters in _read_bootstrap_setting"
241 241
 
242
-   while [ $# -gt 0 ]
242
+   while [ $# -ne 0 ]
243 243
    do
244 244
       suffix="${1}"
245 245
       shift
... ...
@@ -463,7 +463,7 @@ read_fetch_setting()
463 463
    value="`_read_bootstrap_setting "${name}" ".auto" ".local"`"
464 464
    if [ $? -ne 0 ]
465 465
    then
466
-      os="`uname`"
466
+      os="${UNAME:-`uname`}"
467 467
       value="`_read_bootstrap_setting "${name}.${os}" ""`"
468 468
       if [ $? -ne 0 ]
469 469
       then
... ...
@@ -226,8 +226,6 @@ main_tag()
226 226
       tag_usage
227 227
    fi
228 228
 
229
-   [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" != "NO" ] && ensure_consistency
230
-
231 229
    if [ -z "${GIT_FLAGS}" ]
232 230
    then
233 231
       ensure_tags_unknown "${CLONES_SUBDIR}" "${TAG}"