Browse code

Redo the stuff thats stored in .auto and .repos. Try to fully expand stuff.

Nat! authored on 16-02-2017 21:32:02 • Nat! committed on 17-02-2017 13:06:46
Showing 30 changed files
... ...
@@ -336,22 +336,13 @@ bootstrap_setup_trace()
336 336
 {
337 337
    case "${1}" in
338 338
       VERBOSE)
339
-         MULLE_FLAG_LOG_FLUFF="NO"
340 339
          MULLE_FLAG_LOG_VERBOSE="YES"
341
-         if [ -z "${MULLE_FLAG_VERBOSE_BUILD}" ]
342
-         then
343
-            MULLE_FLAG_VERBOSE_BUILD="NO"
344
-         fi
345 340
       ;;
346 341
 
347 342
       FLUFF)
348 343
          MULLE_FLAG_LOG_FLUFF="YES"
349 344
          MULLE_FLAG_LOG_VERBOSE="YES"
350 345
          MULLE_FLAG_LOG_EXECUTOR="YES"
351
-         if [ -z "${MULLE_FLAG_VERBOSE_BUILD}" ]
352
-         then
353
-            MULLE_FLAG_VERBOSE_BUILD="NO"
354
-         fi
355 346
       ;;
356 347
 
357 348
       TRACE)
... ...
@@ -359,26 +350,18 @@ bootstrap_setup_trace()
359 350
          MULLE_FLAG_LOG_EXECUTOR="YES"
360 351
          MULLE_FLAG_LOG_FLUFF="YES"
361 352
          MULLE_FLAG_LOG_VERBOSE="YES"
362
-         if [ -z "${MULLE_FLAG_VERBOSE_BUILD}" ]
363
-         then
364
-            MULLE_FLAG_VERBOSE_BUILD="NO"
365
-         fi
366 353
          bootstrap_dump_env
367 354
       ;;
368 355
 
369 356
       1848)
370 357
          MULLE_FLAG_LOG_SETTINGS="YES"
371
-         MULLE_FLAG_LOG_EXECUTOR="NO"
372 358
          MULLE_FLAG_LOG_FLUFF="YES"
373 359
          MULLE_FLAG_LOG_VERBOSE="YES"
374
-         if [ -z "${MULLE_FLAG_VERBOSE_BUILD}" ]
375
-         then
376
-            MULLE_FLAG_VERBOSE_BUILD="YES"
377
-         fi
360
+         MULLE_FLAG_VERBOSE_BUILD="YES"
378 361
 
379 362
          bootstrap_dump_env
380 363
 
381
-         if [ -z "${MULLE_TRACE_POSTPONE}" ]
364
+         if [ "${MULLE_TRACE_POSTPONE}" = "NO" ]
382 365
          then
383 366
             log_trace "1848 trace (set -x) started"
384 367
             set -x
... ...
@@ -418,7 +401,7 @@ bootstrap_technical_flags()
418 401
 
419 402
       -t|--trace)
420 403
          MULLE_TRACE="1848"
421
-         COPYMOVETARFLAGS="-v"
404
+         COPYMOVEFLAGS="-v"
422 405
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
423 406
          MULLE_TRACE_PATHS_FLIP_X="YES"
424 407
          MULLE_TRACE_RESOLVER_FLIP_X="YES"
... ...
@@ -450,7 +433,7 @@ bootstrap_technical_flags()
450 433
 
451 434
       -tpo|--trace-postpone)
452 435
          [ "${MULLE_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
453
-         MULLE_TRACE_POSTPONE=YES
436
+         MULLE_TRACE_POSTPONE="YES"
454 437
       ;;
455 438
 
456 439
       -tpwd|--trace-pwd)
... ...
@@ -479,7 +462,7 @@ bootstrap_technical_flags()
479 462
         [ "${MULLE_TRACE}" = "1848" ] && log_warning "${MULLE_EXECUTABLE_FAIL_PREFIX}: -vv after -t invalidates -t"
480 463
 
481 464
          MULLE_TRACE="FLUFF"
482
-         COPYMOVETARFLAGS="-v"
465
+         COPYMOVEFLAGS="-v"
483 466
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
484 467
       ;;
485 468
 
... ...
@@ -487,7 +470,7 @@ bootstrap_technical_flags()
487 470
         [ "${MULLE_TRACE}" = "1848" ] && log_warning "${MULLE_EXECUTABLE_FAIL_PREFIX}: -vvv after -t invalidates -t"
488 471
 
489 472
          MULLE_TRACE="TRACE"
490
-         COPYMOVETARFLAGS="-v"
473
+         COPYMOVEFLAGS="-v"
491 474
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
492 475
       ;;
493 476
 
... ...
@@ -559,6 +542,26 @@ bootstrap_main()
559 542
    local command
560 543
    local ps4string
561 544
 
545
+   local MULLE_FLAG_ANSWER="ASK"
546
+   local MULLE_FLAG_DIRTY_HARRY="YES"
547
+   local MULLE_FLAG_IGNORE_GRAVEYARD="NO"
548
+   local MULLE_FLAG_VERBOSE_BUILD="NO"
549
+
550
+   # technical flags
551
+   local MULLE_FLAG_EXECUTOR_DRY_RUN="NO"
552
+   local MULLE_FLAG_LOG_DEBUG="NO"
553
+   local MULLE_FLAG_LOG_EXECUTOR="NO"
554
+   local MULLE_FLAG_LOG_EXECUTOR="NO"
555
+   local MULLE_FLAG_LOG_FLUFF="NO"
556
+   local MULLE_FLAG_LOG_SCRIPTS="NO"
557
+   local MULLE_FLAG_LOG_SETTINGS="NO"
558
+   local MULLE_FLAG_LOG_VERBOSE="NO"
559
+   local MULLE_FLAG_MERGE_LOG="NO"
560
+   local MULLE_TRACE_PATHS_FLIP_X="NO"
561
+   local MULLE_TRACE_POSTPONE="NO"
562
+   local MULLE_TRACE_RESOLVER_FLIP_X="NO"
563
+   local MULLE_TRACE_SETTINGS_FLIP_X="NO"
564
+
562 565
    #
563 566
    # simple option handling
564 567
    #
... ...
@@ -814,6 +817,21 @@ brew_main()
814 817
    local command
815 818
    local ps4string
816 819
 
820
+   # technical flags
821
+   local MULLE_FLAG_EXECUTOR_DRY_RUN="NO"
822
+   local MULLE_FLAG_LOG_DEBUG="NO"
823
+   local MULLE_FLAG_LOG_EXECUTOR="NO"
824
+   local MULLE_FLAG_LOG_EXECUTOR="NO"
825
+   local MULLE_FLAG_LOG_FLUFF="NO"
826
+   local MULLE_FLAG_LOG_SCRIPTS="NO"
827
+   local MULLE_FLAG_LOG_SETTINGS="NO"
828
+   local MULLE_FLAG_LOG_VERBOSE="NO"
829
+   local MULLE_FLAG_MERGE_LOG="NO"
830
+   local MULLE_TRACE_PATHS_FLIP_X="NO"
831
+   local MULLE_TRACE_POSTPONE="NO"
832
+   local MULLE_TRACE_RESOLVER_FLIP_X="NO"
833
+   local MULLE_TRACE_SETTINGS_FLIP_X="NO"
834
+
817 835
    #
818 836
    # simple option handling
819 837
    #
... ...
@@ -81,7 +81,7 @@ _bootstrap_auto_copy()
81 81
          *.build|settings|overrides)
82 82
             if [ -d "${filepath}" ]
83 83
             then
84
-               exekutor cp -Ran ${COPYMOVETARFLAGS} "${filepath}" "${dstfilepath}"
84
+               exekutor cp -Ran ${COPYMOVEFLAGS} "${filepath}" "${dstfilepath}" >&2
85 85
             fi
86 86
          ;;
87 87
 
... ...
@@ -89,6 +89,14 @@ _bootstrap_auto_copy()
89 89
             _bootstrap_merge_repository_files "${filepath}" "${dstfilepath}" "NO"
90 90
          ;;
91 91
 
92
+         embedded_repositories)
93
+            (
94
+               STASHES_DEFAULT_DIR=""
95
+               STASHES_ROOT_DIR=""
96
+               _bootstrap_merge_repository_files "${filepath}" "${dstfilepath}" "NO"
97
+            )
98
+         ;;
99
+
92 100
          *)
93 101
             #
94 102
             # root settings get the benefit of expansion
... ...
@@ -105,7 +113,7 @@ _bootstrap_auto_copy()
105 113
                value="`read_expanded_setting "${filepath}" "" "${tmpdir}"`"
106 114
                redirect_exekutor "${dstfilepath}" echo "${value}"
107 115
             else
108
-               exekutor cp -a ${COPYMOVETARFLAGS} "${filepath}" "${dstfilepath}"
116
+               exekutor cp -a ${COPYMOVEFLAGS} "${filepath}" "${dstfilepath}" >&2
109 117
             fi
110 118
          ;;
111 119
       esac
... ...
@@ -219,6 +227,12 @@ _bootstrap_read_repository_file()
219 227
          ;;
220 228
       esac
221 229
 
230
+      case "${scm}" in
231
+         symlink)
232
+            fail "You can't specify symlink in the repositories file yourself. Use -y flag"
233
+         ;;
234
+      esac
235
+
222 236
       branch="${OVERRIDE_BRANCH:-${branch}}"
223 237
       branch="${branch:-master}"
224 238
 
... ...
@@ -227,6 +241,9 @@ _bootstrap_read_repository_file()
227 241
          dstdir=""
228 242
       fi
229 243
 
244
+      dstdir="`computed_stashdir "${url}" "${name}" "${dstdir}"`"
245
+      scm="${scm:-git}"
246
+
230 247
       echo "${url};${dstdir};${branch};${scm};${tag}"
231 248
    done
232 249
 
... ...
@@ -295,13 +312,14 @@ _bootstrap_auto_merge_root_settings()
295 312
       dstfile="${dst}/${settingname}"
296 313
 
297 314
       #
298
-      # "repositories" file gets special treatment
299
-      #
300
-      if [ "${settingname}" = "repositories" ]
301
-      then
302
-         _bootstrap_merge_repository_files "${srcfile}" "${dstfile}"
303
-         continue
304
-      fi
315
+      # "repositories" files gets special treatment
316
+      # "embedded_repositories" is not merged though
317
+      case "${settingname}" in
318
+            "repositories")
319
+               _bootstrap_merge_repository_files "${srcfile}" "${dstfile}" "YES"
320
+            continue
321
+            ;;
322
+      esac
305 323
 
306 324
       # #
307 325
       # # non mergable settings are not merged
... ...
@@ -336,9 +354,9 @@ _bootstrap_auto_merge_root_settings()
336 354
 
337 355
          log_fluff "Merging expanded \"${settingname}\" from \"${srcfile}\""
338 356
 
339
-         exekutor mv ${COPYMOVETARFLAGS}  "${dstfile}" "${tmpfile}" >&2 || exit 1
357
+         exekutor mv ${COPYMOVEFLAGS}  "${dstfile}" "${tmpfile}" >&2 || exit 1
340 358
          redirect_exekutor "${dstfile}" _bootstrap_merge_expanded_settings_in_front "${srcfile}" "${tmpfile}"  || exit 1
341
-         exekutor rm ${COPYMOVETARFLAGS}  "${tmpfile}" >&2 || exit 1
359
+         exekutor rm ${COPYMOVEFLAGS}  "${tmpfile}" >&2 || exit 1
342 360
       else
343 361
          log_fluff "Copying expanded \"${settingname}\" from \"${srcfile}\""
344 362
 
... ...
@@ -354,7 +372,7 @@ _bootstrap_auto_embedded_copy()
354 372
 {
355 373
    local name="$1"
356 374
    local directory="$2"
357
-   local srcfile="$3"
375
+   local filepath="$3"
358 376
 
359 377
    local dst
360 378
 
... ...
@@ -365,14 +383,19 @@ _bootstrap_auto_embedded_copy()
365 383
    rmdir_safer "${dst}"
366 384
    mkdir_if_missing "${dst}"
367 385
 
368
-   # copy over our stuff
369
-   # _bootstrap_auto_create "${dst}" "${BOOTSTRAP_DIR}"
370
-
371
-   # then augment with embedded_settings
386
+   #
387
+   # augment with embedded_settings
388
+   #
372 389
    local clones
390
+   local dstfilepath
391
+
392
+   dstfilepath="${dst}/embedded_repositories"
373 393
 
374
-   clones="`_bootstrap_merge_expanded_settings_in_front "${srcfile}" ""`" || exit 1
375
-   redirect_exekutor "${dst}/embedded_repositories" echo "${clones}"
394
+   (
395
+      STASHES_DEFAULT_DIR=""
396
+      STASHES_ROOT_DIR="${directory}"
397
+      _bootstrap_merge_repository_files "${filepath}" "${dstfilepath}" "NO"
398
+   )
376 399
 }
377 400
 
378 401
 
... ...
@@ -116,7 +116,7 @@ dispense_headers()
116 116
          # this fails with more nested header set ups, need to fix!
117 117
 
118 118
          log_fluff "Copying \"${src}\" to \"${dst}\""
119
-         exekutor cp -Ra ${COPYMOVETARFLAGS} "${src}"/* "${dst}" >&2 || exit 1
119
+         exekutor cp -Ra ${COPYMOVEFLAGS} "${src}"/* "${dst}" >&2 || exit 1
120 120
 
121 121
          rmdir_safer "${src}"
122 122
       else
... ...
@@ -163,7 +163,7 @@ dispense_binaries()
163 163
          log_fluff "Copying \"${src}\" to \"${dst}\""
164 164
          mkdir_if_missing "${dst}"
165 165
          exekutor find "${src}" -xdev -mindepth 1 -maxdepth 1 \( -type "${findtype}" -o -type "${findtype2}" \) -print0 | \
166
-            exekutor xargs -0 -I % mv ${COPYMOVETARFLAGS} "${copyflag}" % "${dst}" >&2
166
+            exekutor xargs -0 -I % mv ${COPYMOVEFLAGS} "${copyflag}" % "${dst}" >&2
167 167
          [ $? -eq 0 ]  || exit 1
168 168
       else
169 169
          log_fluff "But there are none"
... ...
@@ -285,7 +285,7 @@ collect_and_dispense_product()
285 285
 
286 286
          log_fluff "Copying everything from \"${src}\" to \"${dst}\""
287 287
          exekutor find "${src}" -xdev -mindepth 1 -maxdepth 1 -print0 | \
288
-               exekutor xargs -0 -I % mv ${COPYMOVETARFLAGS} -f % "${dst}" >&2
288
+               exekutor xargs -0 -I % mv ${COPYMOVEFLAGS} -f % "${dst}" >&2
289 289
          [ $? -eq 0 ]  || fail "moving files from ${src} to ${dst} failed"
290 290
       fi
291 291
 
... ...
@@ -2202,7 +2202,7 @@ install_tars()
2202 2202
       else
2203 2203
          mkdir_if_missing "${DEPENDENCIES_DIR}"
2204 2204
          log_info "Installing tarball \"${tar}\""
2205
-         exekutor tar -xz -C "${DEPENDENCIES_DIR}" -f "${tar}" || fail "failed to extract ${tar}"
2205
+         exekutor tar -xz ${TARFLAGS} -C "${DEPENDENCIES_DIR}" -f "${tar}" || fail "failed to extract ${tar}"
2206 2206
       fi
2207 2207
    done
2208 2208
    IFS="${DEFAULT_IFS}"
... ...
@@ -235,13 +235,19 @@ _print_stashdir()
235 235
 
236 236
 print_stashdir_repositories()
237 237
 {
238
-   walk_repositories "repositories" "_print_stashdir"
238
+   walk_repositories "repositories" \
239
+                     "_print_stashdir" \
240
+                     "" \
241
+                     "${REPOS_DIR}"
239 242
 }
240 243
 
241 244
 
242 245
 print_stashdir_embedded_repositories()
243 246
 {
244
-   walk_repositories "embedded_repositories" "_print_stashdir"
247
+   walk_repositories "embedded_repositories" \
248
+                     "_print_stashdir" \
249
+                     "" \
250
+                     "${EMBEDDED_REPOS_DIR}"
245 251
 }
246 252
 
247 253
 
... ...
@@ -258,18 +264,24 @@ ${ADDICTIONS_DIR}
258 264
 ${STASHES_DEFAULT_DIR}
259 265
 ${BOOTSTRAP_DIR}.auto"`"
260 266
 
261
-   #
262
-   # as a master we don't throw the minions out
263
-   #
264
-   if ! is_master_bootstrap_project
267
+   # scrub old stuff
268
+   if [ -d ".repos" ]
265 269
    then
266
-      local stashes
267
-
268
-      stashes="`print_stashdir_repositories`"
269
-      DIST_CLEANABLE_SUBDIRS="`add_line "${DIST_CLEANABLE_SUBDIRS}" "${stashes}"`"
270
-
271
-      stashes="`print_stashdir_embedded_repositories`"
272
-      DIST_CLEANABLE_SUBDIRS="`add_line "${DIST_CLEANABLE_SUBDIRS}" "${stashes}"`"
270
+      DIST_CLEANABLE_SUBDIRS="`add_line "${DIST_CLEANABLE_SUBDIRS}" ".repos"`"
271
+   else
272
+      #
273
+      # as a master we don't throw the minions out
274
+      #
275
+      if ! is_master_bootstrap_project
276
+      then
277
+         local stashes
278
+
279
+         stashes="`print_stashdir_repositories`"
280
+         DIST_CLEANABLE_SUBDIRS="`add_line "${DIST_CLEANABLE_SUBDIRS}" "${stashes}"`"
281
+
282
+         stashes="`print_stashdir_embedded_repositories`"
283
+         DIST_CLEANABLE_SUBDIRS="`add_line "${DIST_CLEANABLE_SUBDIRS}" "${stashes}"`"
284
+      fi
273 285
    fi
274 286
 
275 287
    clean_directories "${DIST_CLEANABLE_SUBDIRS}" "${flag}"
... ...
@@ -94,9 +94,9 @@ _copy_files()
94 94
       exekutor cd "${dstdir}" ;
95 95
       if [ -z "${noclobber}" ]
96 96
       then
97
-         exekutor tar -x ${COPYMOVETARFLAGS} -f -
97
+         exekutor tar -x ${TARFLAGS} -f - >&2 2> /dev/null #intentional order
98 98
       else
99
-         exekutor tar -x ${COPYMOVETARFLAGS} -k -f -
99
+         exekutor tar -x ${TARFLAGS} -k -f - >&2 2> /dev/null
100 100
          :
101 101
       fi
102 102
    )
... ...
@@ -59,16 +59,15 @@ usage:
59 59
    mulle-bootstrap ${COMMAND} [options] [repositories]
60 60
 
61 61
    Options
62
-      -c    :  use caches from CACHES_PATH to locate repositories
63
-      -cU   :  check /usr/local for duplicates
64
-      -e    :  fetch embedded repositories only
65
-      -es   :  allow embedded symlinks (very experimental)
66
-      -fs   :  follow symlinks when updating/upgrading (not recommended)
67
-      -l    :  allow creation of symlinks
68
-      -le   :  allow creation of embedded symlinks
69
-      -i    :  ignore wrongly checked out branches
70
-      -nc   :  don't use caches. Useful to counter flag -y
71
-      -ns   :  don't create symlinks. Useful to counter flag -y
62
+      --caches            :  use CACHES_PATH to locate local repositories
63
+      --check-usr-local   :  check /usr/local for duplicates
64
+      --embedded-only     :  fetch embedded repositories only
65
+
66
+      --allow-symlinks    :  allow symlinking instead of cloning
67
+      --embedded-symlinks :  allow embedded symlinks (very experimental)
68
+      --update-symlinks   :  follow symlinks when updating (not recommended)
69
+      --no-caches         :  don't use caches. Useful to counter flag -y
70
+      --no-symlinks       :  don't create symlinks. Useful to counter flag -y
72 71
 
73 72
    install  :  clone or symlink non-exisiting repositories and other resources
74 73
    update   :  execute a "fetch" in already fetched repositories
... ...
@@ -194,7 +193,7 @@ link_command()
194 193
       branch="${tag}"
195 194
    fi
196 195
 
197
-   if [ ! -z "${branch}" ]
196
+   if [ "${branch}" != "master" ]
198 197
    then
199 198
       log_warning "The intended ${branchlabel} ${C_RESET_BOLD}${branch}${C_WARNING} will be ignored, because"
200 199
       log_warning "the repository is symlinked."
... ...
@@ -379,7 +378,7 @@ clone_or_symlink()
379 378
    local scmflagsdefault
380 379
 
381 380
    case "${scm}" in
382
-      git|"" )
381
+      git)
383 382
          operation="git_clone"
384 383
          scmflagsdefault="--recursive"
385 384
       ;;
... ...
@@ -451,26 +450,28 @@ clone_or_symlink()
451 450
       ;;
452 451
    esac
453 452
 
454
-   local options
455
-
456
-   options="`read_root_setting "${name}.scmflags" "${scmflagsdefault}"`"
457
-
458 453
    "${operation}" "${reposdir}" \
459 454
                   "${name}" \
460 455
                   "${url}" \
461 456
                   "${branch}" \
462 457
                   "${scm}" \
463 458
                   "${tag}" \
464
-                  "${stashdir}" \
465
-                  "${options}"
459
+                  "${stashdir}"
466 460
 
467 461
    warn_scripts_main "${stashdir}/.bootstrap" "${stashdir}" || fail "Ok, aborted"  #sic
462
+
463
+   if [ "${operation}" = "link_command" ]
464
+   then
465
+      return 2
466
+   fi
467
+
468
+   return 0
468 469
 }
469 470
 
470 471
 ##
471 472
 ## CLONE
472 473
 ##
473
-_clone()
474
+_clone_repository()
474 475
 {
475 476
    local reposdir="$1"  # ususally .bootstrap.repos
476 477
    local name="$2"      # name of the clone
... ...
@@ -509,10 +510,7 @@ Suggested fix:
509 510
       _bury_stash "${reposdir}" "${name}" "${stashdir}"
510 511
    fi
511 512
 
512
-   if ! clone_or_symlink "$@"
513
-   then
514
-      fail "failed to fetch $url"
515
-   fi
513
+   clone_or_symlink "$@"   # pass thru rval
516 514
 }
517 515
 
518 516
 
... ...
@@ -520,14 +518,14 @@ clone_repository()
520 518
 {
521 519
    log_action "clone" "$@"
522 520
 
523
-   _clone "$@"
521
+   _clone_repository "$@"   # pass thru rval
524 522
 }
525 523
 
526 524
 
527 525
 ##
528 526
 ## CHECKOUT
529 527
 ##
530
-_checkout()
528
+_checkout_repository()
531 529
 {
532 530
    local reposdir="$1"  # ususally .bootstrap.repos
533 531
    local name="$2"      # name of the clone
... ...
@@ -540,7 +538,7 @@ _checkout()
540 538
    local operation
541 539
 
542 540
    case "${scm}" in
543
-      git|"" )
541
+      git)
544 542
          operation="git_checkout"
545 543
       ;;
546 544
       svn)
... ...
@@ -566,15 +564,9 @@ checkout_repository()
566 564
    local url="$3"       # URL of the clone
567 565
    local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
568 566
 
569
-   if [ -L "${stashdir}" -a "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" != "YES" ]
570
-   then
571
-      echo "Ignoring ${stashdir} because it's a symlink"
572
-      return
573
-   fi
574
-
575 567
    log_action "checkout" "$@"
576 568
 
577
-   _checkout "$@"
569
+   _checkout_repository "$@"
578 570
 }
579 571
 
580 572
 
... ...
@@ -583,7 +575,7 @@ checkout_repository()
583 575
 ## this like git fetch, does not update repository
584 576
 ##
585 577
 
586
-_update()
578
+_update_repository()
587 579
 {
588 580
    local reposdir="$1"  # ususally .bootstrap.repos
589 581
    local name="$2"      # name of the clone
... ...
@@ -596,7 +588,7 @@ _update()
596 588
    local operation
597 589
 
598 590
    case "${scm}" in
599
-      git|"" )
591
+      git)
600 592
          operation="git_fetch"
601 593
       ;;
602 594
       svn)
... ...
@@ -619,15 +611,9 @@ _update()
619 611
 
620 612
 update_repository()
621 613
 {
622
-   if [ -L "${stashdir}" -a "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" != "YES" ]
623
-   then
624
-      log_fluff "Ignoring ${stashdir} because it's a symlink"
625
-      return
626
-   fi
627
-
628 614
    log_action "update" "$@"
629 615
 
630
-   _update "$@" > /dev/null
616
+   _update_repository "$@" > /dev/null
631 617
 
632 618
    echo "${clone}"  # hackish
633 619
 }
... ...
@@ -637,7 +623,7 @@ update_repository()
637 623
 ## UPGRADE
638 624
 ## This is a pull
639 625
 
640
-_upgrade()
626
+_upgrade_repository()
641 627
 {
642 628
    local reposdir="$1"  # ususally .bootstrap.repos
643 629
    local name="$2"      # name of the clone
... ...
@@ -650,7 +636,7 @@ _upgrade()
650 636
    local operation
651 637
 
652 638
    case "${scm}" in
653
-      git|"" )
639
+      git)
654 640
          operation="git_pull"
655 641
       ;;
656 642
       svn)
... ...
@@ -673,15 +659,9 @@ _upgrade()
673 659
 
674 660
 upgrade_repository()
675 661
 {
676
-   if [ -L "${stashdir}" -a "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" != "YES" ]
677
-   then
678
-      log_fluff "Ignoring ${stashdir} because it's a symlink"
679
-      return
680
-   fi
681
-
682 662
    log_action "upgrade" "$@"
683 663
 
684
-   _upgrade "$@" > /dev/null
664
+   _upgrade_repository "$@" > /dev/null
685 665
 
686 666
    echo "${clone}"  # hackish
687 667
 }
... ...
@@ -690,14 +670,14 @@ upgrade_repository()
690 670
 #
691 671
 # Walk repositories with a callback function
692 672
 #
693
-_operation_walk_repositories()
673
+_update_operation_walk_repositories()
694 674
 {
695
-   local operation="$1" ; shift
675
+   local operation="$1"
696 676
 
697 677
    local permissions
698 678
 
699 679
    permissions=""
700
-   if [ "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
680
+   if [ "${OPTION_ALLOW_UPDATING_SYMLINKS}" = "YES" ]
701 681
    then
702 682
       permissions="`add_line "${permissions}" "symlink"`"
703 683
    fi
... ...
@@ -709,14 +689,14 @@ _operation_walk_repositories()
709 689
 }
710 690
 
711 691
 
712
-_operation_walk_embedded_repositories()
692
+_update_operation_walk_embedded_repositories()
713 693
 {
714
-   local operation="$1" ; shift
694
+   local operation="$1"
715 695
 
716 696
    local permissions
717 697
 
718 698
    permissions=""
719
-   if [ "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
699
+   if [ "${OPTION_ALLOW_UPDATING_SYMLINKS}" = "YES" ]
720 700
    then
721 701
       permissions="`add_line "${permissions}" "symlink"`"
722 702
    fi
... ...
@@ -739,14 +719,14 @@ _operation_walk_embedded_repositories()
739 719
 }
740 720
 
741 721
 
742
-_operation_walk_deep_embedded_repositories()
722
+_update_operation_walk_deep_embedded_repositories()
743 723
 {
744
-   local operation="$1" ; shift
724
+   local operation="$1"
745 725
 
746 726
    local permissions
747 727
 
748 728
    permissions=""
749
-   if [ "${OPTION_ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
729
+   if [ "${OPTION_ALLOW_UPDATING_SYMLINKS}" = "YES" ]
750 730
    then
751 731
       permissions="`add_line "${permissions}" "symlink"`"
752 732
    fi
... ...
@@ -783,25 +763,29 @@ did_fetch_repositories()
783 763
    walk_clones "$*" "did_fetch_repository" "${REPOS_DIR}"
784 764
 }
785 765
 
766
+did_fetch_embedded_repositories()
767
+{
768
+   walk_clones "$*" "did_fetch_repository" "${REPOS_DIR}"
769
+}
786 770
 
787 771
 ##
788 772
 ## UPDATE
789 773
 ##
790 774
 update_repositories()
791 775
 {
792
-   _operation_walk_repositories "update_repository"
776
+   _update_operation_walk_repositories "update_repository"
793 777
 }
794 778
 
795 779
 
796 780
 update_embedded_repositories()
797 781
 {
798
-   _operation_walk_embedded_repositories "update_repository"
782
+   _update_operation_walk_embedded_repositories "update_repository"
799 783
 }
800 784
 
801 785
 
802 786
 update_deep_embedded_repositories()
803 787
 {
804
-   _operation_walk_deep_embedded_repositories "update_repository"
788
+   _update_operation_walk_deep_embedded_repositories "update_repository"
805 789
 }
806 790
 
807 791
 
... ...
@@ -810,19 +794,19 @@ update_deep_embedded_repositories()
810 794
 ##
811 795
 upgrade_repositories()
812 796
 {
813
-   _operation_walk_repositories "upgrade_repository"
797
+   _update_operation_walk_repositories "upgrade_repository"
814 798
 }
815 799
 
816 800
 
817 801
 upgrade_embedded_repositories()
818 802
 {
819
-   _operation_walk_embedded_repositories "upgrade_repository"
803
+   _update_operation_walk_embedded_repositories "upgrade_repository"
820 804
 }
821 805
 
822 806
 
823 807
 upgrade_deep_embedded_repositories()
824 808
 {
825
-   _operation_walk_deep_embedded_repositories "upgrade_repository"
809
+   _update_operation_walk_deep_embedded_repositories "upgrade_repository"
826 810
 }
827 811
 
828 812
 
... ...
@@ -881,9 +865,10 @@ required_action_for_clone()
881 865
       return
882 866
    fi
883 867
 
884
-   log_debug "Change: \"${clone}\" -> \"${newclone}\""
885
-
886 868
    local reposdir
869
+
870
+   reposdir="${newreposdir}"
871
+
887 872
    local name
888 873
    local url
889 874
    local branch
... ...
@@ -900,6 +885,14 @@ required_action_for_clone()
900 885
       return
901 886
    fi
902 887
 
888
+   if [ "${scm}" = "symlink" ]
889
+   then
890
+      log_fluff "\"${stashdir}\" is symlink. Ignoring possible differences."
891
+      return
892
+   fi
893
+
894
+   log_debug "Change: \"${clone}\" -> \"${newclone}\""
895
+
903 896
    if [ "${scm}" != "${newscm}" ]
904 897
    then
905 898
       log_fluff "SCM has changed from \"${scm}\" to \"${newscm}\", need to refetch"
... ...
@@ -921,7 +914,17 @@ clone"
921 914
    if [ "${stashdir}" != "${newstashdir}" ]
922 915
    then
923 916
       log_fluff "Destination has changed from \"${stashdir}\" to \"${newstashdir}\", need to move"
924
-      echo "move"
917
+
918
+      local oldstashdir
919
+
920
+      oldstashdir="`get_old_stashdir "${reposdir}" "${name}"`"
921
+      if [ -d "${oldstashdir}" ]
922
+      then
923
+         echo "move ${oldstashdir}"
924
+      else
925
+         log_warning "Can't find ${name} in ${oldstashdir}. Will clone again"
926
+         echo "clone"
927
+      fi
925 928
    fi
926 929
 
927 930
    if [ "${branch}" != "${newbranch}" ]
... ...
@@ -950,27 +953,31 @@ get_old_stashdir()
950 953
    local reposdir="$1"
951 954
    local name="$2"
952 955
 
956
+   [ -z "${reposdir}" ] && internal_fail "reposdir empty"
957
+   [ -z "${name}" ]     && internal_fail "reposdir empty"
958
+
953 959
    local oldstashdir
960
+   local oldparent
954 961
 
955
-   oldstashdir="`stash_of_repository "${reposdir}" "${name}"`"
962
+   oldclone="`clone_of_repository "${reposdir}" "${name}"`"
956 963
 
957
-   if [ ! -d "${oldstashdir}" ]
958
-   then
959
-      local dstdir
960
-      local url
961
-      local name
962
-      local oldclone
964
+   [ -z "${oldclone}" ] && fail "Old clone information for \"${name}\" in \"${reposdir}\" is missing"
963 965
 
964
-      oldclone="`clone_of_repository "${reposdir}" "${name}"`"
965
-      [ -z "${oldclone}" ] && fail "Old clone information for \"${name}\" in \"${reposdir}\" is missing"
966
+   url="`_url_part_from_clone "${oldclone}"`"
967
+   name="`_canonical_clone_name "${url}"`"
968
+   dstdir="`_dstdir_part_from_clone "${oldclone}"`"
966 969
 
967
-      dstdir="`_dstdir_part_from_clone "${oldclone}"`"
968
-      url="`_url_part_from_clone "${oldclone}"`"
969
-      name="`_canonical_clone_name "${url}"`"
970 970
 
971
-      oldstashdir="`computed_stashdir "${url}" "${name}" "${dstdir}"`"
971
+   oldparent="`parentclone_of_repository "${reposdir}" "${name}"`"
972
+   if [ ! -z "${oldparent}" ]
973
+   then
974
+      # figure out what the old stashdir prefix was and remove it
975
+      oldprefix="`_dstdir_part_from_clone "${oldparent}"`"
976
+      dstdir="${dstdir#$oldprefix/}"
972 977
    fi
973 978
 
979
+   oldstashdir="`computed_stashdir "${url}" "${name}" "${dstdir}"`"
980
+
974 981
    echo "${oldstashdir}"
975 982
 }
976 983
 
... ...
@@ -988,13 +995,14 @@ work_clones()
988 995
    local scm
989 996
    local tag
990 997
    local stashdir
998
+   local dstdir
991 999
 
992 1000
    local actionitems
993 1001
    local fetched
994 1002
    local remember
995 1003
    local repotype
996 1004
    local oldstashdir
997
-   local url_is_stash
1005
+   local did_fetch
998 1006
 
999 1007
    case "${reposdir}" in
1000 1008
       *embedded)
... ...
@@ -1006,6 +1014,8 @@ work_clones()
1006 1014
       ;;
1007 1015
    esac
1008 1016
 
1017
+   log_debug "Working \"${clones}\""
1018
+
1009 1019
    IFS="
1010 1020
 "
1011 1021
    for clone in ${clones}
... ...
@@ -1026,19 +1036,15 @@ work_clones()
1026 1036
          continue
1027 1037
       fi
1028 1038
 
1029
-      #
1030
-      # unify clone, by stripping extraneous ;
1031
-      #
1032
-      clone="`echo "${clone}" | sed 's/;*$//'`"
1033
-
1034 1039
       log_debug "${C_INFO}Doing ${clone}..."
1035 1040
 
1036 1041
       __REFRESHED__="`add_line "${__REFRESHED__}" "${clone}"`"
1037 1042
 
1038
-      local dstdir
1039
-
1040 1043
       parse_raw_clone "${clone}"
1041
-      process_clone "${clone}"
1044
+      process_raw_clone
1045
+
1046
+      stashdir="${dstdir}"
1047
+      [ -z "${stashdir}" ] && internal_fail "empty stashdir"
1042 1048
 
1043 1049
       actionitems="`required_action_for_clone "${clone}" \
1044 1050
                                               "${reposdir}" \
... ...
@@ -1051,6 +1057,8 @@ work_clones()
1051 1057
 
1052 1058
       log_debug "${C_INFO}Actions for \"${name}\": ${actionitems:-none}"
1053 1059
 
1060
+      did_fetch="NO"
1061
+
1054 1062
       IFS="
1055 1063
 "
1056 1064
       for item in ${actionitems}
... ...
@@ -1071,28 +1079,42 @@ work_clones()
1071 1079
             ;;
1072 1080
 
1073 1081
             "clone")
1074
-               if clone_repository "${reposdir}" \
1075
-                                   "${name}" \
1076
-                                   "${url}" \
1077
-                                   "${branch}" \
1078
-                                   "${scm}" \
1079
-                                   "${tag}" \
1080
-                                   "${stashdir}"
1081
-               then
1082
-                  fetched="`add_line "${fetched}" "${name}"`"
1083
-               fi
1082
+               clone_repository "${reposdir}" \
1083
+                                "${name}" \
1084
+                                "${url}" \
1085
+                                "${branch}" \
1086
+                                "${scm}" \
1087
+                                "${tag}" \
1088
+                                "${stashdir}"
1089
+
1090
+               case "$?" in
1091
+                  1)
1092
+                     # skipped
1093
+                     continue
1094
+                  ;;
1095
+                  2)
1096
+                     # if we used a symlink, we want to memorize that
1097
+                     scm="symlink"
1098
+                  ;;
1099
+               esac
1100
+               did_fetch="YES"
1084 1101
             ;;
1085 1102
 
1086 1103
             "ignore")
1087 1104
                remember="NO"
1088 1105
             ;;
1089 1106
 
1090
-            "move")
1091
-               oldstashdir="`get_old_stashdir "${reposdir}" "${name}"`"
1107
+            #
1108
+            # its actually wrong to do this here
1109
+            # because deeply embedded repos might lose contact
1110
+            # if also moved at same time
1111
+            #
1112
+            move*)
1113
+               oldstashdir="${item:5}"
1092 1114
 
1093 1115
                log_info "Moving ${repotype}stash ${C_MAGENTA}${C_BOLD}${name}${C_INFO} from \"${oldstashdir}\" to \"${stashdir}\""
1094 1116
 
1095
-               if ! exekutor mv ${COPYMOVETARFLAGS} "${oldstashdir}" "${stashdir}"
1117
+               if ! exekutor mv ${COPYMOVEFLAGS} "${oldstashdir}" "${stashdir}"  >&2
1096 1118
                then
1097 1119
                   fail "Move failed!"
1098 1120
                fi
... ...
@@ -1108,8 +1130,12 @@ work_clones()
1108 1130
                                   "${stashdir}" > /dev/null
1109 1131
             ;;
1110 1132
 
1111
-            "remove")
1112
-               oldstashdir="`get_old_stashdir "${reposdir}" "${name}"`"
1133
+            remove*)
1134
+               oldstashdir="${item:7}"
1135
+               if [ -z "${oldstashdir}" ]
1136
+               then
1137
+                  oldstashdir="`get_old_stashdir "${reposdir}" "${name}"`"
1138
+               fi
1113 1139
 
1114 1140
                log_info "Removing old ${repotype}stash ${C_MAGENTA}${C_BOLD}${oldstashdir}${C_INFO}"
1115 1141
 
... ...
@@ -1140,25 +1166,27 @@ work_clones()
1140 1166
          bootstrap_auto_update "${name}" "${stashdir}"
1141 1167
       fi
1142 1168
 
1169
+      # create clone as it is now
1170
+      clone="`echo "${url};${dstdir};${branch};${scm};${tag}" | sed 's/;*$//'`"
1171
+
1172
+      if [ "${did_fetch}" = "YES" ]
1173
+      then
1174
+         fetched="`add_line "${fetched}" "${url};${stashdir};${branch};${scm};${tag}"`"
1175
+      fi
1176
+
1143 1177
       #
1144 1178
       # always remember, what we have now (except if its a minion)
1145 1179
       #
1146 1180
       if [ "${remember}" = "YES" ]
1147 1181
       then
1148
-         local actualclone
1149
-
1150 1182
          # branch could be overwritten
1151
-         actualclone="`echo "${url};${dstdir};${branch};${scm};${tag}" | sed 's/;*$//'`"
1152
-         log_debug "${C_INFO}Remembering ${actualclone}..."
1183
+         log_debug "${C_INFO}Remembering ${clone}..."
1153 1184
 
1154
-         remember_stash_of_repository "${actualclone}" \
1185
+         remember_stash_of_repository "${clone}" \
1155 1186
                                       "${reposdir}" \
1156 1187
                                       "${name}"  \
1157
-                                      "${url}" \
1158
-                                      "${branch}" \
1159
-                                      "${scm}" \
1160
-                                      "${tag}" \
1161
-                                      "${stashdir}"
1188
+                                      "${stashdir}" \
1189
+                                      "${PARENT_CLONE}"
1162 1190
       fi
1163 1191
       mark_stash_as_alive "${reposdir}" "${name}"
1164 1192
    done
... ...
@@ -1213,8 +1241,10 @@ _fetch_once_deep_repository()
1213 1241
    reposdir="${reposdir}/.deep/${name}.d"
1214 1242
    (
1215 1243
       STASHES_DEFAULT_DIR=""
1216
-      STASHES_ROOT_DIR="${stashdir}"
1244
+      STASHES_ROOT_DIR="${stashdir}"  # hackish
1217 1245
       OPTION_ALLOW_CREATING_SYMLINKS="${OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS}" ;
1246
+      PARENT_REPOSITORY_NAME="${name}"
1247
+      PARENT_CLONE="${clone}"
1218 1248
 
1219 1249
       local clones
1220 1250
 
... ...
@@ -1229,7 +1259,16 @@ fetch_once_deep_embedded_repositories()
1229 1259
 {
1230 1260
    log_debug "fetch_once_deep_embedded_repositories"
1231 1261
 
1232
-   _operation_walk_repositories "_fetch_once_deep_repository"
1262
+   permissions=""
1263
+   if [ "${OPTION_ALLOW_UPDATING_SYMLINKS}" = "YES" ]
1264
+   then
1265
+      permissions="`add_line "${permissions}" "symlink"`"
1266
+   fi
1267
+
1268
+   walk_repositories "repositories"  \
1269
+                     "_fetch_once_deep_repository" \
1270
+                     "${permissions}" \
1271
+                     "${REPOS_DIR}"
1233 1272
 }
1234 1273
 
1235 1274
 
... ...
@@ -1259,7 +1298,7 @@ fetch_loop_repositories()
1259 1298
       esac
1260 1299
 
1261 1300
       after="${before}"
1262
-      before="`read_root_setting "repositories" | sed 's/[ \t]*$//' | sort`"
1301
+      before="`read_root_setting "repositories" | sort`"
1263 1302
       if [ "${after}" = "${before}" ]
1264 1303
       then
1265 1304
          log_fluff "Repositories file is unchanged, so done"
... ...
@@ -1290,21 +1329,27 @@ fetch_loop_repositories()
1290 1329
 
1291 1330
 assume_stashes_are_zombies()
1292 1331
 {
1293
-   zombify_embedded_repository_stashes
1294
-   [ "${OPTION_EMBEDDED_ONLY}" = "YES" ] && return
1332
+   if [ -d "${REPOS_DIR}" ]
1333
+   then
1334
+      zombify_embedded_repository_stashes
1335
+      [ "${OPTION_EMBEDDED_ONLY}" = "YES" ] && return
1295 1336
 
1296
-   zombify_repository_stashes
1297
-   zombify_deep_embedded_repository_stashes
1337
+      zombify_repository_stashes
1338
+      zombify_deep_embedded_repository_stashes
1339
+   fi
1298 1340
 }
1299 1341
 
1300 1342
 
1301 1343
 bury_zombies_in_graveyard()
1302 1344
 {
1303
-   bury_embedded_repository_zombies
1304
-   [ "${OPTION_EMBEDDED_ONLY}" = "YES" ] && return
1345
+   if [ -d "${REPOS_DIR}" ]
1346
+   then
1347
+      bury_embedded_repository_zombies
1348
+      [ "${OPTION_EMBEDDED_ONLY}" = "YES" ] && return
1305 1349
 
1306
-   bury_repository_zombies
1307
-   bury_deep_embedded_repository_zombies
1350
+      bury_repository_zombies
1351
+      bury_deep_embedded_repository_zombies
1352
+   fi
1308 1353
 }
1309 1354
 
1310 1355
 
... ...
@@ -1340,13 +1385,9 @@ fetch_loop()
1340 1385
 {
1341 1386
    local fetched
1342 1387
    local deep_fetched
1343
-   local is_master
1344 1388
 
1345 1389
    unpostpone_trace
1346 1390
 
1347
-   is_master_bootstrap_project
1348
-   is_master=$?
1349
-
1350 1391
    # this is wrong, we just do "stashes" though
1351 1392
    assume_stashes_are_zombies
1352 1393
 
... ...
@@ -1366,10 +1407,7 @@ fetch_loop()
1366 1407
 
1367 1408
    bootstrap_auto_final
1368 1409
 
1369
-   if [ "${is_master}" -ne 0 ]
1370
-   then
1371
-      bury_zombies_in_graveyard
1372
-   fi
1410
+   bury_zombies_in_graveyard
1373 1411
 
1374 1412
    echo "${fetched}"
1375 1413
 }
... ...
@@ -1444,6 +1482,7 @@ _common_main()
1444 1482
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ]          && . mulle-bootstrap-settings.sh
1445 1483
 
1446 1484
    local OPTION_CHECK_USR_LOCAL_INCLUDE="NO"
1485
+   local OPTION_ALLOW_UPDATING_SYMLINKS="NO"
1447 1486
    local OPTION_ALLOW_CREATING_SYMLINKS="NO"
1448 1487
    local OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS="NO"
1449 1488
    local OPTION_ALLOW_SEARCH_CACHES="NO"
... ...
@@ -1456,6 +1495,7 @@ _common_main()
1456 1495
    case "${UNAME}" in
1457 1496
       mingw)
1458 1497
          OPTION_ALLOW_CREATING_SYMLINKS="NO"
1498
+         OPTION_ALLOW_UPDATING_SYMLINKS="NO"
1459 1499
       ;;
1460 1500
 
1461 1501
       *)
... ...
@@ -1480,7 +1520,7 @@ _common_main()
1480 1520
             OPTION_ALLOW_SEARCH_CACHES="YES"
1481 1521
          ;;
1482 1522
 
1483
-         -cu|--check-usr-local-include)
1523
+         -cu|--check-usr-local|--check-usr-local)
1484 1524
             OPTION_CHECK_USR_LOCAL_INCLUDE="YES"
1485 1525
          ;;
1486 1526
 
... ...
@@ -1488,25 +1528,28 @@ _common_main()
1488 1528
             OPTION_EMBEDDED_ONLY="YES"
1489 1529
          ;;
1490 1530
 
1491
-         -fs|--follow-symlinks)
1492
-            OPTION_ALLOW_FOLLOWING_SYMLINKS="YES"
1531
+         # update symlinks, dangerous!
1532
+         --update-symlinks)
1533
+            OPTION_ALLOW_UPDATING_SYMLINKS="YES"
1493 1534
          ;;
1494 1535
 
1536
+         # create symlinks instead of clones for repositories
1495 1537
          -l|--symlink-creation)
1496 1538
             OPTION_ALLOW_CREATING_SYMLINKS="YES"
1497 1539
          ;;
1498 1540
 
1499
-         -le|--embedded-symlink-creation)
1541
+         # create symlinks instead of clones for embedded_repositories
1542
+         --embedded-symlink-creation|--embedded-symlinks)
1500 1543
             OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS="YES"
1501 1544
          ;;
1502 1545
 
1503
-         -nc|--no-caches)
1546
+         --no-caches)
1504 1547
             OPTION_ALLOW_SEARCH_CACHES="NO"
1505 1548
             OPTION_ALLOW_CREATING_SYMLINKS="NO"
1506 1549
          ;;
1507 1550
 
1508
-         -ns|--no-symlink-creation|--no-symlinks)
1509
-            OPTION_ALLOW_FOLLOWING_SYMLINKS="NO"
1551
+         --no-symlink-creation|--no-symlinks)
1552
+            OPTION_ALLOW_UPDATING_SYMLINKS="NO"
1510 1553
             OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS="NO"
1511 1554
             OPTION_ALLOW_CREATING_SYMLINKS="NO"
1512 1555
          ;;
... ...
@@ -1080,8 +1080,8 @@ rmdir_safer()
1080 1080
    if [ -d "$1" ]
1081 1081
    then
1082 1082
       assert_sane_path "$1"
1083
-      exekutor chmod -R u+w "$1" || fail "Failed to make $1 writable"
1084
-      exekutor rm -rf "$1" || fail "failed to remove $1"
1083
+      exekutor chmod -R u+w "$1"  >&2 || fail "Failed to make $1 writable"
1084
+      exekutor rm -rf "$1"  >&2 || fail "failed to remove $1"
1085 1085
    fi
1086 1086
 }
1087 1087
 
... ...
@@ -1090,7 +1090,7 @@ rmdir_if_empty()
1090 1090
 {
1091 1091
    if dir_is_empty "$1"
1092 1092
    then
1093
-      exekutor rmdir "$1" || fail "failed to remove $1"
1093
+      exekutor rmdir "$1"  >&2 || fail "failed to remove $1"
1094 1094
    fi
1095 1095
 }
1096 1096
 
... ...
@@ -1148,7 +1148,7 @@ create_symlink()
1148 1148
    fi
1149 1149
 
1150 1150
    log_info "Symlinking ${C_MAGENTA}${C_BOLD}${srcname}${C_INFO} as \"${url}\" ..."
1151
-   exekutor ln -s -f "${url}" "${stashdir}" || fail "failed to setup symlink \"${stashdir}\" (to \"${url}\")"
1151
+   exekutor ln -s -f "${url}" "${stashdir}"  >&2 || fail "failed to setup symlink \"${stashdir}\" (to \"${url}\")"
1152 1152
 }
1153 1153
 
1154 1154
 
... ...
@@ -1157,8 +1157,8 @@ remove_file_if_present()
1157 1157
    if [ -e "$1" ]
1158 1158
    then
1159 1159
       log_fluff "Removing \"$1\""
1160
-      exekutor chmod u+w "$1" || fail "Failed to make $1 writable"
1161
-      exekutor rm -f "$1" || fail "failed to remove \"$1\""
1160
+      exekutor chmod u+w "$1"  >&2 || fail "Failed to make $1 writable"
1161
+      exekutor rm -f "$1"  >&2 || fail "failed to remove \"$1\""
1162 1162
    fi
1163 1163
 }
1164 1164
 
... ...
@@ -209,8 +209,8 @@ merge_framework_configurations()
209 209
       if [ ! -z "${suffix}" ]
210 210
       then
211 211
          dstexe="${dstdir}/${name}${suffix}"
212
-         exekutor cp "${srcexe}" "${dstexe}"
213
-         exekutor chmod 755 "${dstexe}"
212
+         exekutor cp "${srcexe}" "${dstexe}" >&2
213
+         exekutor chmod 755 "${dstexe}"  >&2
214 214
       fi
215 215
    done
216 216
 
... ...
@@ -161,6 +161,8 @@ check_version()
161 161
 # figure out if we need to run refresh
162 162
 build_needed()
163 163
 {
164
+   [ -z "${REPOS_DIR}" ] && internal_fail "REPOS_DIR undefined"
165
+
164 166
    if [ ! -f "${REPOS_DIR}/.bootstrap_build_done" ]
165 167
    then
166 168
       log_fluff "Need build because \"${REPOS_DIR}/.bootstrap_build_done\" does not exist."
... ...
@@ -179,21 +181,24 @@ build_needed()
179 181
 
180 182
 fetch_needed()
181 183
 {
184
+   [ -z "${REPOS_DIR}" ]     && internal_fail "REPOS_DIR undefined"
185
+   [ -z "${BOOTSTRAP_DIR}" ] && internal_fail "BOOTSTRAP_DIR undefined"
186
+
182 187
    if [ ! -f "${REPOS_DIR}/.bootstrap_fetch_done" ]
183 188
    then
184 189
       log_fluff "Need fetch because \"${REPOS_DIR}/.bootstrap_fetch_done\" does not exist."
185 190
       return 0
186 191
    fi
187 192
 
188
-   if [ "${REPOS_DIR}/.bootstrap_fetch_done" -ot "${BOOTSTRAP_SUBDIR}" ]
193
+   if [ "${REPOS_DIR}/.bootstrap_fetch_done" -ot "${BOOTSTRAP_DIR}" ]
189 194
    then
190
-      log_fluff "Need fetch because \"${BOOTSTRAP_SUBDIR}\" is modified"
195
+      log_fluff "Need fetch because \"${BOOTSTRAP_DIR}\" is modified"
191 196
       return 0
192 197
    fi
193 198
 
194
-   if [ "${REPOS_DIR}/.bootstrap_fetch_done" -ot "${BOOTSTRAP_SUBDIR}.local" ]
199
+   if [ "${REPOS_DIR}/.bootstrap_fetch_done" -ot "${BOOTSTRAP_DIR}.local" ]
195 200
    then
196
-      log_fluff "Need fetch because \"${BOOTSTRAP_SUBDIR}.local\" is modified"
201
+      log_fluff "Need fetch because \"${BOOTSTRAP_DIR}.local\" is modified"
197 202
       return 0
198 203
    fi
199 204
 
... ...
@@ -128,7 +128,18 @@ log_trace2()
128 128
 fail()
129 129
 {
130 130
    log_error "${MULLE_EXECUTABLE_FAIL_PREFIX}:" "$@"
131
-   log_error `caller`
131
+
132
+   local i=0
133
+   local line
134
+
135
+   while line="`caller $i`"
136
+   do
137
+      log_info "$i: #${line}"
138
+      ((i++))
139
+   done
140
+
141
+   # should kill process group...
142
+   kill 0
132 143
 
133 144
    if [ ! -z "${MULLE_EXECUTABLE_PID}" ]
134 145
    then
... ...
@@ -138,6 +149,7 @@ fail()
138 149
          kill -INT $$  # actually useful
139 150
       fi
140 151
    fi
152
+
141 153
    exit 1        # paranoia
142 154
    # don't ask me why the fail message is printed twice
143 155
 }
... ...
@@ -87,7 +87,7 @@ emancipate_minion_bootstrap_project()
87 87
 {
88 88
    local  minionpath="${1:-.}"
89 89
 
90
-   exekutor rm "${minionpath}/${BOOTSTRAP_DIR}.local/is_minion"
90
+   exekutor rm "${minionpath}/${BOOTSTRAP_DIR}.local/is_minion"  >&2
91 91
 }
92 92
 
93 93
 
... ...
@@ -118,25 +118,25 @@ master_owns_minion_bootstrap_project()
118 118
 
119 119
 _copy_environment_files()
120 120
 {
121
-   local masterbootstrap="${1:-.}" ; shift
122
-   local minionbootstrap="${1:-.}" ; shift
121
+   local src="${1:-.}" ; shift
122
+   local dst="${1:-.}" ; shift
123 123
 
124
-   local files
124
+   local srcfiles
125 125
    local name
126
-   local src
127
-   local dst
126
+   local srcfile
127
+   local dstfile
128 128
 
129
-   files="`find "${minionbootstrap}" -xdev -mindepth 1 -maxdepth 1 -name "[A-Z_]*" -type f -print 2> /dev/null`"
129
+   srcfiles="`find "${src}" -xdev -mindepth 1 -maxdepth 1 -name "[A-Z_]*" -type f -print 2> /dev/null`"
130 130
    IFS="
131 131
 "
132
-   for src in ${files}
132
+   for srcfile in ${srcfiles}
133 133
    do
134
-      name="`basename -- "${src}"`"
134
+      name="`basename -- "${srcfile}"`"
135 135
 
136 136
       IFS="${DEFAULT_IFS}"
137
-      dst="${masterbootstrap}/${name}"
137
+      dstfile="${dst}/${name}"
138 138
 
139
-      _copy_no_clobber_setting_file "${dst}" "${src}"
139
+      _copy_no_clobber_setting_file "${srcfile}" "${dstfile}"
140 140
    done
141 141
 
142 142
    IFS="${DEFAULT_IFS}"
... ...
@@ -148,6 +148,8 @@ master_add_minion_bootstrap_project()
148 148
    local masterpath="${1:-.}" ; shift
149 149
    local minionpath="${1:-.}" ; shift
150 150
 
151
+   mkdir_if_missing "${masterpath}/${BOOTSTRAP_DIR}.local"
152
+
151 153
    minionpath="`symlink_relpath "${minionpath}" "${masterpath}"`"
152 154
    redirect_append_exekutor "${masterpath}/${BOOTSTRAP_DIR}.local/repositories" echo "${minionpath};${minionpath}"
153 155
 
... ...
@@ -169,10 +171,21 @@ master_remove_minion_bootstrap_project()
169 171
    local masterpath="${1:-.}" ; shift
170 172
    local minionpath="${1:-.}" ; shift
171 173
    local unregex
174
+   local filepath
172 175
 
173 176
    minionpath="`symlink_relpath "${minionpath}" "${masterpath}"`"
174 177
    unregex="`sed -e 's/[]\/()$*.^|[]/\\&/g' <<< "${minionpath}"`"
175
-   exekutor sed -i "" -e "/^${unregex}\;/d" "${masterpath}/${BOOTSTRAP_DIR}.local/repositories"
178
+   filepath="${masterpath}/${BOOTSTRAP_DIR}.local/repositories"
179
+   exekutor sed -i "" -e "/^${unregex}\;/d" "${filepath}"
180
+
181
+   if [ -z "`read_setting "${filepath}"`" ]
182
+   then
183
+      remove_file_if_present "${filepath}"
184
+
185
+      # not be master anymore if last one is gone ?
186
+      # remove_file_if_present "${masterpath}/${BOOTSTRAP_DIR}.local/is_master"
187
+   fi
188
+
176 189
    exekutor touch "${masterpath}/${BOOTSTRAP_DIR}.local"
177 190
 }
178 191
 
... ...
@@ -50,21 +50,15 @@ MULLE_BOOTSTRAP_REPOSITORIES_SH="included"
50 50
 #
51 51
 remember_stash_of_repository()
52 52
 {
53
-   local clone="$1" ; shift
54
-
55
-   local reposdir="$1"  # ususally .bootstrap.repos
56
-   local name="$2"      # name of the clone
57
-#   local url="$3"       # URL of the clone
58
-#   local branch="$4"    # branch of the clone
59
-#   local scm="$5"       # scm to use for this clone
60
-#   local tag="$6"       # tag to checkout of the clone
61
-   local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
53
+   local clone="$1"
54
+   local reposdir="$2"  # ususally .bootstrap.repos
55
+   local name="$3"      # name of the clone
56
+   local parentclone="$5"
62 57
 
63 58
    [ -z "${clone}" ]    && internal_fail "clone is missing"
64 59
    [ -z "${reposdir}" ] && internal_fail "reposdir is missing"
65 60
    [ -z "${name}" ]     && internal_fail "name is missing"
66 61
    [ -z "${stashdir}" ] && internal_fail "stashdir is missing"
67
-   [ $# -ne 7  ]        && internal_fail "parameter error"
68 62
 
69 63
    local content
70 64
    local filepath
... ...
@@ -72,8 +66,8 @@ remember_stash_of_repository()
72 66
    mkdir_if_missing "${reposdir}"
73 67
    filepath="${reposdir}/${name}"
74 68
 
75
-   content="${stashdir}
76
-${clone}"  ## a clone line
69
+   content="${clone}
70
+${parentclone}"  ## a clone line
77 71
 
78 72
    log_fluff "Remembering repository \"${name}\" via \"${filepath}\""
79 73
 
... ...
@@ -83,7 +77,13 @@ ${clone}"  ## a clone line
83 77
 
84 78
 _clone_of_reposdir_file()
85 79
 {
86
-   tail -1 "${1}"
80
+   sed -n '1p' "${1}"
81
+}
82
+
83
+
84
+_parentclone_of_reposdir_file()
85
+{
86
+   sed -n '2p' "$1"
87 87
 }
88 88
 
89 89
 
... ...
@@ -107,22 +107,25 @@ clone_of_repository()
107 107
 }
108 108
 
109 109
 
110
-clone_of_embedded_repository()
110
+_stash_of_reposdir_file()
111 111
 {
112
-   local reposdir="$1"
113
-   local name="$2"
112
+   local clone
114 113
 
115
-   clone_of_repository "${EMBEDDED_REPOS_DIR}" "${name}"
114
+   clone="`_clone_of_reposdir_file "$@"`"
115
+   _dstdir_part_from_clone "${clone}"
116 116
 }
117 117
 
118 118
 
119
-_stash_of_reposdir_file()
119
+stash_of_repository()
120 120
 {
121
-   head -1 "$1"
121
+   local clone
122
+
123
+   clone="`clone_of_repository "$@"`"
124
+   _dstdir_part_from_clone "${clone}"
122 125
 }
123 126
 
124 127
 
125
-stash_of_repository()
128
+parentclone_of_repository()
126 129
 {
127 130
    local reposdir="$1"
128 131
    local name="$2"
... ...
@@ -135,7 +138,7 @@ stash_of_repository()
135 138
    reposfilepath="${reposdir}/${name}"
136 139
    if [ -f "${reposfilepath}" ]
137 140
    then
138
-      _stash_of_reposdir_file "${reposfilepath}"
141
+      _parentclone_of_reposdir_file "${reposfilepath}"
139 142
    else
140 143
       log_fluff "No stash found for ${name} in ${reposdir}"
141 144
    fi
... ...
@@ -187,7 +190,8 @@ all_repository_stashes()
187 190
 #
188 191
 # Walkers
189 192
 #
190
-
193
+# Possible permissions: "symlink\nmissing"
194
+#
191 195
 walk_check()
192 196
 {
193 197
    local name="$1" ; shift
... ...
@@ -206,11 +210,6 @@ walk_check()
206 210
       fi
207 211
    fi
208 212
 
209
-   if [ "${WALK_MISSING_REPOSITORIES}" = "YES" ]
210
-   then
211
-      return 0
212
-   fi
213
-
214 213
    if [ -L "${stashdir}" ]
215 214
    then
216 215
       # cat is for -e
... ...
@@ -243,20 +242,10 @@ walk_check()
243 242
 
244 243
 _walk_repositories()
245 244
 {
246
-   local permissions
247
-   local callback
248
-   local reposdir
249
-   local clones
250
-
251
-   clones="$1"
252
-   shift
253
-
254
-   callback="$1"
255
-   shift
256
-   permissions="$1"
257