Browse code

Add defer and emancipate. Adjust various internals to support it.

Nat! authored on 07-02-2017 23:09:08
Showing 26 changed files
... ...
@@ -1,5 +1,7 @@
1 1
 # 3.0
2 2
 
3
+#### New commands: defer, emancipate, flags, status
4
+
3 5
 #### mulle-bootstrap command syntax was related to git, but now it's related
4 6
 to homebrew and apt-get. This has been done, because I wan't to have mulle-brew
5 7
 as a separate shell command, and the git syntax doesn't fit.
6 8
new file mode 100644
... ...
@@ -0,0 +1,23 @@
1
+# Changes in repositories
2
+
3
+What can mulle-bootstrap deduce from changes in `repositories` ?
4
+
5
+
6
+## Possible actions
7
+
8
+Change     | Action               | Description
9
+-----------|----------------------|----------------------------------
10
+`url`      | **set-remote**       | If `name` stays the same, `git remote set url`
11
+`name`     | **fetch**            | new name repository
12
+`scm`      | **remove**,**fetch** | the repository is invalid and needs to be replaced
13
+`stashdir` | **move**             | the repository
14
+`branch`   | **fetch**            | with new branch and check out (with tag)
15
+`tag`      | **checkout**         | check out with tag
16
+
17
+>
18
+> The old clone line is remembered in the .bootstrap.repos. It is indexed
19
+> by name. The name is derived from the URL. If the name changes, we can't
20
+> match up with old information. The old repository will become a
21
+> zombie.
22
+>
23
+
... ...
@@ -47,15 +47,15 @@ trap_fail()
47 47
 
48 48
 bootstrap_technical_option_usage()
49 49
 {
50
-   if [ ! -z "${VERBOSE}" -o ! -z "${MULLE_BOOTSTRAP_TRACE}" ]
50
+   if [ "${VERBOSE}" = "YES" -o "${MULLE_BOOTSTRAP_TRACE}" = "YES" ]
51 51
    then
52 52
       cat <<EOF
53 53
    -t        : enable shell trace
54
+   -tb       : also trace scripts
54 55
    -te       : trace execution
56
+   -tf       : also trace filepath functionality
55 57
    -tm       : trace merge and dependencies
56
-   -tss      : also trace scripts
57
-   -tst      : also trace settings
58
-   -tsp      : also trace path functionality
58
+   -ts       : also trace settings
59 59
    -vv       : very verbose
60 60
    -vvv      : extremely vebose
61 61
    -s        : be silent
... ...
@@ -195,19 +195,11 @@ ${value}"
195 195
 }
196 196
 
197 197
 
198
-bootstrap_nomagic_main()
198
+_bootstrap_main()
199 199
 {
200 200
    local command
201 201
 
202
-   command="$1"
203
-   shift
204
-
205
-   log_fluff "::: $command begin :::"
206
-
207
-   if [ "${command}" = "nomagic" ]
208
-   then
209
-      DONT_RECURSE=YES
210
-   fi
202
+   log_fluff "::: bootstrap begin :::"
211 203
 
212 204
    . mulle-bootstrap-fetch.sh
213 205
    . mulle-bootstrap-build.sh
... ...
@@ -221,12 +213,7 @@ bootstrap_nomagic_main()
221 213
    if fetch_needed
222 214
    then
223 215
       MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap fetch"
224
-      if [ -z "${DONT_RECURSE}" ]
225
-      then
226
-         fetch_main "$@" || exit 1
227
-      else
228
-         fetch_main --non-recursive "$@" || exit 1
229
-      fi
216
+      fetch_main "$@" || exit 1
230 217
       # used for option handling only
231 218
       MULLE_BOOTSTRAP_DID_FETCH="YES"
232 219
    fi
... ...
@@ -241,24 +228,6 @@ bootstrap_nomagic_main()
241 228
 }
242 229
 
243 230
 
244
-bootstrap_execute_in_master()
245
-{
246
-   local masterpath
247
-
248
-   masterpath="$1"
249
-   shift
250
-
251
-   local master
252
-
253
-   master="`head -1 "${masterpath}" 2>/dev/null`"
254
-   [ -d "${master}" ] || fail "master \"${master}\" is gone ($masterpath)"
255
-
256
-   (
257
-      cd "${master}" && "${MULLE_BOOTSTRAP_EXECUTABLE}" "$@"
258
-   ) || fail "master failed"
259
-}
260
-
261
-
262 231
 bootstrap_libexec_path()
263 232
 {
264 233
    local exedir
... ...
@@ -328,10 +297,6 @@ bootstrap_init()
328 297
       ;;
329 298
    esac
330 299
 
331
-   MULLE_BOOTSTRAP_ARGUMENTS="$@"
332
-   MULLE_BOOTSTRAP_PID="$$"
333
-   export MULLE_BOOTSTRAP_PID
334
-
335 300
    #  set -e # more pain then gain in the end
336 301
    #  set -u # doesn't work with my style
337 302
 
... ...
@@ -343,13 +308,13 @@ bootstrap_init()
343 308
 
344 309
    trap trap_fail INT
345 310
 
346
-   source_environment
311
+   # source_environment
347 312
 }
348 313
 
349 314
 
350 315
 bootstrap_setup_trace()
351 316
 {
352
-   case "${MULLE_BOOTSTRAP_TRACE}" in
317
+   case "${1}" in
353 318
       VERBOSE)
354 319
          MULLE_BOOTSTRAP_FLUFF="NO"
355 320
          MULLE_BOOTSTRAP_VERBOSE="YES"
... ...
@@ -411,35 +376,46 @@ bootstrap_technical_options()
411 376
          MULLE_EXECUTOR_DRY_RUN="YES"
412 377
       ;;
413 378
 
379
+      -t|--trace)
380
+         MULLE_BOOTSTRAP_TRACE="1848"
381
+         COPYMOVEFLAGS="-v"
382
+         GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
383
+         MULLE_BOOTSTRAP_PATHS_FLIP_X="YES"
384
+         MULLE_BOOTSTRAP_RESOLVER_FLIP_X="YES"
385
+         MULLE_BOOTSTRAP_SETTINGS_FLIP_X="YES"
386
+         MULLE_BOOTSTRAP_TRACE_SCRIPT_CALLS="NO"
387
+         ps4string='${BASH_SOURCE[1]##*/}:${LINENO}'
388
+      ;;
389
+
390
+      -tb|--trace-scripts)
391
+         [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
392
+         MULLE_BOOTSTRAP_TRACE_SCRIPT_CALLS="YES"
393
+      ;;
394
+
414 395
       -te|--trace-execution)
415 396
          MULLE_EXECUTOR_TRACE="YES"
416 397
       ;;
417 398
 
418
-      -tm|--trace-settings-merge)
399
+      -tf|--trace-filepaths)
419 400
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
420
-         MULLE_BOOTSTRAP_TRACE_MERGE="YES"
401
+         MULLE_BOOTSTRAP_PATHS_FLIP_X="NO"
421 402
       ;;
422 403
 
423
-      -tsc|--trace-show-scripts)
404
+      -tm|--trace-merge)
424 405
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
425
-         MULLE_BOOTSTRAP_TRACE_SCRIPT_CALLS="YES"
406
+         MULLE_BOOTSTRAP_TRACE_MERGE="YES"
426 407
       ;;
427 408
 
428
-      -tsr|--trace-show-resolver)
409
+      -tr|--trace-resolver)
429 410
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
430 411
          MULLE_BOOTSTRAP_RESOLVER_FLIP_X="NO"
431 412
       ;;
432 413
 
433
-      -tss|--trace-show-settings)
414
+      -ts|--trace-settings)
434 415
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
435 416
          MULLE_BOOTSTRAP_SETTINGS_FLIP_X="NO"
436 417
       ;;
437 418
 
438
-      -tsp|--trace-show-paths)
439
-         [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
440
-         MULLE_BOOTSTRAP_PATHS_FLIP_X="NO"
441
-      ;;
442
-
443 419
       -tp|--trace-profile)
444 420
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
445 421
          case "${UNAME}" in
... ...
@@ -452,7 +428,7 @@ bootstrap_technical_options()
452 428
          esac
453 429
       ;;
454 430
 
455
-      -tpo|--trace-postponed)
431
+      -tpo|--trace-postpone)
456 432
          [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
457 433
          MULLE_BOOTSTRAP_POSTPONE_TRACE=YES
458 434
       ;;
... ...
@@ -467,30 +443,24 @@ bootstrap_technical_options()
467 443
          ps4string='${BASH_SOURCE[1]##*/}:${LINENO} \".../\W\"'
468 444
       ;;
469 445
 
470
-      -t|--trace)
471
-         MULLE_BOOTSTRAP_TRACE="1848"
472
-         COPYMOVEFLAGS="-v"
473
-         GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
474
-         MULLE_BOOTSTRAP_PATHS_FLIP_X="YES"
475
-         MULLE_BOOTSTRAP_RESOLVER_FLIP_X="YES"
476
-         MULLE_BOOTSTRAP_SETTINGS_FLIP_X="YES"
477
-         MULLE_BOOTSTRAP_TRACE_SCRIPT_CALLS="NO"
478
-         ps4string='${BASH_SOURCE[1]##*/}:${LINENO}'
479
-      ;;
480
-
481 446
       -v|--verbose)
447
+        [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] && log_warning "${MULLE_BOOTSTRAP_FAIL_PREFIX}: -v after -t invalidates -t"
448
+
482 449
          MULLE_BOOTSTRAP_TRACE="VERBOSE"
483
-         COPYMOVEFLAGS="-v"
484 450
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
485 451
       ;;
486 452
 
487
-      -vv|--very-verbose)
453
+      -vv|--very-verbose)v
454
+        [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] && log_warning "${MULLE_BOOTSTRAP_FAIL_PREFIX}: -vv after -t invalidates -t"
455
+
488 456
          MULLE_BOOTSTRAP_TRACE="FLUFF"
489 457
          COPYMOVEFLAGS="-v"
490 458
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
491 459
       ;;
492 460
 
493 461
       -vvv|--very-verbose-with-settings)
462
+        [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] && log_warning "${MULLE_BOOTSTRAP_FAIL_PREFIX}: -vvv after -t invalidates -t"
463
+
494 464
          MULLE_BOOTSTRAP_TRACE="TRACE"
495 465
          COPYMOVEFLAGS="-v"
496 466
          GITOPTIONS="`concat "${GITOPTIONS}" "-v"`"
... ...
@@ -511,42 +481,46 @@ bootstrap_technical_options()
511 481
 }
512 482
 
513 483
 
514
-bootstrap_defer_to_master_if_needed()
484
+bootstrap_should_defer_to_master()
515 485
 {
516 486
    local command="$1"
517 487
 
518 488
    #
519
-   # if we have a.bootstrap.local/minion file then
489
+   # if we have a.bootstrap.local/is_minion file then
520 490
    # some commands can't run, and some commands are re-executed in master
521 491
    # and some commands (like fetch and clean) are executed locally AND in the
522 492
    # master
523 493
    #
494
+   if ! is_minion_bootstrap_project
495
+   then
496
+      return 1
497
+   fi
498
+
524 499
    local masterpath
525 500
 
526
-   masterpath="${BOOTSTRAP_DIR}.local/master"
527
-   if [ -e "${masterpath}" ]
528
-   then
529
-      case "${command}" in
530
-         build)
531
-            log_info "Minion .bootstrap: defer to master for execution"
532
-            exec bootstrap_execute_in_master "${masterpath}" "$@"
533
-         ;;
501
+   . mulle-bootstrap-project.sh
534 502
 
535
-         fetch|install|upgrade|update|clean|dist-clean)
536
-            log_info "Minion .bootstrap: execute partly in master"
537
-            bootstrap_execute_in_master "${masterpath}" "$@"
538
-            EMBEDDED_ONLY=YES
539
-         ;;
503
+   masterpath="`get_master_of_minion_bootstrap_project`"
540 504
 
541
-         git|setup-xcode|xcode|tag|version)
542
-            log_verbose "Minion .bootstrap: execute locally"
543
-         ;;
505
+   case "${command}" in
506
+      build|flags|status|fetch|install|upgrade|update|clean)
507
+         log_info "Minion defers to master \"$masterpath\" for execution"
544 508
 
545
-         *)
546
-            fail "This is a minion bootstrap project (${masterpath}), can't continue"
547
-         ;;
548
-      esac
549
-   fi
509
+         cd "${masterpath}" || fail "master is missing"
510
+         return 0  # this leads to  main deferring later on (but cd is set!)
511
+      ;;
512
+
513
+      git|setup-xcode|xcode|tag|version|defer|emancipate)
514
+         log_verbose "Minion executes locally"
515
+      ;;
516
+
517
+      refer|dist-clean)
518
+         fail "This is a minion bootstrap project.\n \
519
+${MULLE_BOOTSTRAP_EXECUTABLE} ${command}t is not possible."
520
+      ;;
521
+   esac
522
+
523
+   return 1
550 524
 }
551 525
 
552 526
 
... ...
@@ -555,7 +529,6 @@ bootstrap_main()
555 529
    local command
556 530
    local ps4string
557 531
 
558
-   bootstrap_init
559 532
    #
560 533
    # simple option handling
561 534
    #
... ...
@@ -598,8 +571,8 @@ bootstrap_main()
598 571
          ;;
599 572
 
600 573
          -*)
601
-            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown flag \"$1\""
602
-            usage
574
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown option \"$1\""
575
+            mulle_bootstrap_usage
603 576
          ;;
604 577
 
605 578
          *)
... ...
@@ -610,8 +583,7 @@ bootstrap_main()
610 583
       shift
611 584
    done
612 585
 
613
-   bootstrap_setup_trace
614
-
586
+   bootstrap_setup_trace "${MULLE_BOOTSTRAP_TRACE}"
615 587
 
616 588
    if [ "${MULLE_EXECUTOR_DRY_RUN}" = "YES" ]
617 589
    then
... ...
@@ -626,9 +598,8 @@ bootstrap_main()
626 598
    # some commands only run when we have a .bootstrap folder
627 599
    #
628 600
    command=${1:-"bootstrap"}
629
-   [ $# -eq 0 ] || shift
630 601
 
631
-   if [ ! -d "${BOOTSTRAP_DIR}" ]
602
+   if ! is_bootstrap_project
632 603
    then
633 604
       case "$1" in
634 605
          -h|--help)
... ...
@@ -636,19 +607,21 @@ bootstrap_main()
636 607
 
637 608
          *)
638 609
             case "${command}" in
639
-            bootstrap|nomagic|build|dist|clean|dist-clean|fetch|install|syteminstall|upgrade|update|setup-xcode|xcode|tag)
610
+               bootstrap|nomagic|build|dist|clean|dist-clean|fetch|install|syteminstall|upgrade|update|setup-xcode|xcode|tag)
640 611
                fail "There is no ${BOOTSTRAP_DIR} folder here, can't continue"
641 612
             esac
642 613
          ;;
643 614
       esac
644 615
    else
645
-      bootstrap_defer_to_master_if_needed "$@"
616
+      if bootstrap_should_defer_to_master "$@"
617
+      then
618
+         return 1
619
+      fi
646 620
 
647
-      if [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" != "NO" ]
621
+      if [ "${MULLE_BOOTSTRAP_DIRTY_HARRY}" = "YES" ]
648 622
       then
649 623
          case "${command}" in
650
-            clean|dist-clean|init)
651
-               :
624
+            clean|dist-clean|init|status)
652 625
             ;;
653 626
 
654 627
             *)
... ...
@@ -659,10 +632,11 @@ bootstrap_main()
659 632
    fi
660 633
 
661 634
    MULLE_BOOTSTRAP_FAIL_PREFIX="${MULLE_BOOTSTRAP_EXECUTABLE} ${command}"
635
+   [ $# -eq 0 ] || shift
662 636
 
663 637
    case "${command}" in
664
-      bootstrap|nomagic)
665
-         bootstrap_nomagic_main "${command}" "$@"
638
+      bootstrap)
639
+         _bootstrap_main "$@"
666 640
       ;;
667 641
 
668 642
       build)
... ...
@@ -683,10 +657,10 @@ bootstrap_main()
683 657
          config_main "$@" || exit 1
684 658
       ;;
685 659
 
686
-      setting)
687
-         . mulle-bootstrap-settings.sh
660
+      defer)
661
+         . mulle-bootstrap-defer.sh
688 662
 
689
-         setting_main "$@" || exit 1
663
+         defer_main "$@" || exit 1
690 664
       ;;
691 665
 
692 666
       dist)
... ...
@@ -695,6 +669,12 @@ bootstrap_main()
695 669
          clean_main "dist" || exit 1
696 670
       ;;
697 671
 
672
+      emancipate)
673
+         . mulle-bootstrap-defer.sh
674
+
675
+         emancipate_main "$@" || exit 1
676
+      ;;
677
+
698 678
       flags)
699 679
          . mulle-bootstrap-flags.sh
700 680
 
... ...
@@ -724,23 +704,10 @@ bootstrap_main()
724 704
          return 0
725 705
       ;;
726 706
 
727
-      update)
728
-         . mulle-bootstrap-fetch.sh
729
-
730
-         update_main "$@" || exit 1
731
-      ;;
732
-
733
-      upgrade)
734
-         . mulle-bootstrap-fetch.sh
735
-
736
-         upgrade_main "$@" || exit 1
737
-      ;;
738
-
739
-      setup-xcode|xcode)
740
-         . mulle-bootstrap-xcode.sh
707
+      setting)
708
+         . mulle-bootstrap-settings.sh
741 709
 
742
-         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap xcode"
743
-         xcode_main "$@" || exit 1
710
+         setting_main "$@" || exit 1
744 711
       ;;
745 712
 
746 713
       systeminstall)
... ...
@@ -749,10 +716,15 @@ bootstrap_main()
749 716
          install_main "$@" || exit 1
750 717
       ;;
751 718
 
719
+      status)
720
+         . mulle-bootstrap-status.sh
721
+
722
+         status_main "$@" || exit 1
723
+      ;;
724
+
752 725
       tag)
753 726
          . mulle-bootstrap-tag.sh
754 727
 
755
-         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap tag"
756 728
          tag_main "$@" || exit 1
757 729
       ;;
758 730
 
... ...
@@ -761,14 +733,33 @@ bootstrap_main()
761 733
          exit 0
762 734
       ;;
763 735
 
736
+      update)
737
+         . mulle-bootstrap-fetch.sh
738
+
739
+         update_main "$@" || exit 1
740
+      ;;
741
+
742
+      upgrade)
743
+         . mulle-bootstrap-fetch.sh
744
+
745
+         upgrade_main "$@" || exit 1
746
+      ;;
747
+
764 748
       version)
765 749
          echo "${MULLE_BOOTSTRAP_VERSION}"
766 750
          return 0
767 751
       ;;
768 752
 
753
+      xcode|setup-xcode)
754
+         . mulle-bootstrap-xcode.sh
755
+
756
+         MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap xcode"
757
+         xcode_main "$@" || exit 1
758
+      ;;
759
+
769 760
       *)
770 761
          log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown command \"${command}\""
771
-         usage
762
+         mulle_bootstrap_usage
772 763
       ;;
773 764
    esac
774 765
 }
... ...
@@ -779,7 +770,6 @@ brew_main()
779 770
    local command
780 771
    local ps4string
781 772
 
782
-   bootstrap_init
783 773
    #
784 774
    # simple option handling
785 775
    #
... ...
@@ -797,7 +787,7 @@ brew_main()
797 787
          ;;
798 788
 
799 789
          -*)
800
-            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown flag \"$1\""
790
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown option \"$1\""
801 791
             mulle_brew_usage
802 792
          ;;
803 793
 
... ...
@@ -809,7 +799,7 @@ brew_main()
809 799
       shift
810 800
    done
811 801
 
812
-   bootstrap_setup_trace
802
+   bootstrap_setup_trace "${MULLE_BOOTSTRAP_TRACE}"
813 803
 
814 804
    if [ "${MULLE_EXECUTOR_DRY_RUN}" = "YES" ]
815 805
    then
... ...
@@ -840,7 +830,10 @@ brew_main()
840 830
          ;;
841 831
       esac
842 832
    else
843
-      bootstrap_defer_to_master_if_needed "$@"
833
+      if bootstrap_should_defer_to_master "$@"
834
+      then
835
+         return 1
836
+      fi
844 837
    fi
845 838
 
846 839
    MULLE_BOOTSTRAP_FAIL_PREFIX="${MULLE_BOOTSTRAP_EXECUTABLE} ${command}"
... ...
@@ -864,18 +857,24 @@ brew_main()
864 857
          config_main "$@" || exit 1
865 858
       ;;
866 859
 
867
-      setting)
868
-         . mulle-bootstrap-settings.sh
869
-
870
-         setting_main "$@" || exit 1
871
-      ;;
872
-
873 860
       dist)
874 861
          . mulle-bootstrap-clean.sh
875 862
 
876 863
          clean_main "dist" || exit 1
877 864
       ;;
878 865
 
866
+      defer)
867
+         . mulle-bootstrap-defer.sh
868
+
869
+         defer_main "$@" || exit 1
870
+      ;;
871
+
872
+      emancipate)
873
+         . mulle-bootstrap-defer.sh
874
+
875
+         emancipate_main "$@" || exit 1
876
+      ;;
877
+
879 878
       flags)
880 879
          . mulle-bootstrap-flags.sh
881 880
 
... ...
@@ -899,6 +898,17 @@ brew_main()
899 898
          return 0
900 899
       ;;
901 900
 
901
+      setting)
902
+         . mulle-bootstrap-settings.sh
903
+
904
+         setting_main "$@" || exit 1
905
+      ;;
906
+
907
+      uname)
908
+         echo "${UNAME}"
909
+         exit 0
910
+      ;;
911
+
902 912
       update)
903 913
          . mulle-bootstrap-brew.sh
904 914
 
... ...
@@ -911,23 +921,18 @@ brew_main()
911 921
          brew_upgrade_main "$@" || exit 1
912 922
       ;;
913 923
 
914
-      setup-xcode|xcode)
924
+      version)
925
+         echo "${MULLE_BOOTSTRAP_VERSION}"
926
+         return 0
927
+      ;;
928
+
929
+      xcode|setup-xcode)
915 930
          . mulle-bootstrap-xcode.sh
916 931
 
917 932
          MULLE_BOOTSTRAP_FAIL_PREFIX="mulle-bootstrap xcode"
918 933
          xcode_main "$@" || exit 1
919 934
       ;;
920 935
 
921
-      uname)
922
-         echo "${UNAME}"
923
-         exit 0
924
-      ;;
925
-
926
-      version)
927
-         echo "${MULLE_BOOTSTRAP_VERSION}"
928
-         return 0
929
-      ;;
930
-
931 936
       *)
932 937
          log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown command \"${command}\""
933 938
          mulle_bootstrap_usage
... ...
@@ -939,15 +944,29 @@ brew_main()
939 944
 # service both names
940 945
 #
941 946
 MULLE_BOOTSTRAP_EXECUTABLE="`basename -- "$0"`"
947
+MULLE_BOOTSTRAP_ARGUMENTS="$@"
942 948
 MULLE_BOOTSTRAP_FAIL_PREFIX="${MULLE_BOOTSTRAP_EXECUTABLE}"
949
+MULLE_BOOTSTRAP_PID="$$"
950
+export MULLE_BOOTSTRAP_PID
951
+
952
+
953
+bootstrap_init
943 954
 
944 955
 case "${MULLE_BOOTSTRAP_EXECUTABLE}" in
945 956
    "mulle-brew")
946
-      brew_main "$@"
957
+      if ! brew_main "$@"
958
+      then
959
+         "${MULLE_BOOTSTRAP_EXECUTABLE}" "$@" # is array
960
+         exit $?
961
+      fi
947 962
    ;;
948 963
 
949 964
    "mulle-bootstrap")
950
-      bootstrap_main "$@"
965
+      if ! bootstrap_main "$@"
966
+      then
967
+         "${MULLE_BOOTSTRAP_EXECUTABLE}" "$@" # is array
968
+         exit $?
969
+      fi
951 970
    ;;
952 971
 esac
953 972
 
... ...
@@ -54,7 +54,12 @@ bootstrap_auto_create()
54 54
    #
55 55
    if dir_has_files "${BOOTSTRAP_DIR}.local"
56 56
    then
57
-      exekutor cp -Ra ${COPYMOVEFLAGS} "${BOOTSTRAP_DIR}.local/" "${BOOTSTRAP_DIR}.auto/" >&2
57
+      exekutor cp -Ra ${COPYMOVEFLAGS} "${BOOTSTRAP_DIR}.local/"* "${BOOTSTRAP_DIR}.auto" >&2
58
+   fi
59
+
60
+   if ! dir_has_files "${BOOTSTRAP_DIR}"
61
+   then
62
+      return
58 63
    fi
59 64
 
60 65
    #
... ...
@@ -221,7 +226,6 @@ _bootstrap_auto_merge_root_settings()
221 226
 
222 227
    local srcfile
223 228
    local dstfile
224
-   local localfile
225 229
    local tmpfile
226 230
    local settingname
227 231
    local match
... ...
@@ -244,19 +248,22 @@ _bootstrap_auto_merge_root_settings()
244 248
          continue
245 249
       fi
246 250
 
247
-      localfile="${BOOTSTRAP_DIR}.local/${settingname}"
251
+      dstfile="${BOOTSTRAP_DIR}.auto/${settingname}"
248 252
 
249
-      if [ -e "${localfile}" ]
253
+      # cat is for -e
254
+      match="`echo "${NON_MERGABLE_SETTINGS}" | fgrep -s -x "${settingname}"`"
255
+      if [ ! -z "${match}" ]
250 256
       then
251
-         log_info "Setting \"${settingname}\" is locally specified, so not merged"
257
+         log_fluff "Setting \"${settingname}\" is not mergable, so ignored"
252 258
          continue
253 259
       fi
254 260
 
255
-      # cat is for -e
256
-      match="`echo "${NON_MERGABLE_SETTINGS}" | fgrep -s -x "${settingname}"`"
261
+      # environment is copied over, but crashes if the contents differ
262
+
263
+      match="`egrep -s -x "^[A-Z_]+$" <<< "${settingname}"`"
257 264
       if [ ! -z "${match}" ]
258 265
       then
259
-         log_fluff "Setting \"${settingname}\" is not mergable, so ignored"
266
+         _copy_no_clobber_setting_file "${dstfile}" "${srcfile}"
260 267
          continue
261 268
       fi
262 269
 
... ...
@@ -264,11 +271,10 @@ _bootstrap_auto_merge_root_settings()
264 271
       match="`echo "${MERGABLE_SETTINGS}" | fgrep -s -x "${settingname}"`"
265 272
       if [ -z "${match}" ]
266 273
       then
267
-         log_fluff "Setting \"${settingname}\" is unknown"
274
+         log_fluff "Setting \"${settingname}\" is unknown."
268 275
          continue
269 276
       fi
270 277
 
271
-      dstfile="${BOOTSTRAP_DIR}.auto/${settingname}"
272 278
       if [ -f "${dstfile}" ]
273 279
       then
274 280
          tmpfile="${BOOTSTRAP_DIR}.auto/${settingname}.tmp"
... ...
@@ -429,12 +435,20 @@ bootstrap_auto_final()
429 435
    local tag
430 436
    local clone
431 437
    local order
438
+   local clones
439
+
440
+   clones="`read_root_setting "repositories"`"
441
+   if [ -z "${clones}" ]
442
+   then
443
+      log_fluff "There is apparently nothing to build."
444
+      return
445
+   fi
432 446
 
433 447
    order=""
434 448
 
435 449
    IFS="
436 450
 "
437
-   for clone in `read_root_setting "repositories"`
451
+   for clone in ${clones}
438 452
    do
439 453
       IFS="${DEFAULT_IFS}"
440 454
 
... ...
@@ -444,7 +458,7 @@ bootstrap_auto_final()
444 458
 
445 459
    IFS="${DEFAULT_IFS}"
446 460
 
447
-   echo "${order}" > "${BOOTSTRAP_DIR}.auto/build_order"
461
+   redirect_exekutor "${BOOTSTRAP_DIR}.auto/build_order" echo "${order}"
448 462
 
449 463
    bootstrap_create_build_folders
450 464
 }
... ...
@@ -31,7 +31,6 @@
31 31
 MULLE_BOOTSTRAP_BREW_SH="included"
32 32
 
33 33
 
34
-
35 34
 _brew_usage()
36 35
 {
37 36
    cat <<EOF >&2
... ...
@@ -58,6 +57,8 @@ EOF
58 57
 
59 58
 fetch_brew_if_needed()
60 59
 {
60
+   [ ! -z "${BREW}" ] ||  internal_fail "BREW undefined"
61
+
61 62
    if [ -x "${BREW}" ]
62 63
    then
63 64
       return
... ...
@@ -81,7 +82,7 @@ fetch_brew_if_needed()
81 82
 
82 83
    if [ ! -x "${BREW}" ]
83 84
    then
84
-      fail "brew was not successfully installed"
85
+      fail "brew was not successfully installed (PATH=$PATH)"
85 86
    fi
86 87
 
87 88
    return 1
... ...
@@ -123,6 +124,8 @@ _brew_install_brews()
123 124
       fi
124 125
    fi
125 126
 
127
+   fetch_brew_if_needed
128
+
126 129
    if [ "${brewcmd}" = "update" ]
127 130
    then
128 131
       exekutor "${BREW}" update
... ...
@@ -176,9 +179,7 @@ brew_install_brews()
176 179
 {
177 180
    local unprotect
178 181
 
179
-   fetch_brew_if_needed
180
-
181
-   unprotect="NO"
182
+   unprotect=
182 183
    if [ -d "${ADDICTIONS_DIR}" ]
183 184
    then
184 185
       log_fluff "Unprotecting \"${ADDICTIONS_DIR}\" for ${command}."
... ...
@@ -247,10 +248,6 @@ _brew_common_main()
247 248
             ${USAGE}
248 249
          ;;
249 250
 
250
-         -nr|--no-recursion)
251
-            DONT_RECURSE="YES"
252
-         ;;
253
-
254 251
          -cs|--check-usr-local-include)
255 252
             CHECK_USR_LOCAL_INCLUDE="YES"
256 253
             ;;
... ...
@@ -2037,11 +2037,17 @@ build_wrapper()
2037 2037
    # need that path for includes though
2038 2038
    #
2039 2039
 
2040
-   run_repo_settings_script "${name}" "${srcdir}" "pre-build" "$@" || exit 1
2040
+   run_build_settings_script "pre-build" "${name}" \
2041
+                                         "${REPOS_DIR}" \
2042
+                                         "?" \
2043
+                                         "${name}" \
2044
+                                         "-" \
2045
+                                         "-" \
2046
+                                         "${stashdir}" || exit 1
2041 2047
 
2042 2048
    build "${name}" "${srcdir}" || exit 1
2043 2049
 
2044
-   run_repo_settings_script "${name}" "${srcdir}" "post-build" "$@" || exit 1
2050
+   run_build_settings_script "post-build" "${name}" "$@" || exit 1
2045 2051
 
2046 2052
    if [ "${COMMAND}" != "ibuild"  ]
2047 2053
    then
... ...
@@ -2061,15 +2067,15 @@ build_wrapper()
2061 2067
 build_if_alive()
2062 2068
 {
2063 2069
    local name
2064
-   local srcdir
2070
+   local stashdir
2065 2071
 
2066 2072
    name="$1"
2067
-   srcdir="$2"
2073
+   stashdir="$2"
2068 2074
 
2069 2075
    local xdone
2070 2076
    local zombie
2071 2077
 
2072
-   zombie="`dirname -- "${srcdir}"`/.zombies/${name}"
2078
+   zombie="`dirname -- "${stashdir}"`/.zombies/${name}"
2073 2079
    if [ -e "${zombie}" ]
2074 2080
    then
2075 2081
       log_warning "Ignoring zombie repo ${name} as \"${zombie}${C_WARNING} exists"
... ...
@@ -2077,7 +2083,7 @@ build_if_alive()
2077 2083
       xdone="`/bin/echo "${BUILT}" | grep -x "${name}"`"
2078 2084
       if [ "$xdone" = "" ]
2079 2085
       then
2080
-         build_wrapper "${name}" "${srcdir}"
2086
+         build_wrapper "${name}" "${stashdir}"
2081 2087
          BUILT="${name}
2082 2088
 ${BUILT}"
2083 2089
       else
... ...
@@ -2103,7 +2109,7 @@ build_stashes()
2103 2109
    done
2104 2110
    IFS="${DEFAULT_IFS}"
2105 2111
 
2106
-   run_build_settings_script "" "pre-build" "$@"
2112
+   run_root_settings_script "pre-build"
2107 2113
 
2108 2114
    #
2109 2115
    # build_order is created by refresh
... ...
@@ -2143,11 +2149,11 @@ build_stashes()
2143 2149
    else
2144 2150
       for name in "$@"
2145 2151
       do
2146
-         srcdir="`stash_of_repository "${REPOS_DIR}" "${name}"`"
2152
+         stashdir="`stash_of_repository "${REPOS_DIR}" "${name}"`"
2147 2153
 
2148
-         if [ -d "${srcdir}" ]
2154
+         if [ -d "${stashdir}" ]
2149 2155
          then
2150
-            build_if_alive "${name}" "${srcdir}"|| exit 1
2156
+            build_if_alive "${name}" "${stashdir}"|| exit 1
2151 2157
          else
2152 2158
             if [ "${CHECK_USR_LOCAL_INCLUDE}" = "YES" ] && has_usr_local_include "${name}"
2153 2159
             then
... ...
@@ -2162,7 +2168,7 @@ build_stashes()
2162 2168
 
2163 2169
    IFS="${DEFAULT_IFS}"
2164 2170
 
2165
-   run_build_settings_script "" "post-build" "$@"
2171
+   run_root_settings_script "post-build"
2166 2172
 }
2167 2173
 
2168 2174
 
... ...
@@ -2319,6 +2325,7 @@ build_main()
2319 2325
 
2320 2326
 
2321 2327
    remove_file_if_present "${REPOS_DIR}/.bootstrap_build_done"
2328
+   create_file_if_missing "${REPOS_DIR}/.bootstrap_build_started"
2322 2329
 
2323 2330
    if [ $# -eq 0 ]
2324 2331
    then
... ...
@@ -2353,6 +2360,7 @@ build_main()
2353 2360
       log_fluff "No dependencies have been generated"
2354 2361
    fi
2355 2362
 
2363
+   remove_file_if_present "${REPOS_DIR}/.bootstrap_build_started"
2356 2364
    create_file_if_missing "${REPOS_DIR}/.bootstrap_build_done"
2357 2365
 
2358 2366
    log_fluff "::: build end :::"
... ...
@@ -212,6 +212,32 @@ clean_directories()
212 212
 }
213 213
 
214 214
 
215
+#
216
+# dist cleaning is dangerous
217
+#
218
+_dist_clean()
219
+{
220
+   if is_master_bootstrap_project
221
+   then
222
+      fail "You can't dist clean a master repository"
223
+   fi
224
+
225
+   DIST_CLEANABLE_SUBDIRS="`read_sane_config_path_setting "dist_clean_folders" "${REPOS_DIR}
226
+${ADDICTIONS_DIR}
227
+${STASHES_DIR}
228
+.bootstrap.auto"`"
229
+   EMBEDDED="`stashes_of_embedded_repositories "${REPOS_DIR}"`"
230
+
231
+   if [ ! -z "$EMBEDDED" ]
232
+   then
233
+      DIST_CLEANABLE_SUBDIRS="${DIST_CLEANABLE_SUBDIRS}
234
+${EMBEDDED}"
235
+   fi
236
+   clean_directories "${DIST_CLEANABLE_SUBDIRS}" "${flag}"
237
+   clean_files "${DIST_CLEANABLE_FILES}"
238
+}
239
+
240
+
215 241
 #
216 242
 # for mingw its faster, if we have separate clean functions
217 243
 #
... ...
@@ -228,7 +254,7 @@ _clean_execute()
228 254
    [ -z "${ADDICTIONS_DIR}"   ]   && internal_fail "ADDICTIONS_DIR is empty"
229 255
    [ -z "${STASHES_DIR}"   ]      && internal_fail "STASHES_DIR is empty"
230 256
 
231
-   flag="NO"
257
+   flag=
232 258
    CLEAN_EMPTY_PARENTS="`read_config_setting "clean_empty_parent_folders" "YES"`"
233 259
 
234 260
 
... ...
@@ -278,19 +304,7 @@ ${DEPENDENCIES_DIR}/tmp"`"
278 304
 
279 305
    case "${COMMAND}" in
280 306
       dist)
281
-         DIST_CLEANABLE_SUBDIRS="`read_sane_config_path_setting "dist_clean_folders" "${REPOS_DIR}
282
-${ADDICTIONS_DIR}
283
-${STASHES_DIR}
284
-.bootstrap.auto"`"
285
-         EMBEDDED="`stashes_of_embedded_repositories "${REPOS_DIR}"`"
286
-
287
-         if [ ! -z "$EMBEDDED" ]
288
-         then
289
-            DIST_CLEANABLE_SUBDIRS="${DIST_CLEANABLE_SUBDIRS}
290
-${EMBEDDED}"
291
-         fi
292
-         clean_directories "${DIST_CLEANABLE_SUBDIRS}" "${flag}"
293
-         clean_files "${DIST_CLEANABLE_FILES}"
307
+         dist_clean
294 308
       ;;
295 309
    esac
296 310
 }
... ...
@@ -324,7 +338,7 @@ clean_main()
324 338
    [ -z "${DEFAULT_IFS}" ] && internal_fail "IFS fail"
325 339
 
326 340
    build_complete_environment
327
-   
341
+
328 342
    COMMAND=
329 343
 
330 344
    while [ $# -ne 0 ]
... ...
@@ -50,6 +50,15 @@ build_complete_environment()
50 50
    fi
51 51
    N_CONFIGURATIONS="`echo "${CONFIGURATIONS}" | wc -l | awk '{ print $1 }'`"
52 52
 
53
+   #
54
+   # expand PATH for build, but it's kinda slow
55
+   # so don't do it all the time
56
+   #
57
+   PATH="`prepend_to_search_path_if_missing "$PATH" "${DEPENDENCIES_DIR}/bin" "${ADDICTIONS_DIR}/bin"`"
58
+   export PATH
59
+
60
+   log_fluff "PATH set to: $PATH"
61
+
53 62
    #
54 63
    # dont export stuff for scripts
55 64
    # if scripts want it, they should source this file
... ...
@@ -98,11 +107,6 @@ common_settings_initialize()
98 107
    [ -z "${DEPENDENCIES_DIR}" ]   && internal_fail "variable DEPENDENCIES_DIR is empty"
99 108
    [ -z "${ADDICTIONS_DIR}" ]     && internal_fail "variable ADDICTIONS_DIR is empty"
100 109
    [ -z "${STASHES_DIR}" ]        && internal_fail "variable STASHES_DIR is empty"
101
-
102
-   PATH="`prepend_to_search_path_if_missing "$PATH" "${DEPENDENCIES_DIR}/bin" "${ADDICTIONS_DIR}/bin"`"
103
-   export PATH
104
-
105
-   log_fluff "PATH set to: $PATH"
106 110
 }
107 111
 
108 112
 common_settings_initialize
109 113
new file mode 100644
... ...
@@ -0,0 +1,192 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2017 Nat! - Mulle kybernetiK
4
+#   All rights reserved.
5
+#
6
+#   Redistribution and use in source and binary forms, with or without
7
+#   modification, are permitted provided that the following conditions are met:
8
+#
9
+#   Redistributions of source code must retain the above copyright notice, this
10
+#   list of conditions and the following disclaimer.
11
+#
12
+#   Redistributions in binary form must reproduce the above copyright notice,
13
+#   this list of conditions and the following disclaimer in the documentation
14
+#   and/or other materials provided with the distribution.
15
+#
16
+#   Neither the name of Mulle kybernetiK nor the names of its contributors
17
+#   may be used to endorse or promote products derived from this software
18
+#   without specific prior written permission.
19
+#
20
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+#   POSSIBILITY OF SUCH DAMAGE.
31
+#
32
+MULLE_BOOTSTRAP_DEFER_SH="included"
33
+
34
+
35
+emancipate_usage()
36
+{
37
+    cat <<EOF >&2
38
+usage:
39
+   mulle-bootstrap emancipate
40
+
41
+   Emancipate from master. mulle-bootstrap will produce local builds again.
42
+EOF
43
+  exit 1
44
+}
45
+
46
+
47
+defer_usage()
48
+{
49
+    cat <<EOF >&2
50
+usage:
51
+   mulle-bootstrap defer <master>
52
+
53
+   Share and defer builds to master. The master will be used
54
+   to fetch dependencies and build them. Use mulle-bootstrap flags
55
+   to get paths to addictions and dependencies.
56
+EOF
57
+  exit 1
58
+}
59
+
60
+
61
+defer_main()
62
+{
63
+   log_fluff ":defer_main:"
64
+
65
+   while [ $# -ne 0 ]
66
+   do
67
+      case "$1" in
68
+         -h|-help|--help)
69
+            defer_usage
70
+         ;;
71
+
72
+         -*)
73
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown option $1"
74
+            defer_usage
75
+         ;;
76
+
77
+         *)
78
+            break
79
+         ;;
80
+      esac
81
+
82
+      shift
83
+   done
84
+
85
+   [ -z "${MULLE_BOOTSTRAP_PROJECT_SH}" ] && . mulle-bootstrap-project.sh
86
+
87
+   unpostpone_trace
88
+
89
+   local masterpath
90
+   local minionpath
91
+
92
+   minionpath="${PWD}"
93
+   minionpath="`absolutepath "${minionpath}"`"
94
+
95
+   if is_minion_bootstrap_project "${minionpath}"
96
+   then
97
+      masterpath="`get_master_of_minion_bootstrap_project "${minionpath}"`"
98
+      [ ! -z "${masterpath}" ]  || internal_fail "is_minion file empty"
99
+      log_info "Master \"${masterpath}\" already owns \"${minionpath}\""
100
+      return
101
+   fi
102
+
103
+   masterpath="${1:-..}"
104
+   masterpath="`absolutepath "${masterpath}"`"
105
+
106
+   if [ ! -d "${masterpath}" ]
107
+   then
108
+      fail "Master \"${masterpath}\" not found"
109
+   fi
110
+
111
+   if ! can_be_master_bootstrap_project "${masterpath}"
112
+   then
113
+      fail "\"${masterpath}\" contains a .bootstrap folder. It can't be used as a master"
114
+   fi
115
+
116
+   if master_owns_minion_bootstrap_project "${masterpath}" "${minionpath}"
117
+   then
118
+      internal_fail "Master \"${masterpath}\" already owns \"${minionpath}\", but it was not detected before"
119
+   fi
120
+
121
+   make_master_bootstrap_project "${masterpath}"
122
+   make_minion_bootstrap_project "${minionpath}" "${masterpath}"
123
+   log_verbose "Adding project as minion to \"${masterpath}\""
124
+   master_add_minion_bootstrap_project "${masterpath}" "${minionpath}"
125
+   log_info "Project defers to \"${masterpath}\""
126
+}
127
+
128
+
129
+emancipate_main()
130
+{
131
+   log_fluff ":emancipate_main:"
132
+
133
+   while [ $# -ne 0 ]
134
+   do
135
+      case "$1" in
136
+         -h|-help|--help)
137
+            defer_usage
138
+         ;;
139
+
140
+         -*)
141
+            log_error "${MULLE_BOOTSTRAP_FAIL_PREFIX}: Unknown option $1"
142
+            defer_usage
143
+         ;;
144
+
145
+         *)
146
+            break
147
+         ;;
148
+      esac
149
+
150
+      shift
151
+   done
152
+
153
+   [ -z "${MULLE_BOOTSTRAP_PROJECT_SH}" ] && . mulle-bootstrap-project.sh
154
+
155
+   unpostpone_trace
156
+
157
+   local masterpath
158
+   local minionpath
159
+
160
+   [ $# -ne 0 ] && defer_usage
161
+
162
+   minionpath="${PWD}"
163
+   minionpath="`absolutepath "${minionpath}"`"
164
+   if ! is_minion_bootstrap_project "${minionpath}"
165
+   then
166
+      log_info "Project \"${minionpath}\" does not defer to a master and is already emancipated"
167
+      return
168
+   fi
169
+
170
+   masterpath="`get_master_of_minion_bootstrap_project \"${minionpath}\"`"
171
+   if [ -z "${masterpath}" ]
172
+   then
173
+      fail "Can not determine master for \"${minionpath}\""
174
+   fi
175
+
176
+   if [ ! -d "${masterpath}" ]
177
+   then
178
+      fail "Master \"${masterpath}\" is missing"
179
+   fi
180
+
181
+   if ! is_master_bootstrap_project "${masterpath}"
182
+   then
183
+      fail "\"${masterpath}\" is not a master project"
184
+   fi
185
+
186
+   log_verbose "Removing minion from \"${masterpath}\""
187
+   master_remove_minion_bootstrap_project "${masterpath}" "${minionpath}"
188
+   emancipate_minion_bootstrap_project "${minionpath}"
189
+
190
+   log_info "Project is standalone again"
191
+}
192
+
... ...
@@ -542,7 +542,18 @@ _clone()
542 542
       return 1
543 543
    fi
544 544
 
545
-   [ -e "${stashdir}" ] && fail "${stashdir} already exists"
545
+   if [ "${url}" = "${stashdir}" ]
546
+   then
547
+      is_minion_bootstrap_project "${stashdir}" || fail "\"${stashdir}\" should be a minion but isnt't"
548
+      log_info "${C_MAGENTA}${C_BOLD}${name}${C_INFO} is a minion, so skipped"
549
+      return 1
550
+   fi
551
+
552
+
553
+   if [ -e "${stashdir}" ]
554
+   then
555
+      _bury_stash "${reposdir}" "${name}" "${stashdir}"
556
+   fi
546 557
 
547 558
    if ! clone_or_symlink "$@"
548 559
    then
... ...
@@ -598,9 +609,10 @@ _checkout()
598 609
 
599 610
 checkout_repository()
600 611
 {
612
+   local url="$3"       # URL of the clone
601 613
    local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
602 614
 
603
-   if [ -L "${stashdir}" -a "${MULLE_BOOTSTRAP_WORK_SYMLINKS}" != "YES" ]
615
+   if [ -L "${stashdir}" -a "${ALLOW_FOLLOWING_SYMLINKS}" != "YES" ]
604 616
    then
605 617
       echo "Ignoring ${stashdir} because it's a symlink"
606 618
       return
... ...
@@ -653,7 +665,7 @@ update_repository()
653 665
 {
654 666
    local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
655 667
 
656
-   if [ -L "${stashdir}" -a "${MULLE_BOOTSTRAP_WORK_SYMLINKS}" != "YES" ]
668
+   if [ -L "${stashdir}" -a "${ALLOW_FOLLOWING_SYMLINKS}" != "YES" ]
657 669
    then
658 670
       echo "Ignoring ${stashdir} because it's a symlink"
659 671
       return
... ...
@@ -705,14 +717,6 @@ _update()
705 717
 
706 718
 update_repository()
707 719
 {
708
-   local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
709
-
710
-   if [ -L "${stashdir}" -a "${MULLE_BOOTSTRAP_WORK_SYMLINKS}" != "YES" ]
711
-   then
712
-      echo "Ignoring ${stashdir} because it's a symlink"
713
-      return
714
-   fi
715
-
716 720
    log_action "update" "$@"
717 721
 
718 722
    _update "$@"
... ...
@@ -759,14 +763,6 @@ _upgrade()
759 763
 
760 764
 upgrade_repository()
761 765
 {
762
-   local stashdir="$7"  # stashdir of this clone (absolute or relative to $PWD)
763
-
764
-   if [ -L "${stashdir}" -a "${MULLE_BOOTSTRAP_WORK_SYMLINKS}" != "YES" ]
765
-   then
766
-      echo "Ignoring ${stashdir} because it's a symlink"
767
-      return
768
-   fi
769
-
770 766
    log_action "upgrade" "$@"
771 767
 
772 768
    _upgrade "$@"
... ...
@@ -783,7 +779,7 @@ _operation_walk_repositories()
783 779
    local permissions
784 780
 
785 781
    permissions=""
786
-   if [ -z "${MULLE_BOOTSTRAP_WORK_SYMLINKS}" ]
782
+   if [ "${ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
787 783
    then
788 784
       permissions="`add_line "${permissions}" "symlink"`"
789 785
    fi
... ...
@@ -802,7 +798,7 @@ _operation_walk_embedded_repositories()
802 798
    local permissions
803 799
 
804 800
    permissions=""
805
-   if [ -z "${ALLOW_FOLLOWING_SYMLINKS}" ]
801
+   if [ "${ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
806 802
    then
807 803
       permissions="`add_line "${permissions}" "symlink"`"
808 804
    fi
... ...
@@ -831,7 +827,7 @@ _operation_walk_deep_embedded_repositories()
831 827
    local permissions
832 828
 
833 829
    permissions=""
834
-   if [ -z "${ALLOW_FOLLOWING_SYMLINKS}" ]
830
+   if [ "${ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
835 831
    then
836 832
       permissions="`add_line "${permissions}" "symlink"`"
837 833
    fi
... ...
@@ -848,27 +844,12 @@ _operation_walk_deep_embedded_repositories()
848 844
 ##
849 845
 ## FETCH
850 846
 ##
851
-# fetch_repositories()
852
-# {
853
-#    _operation_walk_repositories "fetch_repository"
854
-# }
855
-
856
-
857
-# fetch_embedded_repositories()
858
-# {
859
-#    _operation_walk_embedded_repositories "fetch_embedded_repository"
860
-# }
861
-
862
-
863
-# fetch_deep_embedded_repositories()
864
-# {
865
-#    _operation_walk_deep_embedded_repositories "fetch_embedded_repository"
866
-# }
867
-
868 847
 
869 848
 did_fetch_repository()
870 849
 {
871
-   fetch__run_build_settings_script "did-install" "$@"
850
+   local name="$2"      # name of the clone
851
+
852
+   fetch__run_build_settings_script "did-install" "${name}" "$@"
872 853
 }
873 854
 
874 855
 
... ...
@@ -883,19 +864,19 @@ did_fetch_repositories()
883 864
 ##
884 865
 update_repositories()
885 866
 {
886
-   _operation_walk_repositories "update_repository" > /dev/null
867
+   _operation_walk_repositories "update_repository"
887 868
 }
888 869
 
889 870
 
890 871
 update_embedded_repositories()
891 872
 {
892
-   _operation_walk_embedded_repositories "update_repository" > /dev/null
873
+   _operation_walk_embedded_repositories "update_repository"
893 874
 }
894 875
 
895 876
 
896 877
 update_deep_embedded_repositories()
897 878
 {
898
-   _operation_walk_deep_embedded_repositories "update_repository" > /dev/null
879
+   _operation_walk_deep_embedded_repositories "update_repository"
899 880
 }
900 881
 
901 882
 
... ...
@@ -904,25 +885,27 @@ update_deep_embedded_repositories()
904 885
 ##
905 886
 upgrade_repositories()
906 887
 {
907
-   _operation_walk_repositories "upgrade_repository" > /dev/null
888
+   _operation_walk_repositories "upgrade_repository"
908 889
 }
909 890
 
910 891
 
911 892
 upgrade_embedded_repositories()
912 893
 {
913
-   _operation_walk_embedded_repositories "upgrade_repository" > /dev/null
894
+   _operation_walk_embedded_repositories "upgrade_repository"
914 895
 }
915 896
 
916 897
 
917 898
 upgrade_deep_embedded_repositories()
918 899
 {
919
-   _operation_walk_deep_embedded_repositories "upgrade_repository" > /dev/null
900
+   _operation_walk_deep_embedded_repositories "upgrade_repository"
920 901
 }
921 902
 
922 903
 
923 904
 did_upgrade_repository()
924 905
 {
925
-   fetch__run_build_settings_script "did-upgrade" "$@"
906
+   local name="$2"      # name of the clone
907
+
908
+   fetch__run_build_settings_script "did-upgrade" "${name}" "$@"
926 909
 }
927 910
 
928 911
 
... ...
@@ -974,6 +957,11 @@ required_action_for_clone()
974 957
 
975 958
    parse_clone "${clone}"
976 959
 
960
+   if is_minion_bootstrap_directory "${stashdir}"
961
+   then
962
+      fail "\"${stashdir}\" is a minion. Don't hand edit master repositories."
963
+   fi
964
+
977 965
    if [ "${scm}" != "${newscm}" ]
978 966
    then
979 967
       log_fluff "SCM has changed from ${scm} to ${newscm}, need to refetch"
... ...
@@ -990,7 +978,15 @@ clone"
990 978
 
991 979
    #
992 980
    # if scm is not git, don't try to be clever
993
-   if [ ! -z "${scm}" -a "${scm}" != "git" ]
981
+   #
982
+   if [ ! -z "${scm}"  -a "${scm}" != "git" ]
983
+   then
984
+      echo "remove
985
+clone"
986
+      return
987
+   fi
988
+
989
+   if [ "${scm}" != "${newscm}" ]
994 990
    then
995 991
       echo "remove
996 992
 clone"
... ...
@@ -1036,6 +1032,7 @@ work_clones()
1036 1032
    local fetched
1037 1033
    local repotype
1038 1034
    local oldstashdir
1035
+   local url_is_stash
1039 1036
 
1040 1037
    case "${reposdir}" in
1041 1038
       *embedded)
... ...
@@ -1047,11 +1044,6 @@ work_clones()
1047 1044
       ;;
1048 1045
    esac
1049 1046
 
1050
-   if [ "${DONT_RECURSE}" = YES ]
1051
-   then
1052
-      autoupdate="NO"
1053
-   fi
1054
-
1055 1047
    IFS="
1056 1048
 "
1057 1049
    for clone in ${clones}
... ...
@@ -1071,9 +1063,10 @@ work_clones()
1071 1063
       then
1072 1064
          continue
1073 1065
       fi
1066
+
1074 1067
       __REFRESHED__="`add_line "${__REFRESHED__}" "${clone}"`"
1075 1068
 
1076
-      parse_clone "${clone}" "${stashrootdir}" || exit 1