Browse code

Implemented -n on init, fetch, clean and tag. Split functions into two files. Reworked the way xcodebuild is called. Reworked the way clean is doing it. Added support for MULLE_BOOTSTRAP_TRACE_SETTINGS and MULLE_BOOTSTRAP_TRACE_ACCESS_SETTINGS) e.g. MULLE_BOOTSTRAP_TRACE_SETTINGS=YES ./mulle-bootstrap Can now deal with spaces in setting variables.

Nat! authored on 29-09-2015 16:36:18
Showing 11 changed files
... ...
@@ -6,9 +6,10 @@ mulle-bootstrap-functions.sh \
6 6
 mulle-bootstrap-gcc.sh \
7 7
 mulle-bootstrap-init.sh \
8 8
 mulle-bootstrap-local-environment.sh \
9
-mulle-bootstrap-setup-xcode.sh \
9
+mulle-bootstrap-settings.sh \
10 10
 mulle-bootstrap-tag.sh \
11
-mulle-bootstrap-warn-scripts.sh
11
+mulle-bootstrap-warn-scripts.sh \
12
+mulle-bootstrap-xcode.sh
12 13
 
13 14
 CHECKSTAMPS=$(SCRIPTS:.sh=.chk)
14 15
 SHELLFLAGS=-x -e SC2164,SC2166,SC2006 -s sh
... ...
@@ -39,9 +39,20 @@ BOOTSTRAP_SUBDIR=.bootstrap
39 39
 PATH="/usr/local/libexec/mulle-bootstrap:$PATH"
40 40
 export PATH
41 41
 
42
+#
43
+# simple option handling
44
+#
45
+if [ "$1" = "-n" ]
46
+then
47
+   MULLE_BOOTSTRAP_DRY_RUN=YES
48
+   export MULLE_BOOTSTRAP_DRY_RUN
49
+   shift
50
+fi
51
+
42 52
 command=${1:-"bootstrap"}
43 53
 shift
44 54
 
55
+
45 56
 . mulle-bootstrap-warn-scripts.sh
46 57
 
47 58
 
... ...
@@ -107,8 +118,8 @@ case "${command}" in
107 118
       mulle-bootstrap-tag.sh "$@" || exit 1
108 119
       ;;
109 120
    *)
110
-      echo "usage: mulle-bootstrap [command]" >&2
111
-      echo "version 0.0" >&2
121
+      echo "usage: mulle-bootstrap [-n] [command]" >&2
122
+      echo "version 0.1" >&2
112 123
       echo    " Common user commands:" >&2
113 124
       echo    "   bootstrap : does fetch and build recursively [default]" >&2
114 125
       echo    "   nomagic   : does fetch and build, but not recursively" >&2
... ...
@@ -58,11 +58,11 @@ collect_and_dispense_product()
58 58
       if dir_has_files "${src}"
59 59
       then
60 60
          dst="${DEPENDENCY_SUBDIR}${HEADER_PATH}"
61
-         mkdir -p "${dst}" 2> /dev/null
62
-         find -x "${src}" ! -path "${src}" -depth 1 -type d -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
63
-         find -x  "${src}" ! -path "${src}" -depth 1 -type f -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
61
+         exekutor mkdir -p "${dst}" 2> /dev/null
62
+         exekutor find -x "${src}" ! -path "${src}" -depth 1 -type d -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
63
+         exekutor find -x  "${src}" ! -path "${src}" -depth 1 -type f -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
64 64
       fi
65
-      rm -rf "${src}"
65
+      exekutor rm -rf "${src}"
66 66
    fi
67 67
 
68 68
    src="${output}/lib"
... ...
@@ -71,10 +71,10 @@ collect_and_dispense_product()
71 71
       if dir_has_files "${src}"
72 72
       then
73 73
          dst="${DEPENDENCY_SUBDIR}${LIBRARY_PATH}${subdir}"
74
-         mkdir -p "${dst}" 2> /dev/null
75
-         find -x  "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \;  2> /dev/null
74
+         exekutor mkdir -p "${dst}" 2> /dev/null
75
+         exekutor find -x  "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \;  2> /dev/null
76 76
       fi
77
-      rm -rf "${src}"
77
+      exekutor rm -rf "${src}"
78 78
    fi
79 79
 
80 80
    src="${output}/Frameworks"
... ...
@@ -83,16 +83,16 @@ collect_and_dispense_product()
83 83
       if dir_has_files "${src}"
84 84
       then
85 85
          dst="${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${subdir}"
86
-         mkdir -p "${dst}" 2> /dev/null
87
-         find -x "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \; 2> /dev/null
86
+         exekutor mkdir -p "${dst}" 2> /dev/null
87
+         exekutor find -x "${src}" ! -path "${src}" -depth 1 -exec mv -v '{}' "${dst}" \; 2> /dev/null
88 88
       fi
89
-      rm -rf "${src}"
89
+      exekutor rm -rf "${src}"
90 90
    fi
91 91
 
92 92
    # now copy over the rest of the output
93 93
 
94 94
    dst="${DEPENDENCY_SUBDIR}"
95
-   find -x "${output}" ! -path "${output}" -depth 1 -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
95
+   exekutor find -x "${output}" ! -path "${output}" -depth 1 -exec mv -v -n '{}' "${dst}" \;  2> /dev/null
96 96
 
97 97
    return 0
98 98
 }
... ...
@@ -108,7 +108,7 @@ enforce_build_sanity()
108 108
 
109 109
    if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
110 110
    then
111
-      rm -rf "${builddir}"
111
+      exekutor rm -rf "${builddir}"
112 112
    fi
113 113
 
114 114
 }
... ...
@@ -124,8 +124,8 @@ determine_suffix()
124 124
    configuration="$1"
125 125
    sdk="$2"
126 126
 
127
-   [ ! -z $configuration ] || fail "configuration must not be empty"
128
-   [ ! -z $sdk ] || fail "sdk must not be empty"
127
+   [ ! -z "$configuration" ] || fail "configuration must not be empty"
128
+   [ ! -z "$sdk" ] || fail "sdk must not be empty"
129 129
 
130 130
    suffix="/${configuration}"
131 131
    if [ "${sdk}" != "Default" ]
... ...
@@ -187,24 +187,24 @@ build_cmake()
187 187
 
188 188
    owd="${PWD}"
189 189
    # to avoid warning make sure directories are all there
190
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
191
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
192
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
190
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
191
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
192
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
193 193
 
194
-   mkdir -p "${builddir}" 2> /dev/null
195
-   cd "${builddir}" || exit 1
194
+   exekutor mkdir -p "${builddir}" 2> /dev/null
195
+   exekutor cd "${builddir}" || exit 1
196 196
 
197 197
       # check that relative ise right
198
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
199
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
200
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
198
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
199
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
200
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
201 201
 
202 202
       #
203 203
       # cmake doesn't seem to "get" CMAKE_CXX_FLAGS or -INCLUDE
204 204
       #
205 205
       set -f
206
-      set -x
207
-      cmake "-DCMAKE_BUILD_TYPE=${mapped}" \
206
+
207
+      exekutor cmake "-DCMAKE_BUILD_TYPE=${mapped}" \
208 208
 "-DCMAKE_INSTALL_PREFIX:PATH=${owd}/${DEPENDENCY_SUBDIR}/tmp"  \
209 209
 "-DCMAKE_C_FLAGS=\
210 210
 -I${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH} \
... ...
@@ -231,15 +231,15 @@ ${other_ldflags} \
231 231
 ${sdk}" \
232 232
 "${relative}/${srcdir}" 1>&2  || exit 1
233 233
 
234
-      make all install 1>&2 || exit 1
235
-      set +x
234
+      exekutor make all install 1>&2 || exit 1
235
+
236 236
       set +f
237 237
 
238
-   cd "${owd}"
238
+   exekutor cd "${owd}"
239 239
 
240 240
    collect_and_dispense_product "${owd}/${DEPENDENCY_SUBDIR}/tmp" "${suffix}" || exit 1
241 241
 
242
-   rm -rf "${owd}/${DEPENDENCY_SUBDIR}/tmp"
242
+   exekutor rm -rf "${owd}/${DEPENDENCY_SUBDIR}/tmp"
243 243
 }
244 244
 
245 245
 
... ...
@@ -282,20 +282,19 @@ build_configure()
282 282
 
283 283
    owd="${PWD}"
284 284
    # to avoid warning make sure directories are all there
285
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
286
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
287
-   mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
285
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" 2> /dev/null
286
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" 2> /dev/null
287
+   exekutor mkdir -p "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" 2> /dev/null
288 288
 
289
-   mkdir -p "${builddir}" 2> /dev/null
290
-   cd "${builddir}" || exit 1
289
+   exekutor mkdir -p "${builddir}" 2> /dev/null
290
+   exekutor cd "${builddir}" || exit 1
291 291
 
292 292
       # check that relative ise right
293
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
294
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
295
-      [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
293
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" ] || exit 1
294
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${configuration}" ] || exit 1
295
+      exekutor [ -d "${relative}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}${suffix}" ] || exit 1
296 296
 
297 297
       set -f
298
-      set -x
299 298
 
300 299
       # use absolute paths for configure, safer (and easier to read IMO)
301 300
       CFLAGS="\
... ...
@@ -321,14 +320,13 @@ ${sdk}" \
321 320
 -L${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH} \
322 321
 ${other_ldflags} \
323 322
 ${sdk}" \
324
-      "${owd}/${srcdir}/configure" --prefix "${owd}/${DEPENDENCY_SUBDIR}/tmp" 1>&2  || exit 1
323
+      exekutor "${owd}/${srcdir}/configure" --prefix "${owd}/${DEPENDENCY_SUBDIR}/tmp" 1>&2  || exit 1
325 324
 
326
-      make all install 1>&2 || exit 1
325
+      exekutor make all install 1>&2 || exit 1
327 326
 
328
-      set +x
329 327
       set +f
330 328
 
331
-   cd "${owd}"
329
+   exekutor cd "${owd}"
332 330
 
333 331
    collect_and_dispense_product "${owd}/${DEPENDENCY_SUBDIR}/tmp" "${suffix}" || exit 1
334 332
 
... ...
@@ -339,20 +337,107 @@ ${sdk}" \
339 337
 xcode_get_setting()
340 338
 {
341 339
    local key
342
-   local configuration
343 340
 
344 341
    key="$1"
345 342
    shift
346
-   configuration="$1"
347
-   shift
348 343
 
349
-   xcodebuild -showBuildSettings -configuration "${configuration}" $* | \
344
+   eval "xcodebuild -showBuildSettings $*" | \
350 345
    egrep "^[ ]*${key}" | \
351 346
    sed 's/^[^=]*=[ ]*\(.*\)/\1/' || \
352 347
    exit 1
353 348
 }
354 349
 
355 350
 
351
+fixup_header_path()
352
+{
353
+   local key
354
+   local setting_key
355
+   local default
356
+   local name
357
+
358
+   key="$1"
359
+   shift
360
+   setting_key="$1"
361
+   shift
362
+   name="$1"
363
+   shift
364
+   default="$1"
365
+   shift
366
+
367
+   local headers
368
+
369
+   headers=`xcode_get_setting "${key}" $*`
370
+   log_info "${key} read as \"${headers}\""
371
+
372
+   read_yes_no_build_setting "${name}" "keep_xcode_header_settings"
373
+   if [ $? -ne 0 ]
374
+   then
375
+      case "${headers}" in
376
+         /*)
377
+         ;;
378
+
379
+         ./*|../*)
380
+            log_warning "relative path \"${headers}\" as header path ???"
381
+         ;;
382
+
383
+         "")
384
+            headers="${default}"
385
+         ;;
386
+
387
+         *)
388
+            headers="/${headers}"
389
+         ;;
390
+      esac
391
+
392
+      local header_name
393
+
394
+      header_name=`remove_absolute_path_prefix_up_to "${headers}" "include"`
395
+
396
+      if read_yes_no_build_setting "${name}" "mangle_header_dash"
397
+      then
398
+         header_name="`echo "${header_name}" | tr '-' '_'`"
399
+      fi
400
+
401
+      if [ ! -z "${header_name}" ]
402
+      then
403
+         header_name="/${header_name}"
404
+      fi
405
+
406
+      headers="`read_repo_setting "${name}" "${setting_key}" "${HEADER_PATH}${header_name}"`"
407
+
408
+      log_info "${key} set to \"${headers}\""
409
+   fi
410
+
411
+   echo "${headers}"
412
+}
413
+
414
+
415
+escaped_spaces()
416
+{
417
+   echo "$1" | sed 's/ /\\ /g'
418
+}
419
+
420
+
421
+combined_escaped_search_path()
422
+{
423
+   for i in $*
424
+   do
425
+      if [ ! -z "$i" ]
426
+      then
427
+         i="`escaped_spaces "$i"`"
428
+         if [ -z "$path" ]
429
+         then
430
+            path="$i"
431
+         else
432
+            path="$path $i"
433
+         fi
434
+      fi
435
+   done
436
+
437
+   echo "${path}"
438
+}
439
+
440
+
356 441
 build_xcodebuild()
357 442
 {
358 443
    local configuration
... ...
@@ -383,13 +468,14 @@ build_xcodebuild()
383 468
    [ -z "${sdk}" ]         && internal_fail "sdk is empty"
384 469
    [ -z "${project}" ]     && internal_fail "project is empty"
385 470
 
386
-   log_info "Do a xcodebuild for SDK ${sdk}, ${targetname}${schemename}..."
471
+   log_fluff "Do a xcodebuild ${C_MAGENTA}${configuration}${C_FLUFF} of \
472
+${C_MAGENTA}${name}${C_FLUFF} for SDK ${C_MAGENTA}${sdk}${C_FLUFF} \
473
+${C_MAGENTA}${targetname}${schemename}${C_FLUFF} ..."
387 474
 
388 475
    local projectname
389 476
 
390 477
     # always pass project directly
391 478
    projectname=`read_repo_setting "${name}" "project" "${project}"`
392
-   project="-project ${projectname}"
393 479
 
394 480
    local mapped
395 481
 
... ...
@@ -405,7 +491,6 @@ build_xcodebuild()
405 491
    then
406 492
       hackish=`echo "${sdk}" | sed 's/^\([a-zA-Z]*\).*$/\1/g'`
407 493
       suffix="${suffix}-${hackish}"
408
-      sdk="-sdk ${sdk}"
409 494
    else
410 495
       sdk=
411 496
    fi
... ...
@@ -431,49 +516,25 @@ build_xcodebuild()
431 516
       exit 1
432 517
    fi
433 518
 
434
-   local xcflags
435
-
436
-   xcflags=`read_build_setting "${name}" "xcodebuild-flags"`
437
-   local xcconfig
438
-   local xcconfigname
439
-
440
-   xcconfig=
441
-   xcconfigname=`read_build_setting "${name}" xcconfig`
442
-   if [ "$xcconfigname" != "" ]
443
-   then
444
-      xcconfig="-xcconfig ${xcconfigname}"
445
-   fi
446 519
 
447 520
    #
448 521
    # xctool needs schemes, these are often autocreated, which xctool cant do
449 522
    # xcodebuild can just use a target
450 523
    # xctool is by and large useless fluff IMO
451 524
    #
452
-   local target
453
-   local scheme
454
-
455 525
    if [ "$xcodebuild" = "xctool"  -a "${schemename}" = ""  ]
456 526
    then
457 527
       if [ "$targetname" != "" ]
458 528
       then
459
-         target=
460
-         scheme="-scheme ${targetname}"
529
+         schemename="${targetname}"
530
+         targetname=
461 531
       else
462 532
          echo "Please specify a scheme to compile in ${BOOTSTRAP_SUBDIR}/${name}/SCHEME for xctool" >& 2
463 533
          echo "and be sure that this scheme exists and is shared." >& 2
464 534
          echo "Or just delete ${HOME}/.mulle-bootstrap/xcodebuild and use xcodebuild (preferred)" >& 2
465 535
          exit 1
466 536
       fi
467
-   else
468
-     if [ "${schemename}" != "" ]
469
-     then
470
-        scheme="-scheme ${schemename}"
471
-     fi
472
-     if [ "${targetname}" != "" ]
473
-     then
474
-        target="-target ${targetname}"
475
-     fi
476
-  fi
537
+   fi
477 538
 
478 539
    local key
479 540
    local aux
... ...
@@ -502,42 +563,43 @@ build_xcodebuild()
502 563
    owd=`pwd`
503 564
    cd "${srcdir}" || exit 1
504 565
 
566
+      set -f
567
+
568
+      arguments=""
569
+      if [ ! -z "${projectname}" ]
570
+      then
571
+         arguments="${arguments} -project \"${projectname}\""
572
+      fi
573
+      if [ ! -z "${sdk}" ]
574
+      then
575
+         arguments="${arguments} -sdk \"${sdk}\""
576
+      fi
577
+      if [ ! -z "${schemename}" ]
578
+      then
579
+         arguments="${arguments} -scheme \"${schemename}\""
580
+      fi
581
+      if [ ! -z "${targetname}" ]
582
+      then
583
+         arguments="${arguments} -target \"${targetname}\""
584
+      fi
585
+      if [ ! -z "${mapped}" ]
586
+      then
587
+         arguments="${arguments} -configuration \"${mapped}\""
588
+      fi
589
+
590
+
505 591
       #
506 592
       # headers are complicated, the preference is to get it uniform into
507 593
       # dependencies/include/libraryname/..
508 594
       #
595
+
509 596
       local public_headers
510 597
       local private_headers
511
-      local public_header_name
512
-      local private_header_name
513
-
514
-      public_headers=`xcode_get_setting PUBLIC_HEADERS_FOLDER_PATH "${mapped}" "${project}" "${scheme}" "${target}"`
515
-      private_headers=`xcode_get_setting PRIVATE_HEADERS_FOLDER_PATH "${mapped}" "${project}" "${scheme}" "${target}"`
516
-
517
-      read_yes_no_build_setting "${name}" "keep_xcode_header_settings"
518
-      if [ $? -ne 0 ]
519
-      then
520
-         public_header_name=`remove_absolute_path_prefix_up_to "${public_headers}" "include"`
521
-         private_header_name=`remove_absolute_path_prefix_up_to "${private_headers}" "include"`
522
-
523
-         if read_yes_no_build_setting "${name}" "mangle_header_dash"
524
-         then
525
-            public_header_name=`echo "${public_header_name}" | tr '-' '_'`"
526
-            private_header_name=`echo "${private_header_name}" | tr '-' '_'`"
527
-         fi
528
-
529
-         if [ "${public_header_name}" != "" ]
530
-         then
531
-            public_header_name="/${public_header_name}"
532
-         fi
533
-         if [ "${private_header_name}" != "" ]
534
-         then
535
-            private_header_name="/${private_header_name}"
536
-         fi
537
-
538
-         public_headers=`read_repo_setting "${name}" "public_headers" "${HEADER_PATH}${public_header_name}"`
539
-         private_headers=`read_repo_setting "${name}" "private_headers" "${HEADER_PATH}${private_header_name}"`
540
-      fi
598
+      local default
599
+      default="/include/${name}"
600
+      public_headers="`fixup_header_path "PUBLIC_HEADERS_FOLDER_PATH" "public_headers" "${name}" "${default}" ${arguments}`"
601
+      default="/include/${name}/private"
602
+      private_headers="`fixup_header_path "PRIVATE_HEADERS_FOLDER_PATH" "private_headers" "${name}" "${default}" ${arguments}`"
541 603
 
542 604
 
543 605
       # manually point xcode to our headers and libs
... ...
@@ -546,73 +608,74 @@ build_xcodebuild()
546 608
       local dependencies_header_search_path
547 609
       local dependencies_lib_search_path
548 610
       local inherited
611
+      local path
612
+      local escaped
549 613
 
550 614
       #
551 615
       # TODO: need to figure out the correct mapping here
552 616
       #
553
-      inherited=`xcode_get_setting HEADER_SEARCH_PATHS "${mapped}" $project $scheme $target`
554
-      dependencies_header_search_path="HEADER_SEARCH_PATHS="
555
-      dependencies_header_search_path="${dependencies_header_search_path} \
556
-         ${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}"
557
-      dependencies_header_search_path="${dependencies_header_search_path} \
558
-         /usr/local/include"
559
-      dependencies_header_search_path="${dependencies_header_search_path} \
560
-         ${inherited}"
561
-
562
-      inherited=`xcode_get_setting LIBRARY_SEARCH_PATHS "${mapped}" $project $scheme $target`
563
-      dependencies_lib_search_path="LIBRARY_SEARCH_PATHS="
564
-      if [ ! -z $sdk ]
617
+      inherited=`xcode_get_setting HEADER_SEARCH_PATHS ${arguments}`
618
+      path=`combined_escaped_search_path \
619
+"${owd}/${DEPENDENCY_SUBDIR}${HEADER_PATH}" \
620
+"/usr/local/include"`
621
+      if [ -z "${inherited}" ]
565 622
       then
566
-         dependencies_lib_search_path="${dependencies_lib_search_path} \
567
-            ${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}-\$(EFFECTIVE_PLATFORM_NAME)"
623
+         dependencies_header_search_path="${path}"
624
+      else
625
+         dependencies_header_search_path="${path} ${inherited}"
568 626
       fi
569
-      dependencies_lib_search_path="${dependencies_lib_search_path} \
570
-         ${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}"
571
-      dependencies_lib_search_path="${dependencies_lib_search_path} \
572
-         ${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}"
573
-      dependencies_lib_search_path="${dependencies_lib_search_path} \
574
-         /usr/local/lib"
575
-      dependencies_lib_search_path="${dependencies_lib_search_path} \
576
-         ${inherited}"
577
-
578
-      inherited=`xcode_get_setting FRAMEWORK_SEARCH_PATHS "${mapped}" $project $scheme $target`
579
-      dependencies_framework_search_path="FRAMEWORK_SEARCH_PATHS="
580
-      if [ ! -z $sdk ]
627
+
628
+      inherited=`xcode_get_setting LIBRARY_SEARCH_PATHS ${arguments}`
629
+      path=`combined_escaped_search_path \
630
+"${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}" \
631
+"${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}" \
632
+"/usr/local/lib"`
633
+      if [ ! -z "$sdk" ]
581 634
       then
582
-         dependencies_framework_search_path="${dependencies_framework_search_path} \
583
-            ${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}-\$(EFFECTIVE_PLATFORM_NAME)"
635
+         escaped="`escaped_spaces "${owd}/${DEPENDENCY_SUBDIR}${LIBRARY_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
636
+         path="${escaped} ${path}" # prepend
637
+      fi
638
+      if [ -z "${inherited}" ]
639
+      then
640
+         dependencies_lib_search_path="${path}"
641
+      else
642
+         dependencies_lib_search_path="${path} ${inherited}"
584 643
       fi
585
-      dependencies_framework_search_path="${dependencies_framework_search_path} \
586
-         ${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}"
587
-      dependencies_framework_search_path="${dependencies_framework_search_path} \
588
-         ${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}"
589
-      dependencies_framework_search_path="${dependencies_framework_search_path} \
590
-         ${inherited}"
591 644
 
592
-      set -f
593
-      set +x
594 645
 
646
+      inherited=`xcode_get_setting FRAMEWORK_SEARCH_PATHS ${arguments}`
647
+      path=`combined_escaped_search_path \
648
+"${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}" \
649
+"${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}"`
650
+      if [ ! -z "$sdk" ]
651
+      then
652
+         escaped="`escaped_spaces "${owd}/${DEPENDENCY_SUBDIR}${FRAMEWORK_PATH}/${mapped}"'-$(EFFECTIVE_PLATFORM_NAME)'`"
653
+         path="${escaped} ${path}" # prepend
654
+      fi
655
+      if [ -z "${inherited}" ]
656
+      then
657
+         dependencies_framework_search_path="${path}"
658
+      else
659
+         dependencies_framework_search_path="${path} ${inherited}"
660
+      fi
595 661
       # if it doesn't install, probably SKIP_INSTALL is set
596
-      $xcodebuild $command $project $sdk $scheme $target -configuration "${mapped}" \
597
-      ${xcflags} \
598
-      ${xcconfig} \
599
-      ${aux} \
600
-      "ARCHS=\${ARCHS_STANDARD_32_64_BIT}" \
601
-      "DEPLOYMENT_LOCATION=YES" \
602
-      "DSTROOT=${owd}/${DEPENDENCY_SUBDIR}" \
603
-      "INSTALL_PATH=${LIBRARY_PATH}${suffix}" \
604
-      "PUBLIC_HEADERS_FOLDER_PATH=${public_headers}" \
605
-      "PRIVATE_HEADERS_FOLDER_PATH=${private_headers}" \
606
-      SYMROOT="${owd}/${builddir}/" \
607
-      OBJROOT="${owd}/${builddir}/obj" \
608
-      ONLY_ACTIVE_ARCH=NO \
609
-      ${skip_install} \
610
-      "${dependencies_header_search_path}" \
611
-      "${dependencies_lib_search_path}" \
612
-      "${dependencies_framework_search_path} " \
613
-      1>&2 || exit 1
614
-   # TODO: why is it ${builddir} and not ../../${builddir} ??
615
-      set +x
662
+      cmdline="\"${xcodebuild}\" \"${command}\" ${arguments} \
663
+ARCHS='\${ARCHS_STANDARD_32_64_BIT}' \
664
+DEPLOYMENT_LOCATION=YES \
665
+DSTROOT='${owd}/${DEPENDENCY_SUBDIR}' \
666
+INSTALL_PATH='${LIBRARY_PATH}${suffix}' \
667
+PUBLIC_HEADERS_FOLDER_PATH='${public_headers}' \
668
+PRIVATE_HEADERS_FOLDER_PATH='${private_headers}' \
669
+SYMROOT='${owd}/${builddir}/' \
670
+OBJROOT='${owd}/${builddir}/obj' \
671
+ONLY_ACTIVE_ARCH=NO \
672
+${skip_install} \
673
+HEADER_SEARCH_PATHS='${dependencies_header_search_path}' \
674
+LIBRARY_SEARCH_PATHS='${dependencies_lib_search_path}' \
675
+FRAMEWORK_SEARCH_PATHS='${dependencies_framework_search_path}'"
676
+
677
+      eval_exekutor "${cmdline}" 1>&2 || exit 1
678
+
616 679
       set +f
617 680
 
618 681
    cd "${owd}"
... ...
@@ -629,26 +692,40 @@ build_xcodebuild_schemes_or_target()
629 692
 
630 693
    if [ -d "${builddir}" -a "${CLEAN_BEFORE_BUILD}" != "" ]
631 694
    then
632
-      rm -rf "${builddir}"
695
+      exekutor rm -rf "${builddir}"
633 696
    fi
634 697
 
635 698
    local scheme
636 699
    local schemes
637 700
 
638 701
    schemes=`read_repo_setting "${name}" "schemes"`
702
+
703
+   local old
704
+
705
+   old="${IFS:-" "}"
706
+   IFS="
707
+"
639 708
    for scheme in $schemes
640 709
    do
710
+      IFS="$old"
641 711
       build_xcodebuild "$@" "${scheme}" ""
642 712
    done
713
+   IFS="${old}"
643 714
 
644 715
    local target
645 716
    local targets
646 717
 
647 718
    targets=`read_repo_setting "${name}" "targets"`
719
+
720
+   old="$IFS"
721
+   IFS="
722
+"
648 723
    for target in $targets
649 724
    do
725
+      IFS="${old}"
650 726
       build_xcodebuild "$@" "" "${target}"
651 727
    done
728
+   IFS="${old}"
652 729
 
653 730
    if [ "${targets}" = "" -a "${schemes}" = "" ]
654 731
    then
... ...
@@ -659,24 +736,17 @@ build_xcodebuild_schemes_or_target()
659 736
 
660 737
 build()
661 738
 {
662
-   local clone
663
-   local name
664
-   local builddir
665
-   local relative
666 739
    local srcdir
667
-   local built
668
-   local sdk
669
-   local configuration
670
-   local preference
671 740
 
672 741
    srcdir="$1"
742
+
743
+   local name
744
+
673 745
    name=`basename "${srcdir}"`
746
+   [ "${name}" != "${CLONES_SUBDIR}" ] || internal_fail "missing repo argument (${srcdir})"
674 747
 
675 748
    local preferences
676 749
    local configurations
677
-   local sdks
678
-   local cmake
679
-   local xcodebuild
680 750
 
681 751
    preferences=`read_config_setting "build_preferences" "script
682 752
 xcodebuild
... ...
@@ -686,14 +756,24 @@ configure"`
686 756
    configurations=`read_build_root_setting "configurations" "Debug
687 757
 Release"`
688 758
 
759
+   local xcodebuild
760
+   local cmake
761
+
689 762
    xcodebuild=`which "xcodebuild"`
690 763
    cmake=`which "cmake"`
691 764
 
765
+   local sdk
766
+   local sdks
767
+
692 768
    # need uniform SDK for our builds
693 769
    sdks=`read_build_root_setting "sdks" "Default"`
694 770
    [ -z "${sdks}" ] && fail "setting \"sdks\" must at least contain \"Default\" to build anything"
695 771
 
696
-   log_info "building ${srcdir} ..." >&2
772
+   local builddir
773
+   local relative
774
+   local built
775
+   local configuration
776
+   local preference
697 777
 
698 778
    for sdk in ${sdks}
699 779
    do
... ...
@@ -837,7 +917,7 @@ build_clones()
837 917
          fi
838 918
       done
839 919
 
840
-      for clone in ${CLONES_SUBDIR}/*
920
+      for clone in "${CLONES_SUBDIR}"/*
841 921
       do
842 922
          name=`basename "${clone}"`
843 923
 
... ...
@@ -847,11 +927,16 @@ build_clones()
847 927
          fi
848 928
       done
849 929
    else
850
-      for clone in "$@"
930
+      for name in "$@"
851 931
       do
852 932
          clone="${CLONES_SUBDIR}/${name}"
853 933
 
854
-         built=`build_if_readable "${clone}" "${name}" "${built}"`
934
+         if [ -d "${clone}" ]
935
+         then
936
+            built=`build_if_readable "${clone}" "${name}" "${built}"`
937
+         else
938
+            fail "unknown repo ${name}"
939
+         fi
855 940
       done
856 941
    fi
857 942
 }
... ...
@@ -2,7 +2,7 @@
2 2
 #
3 3
 # (c) 2015, coded by Nat!, Mulle KybernetiK
4 4
 #
5
-COMMAND=${1:-"build"}
5
+COMMAND=${1:-"objs"}
6 6
 
7 7
 . mulle-bootstrap-local-environment.sh
8 8
 
... ...
@@ -11,8 +11,10 @@ case "$COMMAND" in
11 11
    ;;
12 12
    dist)
13 13
    ;;
14
+   objects|objs)
15
+   ;;
14 16
    *)
15
-   echo "usage: mulle-bootstrap-clean.sh <build|dist>" 2>&1
17
+   echo "usage: mulle-bootstrap-clean.sh <build|dist|objs>" 2>&1
16 18
    exit 1
17 19
    ;;
18 20
 esac
... ...
@@ -22,29 +24,49 @@ esac
22 24
 # to have other tools provide stuff besides /include and /lib
23 25
 # and sometimes  projects install other stuff into /share
24 26
 #
25
-if [ "${CLONES_SUBDIR_IS_CLEANABLE}" = "YES" ]
26
-then
27
-   if [ "${COMMAND}" = "objects" -o "${COMMAND}" = "dist" -o "${COMMAND}" = "build"  ]
27
+clean()
28
+{
29
+   if [ ! -z "$OBJECTS_CLEANABLE_SUBDIRS" ]
28 30
    then
29
-      rm -rf "${CLONESBUILD_SUBDIR}" 2> /dev/null
31
+      if [ "${COMMAND}" = "objects" -o "${COMMAND}" = "dist" -o "${COMMAND}" = "build"  ]
32
+      then
33
+         for dir in ${OBJECTS_CLEANABLE_SUBDIRS}
34
+         do
35
+            clean_asserted_folder "${dir}"
36
+         done
37
+      fi
30 38
    fi
31
-fi
32 39
 
33
-if [ "${DEPENDENCY_SUBDIR_IS_DIST_CLEANABLE}" = "YES" ]
34
-then
35
-   if [ "${COMMAND}" = "dist" -o "${COMMAND}" = "build"  ]
40
+
41
+   if [ ! -z "$BUILD_CLEANABLE_SUBDIRS" ]
36 42
    then
37
-      rm -rf "${DEPENDENCY_SUBDIR}" 2> /dev/null
43
+      if [ "${COMMAND}" = "dist" -o "${COMMAND}" = "build"  ]
44
+      then
45
+         for dir in ${BUILD_CLEANABLE_SUBDIRS}
46
+         do
47
+            clean_asserted_folder "${dir}"
48
+         done
49
+      fi
38 50
    fi
39
-fi
40 51
 
41 52
 
42
-if [ "${COMMAND}" = "dist" ]
43
-then
44
-   rm -rf "${BOOTSTRAP_SUBDIR}.auto" 2> /dev/null
45
-
46
-   if [ "${CLONES_SUBDIR_IS_CLEANABLE}" = "YES" ]
53
+   if [ ! -z "$DIST_CLEANABLE_SUBDIRS" ]
47 54
    then
48
-      rm -rf "${CLONES_SUBDIR}"  2> /dev/null
55
+      if [ "${COMMAND}" = "dist" ]
56
+      then
57
+         for dir in ${DIST_CLEANABLE_SUBDIRS}
58
+         do
59
+            clean_asserted_folder "${dir}"
60
+         done
61
+      fi
49 62
    fi
50
-fi
63
+}
64
+
65
+
66
+main()
67
+{
68
+   clean
69
+}
70
+
71
+
72
+main
... ...
@@ -29,12 +29,24 @@
29 29
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 
32
+# Escape sequence and resets
33
+if [ "${MULLE_BOOTSTRAP_NO_COLOR}" != "YES" ]
34
+then
35
+   C_RESET="\033[0m"
36
+
37
+   # Foreground colours
38
+   C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
39
+   C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
40
+   C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
41
+fi
42
+
43
+
32 44
 #
33 45
 # some common functions
34 46
 #
35 47
 fail()
36 48
 {
37
-   echo "\033[0;31m$*\033[0m" >&2
49
+   echo "${C_RED}$*${C_RESET}" >&2
38 50
    exit 1
39 51
 }
40 52
 
... ...
@@ -46,6 +58,34 @@ $*"
46 58
 }
47 59
 
48 60
 
61
+
62
+eval_exekutor()
63
+{
64
+   if [ "$MULLE_BOOTSTRAP_DRY_RUN" = "YES" -o "$MULLE_BOOTSTRAP_TRACE" = "YES" ]
65
+   then
66
+      echo "$@" >&2
67
+   fi
68
+
69
+   if [ "$MULLE_BOOTSTRAP_DRY_RUN" != "YES" ]
70
+   then
71
+      eval "$@"
72
+   fi
73
+}
74
+
75
+exekutor()
76
+{
77
+   if [ "$MULLE_BOOTSTRAP_DRY_RUN" = "YES" -o "$MULLE_BOOTSTRAP_TRACE" = "YES" ]
78
+   then
79
+      echo "$@" >&2
80
+   fi
81
+
82
+   if [ "$MULLE_BOOTSTRAP_DRY_RUN" != "YES" ]
83
+   then
84
+      "$@"
85
+   fi
86
+}
87
+
88
+
49 89
 is_yes()
50 90
 {
51 91
    local s
... ...
@@ -154,7 +194,7 @@ user_say_yes()
154 194
   x="nix"
155 195
   while [ "$x" != "y" -a "$x" != "n" -a "$x" != "" ]
156 196
   do
157
-     echo "$@" "(y/N)" >&2
197
+     echo "${C_YELLOW}$* (${C_WHITE}y${C_YELLOW}/${C_GREEN}N${C_YELLOW})${C_RESET}" >&2
158 198
      read x
159 199
   done
160 200
 
... ...
@@ -199,13 +239,13 @@ Install brew now (Linux or OS X should work) ? "
199 239
       fi
200 240
       if [ "`uname`" = 'Darwin' ]
201 241
       then
202
-         ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
242
+         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" || exit 1
203 243
       else
204
-         ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" || exit 1
244
+         exekutor ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/linuxbrew/go/install)" || exit 1
205 245
       fi
206 246
 
207
-      mkdir -p "`dirname "${last_update}"`" 2> /dev/null
208
-      touch "${last_update}"
247
+      exekutor mkdir -p "`dirname "${last_update}"`" 2> /dev/null
248
+      exekutor touch "${last_update}"
209 249
       return 1
210 250
    fi
211 251
    return 0
... ...
@@ -254,352 +294,85 @@ find_xcodeproj()
254 294
 }
255 295
 
256 296
 
257
-warn_user_setting()
258
-{
259
-   local name
260
-
261
-   name="$1"
262
-   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_user_setting\"`" = "" ]
263
-   then
264
-      echo "Using ~/.mulle-bootstrap/${name}" >& 2
265
-   fi
266
-}
267
-
268
-
269
-warn_local_setting()
270
-{
271
-   local name
272
-
273
-   name="$1"
274
-   if [ "${DONT_WARN_RECURSION}" = "" -a "`DONT_WARN_RECURSION=YES read_local_setting \"dont_warn_local_setting\"`" = "" ]
275
-   then
276
-      echo "Using ${BOOTSTRAP_SUBDIR}.local/${name}" >& 2
277
-   fi
278
-}
279
-
280 297
 #
281
-# this knows intentionally no default, you cant have an empty
282
-# local setting
298
+# consider . .. ~ or absolute paths as unsafe
299
+# anything starting with a $ is probably also bad
300
+# this just catches some obvious problems, not all
301
+# when in the environment, clones_subdir may be ..
283 302
 #
284
-_read_local_setting()
303
+assert_sane_path()
285 304
 {
286
-   local name
287
-   local value
288
-   local envname
289
-
290
-   name="$1"
291
-
292
-   [ "$name" = "" ] && internal_fail "missing parameters in _read_local_setting"
293
-
294
-   envname=`echo "${name}" | tr '[:lower:]' '[:upper:]'`
295
-   value=`printenv "MULLE_BOOTSTRAP_${envname}"`
296
-
297
-   if [ "${value}" != "" ]
298
-   then
299
-      echo "${value}"
300
-      return 1
301
-   else
302
-      value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}.local/${name}" 2> /dev/null`
303
-      if [ $? -gt 1 ]
304
-      then
305
-         value=`egrep -v '^#|^[ ]*$' "${HOME}/.mulle-bootstrap/${name}" 2> /dev/null`
306
-         if [ "$value" != "" ]
307
-         then
308
-             warn_user_setting "${name}"
309
-         fi
310
-      else
311
-         warn_local_setting "${name}"
312
-      fi
313
-   fi
314
-
315
-   echo "${value}"
305
+   case "$1"  in
306
+      \$*|~/.|..|./|../|/*)
307
+         echo "refuse unsafe path $1" >&2
308
+         exit 1
309
+      ;;
310
+   esac
316 311
 }
317 312
 
318 313
 
319
-read_local_setting()
320
-{
321
-   local name
322
-   local value
323
-   local default
324
-
325
-   [ $# -lt 1 -o $# -gt 2 ] && internal_fail "parameterization error"
326
-
327
-   name="$1"
328
-   default="$2"
329
-
330
-   value=`_read_local_setting "$name"`
331
-   if [ "${value}" = "" ]
332
-   then
333
-      value="${default}"
334
-   fi
335
-
336
-   echo "$value"
337 314
 
338
-   [ "${value}" = "${default}" ]
339
-   return $?
340
-}
341
-
342
-
343
-#
344
-# this has to be flexible, because fetch and build settings read differently
345
-#
346
-_read_bootstrap_setting()
315
+clean_asserted_folder()
347 316
 {
348
-   local name
349
-   local value
350
-   local default
351
-   local suffix1
352
-   local suffix2
353
-   local suffix3
354
-
355
-   name="$1"
356
-   suffix1="$2"
357
-   suffix2="$3"
358
-   suffix3="$4"
359
-   default="$5"
360
-
361
-   [ $# -lt 4 -o $# -gt 5 ] && internal_fail "parameterization error"
362
-   [ "$name" = "" ] && internal_fail "missing parameters in _read_bootstrap_setting"
363
-
364
-   value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix1}/${name}" 2> /dev/null`
365
-   if [ $? -gt 1 ]
317
+   if [ -d "$1" ]
366 318
    then
367
-      value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix2}/${name}" 2> /dev/null`
368
-      if [ $? -gt 1 ]
369
-      then
370
-         value=`egrep -v '^#|^[ ]*$' "${BOOTSTRAP_SUBDIR}${suffix3}/${name}" 2> /dev/null`
371
-         if [ $? -gt 1 ]
372
-         then
373
-            if [ $# -eq 4 ]
374
-            then
375
-               return 2
376
-            fi
377
-            value="${default}"
378
-         else
379
-            case "$1" in
380
-               .local*)
381
-                  warn_local_setting "${name}"
382
-               ;;
383
-            esac
384
-         fi
385
-      else
386
-         case "$1" in
387
-            .local*)
388
-               warn_local_setting "${name}"
389
-            ;;
390
-         esac
391
-      fi
392
-   else
393
-      case "$1" in
394
-         .local*)
395
-            warn_local_setting "${name}"
396
-         ;;
397
-      esac
398
-   fi
399
-
400
-   echo "$value"
401
-
402
-   [ "${value}" = "${default}" ]
403
-   return $?
404
-}
405
-
406
-
407
-read_repo_setting()
408
-{
409
-   local name
410
-   local value
411
-   local default
412
-   local value
413
-
414
-   [ $# -lt 2 -o $# -gt 3 ] && internal_fail "parameterization error"
415
-
416
-   package="$1"
417
-   name="$2"
418
-   default="$3"
419
-
420
-   [ "$name" = "" -o "$package" = "" ] && internal_fail "missing parameters in read_repo_setting"
421
-
422
-   # need to conserve return value 2 if empty
423
-   if [ $# -eq 2 ]
424
-   then
425
-      _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto"
426
-   else
427
-      _read_bootstrap_setting  "settings/${package}/${name}" ".local" "" ".auto" "${default}"
319
+      assert_sane_path "$1"
320
+      exekutor rm -rf "$1"
428 321
    fi
322
+   set +x
429 323
 }
430 324
 
431 325
 
432
-#
433
-# the default
434
-#
435
-read_config_setting()
436
-{
437
-   local name
438
-   local value
439
-   local default
440
-
441
-   [ $# -lt 1 -o $# -gt 2 ] && internal_fail "parameterization error"
442
-
443
-   name="$1"
444
-   default="$2"
445
-
446
-   value=`_read_bootstrap_setting "${name}" ".local/config" "config" ".auto/config"`
447
-   if [ "${value}" = "" ]
448
-   then
449
-      value=`read_local_setting "${name}" "${default}"`
450
-   fi
451
-
452
-   echo "$value"
453
-
454
-   [ "${value}" = "${default}" ]
455
-   return $?
456
-}
457 326
 
458 327
 
459
-read_fetch_setting()
328
+# http://askubuntu.com/questions/152001/how-can-i-get-octal-file-permissions-from-command-line
329
+lso()
460 330
 {
461
-   _read_bootstrap_setting "$1" ".auto" ".local" "" "$2"
331
+   ls -aldG "$@" | \
332
+   awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print }' | \
333
+   awk '{print $1}'
462 334
 }
463 335
 
464 336
 
465
-_read_build_setting()
466
-{
467
-   _read_bootstrap_setting "$1" ".local/settings" "/settings" ".auto/settings" "$2"
468
-}
469
-
470 337
 
471
-read_build_setting()
338
+C_WARNING="${C_YELLOW}"
339
+log_warning()
472 340
 {
473
-   local name
474
-   local value
475
-   local default
476
-
477
-   package="$1"
478
-   name="$2"
479
-   default="$3"
480
-
481
-   [ $# -lt 2 -o $# -gt 3 ] && internal_fail "parameterization error"
482
-   [ "$name" = "" -o "$package" = "" ] && internal_fail "empty parameters in read_build_setting"
483
-
484
-   value=`read_repo_setting "${package}" "${name}"`
485
-   if [ $? -gt 1 ]
341
+   if [ "$MULLE_BOOTSTRAP_TERSE" != "YES" ]
486 342
    then
487
-      if [ $# -eq 2 ]
488
-      then
489
-          value=`_read_build_setting "${name}"`
490
-      else
491
-          value=`_read_build_setting "${name}" "${default}"`
492
-      fi
493
-
494
-      if [ $? -gt 1 ]
495
-      then
496
-         return 2
497
-      fi
343
+      echo "${C_WARNING}$*${C_RESET}" >&2
498 344
    fi
499
-   echo "$value"
500
-
501
-   [ "${value}" = "${default}" ]
502
-   return $?
503
-}
504
-
505
-
506
-read_build_root_setting()
507
-{
508
-   _read_build_setting "$@"
509 345
 }
510 346
 
511
-
512
-read_yes_no_build_setting()
347
+C_INFO="${C_GREEN}"
348
+log_info()
513 349
 {
514
-   local value
515
-
516
-   value=`read_build_setting "$1" "$2" "$3"`
517
-   is_yes "$value" "$1/$2"
350
+   if [ "$MULLE_BOOTSTRAP_TERSE" != "YES" ]
351
+   then
352
+      echo "${C_INFO}$*${C_RESET}" >&2
353
+   fi
518 354
 }
519 355
 
520
-
521
-read_sane_config_path_setting()
356
+C_FLUFF="${C_CYAN}"
357
+log_fluff()
522 358
 {
523
-   local name
524
-   local value
525
-   local default
526
-
527
-   name="$1"
528
-   default="$2"
529
-
530
-   value=`read_config_setting "${name}"`
531
-   if [ "$?" -ne 0 ]
359
+   if [ "$MULLE_BOOTSTRAP_TERSE" != "YES" ]
532 360
    then
533
-      case "${value}"  in
534
-         \$*|~/.|..|./|../|/*)
535
-            echo "refuse unsafe path ${value} for ${name}" >&2
536
-            exit 1
537
-         ;;
538
-      esac
539
-   else
540
-      if [ "$value" = "" ]
541
-      then
542
-         value="${default}"
543
-      fi
361
+      echo "${C_FLUFF}$*${C_RESET}" >&2
544 362
    fi
545
-
546
-   echo "$value"
547
-
548
-   [ "${value}" = "${default}" ]
549
-   return $?
550 363
 }
551 364
 
552
-
553
-all_build_flag_keys()
365
+C_TRACE="${C_FLUFF}"
366
+log_trace()
554 367
 {
555
-   local keys1
556
-   local keys2
557
-   local keys3
558
-   local keys4
559
-   local keys5
560
-   local keys6
561
-   local package
562
-
563
-   package="$1"
564
-
565
-   [ "$package" = "" ] && fail "script error"
566
-
567
-   keys1=`(cd "${BOOTSTRAP_SUBDIR}.local/settings/${package}" 2> /dev/null || exit 1; \
568
-           ls -1 | egrep '\b[A-Z][A-Z_0-9]+\b')`
569
-   keys2=`(cd "${BOOTSTRAP_SUBDIR}/settings/${package}" 2> /dev/null || exit 1 ; \
570
-           ls -1 | egrep '\b[A-Z][A-Z_0-9]+\b')`
571
-   keys3=`(cd "${BOOTSTRAP_SUBDIR}.auto/settings/${package}" 2> /dev/null || exit 1 ; \
572
-           ls -1 | egrep '\b[A-Z][A-Z_0-9]+\b')`
573
-   keys4=`(cd "${BOOTSTRAP_SUBDIR}.local" 2> /dev/null || exit 1 ; \
574
-           ls -1 | egrep '\b[A-Z][A-Z_0-9]+\b')`
575
-   keys5=`(cd "${BOOTSTRAP_SUBDIR}"  2> /dev/null || exit 1 ; \
576
-           ls -1  | egrep '\b[A-Z][A-Z_0-9]+\b')`
577
-   keys6=`(cd "${BOOTSTRAP_SUBDIR}.auto"  2> /dev/null || exit 1 ; \
578
-           ls -1  | egrep '\b[A-Z][A-Z_0-9]+\b')`
579
-
580
-   echo "${keys1}
581
-${keys2}
582
-${keys3}
583
-${keys4}
584
-${keys5}
585
-${keys6}" | sort | sort -u | egrep -v '^[ ]*$'
586
-   return 0
368
+  echo "${C_TRACE}$*${C_RESET}" >&2
587 369
 }
588 370
 
589 371
 
590
-# http://askubuntu.com/questions/152001/how-can-i-get-octal-file-permissions-from-command-line
591
-lso()
372
+C_TRACE2="${C_WHITE}"
373
+log_trace2()
592 374
 {
593
-   ls -aldG "$@" | \
594
-   awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print }' | \
595
-   awk '{print $1}'
375
+  echo "${C_TRACE2}$*${C_RESET}" >&2
596 376
 }
597 377
 
598 378
 
599
-log_info()
600
-{
601
-   if [ "$MULLE_BOOTSTRAP_TERSE" != "YES" ]
602
-   then
603
-      echo "$@" >&2
604
-   fi
605
-}
606 379
\ No newline at end of file
... ...
@@ -66,11 +66,11 @@ do
66 66
 done
67 67
 
68 68
 
69
-mkdir -p "${BOOTSTRAP_SUBDIR}" || exit 1
69
+exekutor mkdir -p "${BOOTSTRAP_SUBDIR}" || exit 1
70 70
 
71 71
 if [ "${NO_DEFAULT_FILES}" = "" ]
72 72
 then
73
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/brews"
73
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/brews"
74 74
 # add projects that should be installed by brew
75 75
 # e.g.
76 76
 # zlib
... ...
@@ -83,7 +83,7 @@ EOF
83 83
 #EOF
84 84
 
85 85
 
86
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/gits"
86
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/gits"
87 87
 # add projects that should be cloned with git in order
88 88
 # of their inter-dependencies
89 89
 #
... ...
@@ -99,41 +99,41 @@ fi
99 99
 if [ "${NO_EXAMPLE_FILES}" = "" ]
100 100
 then
101 101
 
102
-   mkdir -p "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin" || exit 1
102
+   exekutor mkdir -p "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin" || exit 1
103 103
 
104
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/tag"
104
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/tag"
105 105
 # specify a tag or branch for a project named MulleScion
106 106
 # leave commented out or delete file for default branch (usually master)
107 107
 # v1848.5.p3
108 108
 EOF
109 109
 
110
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/Release.map"
110
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/Release.map"
111 111
 # map configuration Release in project MulleScion to DebugRelease
112 112
 # leave commented out or delete file for no mapping
113 113
 # DebugRelease
114 114
 EOF
115 115
 
116
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/project"
116
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/project"
117 117
 # Specify a xcodeproj to compile in project MulleScion instead of default
118 118
 # leave commented out or delete file for default project
119 119
 # mulle-scion
120 120
 EOF
121 121
 
122
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/scheme"
122
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/scheme"
123 123
 # Specify a scheme to compile in project MulleScion instead of default
124 124
 # Might bite itself with TARGET, so only specify one.
125 125
 # leave commented out or delete file for default scheme
126 126
 # mulle-scion
127 127
 EOF
128 128
 
129
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/target"
129
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/target"
130 130
 # Specify a target to compile in project MulleScion instead of default.
131 131
 # Might bite itself with SCHEME, so only specify one.
132 132
 # leave commented out or delete file for default scheme
133 133
 # mulle-scion
134 134
 EOF
135 135
 
136
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-install.sh"
136
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-install.sh"
137 137
 # Run some commands after installing project MulleScion
138 138
 # leave commented out or delete file for no action
139 139
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh
... ...
@@ -142,7 +142,7 @@ EOF
142 142
 EOF
143 143
 #chmod 755 "${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh"
144 144
 
145
-   cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-update.sh"
145
+   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-update.sh"
146 146
 # Run some commands after upgrading project MulleScion
147 147
 # leave commented out or delete file for no action
148 148
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-update.sh
... ...
@@ -157,6 +157,6 @@ echo "${BOOTSTRAP_SUBDIR} folder has been set up. Now add your gits to ${BOOTSTR
157 157
 
158 158
 if [ "${DONT_OPEN_GITS}" = "" -a "${NO_DEFAULT_FILES}" = "" ]
159 159
 then
160
-    open -e "${BOOTSTRAP_SUBDIR}/gits"
160
+    exekutor open -e "${BOOTSTRAP_SUBDIR}/gits"
161 161
 fi
162 162
 
... ...
@@ -44,44 +44,23 @@ then
44 44
    exit 1
45 45
 fi
46 46
 
47
-. mulle-bootstrap-functions.sh
47
+. mulle-bootstrap-settings.sh
48 48
 
49
-#
50
-# consider . .. ~ or absolute paths as unsafe
51
-# anything starting with a $ is probably also bad
52
-# this just catches some obvious problems, not all
53
-# when in the environment, clones_subdir may be ..
54
-#
55 49
 
56
-
57
-CLONES_SUBDIR_IS_CLEANABLE=`read_config_setting clean_repos_folder`
58 50
 CLONES_SUBDIR=`read_sane_config_path_setting "repos_foldername" ".repos"`
59
-if [ $? -eq 0 -a "${CLONES_SUBDIR_IS_CLEANABLE}" = "" ]
60
-then
61
-   CLONES_SUBDIR_IS_CLEANABLE="YES"
62
-fi
63
-