Browse code

Improved handling of repository entries with variables. Prefix fails with mulle-bootstrap <action> so the user knows, whos complaining (if running in a script). -i flag for fetch and update

Nat! authored on 20-10-2016 23:43:05
Showing 18 changed files
... ...
@@ -1,3 +1,41 @@
1
+2.3
2
+===
3
+The main new feature of 2.3 is support for working with different repositories.
4
+E.g. I host releases on GitHub on a branch "release", which are accessed via
5
+https://, but when I develop I use Mulle KybernetiK on branch "master".
6
+
7
+The "trick" is to use parameterized branches and urls like so:
8
+
9
+```
10
+$ cat .bootstrap/repositories
11
+${MULLE_REPOSITORIES}/mulle-c11;;${MULLE_C11_BRANCH:-release}
12
+$ cat .bootstrap/MULLE_REPOSITORIES
13
+https://github.com/mulle-nat
14
+```
15
+
16
+This works for the release part. Locally though in the non-committed
17
+`.bootstrap.local`:
18
+
19
+```
20
+$ cat MULLE_REPOSITORIES
21
+nat@mulle-kybernetik.com:/scm/public_git/repositories
22
+$ cat MULLE_C11_BRANCH
23
+master
24
+```
25
+
26
+Changes:
27
+
28
+* clarified the use of options vs. flags some more. e.g. git GITFLAGS command GITOPTIONS.
29
+* update will now also refresh
30
+* start version checking bootstrap contents
31
+* -f flag will now also try to checkout branches, that are checked out
32
+incorrectly
33
+* fetch gains -i option, to ignore "wrongly" checked out repositories
34
+* fails are prefixed with the command, that caused the failure now
35
+* use unexpanded URLs for dependency matches and store those into .bootstrap.auto
36
+* mulle-bootstrap now picks up URL changes and corrects them in fetched
37
+repositiories, but that does not per se force an update.
38
+
1 39
 2.2.1
2 40
 ===
3 41
 
... ...
@@ -28,8 +28,12 @@
28 28
 #   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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
+MULLE_BOOTSTRAP_VERSION_MAJOR=2
32
+MULLE_BOOTSTRAP_VERSION_MINOR=3
33
+MULLE_BOOTSTRAP_VERSION_PATCH=0
31 34
 
32
-MULLE_BOOTSTRAP_VERSION="2.2.1"
35
+MULLE_BOOTSTRAP_VERSION="${MULLE_BOOTSTRAP_VERSION_MAJOR}.${MULLE_BOOTSTRAP_VERSION_MINOR}.${MULLE_BOOTSTRAP_VERSION_PATCH}"
36
+MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap"
33 37
 
34 38
 #
35 39
 # This is the main user interface to mulle-bootstrap
... ...
@@ -49,6 +53,7 @@ usage: mulle-bootstrap [flags] [command] [options]
49 53
  Flags:
50 54
    -a -y     : default answer to questions (scripts wont be checked)
51 55
                -a (clone preferred) -y (local copy/symlink preferred)
56
+   -f        : force operation
52 57
    -n        : do nothing creative or destructive
53 58
    -v        : -v to be more verbose (-vv or -vvv for more verbosity)
54 59
 
... ...
@@ -106,7 +111,6 @@ bootstrap_nomagic_main()
106 111
 {
107 112
    local command
108 113
 
109
-
110 114
    command="$1"
111 115
    shift
112 116
 
... ...
@@ -130,6 +134,7 @@ bootstrap_nomagic_main()
130 134
 
131 135
    if fetch_needed
132 136
    then
137
+      MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap fetch"
133 138
       if [ -z "${DONT_RECURSE}" ]
134 139
       then
135 140
          fetch_main "$@" || exit 1
... ...
@@ -142,6 +147,7 @@ bootstrap_nomagic_main()
142 147
 
143 148
    if build_needed
144 149
    then
150
+      MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap build"
145 151
       build_main "$@" || exit 1
146 152
    fi
147 153
 
... ...
@@ -185,6 +191,8 @@ bootstrap_main()
185 191
 
186 192
    trap trap_fail INT
187 193
 
194
+   source_environment
195
+
188 196
    #
189 197
    # simple option handling
190 198
    #
... ...
@@ -242,7 +250,7 @@ bootstrap_main()
242 250
          -t|--trace)
243 251
             MULLE_BOOTSTRAP_TRACE="1848"
244 252
             COPYMOVEFLAGS="-v"
245
-            GITFLAGS="${GITFLAGS} -v"
253
+            GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
246 254
          ;;
247 255
 
248 256
          -V|--verbose-build)
... ...
@@ -252,25 +260,25 @@ bootstrap_main()
252 260
          -v|--verbose)
253 261
             MULLE_BOOTSTRAP_TRACE="VERBOSE"
254 262
             COPYMOVEFLAGS="-v"
255
-            GITFLAGS="${GITFLAGS} -v"
263
+            GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
256 264
          ;;
257 265
 
258 266
          -vv|--very-verbose)
259 267
             MULLE_BOOTSTRAP_TRACE="FLUFF"
260 268
             COPYMOVEFLAGS="-v"
261
-            GITFLAGS="${GITFLAGS} -v"
269
+            GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
262 270
          ;;
263 271
 
264 272
          -vvv|--very-verbose-with-settings)
265 273
             MULLE_BOOTSTRAP_TRACE="TRACE"
266 274
             COPYMOVEFLAGS="-v"
267
-            GITFLAGS="${GITFLAGS} -v"
275
+            GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
268 276
          ;;
269 277
 
270 278
          -s|--silent)
271 279
             MULLE_BOOTSTRAP_TRACE=
272 280
             MULLE_BOOTSTRAP_TERSE="YES"
273
-            GITFLAGS="${GITFLAGS} -q"
281
+            GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
274 282
          ;;
275 283
 
276 284
          -h|--help)
... ...
@@ -278,7 +286,7 @@ bootstrap_main()
278 286
          ;;
279 287
 
280 288
          -*)
281
-            log_error "unknown option \"$1\""
289
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown flag \"$1\""
282 290
             usage
283 291
          ;;
284 292
 
... ...
@@ -341,6 +349,10 @@ bootstrap_main()
341 349
       log_trace "Dry run is active."
342 350
    fi
343 351
 
352
+   # source in environment now
353
+
354
+   local_environment_main
355
+
344 356
    #
345 357
    # some commands only run when we have a .bootstrap folder
346 358
    #
... ...
@@ -374,7 +386,7 @@ bootstrap_main()
374 386
    if [ "${MULLE_BOOTSTRAP_NEEDS_REFRESH}" = "YES" ] || refresh_needed
375 387
    then
376 388
       case "${command}" in
377
-         bootstrap|nomagic|fetch)
389
+         bootstrap|nomagic|fetch|update)
378 390
             MULLE_BOOTSTRAP_WILL_FETCH="YES"
379 391
             . mulle-bootstrap-refresh.sh
380 392
             refresh_main || exit 1
... ...
@@ -391,7 +403,7 @@ bootstrap_main()
391 403
             refresh_main refresh_if_bare || exit 1
392 404
          ;;
393 405
 
394
-         update|refresh)
406
+         refresh)
395 407
            . mulle-bootstrap-refresh.sh
396 408
 
397 409
            # 4 laters
... ...
@@ -407,41 +419,49 @@ bootstrap_main()
407 419
       build)
408 420
          . mulle-bootstrap-build.sh
409 421
 
422
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap build"
410 423
          build_main "$@" || exit 1
411 424
       ;;
412 425
 
413 426
       clean)
414 427
          . mulle-bootstrap-clean.sh
415 428
 
429
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap clean"
416 430
          clean_main "$@" || exit 1
417 431
       ;;
418 432
 
419 433
       config)
420 434
          . mulle-bootstrap-settings.sh
435
+
436
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap config"
421 437
          config_main "$@" || exit 1
422 438
       ;;
423 439
 
424 440
       dist)
425 441
          . mulle-bootstrap-clean.sh
426 442
 
443
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap clean"
427 444
          clean_main "dist" || exit 1
428 445
       ;;
429 446
 
430 447
       fetch)
431 448
          . mulle-bootstrap-fetch.sh
432 449
 
450
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap fetch"
433 451
          DONT_ASK_AFTER_WARNING=YES fetch_main "$@" || exit 1
434 452
       ;;
435 453
 
436 454
       init)
437 455
          . mulle-bootstrap-init.sh
438 456
 
457
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap init"
439 458
          init_main "$@" || exit 1
440 459
       ;;
441 460
 
442 461
       install)
443 462
          . mulle-bootstrap-install.sh
444 463
 
464
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap install"
445 465
          install_main "$@" || exit 1
446 466
       ;;
447 467
 
... ...
@@ -453,33 +473,39 @@ bootstrap_main()
453 473
       refresh)
454 474
          [ -z "${MULLE_BOOTSTRAP_REFRESH_SH}" ] && . mulle-bootstrap-refresh.sh
455 475
 
476
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap refresh"
456 477
          refresh_main "$@" || exit 1
457 478
       ;;
458 479
 
459 480
       update|pull)
460 481
          . mulle-bootstrap-fetch.sh
461 482
 
483
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap update"
462 484
          update_main "$@" || exit 1
463 485
 
464 486
          [ -z "${MULLE_BOOTSTRAP_REFRESH_SH}" ] && . mulle-bootstrap-refresh.sh
487
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap refresh"
465 488
          refresh_main || exit 1
466 489
       ;;
467 490
 
468 491
       setup-xcode|xcode)
469 492
          . mulle-bootstrap-xcode.sh
470 493
 
494
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap xcode"
471 495
          xcode_main "$@" || exit 1
472 496
       ;;
473 497
 
474 498
       tag)
475 499
          . mulle-bootstrap-tag.sh
476 500
 
501
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap tag"
477 502
          tag_main "$@" || exit 1
478 503
       ;;
479 504
 
480 505
       git)
481 506
          . mulle-bootstrap-scm.sh
482 507
 
508
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap git"
483 509
          git_main "$@" || exit 1
484 510
       ;;
485 511
 
... ...
@@ -488,7 +514,7 @@ bootstrap_main()
488 514
       ;;
489 515
 
490 516
       *)
491
-         log_error "Unknown command \"${command}\""
517
+         log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown command \"${command}\""
492 518
          usage
493 519
       ;;
494 520
    esac
... ...
@@ -59,6 +59,8 @@ find_library_in_directories()
59 59
    local directory
60 60
    local path
61 61
 
62
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
63
+
62 64
    IFS="
63 65
 "
64 66
    for directory in ${directories}
... ...
@@ -290,7 +292,7 @@ ${SEARCH_PATH}"
290 292
          ;;
291 293
 
292 294
          -*)
293
-            echo "unknown option $1" >&2
295
+            echo "mulle-mingw-dumpdef.sh: Unknown option $1" >&2
294 296
             usage
295 297
          ;;
296 298
 
... ...
@@ -50,6 +50,8 @@ bootstrap_auto_update_merge()
50 50
    local match
51 51
    local i
52 52
 
53
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
54
+
53 55
    IFS="
54 56
 "
55 57
    for i in `ls -1 "${directory}/.bootstrap"`
... ...
@@ -213,6 +215,8 @@ bootstrap_auto_create()
213 215
 {
214 216
    log_verbose "Creating .bootstrap.auto from .bootstrap and .bootstrap.local"
215 217
 
218
+   assert_mulle_bootstrap_version
219
+
216 220
    mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto"
217 221
 
218 222
    if dir_has_files "${BOOTSTRAP_SUBDIR}.local"
... ...
@@ -228,6 +232,7 @@ bootstrap_auto_create()
228 232
    local file
229 233
    local name
230 234
 
235
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
231 236
    IFS="
232 237
 "
233 238
    for file in `ls -1 "${BOOTSTRAP_SUBDIR}"`
... ...
@@ -256,9 +261,10 @@ bootstrap_auto_create()
256 261
 
257 262
 auto_update_initialize()
258 263
 {
259
-    log_fluff ":auto_update_initialize:"
264
+   log_fluff ":auto_update_initialize:"
260 265
 
261
-  NON_MERGABLE_SETTINGS='embedded_repositories
266
+   NON_MERGABLE_SETTINGS='embedded_repositories
267
+version
262 268
 '
263 269
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
264 270
 }
... ...
@@ -882,6 +882,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
882 882
 
883 883
 
884 884
       # cmake separator
885
+      [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
885 886
       IFS=";"
886 887
       for path in ${native_includelines}
887 888
       do
... ...
@@ -2185,7 +2186,7 @@ build_clones()
2185 2186
             then
2186 2187
                :
2187 2188
             else
2188
-               fail "unknown repo ${name}"
2189
+               fail "Unknown repo ${name}"
2189 2190
             fi
2190 2191
          fi
2191 2192
       done
... ...
@@ -2242,6 +2243,8 @@ build_main()
2242 2243
 
2243 2244
    [ -z "${MULLE_BOOTSTRAP_BUILD_ENVIRONMENT_SH}" ] && . mulle-bootstrap-build-environment.sh
2244 2245
 
2246
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
2247
+
2245 2248
    #
2246 2249
    # it is useful, that fetch understands build options and
2247 2250
    # ignores them
... ...
@@ -2277,17 +2280,13 @@ build_main()
2277 2280
             CONFIGURATIONS="`printf "%s" "$1" | tr ',' '\012'`"
2278 2281
             ;;
2279 2282
 
2280
-         # fetch options
2281
-         -cs|--check-usr-local-include|-nr|--no-recursion|-e|--embedded-only|-u|--update-symlinks)
2282
-            if [ -z "${MULLE_BOOTSTRAP_DID_FETCH}" ]
2283
-            then
2284
-               log_error "unknown option $1"
2285
-               ${USAGE}
2286
-            fi
2283
+         # fetch options, are just ignored
2284
+         -i|--ignore-branch|-fc|--force-checkout|-cs|--check-usr-local-include|-nr|--no-recursion|-e|--embedded-only|-u|--update-symlinks)
2285
+            :
2287 2286
          ;;
2288 2287
 
2289 2288
          -*)
2290
-            log_error "unknown option $1"
2289
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown build option $1"
2291 2290
             build_usage
2292 2291
          ;;
2293 2292
 
... ...
@@ -51,11 +51,7 @@ ${ADDICTION_SUBDIR}
51 51
 .bootstrap.auto"`"
52 52
    EMBEDDED="`embedded_repository_directories_from_repos`"
53 53
 
54
-   if [ ! -z "$EMBEDDED" ]
55
-   then
56
-      DIST_CLEANABLE_SUBDIRS="${DIST_CLEANABLE_SUBDIRS}
57
-${EMBEDDED}"
58
-   fi
54
+   DIST_CLEANABLE_SUBDIRS="`add_line "${EMBEDDED}" "${DIST_CLEANABLE_SUBDIRS}"`"
59 55
 }
60 56
 
61 57
 
... ...
@@ -319,6 +315,8 @@ clean_main()
319 315
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ] && . mulle-bootstrap-settings.sh
320 316
    [ -z "${MULLE_BOOTSTRAP_REPOSITORIES_SH}" ] && . mulle-bootstrap-repositories.sh
321 317
 
318
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
319
+
322 320
    COMMAND=
323 321
 
324 322
    while [ $# -ne 0 ]
... ...
@@ -329,7 +327,7 @@ clean_main()
329 327
          ;;
330 328
 
331 329
          -*)
332
-            log_error "unknown option $1"
330
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown clean option $1"
333 331
             COMMAND=help
334 332
          ;;
335 333
 
... ...
@@ -33,58 +33,6 @@
33 33
 MULLE_BOOTSTRAP_DEPENDENY_RESOLVE_SH="included"
34 34
 
35 35
 
36
-_dependency_resolve()
37
-{
38
-   local map
39
-   local name
40
-
41
-   map="$1"
42
-   name="$2"
43
-
44
-   if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
45
-   then
46
-      log_trace2 "resolve ${name}"
47
-   fi
48
-
49
-   local escaped_dependencies
50
-   local dependencies
51
-
52
-   escaped_dependencies="`assoc_array_get "${map}" "${name}"`"
53
-   dependencies="`unescape_linefeeds "${escaped_dependencies}"`"
54
-
55
-   UNRESOLVED_DEPENDENCIES="`array_add "${UNRESOLVED_DEPENDENCIES}" "${name}"`"
56
-
57
-   local sub_name
58
-   #local insert
59
-
60
-   #insert="`array_count "${RESOLVED_DEPENDENCIES}"`"
61
-
62
-   IFS="
63
-"
64
-   for sub_name in ${dependencies}
65
-   do
66
-      IFS="${DEFAULT_IFS}"
67
-
68
-      if array_contains "${RESOLVED_DEPENDENCIES}" "${sub_name}"
69
-      then
70
-         continue
71
-      fi
72
-
73
-      if array_contains "${UNRESOLVED_DEPENDENCIES}" "${sub_name}"
74
-      then
75
-         fail "circular dependency ${sub_name} and ${name}"
76
-      fi
77
-
78
-      _dependency_resolve "${map}" "${sub_name}"
79
-   done
80
-
81
-   IFS="${DEFAULT_IFS}"
82
-
83
-   UNRESOLVED_DEPENDENCIES="`array_remove "${UNRESOLVED_DEPENDENCIES}" "${name}"`"
84
-   RESOLVED_DEPENDENCIES="`array_add "${RESOLVED_DEPENDENCIES}" "${name}"`"
85
-}
86
-
87
-
88 36
 dependency_add()
89 37
 {
90 38
    local map
... ...
@@ -144,6 +92,58 @@ dependency_add_array()
144 92
 }
145 93
 
146 94
 
95
+_dependency_resolve()
96
+{
97
+   local map
98
+   local name
99
+
100
+   map="$1"
101
+   name="$2"
102
+
103
+   if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
104
+   then
105
+      log_trace2 "resolve ${name}"
106
+   fi
107
+
108
+   local escaped_dependencies
109
+   local dependencies
110
+
111
+   escaped_dependencies="`assoc_array_get "${map}" "${name}"`"
112
+   dependencies="`unescape_linefeeds "${escaped_dependencies}"`"
113
+
114
+   UNRESOLVED_DEPENDENCIES="`array_add "${UNRESOLVED_DEPENDENCIES}" "${name}"`"
115
+
116
+   local sub_name
117
+   #local insert
118
+
119
+   #insert="`array_count "${RESOLVED_DEPENDENCIES}"`"
120
+
121
+   IFS="
122
+"
123
+   for sub_name in ${dependencies}
124
+   do
125
+      IFS="${DEFAULT_IFS}"
126
+
127
+      if array_contains "${RESOLVED_DEPENDENCIES}" "${sub_name}"
128
+      then
129
+         continue
130
+      fi
131
+
132
+      if array_contains "${UNRESOLVED_DEPENDENCIES}" "${sub_name}"
133
+      then
134
+         fail "circular dependency ${sub_name} and ${name}"
135
+      fi
136
+
137
+      _dependency_resolve "${map}" "${sub_name}"
138
+   done
139
+
140
+   IFS="${DEFAULT_IFS}"
141
+
142
+   UNRESOLVED_DEPENDENCIES="`array_remove "${UNRESOLVED_DEPENDENCIES}" "${name}"`"
143
+   RESOLVED_DEPENDENCIES="`array_add "${RESOLVED_DEPENDENCIES}" "${name}"`"
144
+}
145
+
146
+
147 147
 dependency_resolve()
148 148
 {
149 149
    local map
... ...
@@ -47,6 +47,7 @@ usage:
47 47
    Options
48 48
       -cs   :  check /usr/local for duplicates
49 49
       -e    :  fetch embedded repositories only
50
+      -i    :  ignore wrongly checked out branches
50 51
       -nr   :  ignore .bootstrap folders of fetched repositories
51 52
       -u    :  try to update symlinked folders as well (not recommended)
52 53
 
... ...
@@ -74,6 +75,8 @@ install_taps()
74 75
 
75 76
    log_fluff "Looking for taps"
76 77
 
78
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
79
+
77 80
    taps=`read_fetch_setting "taps" | sort | sort -u`
78 81
    if [ "${taps}" != "" ]
79 82
    then
... ...
@@ -223,6 +226,7 @@ check_tars()
223 226
    tarballs="`read_fetch_setting "tarballs" | sort | sort -u`"
224 227
    if [ "${tarballs}" != "" ]
225 228
    then
229
+      [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
226 230
       IFS="
227 231
 "
228 232
       for tar in ${tarballs}
... ...
@@ -288,9 +292,10 @@ link_command()
288 292
          local name
289 293
 
290 294
          name="`basename -- "${dst}"`"
291
-         log_warning "tag ${tag} will be ignored, due to symlink" >&2
292
-         log_warning "if you want to checkout this tag do:" >&2
293
-         log_warning "${C_RESET}${C_BOLD}(cd .repos/${name}; git checkout ${GITFLAGS} \"${tag}\" )${C_WARNING}" >&2
295
+         log_warning "The intended tag ${C_RESET_BOLD}${tag}${C_WARNING} will be ignored, because"
296
+         log_warning "the repository is symlinked."
297
+         log_warning "If you want to checkout this tag do:"
298
+         log_warning "${C_RESET_BOLD}(cd .repos/${name}; git checkout ${GITOPTIONS} \"${tag}\" )${C_WARNING}"
294 299
       fi
295 300
    fi
296 301
 
... ...
@@ -465,7 +470,7 @@ checkout()
465 470
          ;;
466 471
 
467 472
       *)
468
-         fail "unknown scm system ${scm}"
473
+         fail "Unknown scm system ${scm}"
469 474
          ;;
470 475
    esac
471 476
 
... ...
@@ -540,16 +545,42 @@ checkout()
540 545
          ;;
541 546
       esac
542 547
 
543
-      local scmflags
548
+      local options
544 549
 
545
-      scmflags="`read_repo_setting "${name}" "checkout" "${scmflagsdefault}"`"
546
-      "${operation}" "${src}" "${dstdir}" "${branch}" "${tag}" "${scmflags}"
550
+      options="`read_repo_setting "${name}" "checkout" "${scmflagsdefault}"`"
551
+      "${operation}" "${src}" "${dstdir}" "${branch}" "${tag}" "${options}"
547 552
 
548 553
       warn_scripts_main "${dstdir}/.bootstrap" "${dstdir}" || fail "Ok, aborted"  #sic
549 554
    fi
550 555
 }
551 556
 
552 557
 
558
+ensure_clone_url_is_correct()
559
+{
560
+   local dstdir
561
+   local url
562
+
563
+   dstdir="$1"
564
+   url="$2"
565
+
566
+   local remote
567
+   local actual
568
+
569
+   remote="`git_get_default_remote "${dstdir}"`"
570
+   if [ -z "${remote}" ]
571
+   then
572
+      fail "Could not figure out a remote for \"${dstdir}\""
573
+   fi
574
+
575
+   actual="`git_get_url "${dstdir}" "${remote}"`"
576
+   if [ "${actual}" != "${url}" ]
577
+   then
578
+      log_verbose "URL change for $remote in \"${dstdir}\" from $actual to $url"
579
+      git_set_url "${dstdir}" "${remote}" "${url}"
580
+   fi
581
+}
582
+
583
+
553 584
 ensure_clone_branch_is_correct()
554 585
 {
555 586
    local dstdir
... ...
@@ -560,16 +591,25 @@ ensure_clone_branch_is_correct()
560 591
 
561 592
    local actual
562 593
 
563
-   if [ ! -z "${branch}" ]
594
+   if [ ! -z "${branch}" -a -z "${MULLE_BOOTSTRAP_IGNORE_BRANCH}" ]
564 595
    then
565 596
       actual="`git_get_branch "${dstdir}"`"
566 597
       if [ "${actual}" != "${branch}" ]
567 598
       then
568
-         fail "Repository \"${dstdir}\" checked-out branch is \"${actual}\".
599
+         if [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" = "NO" ] # abuse force flag
600
+         then
601
+            git_checkout_tag "${dstdir}" "${branch}"
602
+            actual="`git_get_branch "${dstdir}"`"
603
+         fi
604
+
605
+         if [ "${actual}" != "${branch}" ]
606
+         then
607
+            fail "Repository \"${dstdir}\" checked-out branch is \"${actual}\".
569 608
 But \"${branch}\" is specified.
570 609
 Suggested fix:
571 610
    mulle-bootstrap clean dist
572 611
    mulle-bootstrap"
612
+         fi
573 613
       fi
574 614
    fi
575 615
 }
... ...
@@ -622,6 +662,7 @@ checkout_repository()
622 662
 
623 663
    if [ -e "${dstdir}" ]
624 664
    then
665
+      ensure_clone_url_is_correct "${dstdir}" "${url}"
625 666
       ensure_clone_branch_is_correct "${dstdir}" "${branch}"
626 667
 
627 668
       log_fluff "Repository \"${dstdir}\" already exists"
... ...
@@ -630,6 +671,8 @@ checkout_repository()
630 671
       then
631 672
          log_info "Restoring ${name} from graveyard"
632 673
          exekutor mv "${CLONESFETCH_SUBDIR}/.graveyard/${name}" "${CLONESFETCH_SUBDIR}" || fail "move failed"
674
+
675
+         ensure_clone_url_is_correct "${dstdir}" "${url}"
633 676
          ensure_clone_branch_is_correct "${dstdir}" "${branch}"
634 677
       else
635 678
          checkout "$@"
... ...
@@ -728,6 +771,8 @@ clone_repositories()
728 771
    local scm
729 772
    local tag
730 773
 
774
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
775
+
731 776
    stop=0
732 777
    while [ $stop -eq 0 ]
733 778
    do
... ...
@@ -744,7 +789,7 @@ clone_repositories()
744 789
          do
745 790
             IFS="${DEFAULT_IFS}"
746 791
 
747
-            clone="`expanded_setting "${clone}"`"
792
+            clone="`expanded_variables "${clone}"`"
748 793
 
749 794
             # avoid superflous updates
750 795
             match="`echo "${fetched}" | grep -x "${clone}"`"
... ...
@@ -764,6 +809,7 @@ ${clone}"
764 809
                fi
765 810
             fi
766 811
          done
812
+
767 813
          IFS="${DEFAULT_IFS}"
768 814
 
769 815
       fi
... ...
@@ -820,7 +866,7 @@ update()
820 866
          operation="svn_update"
821 867
          ;;
822 868
       *)
823
-         fail "unknown scm system ${scm}"
869
+         fail "Unknown scm system ${scm}"
824 870
          ;;
825 871
    esac
826 872
 
... ...
@@ -850,6 +896,7 @@ update()
850 896
       fetch__run_repo_settings_script "${name}" "${dstdir}" "post-update" "$@"
851 897
    else
852 898
       ensure_clone_branch_is_correct "${dstdir}" "${branch}"
899
+
853 900
       log_info "Repository ${C_MAGENTA}${C_BOLD}${name}${C_INFO} exists and is symlinked, so not updated."
854 901
 
855 902
       rval=1
... ...
@@ -913,6 +960,7 @@ update_repository()
913 960
       fi
914 961
    fi
915 962
 
963
+   ensure_clone_url_is_correct "${dstdir}" "${url}"
916 964
    ensure_clone_branch_is_correct "${dstdir}" "${branch}"
917 965
    [ $rval -eq 0 -o $rval -eq 2 ]
918 966
    return $?
... ...
@@ -952,11 +1000,13 @@ update_repositories()
952 1000
 
953 1001
    if [ $# -ne 0 ]
954 1002
    then
1003
+      [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
955 1004
       IFS="
956 1005
 "
957 1006
       for name in "$@"
958 1007
       do
959 1008
          IFS="${DEFAULT_IFS}"
1009
+
960 1010
          create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
961 1011
             update_repository "${name}" "${CLONESFETCH_SUBDIR}/${name}"
962 1012
          remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
... ...
@@ -967,6 +1017,7 @@ update_repositories()
967 1017
       for name in "$@"
968 1018
       do
969 1019
          IFS="${DEFAULT_IFS}"
1020
+
970 1021
          create_file_if_missing "${CLONESFETCH_SUBDIR}/.fetch_update_started"
971 1022
             did_update_repository "${name}" "${CLONESFETCH_SUBDIR}/${name}"
972 1023
          remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_update_started"
... ...
@@ -989,6 +1040,7 @@ update_repositories()
989 1040
    local updated
990 1041
 
991 1042
    updated=""
1043
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
992 1044
 
993 1045
    stop=0
994 1046
    while [ $stop -eq 0 ]
... ...
@@ -1006,7 +1058,7 @@ update_repositories()
1006 1058
          do
1007 1059
             IFS="${DEFAULT_IFS}"
1008 1060
 
1009
-            clone="`expanded_setting "${clone}"`"
1061
+            clone="`expanded_variables "${clone}"`"
1010 1062
 
1011 1063
             # avoid superflous updates
1012 1064
             match="`echo "${updated}" | grep -x "${clone}"`"
... ...
@@ -1188,6 +1240,8 @@ clone_embedded_repository()
1188 1240
          esac
1189 1241
 
1190 1242
          exekutor mv "${CLONESFETCH_SUBDIR}/.embedded/.graveyard/${name}" "${dstdir}" || fail "move failed"
1243
+
1244
+         ensure_clone_url_is_correct "${dstdir}" "${url}"
1191 1245
          ensure_clone_branch_is_correct "${dstdir}" "${branch}"
1192 1246
       else
1193 1247
          #
... ...
@@ -1213,6 +1267,7 @@ clone_embedded_repository()
1213 1267
       fi
1214 1268
 
1215 1269
    else
1270
+      ensure_clone_url_is_correct "${dstdir}" "${url}"
1216 1271
       ensure_clone_branch_is_correct "${dstdir}" "${branch}"
1217 1272
 
1218 1273
       log_fluff "Repository \"${dstdir}\" already exists"
... ...
@@ -1237,6 +1292,7 @@ clone_embedded_repositories()
1237 1292
    local clone
1238 1293
 
1239 1294
    MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
1295
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
1240 1296
 
1241 1297
    clones="`read_fetch_setting "embedded_repositories"`"
1242 1298
    if [ ! -z "${clones}" ]
... ...
@@ -1278,6 +1334,7 @@ update_embedded_repositories()
1278 1334
    local dstdir
1279 1335
 
1280 1336
    MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
1337
+   [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
1281 1338
 
1282 1339
    clones="`read_fetch_setting "embedded_repositories"`"
1283 1340
    clones="`echo "${clones}" | sed '1!G;h;$!d'`"  # reverse lines
... ...
@@ -1339,6 +1396,10 @@ _common_main()
1339 1396
             EMBEDDED_ONLY="YES"
1340 1397
          ;;
1341 1398
 
1399
+         -i|--ignore-branch)
1400
+            MULLE_BOOTSTRAP_IGNORE_BRANCH="YES"
1401
+         ;;
1402
+
1342 1403
          -u|--update-symlinks)
1343 1404
             MULLE_BOOTSTRAP_UPDATE_SYMLINKS="YES"
1344 1405
          ;;
... ...
@@ -1347,7 +1408,7 @@ _common_main()
1347 1408
          -K|--clean|-k|--no-clean)
1348 1409
             if [ -z "${MULLE_BOOTSTRAP_WILL_BUILD}" ]
1349 1410
             then
1350
-               log_error "unknown option $1"
1411
+               log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown fetch option $1"
1351 1412
                ${USAGE}
1352 1413
             fi
1353 1414
          ;;
... ...
@@ -1356,20 +1417,20 @@ _common_main()
1356 1417
          -j|--cores|-c|--configuration)
1357 1418
             if [ -z "${MULLE_BOOTSTRAP_WILL_BUILD}" ]
1358 1419
             then
1359
-               log_error "unknown option $1"
1420
+               log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown fetch option $1"
1360 1421
                ${USAGE}
1361 1422
             fi
1362 1423
 
1363 1424
             if [ $# -eq 1 ]
1364 1425
             then
1365
-               log_error "missing parameter to option $1"
1426
+               log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Missing parameter to fetch option $1"
1366 1427
                ${USAGE}
1367 1428
             fi
1368 1429
             shift
1369 1430
          ;;
1370 1431
 
1371 1432
          -*)
1372
-            log_error "unknown option $1"
1433
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown fetch option $1"
1373 1434
             ${USAGE}
1374 1435
          ;;
1375 1436
 
... ...
@@ -201,28 +201,6 @@ is_yes()
201 201
 }
202 202
 
203 203
 
204
-concat()
205
-{
206
-   local i
207
-   local s
208
-
209
-   for i in "$@"
210
-   do
211
-      if [ "${i}" != "" ]
212
-      then
213
-         if [ "${s}" != "" ]
214
-         then
215
-            s="${s} ${i}"
216
-         else
217
-            s="${i}"
218
-         fi
219
-      fi
220
-   done
221
-
222
-   echo "${s}"
223
-}
224
-
225
-
226 204
 add_cmake_path()
227 205
 {
228 206
    local line
... ...
@@ -277,7 +255,6 @@ add_line()
277 255
    then
278 256
       echo "${line}"
279 257
    else
280
-
281 258
       echo "${lines}
282 259
 ${line}"
283 260
    fi
... ...
@@ -1101,8 +1078,6 @@ write_protect_directory()
1101 1078
 # ####################################################################
1102 1079
 functions_initialize()
1103 1080
 {
1104
-   DEFAULT_IFS="${IFS}"
1105
-
1106 1081
    [ -z "${MULLE_BOOTSTRAP_LOGGING_SH}" ] && . mulle-bootstrap-logging.sh
1107 1082
    [ -z "${MULLE_BOOTSTRAP_ARRAY_SH}" ] && . mulle-bootstrap-array.sh
1108 1083
 
... ...
@@ -78,7 +78,7 @@ init_main()
78 78
          ;;
79 79
 
80 80
          -*)
81
-            log_error "unknown option $1"
81
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown init option $1"
82 82
             ${USAGE}
83 83
 
84 84
          ;;
... ...
@@ -114,6 +114,11 @@ init_main()
114 114
    log_fluff "Create \"${BOOTSTRAP_SUBDIR}\""
115 115
    mkdir_if_missing "${BOOTSTRAP_SUBDIR}"
116 116
 
117
+   redirect_exekutor "${BOOTSTRAP_SUBDIR}/version" cat <<EOF
118
+# required mulle-bootstrap version
119
+${MULLE_BOOTSTRAP_VERSION_MAJOR}.0.0
120
+EOF
121
+
117 122
    if [ "${CREATE_DEFAULT_FILES}" = "YES" ]
118 123
    then
119 124
       log_fluff "Create default files"
... ...
@@ -31,7 +31,6 @@
31 31
 #
32 32
 MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH="included"
33 33
 
34
-
35 34
 # returns 0 if said yes
36 35
 user_say_yes()
37 36
 {
... ...
@@ -162,8 +161,218 @@ refresh_needed()
162 161
 }
163 162
 
164 163
 
164
+#
165
+# version must be <= min_major.min_minor
166
+#
167
+check_version()
168
+{
169
+   local version
170
+   local min_major
171
+   local min_minor
172
+
173
+   version="$1"
174
+   min_major="$2"
175
+   min_minor="$3"
176
+
177
+   local major
178
+   local minor
179
+
180
+   if [ -z "${version}" ]
181
+   then
182
+      return 0
183
+   fi
184
+
185
+   major="`echo "${version}" | head -1 | cut -d. -f1`"
186
+   if [ "${major}" -lt "${min_major}" ]
187
+   then
188
+      return 0
189
+   fi
190
+
191
+   if [ "${major}" -ne "${min_major}" ]
192
+   then
193
+      return 1
194
+   fi
195
+
196
+   minor="`echo "${version}" | head -1 | cut -d. -f2`"
197
+   [ "${minor}" -le "${min_minor}" ]
198
+}
199
+
200
+
201
+assert_mulle_bootstrap_version()
202
+{
203
+   local version
204
+
205
+   # has to be read before .auto is setup
206
+   version="`_read_setting "${BOOTSTRAP_SUBDIR}/version"`"
207
+   if check_version "$version" "${MULLE_BOOTSTRAP_VERSION_MAJOR}" "${MULLE_BOOTSTRAP_VERSION_MINOR}"
208
+   then
209
+      return
210
+   fi
211
+
212
+   fail "This ${BOOTSTRAP_SUBDIR} requires mulle-bootstrap version ${version} at least, you have ${MULLE_BOOTSTRAP_VERSION}"
213
+}
214
+
215
+
216
+#
217
+# expands ${setting} and ${setting:-foo}
218
+#
219
+_expanded_variables()
220
+{
221
+   local string
222
+
223
+   string="$1"
224
+
225
+   local key
226
+   local value
227
+   local prefix
228
+   local suffix
229
+   local next
230
+   local default
231
+   local tmp
232
+
233
+
234
+   key="`echo "${string}" | sed -n 's/^\(.*\)\${\([A-Za-z_][A-Za-z0-9_:-]*\)}\(.*\)$/\2/p'`"
235
+   if [ -z "${key}" ]
236
+   then
237
+      echo "$1"
238
+      return
239
+   fi
240
+
241
+   prefix="`echo "${string}" | sed 's/^\(.*\)\${\([A-Za-z_][A-Za-z0-9_:-]*\)}\(.*\)$/\1/'`"
242
+   suffix="`echo "${string}" | sed 's/^\(.*\)\${\([A-Za-z_][A-Za-z0-9_:-]*\)}\(.*\)$/\3/'`"
243
+
244
+   tmp="`echo "${key}" | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)[:][-]\(.*\)$/\1/p'`"
245
+   if [ ! -z "${tmp}" ]
246
+   then
247
+      default="`echo "${key}" | sed -n 's/^\([A-Za-z_][A-Za-z0-9_]*\)[:][-]\(.*\)$/\2/p'`"
248
+      key="${tmp}"
249
+   fi
250
+
251
+   value="`read_fetch_setting "${key}" "${default}"`"
252
+   next="${prefix}${value}${suffix}"
253
+   if [ "${next}" = "${string}" ]
254
+   then
255
+      fail "${string} expands to itself"
256
+   fi
257
+
258
+   _expanded_variables "${next}"
259
+}
260
+
261
+
262
+expanded_variables()
263
+{
264
+   local memo
265
+   local value
266
+
267
+   # a hack ?
268
+
269
+   memo="${MULLE_BOOTSTRAP_SETTINGS_NO_AUTO}"
270
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="NO"
271
+
272
+   value="`_expanded_variables "$1"`"
273
+
274
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="${memo}"
275
+
276
+   if [ "$1" != "${value}" ]
277
+   then
278
+      log_fluff "Expanded \"$1\" to \"${value}\""
279
+   fi
280
+
281
+   echo "$value"
282
+}
283
+
284
+
285
+source_environment_file()
286
+{
287
+   local filename
288
+
289
+   filename="$1"
290
+   if [ ! -r "${filename}" ]
291
+   then
292
+      log_fluff "Environment file ${filename} not found"
293
+      return 1
294
+   fi
295
+
296
+   local lines
297
+   local line
298
+   local key
299
+   local value
300
+
301
+   log_fluff "Environment file ${filename} exists"
302
+
303
+   lines="`egrep -s -v '^#|^[ ]*$' "${filename}"`"
304
+   IFS="
305
+"
306
+   for line in $lines
307
+   do
308
+      IFS="${DEFAULT_IFS}"
309
+
310
+      key="`echo "${line}" | cut -d= -f1`"
311
+      value="`echo "${line}" | cut -d= -f2`"
312
+
313
+      value="`expanded_variables "${value}"`"
314
+      case "${key}" in
315
+         *\`*|*\$*|*\!*)
316
+            fail "Illegal characters in $key of $filename"
317
+         ;;
318
+      esac
319
+      case "${value}" in
320
+         *\`*|*\$*|*\!*)
321
+            fail "Illegal characters in $value of $filename"
322
+         ;;
323
+      esac
324
+      log_verbose "Environment variable $key defined as $value"
325
+
326
+      eval "${key}=${value}; export ${key}"
327
+   done
328
+
329
+   IFS="${DEFAULT_IFS}"
330
+
331
+   return 0
332
+}
333
+
334
+
335
+#
336
+# source environment
337
+#
338
+source_environment()
339
+{
340
+   local flag
341
+
342
+   flag=""
343
+
344
+   if source_environment_file "${HOME}/.mulle-bootstrap/environment"
345
+   then
346
+      flag="${MULLE_BOOTSTRAP_FLUFF}"
347
+   fi
348
+
349
+   if source_environment_file "${BOOTSTRAP_SUBDIR}.auto/environment"
350
+   then
351
+      flag="${MULLE_BOOTSTRAP_FLUFF}"
352
+   else
353
+      if source_environment_file "${BOOTSTRAP_SUBDIR}.local/environment"
354
+      then
355
+         flag="${MULLE_BOOTSTRAP_FLUFF}"
356
+      else
357
+         if source_environment_file "${BOOTSTRAP_SUBDIR}/environment"
358
+         then
359
+            flag="${MULLE_BOOTSTRAP_FLUFF}"
360
+         fi
361
+      fi
362
+   fi
363
+
364
+   if [ "${flag}" = "YES" ]
365
+   then
366
+      log_fluff "Environment:"
367
+      env >&2
368
+   fi
369
+}
370
+
371
+
165 372
 local_environment_initialize()
166 373
 {
374
+   [ -z "${MULLE_BOOTSTRAP_LOGGING_SH}" ] && . mulle-bootstrap-logging.sh
375
+
167 376
    #
168 377
    # read local environment
169 378
    # source this file
... ...
@@ -210,4 +419,12 @@ local_environment_initialize()
210 419
    esac
211 420
 }
212 421
 
422
+
423
+local_environment_main()
424
+{
425
+#  don't do it, so far it's been overkill
426
+#   source_environment
427
+   :
428
+}
429
+
213 430
 local_environment_initialize
... ...
@@ -108,7 +108,7 @@ log_trace2()
108 108
 #
109 109
 fail()
110 110
 {
111
-   log_error "$@"
111
+   log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}:" "$@"
112 112
    if [ ! -z "${MULLE_BOOTSTRAP_PID}" ]
113 113
    then
114 114
       kill -INT "${MULLE_BOOTSTRAP_PID}"  # kill myself (especially, if executing in subshell)
... ...
@@ -128,9 +128,40 @@ internal_fail()
128 128
 }
129 129
 
130 130
 
131
+#
132
+# here because often needed :-/
133
+#
134
+concat()
135
+{
136
+   local i
137
+   local s
138
+
139
+   for i in "$@"
140
+   do
141
+      if [ -z "${i}" ]
142
+      then
143
+         continue
144
+      fi
145
+
146
+      if [ -z "${s}" ]
147
+      then
148
+         s="${i}"
149
+      else
150
+         s="${s} ${i}"
151
+      fi
152
+   done
153
+
154
+   echo "${s}"
155
+}
156
+
157
+
158
+
159
+
131 160
 # Escape sequence and resets, should use tput here instead of ANSI
132 161
 logging_initialize()
133 162
 {
163
+   DEFAULT_IFS="${IFS}" # as early as possible
164
+
134 165
    #
135 166
    # need this for scripts also
136 167
    #
... ...
@@ -54,12 +54,12 @@ refresh_repositories_settings()
54 54
 {
55 55
    local stop
56 56
    local clones
57
-   local clone
58 57
    local stop
59 58
    local refreshed
60 59
    local match
61 60
    local dependency_map
62
-
61
+   local unexpanded
62
+   local unexpanded_url
63 63
 
64 64
    refreshed=""
65 65
    dependency_map=""
... ...
@@ -74,22 +74,20 @@ refresh_repositories_settings()
74 74
       then
75 75
          IFS="
76 76
 "
77
-         for clone in ${clones}
77
+         for unexpanded in ${clones}
78 78
          do
79 79
             IFS="${DEFAULT_IFS}"
80 80
 
81
-            clone="`expanded_setting "${clone}"`"
82
-            # avoid superflous updates
83
-            match="`echo "${refreshed}" | grep -x "${clone}"`"
84
-            # could remove prefixes here https:// http://
85
-
86
-            if [ "${match}" = "${clone}" ]
81
+            match="`echo "${refreshed}" | fgrep -s -x "${unexpanded}"`"
82
+            if [ ! -z "${match}" ]
87 83
             then
88 84
                continue
89 85
             fi
90 86
 
91 87
             refreshed="${refreshed}
92
-${clone}"
88
+${unexpanded}"
89
+
90
+            # avoid superflous updates
93 91
 
94 92
             local branch
95 93
             local dstdir
... ...
@@ -97,7 +95,9 @@ ${clone}"
97 95
             local scm
98 96
             local tag
99 97
             local url
98
+            local clone
100 99
 
100
+            clone="`expanded_variables "${unexpanded}"`"
101 101
             __parse_expanded_clone "${clone}"
102 102
 
103 103
             dstdir="${CLONESFETCH_SUBDIR}/${name}"
... ...
@@ -120,11 +120,12 @@ ${clone}"
120 120
                sub_repos="`_read_setting "${filename}"`"
121 121
                if [ ! -z "${sub_repos}" ]
122 122
                then
123
-                  dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${url}"`"
124
-                  dependency_map="`dependency_add_array "${dependency_map}" "${url}" "${sub_repos}"`"
123
+#                  unexpanded_url="`url_from_clone "${unexpanded}"`"
124
+                  dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${unexpanded}"`"
125
+                  dependency_map="`dependency_add_array "${dependency_map}" "${unexpanded}" "${sub_repos}"`"
125 126
                   if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
126 127
                   then
127
-                     log_trace2 "add \"${sub_repos}\" for ${url} to ${dependency_map}"
128
+                     log_trace2 "add \"${sub_repos}\" for ${unexpanded} to ${dependency_map}"
128 129
                   fi
129 130
                fi
130 131
             else
... ...
@@ -326,7 +326,7 @@ __parse_clone()
326 326
 {
327 327
    local clone
328 328
 
329
-   clone="`expanded_setting "${1}"`"
329
+   clone="`expanded_variables "${1}"`"
330 330
 
331 331
    __parse_expanded_clone "${clone}"
332 332
 }
... ...
@@ -347,7 +347,7 @@ __parse_embedded_clone()
347 347
 {
348 348
    local clone
349 349
 
350
-   clone="`expanded_setting "${1}"`"
350
+   clone="`expanded_variables "${1}"`"
351 351
 
352 352
    __parse_expanded_clone "${clone}"
353 353
 
... ...
@@ -41,6 +41,73 @@ git_is_bare_repository()
41 41
 }
42 42
 
43 43
 
44
+git_get_url()
45
+{
46
+   local remote
47
+   remote="$2"
48
+
49
+   ( cd "$1" ; git remote get-url "${remote}" )
50
+}
51
+
52
+
53
+git_set_url()
54
+{
55
+   local remote
56
+   local url
57
+
58
+   remote="$2"
59
+   url="$3"
60
+
61
+   (
62
+      cd "$1" ;
63
+      git remote set-url "${remote}" "${url}" ;
64
+      git fetch "${remote}" # prefetch to get new branches
65
+   )
66
+}
67
+
68
+
69
+#
70
+# prefer origin over others, probably could be smarter
71
+# by passing in the desired branch and figuring more
72
+# stuff out
73
+#
74
+git_get_default_remote()
75
+{
76
+   local i
77
+   local match
78
+
79
+   match=""
80
+   IFS="
81
+"
82
+   for i in `( cd "$1" ; git remote)`
83
+   do
84
+      case "$i" in
85
+         origin)
86
+            match="$i"
87
+            break
88
+         ;;
89
+
90
+         *)
91
+            if [ -z "${match}" ]
92
+            then
93
+               match="$i"
94
+            fi
95
+         ;;
96
+      esac
97
+   done
98
+
99
+   IFS="${DEFAULT_IFS}"
100
+
101
+   echo "$match"
102
+}
103
+
104
+
105
+git_has_branch()
106
+{
107
+   ( cd "$1" ; git branch | cut -c3- | fgrep -q -s -x "$2" > /dev/null )
108
+}
109
+
110
+
44 111
 git_get_branch()
45 112
 {
46 113
    ( cd "$1" ; git rev-parse --abbrev-ref HEAD 2> /dev/null )
... ...
@@ -55,13 +122,16 @@ git_checkout_tag()
55 122
    dst="$1"
56 123
    tag="$2"
57 124
 
58
-   local flags
125
+   [ -z "${dst}" ] && internal_fail "dst is empty"
126
+   [ -z "${tag}" ] && internal_fail "tag is empty"
127
+
128
+   local options
59 129
 
60 130
    # checkout don't know -v
61
-   flags="${GITFLAGS}"
62
-   if [ "${flags}" = "-v" ]
131
+   options="${GITOPTIONS}"
132
+   if [ "${options}" = "-v" ]
63 133
    then
64
-      flags=""
134
+      options=""
65 135
    fi
66 136
 
67 137
    local branch
... ...
@@ -71,13 +141,12 @@ git_checkout_tag()
71 141
    if [ "${branch}" != "${tag}" ]
72 142
    then
73 143
       log_info "Checking out version ${C_WHITE}${C_BOLD}${tag}${C_INFO} of ${C_MAGENTA}${C_BOLD}${dst}${C_INFO} ..."
74
-      ( exekutor cd "${dst}" ; exekutor git checkout ${flags} "${tag}" )
144
+      ( exekutor cd "${dst}" ; exekutor git ${GITFLAGS} checkout ${options} "${tag}" )
75 145
 
76 146
       if [ $? -ne 0 ]
77 147
       then
78 148
          log_error "Checkout failed, moving ${C_CYAN}${C_BOLD}${dst}${C_ERROR} to ${C_CYAN}${C_BOLD}${dst}.failed${C_ERROR}"
79 149
          log_error "You need to fix this manually and then move it back."
80
-         log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename -- "${dst}"`/TAG" >&2
81 150
 
82 151
          rmdir_safer "${dst}.failed"
83 152
          exekutor mv "${dst}" "${dst}.failed"
... ...
@@ -95,28 +164,29 @@ git_clone()
95 164
    local dst
96 165
    local branch
97 166
    local tag
98
-   local flags
167
+   local options
99 168
 
100 169
    src="$1"
101 170
    dst="$2"
102 171
    branch="$3"
103 172
    tag="$4"
104
-   flags="$5"
173
+   options="$5"
105 174
 
106 175
    [ ! -z "${src}" ] || internal_fail "src is empty"
107 176
    [ ! -z "${dst}" ] || internal_fail "dst is empty"
177
+   [ -z "${DEFAULT_IFS}" ] && internal_internal_fail "IFS fail"
108 178
 
109 179
    if [ ! -z "${branch}" ]
110 180
    then
111 181
       log_info "Cloning branch ${C_RESET_BOLD}$branch${C_INFO} of ${C_MAGENTA}${C_BOLD}${src}${C_INFO} ..."
112
-      flags="${flags} -b ${branch}"
182
+      options="`concat "${options}" "-b ${branch}"`"
113 183
    else
114 184
       log_info "Cloning ${C_MAGENTA}${C_BOLD}${src}${C_INFO} ..."
115 185
    fi
116 186
 
117
-   exekutor git clone ${flags} ${GITFLAGS} "${src}" "${dst}" || fail "git clone of \"${src}\" into \"${dst}\" failed"
187
+   exekutor git ${GITFLAGS} clone ${options} ${GITOPTIONS} -- "${src}" "${dst}" || fail "git clone of \"${src}\" into \"${dst}\" failed"
118 188
 
119
-   if [ "${tag}" != "" ]
189
+   if [ ! -z "${tag}" ]
120 190
    then
121 191
       git_checkout_tag "${dst}" "${tag}"
122 192
    fi
... ...
@@ -128,20 +198,20 @@ git_pull()
128 198
    local dst
129 199
    local branch
130 200
    local tag
131
-   local flags
201
+   local options
132 202
 
133 203
    dst="$1"
134 204
    branch="$2"
135 205
    tag="$3"
136
-   tag="$4"
206
+   options="$4"
137 207
 
138 208
    [ ! -z "$dst" ] || internal_fail "dst is empty"
139