Browse code

Looks pretty good, now.

Nat! authored on 02-02-2017 16:40:03
Showing 14 changed files
... ...
@@ -3,46 +3,52 @@ digraph refresh {
3 3
    node [shape="none"]
4 4
 
5 5
    "fetch"  [ fillcolor="red", style="filled", fontcolor="white"]
6
-   "update" [ fillcolor="blue", style="filled", fontcolor="white"]
6
+   "upgrade" [ fillcolor="blue", style="filled", fontcolor="white"]
7 7
 
8 8
    node [shape="record"]
9 9
 
10
-   fetch  -> "mark_all_repositories_as_zombies" [ lhead=cluster_0]
11
-   update -> "update_embedded_repositories"     [ lhead=cluster_1]
12
-   "run_update_scripts"            -> "fetch" [ lhead=cluster_0]
10
+   fetch  -> "assume_stashes_are_zombies" [ lhead=cluster_0]
11
+   upgrade -> "upgrade_embedded_repositories"     [ lhead=cluster_1]
13 12
 
14 13
 
15 14
    subgraph cluster_0 {
16 15
       node [shape="record"]
17 16
       color="red"
18 17
 
19
-      "bootstrap_auto_update"
20 18
       "inviso" [ style="invisible"]
21
-      "mark_all_repositories_as_zombies"    -> "bootstrap_auto_create"
22 19
 
23
-      "bootstrap_auto_create"               -> "fetch_missing_embedded_repositories"
20
+      "assume_stashes_are_zombies"          -> "bootstrap_auto_create"
24 21
 
25
-      "fetch_missing_embedded_repositories" -> "fetch_missing_repositories" [color="red"]
26
-      "fetch_missing_repositories"          -> "bootstrap_auto_update" [color="red"]
27
-      "bootstrap_auto_update"               -> "fetch_missing_repositories"   [color="red"]
22
+      "bootstrap_auto_create"               -> "work_all_repositories"
28 23
 
29
-      "bootstrap_auto_update"               -> "fetch_missing_deep_embedded_repositories" [color="red"]
30
-      "fetch_missing_deep_embedded_repositories" -> "bootstrap_auto_final"
31
-      "bootstrap_auto_final"                -> "unmark_alive_stashes"
24
+      "work_all_repositories"               -> "work_embedded_clones"     [color="red"]
25
+      "work_embedded_clones"                -> "work_clones"              [color="red"]
26
+      "work_clones"                         -> "bootstrap_auto_update"    [color="red"]
27
+      "bootstrap_auto_update"               -> "mark_stash_as_alive"      [color="red"]
28
+      "mark_stash_as_alive"                 -> "work_embedded_clones (2)" [color="red"]
29
+      "work_embedded_clones (2)"            -> "work_clones"              [color="red"]
30
+      "work_all_repositories"               -> "bootstrap_auto_final"
31
+      "bootstrap_auto_final"                -> "bury_zombies_in_graveyard"
32 32
 
33
-      "unmark_alive_stashes"                -> "bury_zombies_in_graveyard"
34
-      "bury_zombies_in_graveyard"           -> "run_fetch_scripts"
33
+      "bury_zombies_in_graveyard"           -> "run_post_fetch_scripts"
35 34
 
36
-      "fetch_missing_embedded_repositories"        [ fontcolor="red"]
37
-      "fetch_missing_repositories"                 [ fontcolor="red"]
38
-      "fetch_missing_deep_embedded_repositories"   [ fontcolor="red"]
35
+      "work_embedded_clones"                 [ fontcolor="red"]
36
+      "work_clones"                          [ fontcolor="red"]
37
+      "work_clones"                          [ fontcolor="red"]
38
+      "mark_stash_as_alive"                  [ fontcolor="red"]
39
+      "bootstrap_auto_update"                [ fontcolor="red"]
40
+      "work_embedded_clones (2)"             [ label="work_embedded_clones", fontcolor="red"]
39 41
    }
42
+
40 43
    subgraph cluster_1 {
41 44
       node [shape="record"]
42 45
       color="blue"
43 46
 
44
-      "update_embedded_repositories"  -> "update_repositories"
45
-      "update_repositories"           -> "update_deep_embedded_repositories"
46
-      "update_deep_embedded_repositories"  -> "run_update_scripts"
47
+      "upgrade_embedded_repositories"       -> "upgrade_repositories"
48
+      "upgrade_repositories"                -> "upgrade_deep_embedded_repositories"
49
+      "upgrade_deep_embedded_repositories"  -> "fetch"
50
+      "run_post_fetch_scripts"              -> "run_post_upgrade_scripts" [ lhead="cluster_0"]
47 51
    }
52
+
53
+
48 54
 }
49 55
\ No newline at end of file
... ...
@@ -249,10 +249,21 @@ bootstrap_libexec_path()
249 249
 }
250 250
 
251 251
 
252
+bootstrap_dump_env()
253
+{
254
+   log_trace "FULL trace started"
255
+   log_trace "ARGS:${C_TRACE2} ${MULLE_BOOTSTRAP_ARGUMENTS}"
256
+   log_trace "PWD :${C_TRACE2} `pwd -P`"
257
+   log_trace "ENV :${C_TRACE2} `env | sort`"
258
+   log_trace "LS  :${C_TRACE2} `ls -a1F`"
259
+}
260
+
261
+
252 262
 bootstrap_main()
253 263
 {
254 264
    local command
255 265
    local libexecpath
266
+   local ps4string
256 267
 
257 268
    BOOTSTRAP_DIR=.bootstrap
258 269
 
... ...
@@ -362,6 +373,34 @@ bootstrap_main()
362 373
             MULLE_BOOTSTRAP_PATHS_FLIP_X="NO"
363 374
          ;;
364 375
 
376
+         -tp|--trace-profile)
377
+            [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
378
+            case "${UNAME}" in
379
+               linux)
380
+                  ps4string='$(date "\+ +%s.%N (${BASH_SOURCE[1]##*/}:$LINENO)")'
381
+               ;;
382
+               *)
383
+                  ps4string='$(date "\+ +%s (${BASH_SOURCE[1]##*/}:$LINENO)")'
384
+               ;;
385
+            esac
386
+         ;;
387
+
388
+         -tpo|--trace-postponed)
389
+            [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
390
+            MULLE_BOOTSTRAP_POSTPONE_TRACE=YES
391
+         ;;
392
+
393
+         -tfpwd|--trace-full-pwd)
394
+            [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
395
+            ps4string='${BASH_SOURCE[1]##*/}:$LINENO \"\w\"'
396
+         ;;
397
+
398
+
399
+         -tpwd|--trace-pwd)
400
+            [ "${MULLE_BOOTSTRAP_TRACE}" = "1848" ] || fail "option \"$1\" must be specified after -t"
401
+            ps4string='${BASH_SOURCE[1]##*/}:$LINENO \".../\W\"'
402
+         ;;
403
+
365 404
          -t|--trace)
366 405
             MULLE_BOOTSTRAP_TRACE="1848"
367 406
             COPYMOVEFLAGS="-v"
... ...
@@ -370,6 +409,7 @@ bootstrap_main()
370 409
             MULLE_BOOTSTRAP_RESOLVER_FLIP_X="YES"
371 410
             MULLE_BOOTSTRAP_SETTINGS_FLIP_X="YES"
372 411
             MULLE_BOOTSTRAP_TRACE_SCRIPT_CALLS="NO"
412
+            ps4string='${BASH_SOURCE[1]##*/}:$LINENO'
373 413
          ;;
374 414
 
375 415
          -v|--verbose)
... ...
@@ -451,11 +491,7 @@ bootstrap_main()
451 491
          then
452 492
             MULLE_BOOTSTRAP_VERBOSE_BUILD="NO"
453 493
          fi
454
-         log_trace "FULL trace started"
455
-         log_trace "ARGS:${C_TRACE2} ${MULLE_BOOTSTRAP_ARGUMENTS}"
456
-         log_trace "PWD :${C_TRACE2} `pwd -P`"
457
-         log_trace "ENV :${C_TRACE2} `env | sort`"
458
-         log_trace "LS  :${C_TRACE2} `ls -a1F`"
494
+         bootstrap_dump_env
459 495
       ;;
460 496
 
461 497
       1848)
... ...
@@ -467,8 +503,15 @@ bootstrap_main()
467 503
          then
468 504
             MULLE_BOOTSTRAP_VERBOSE_BUILD="YES"
469 505
          fi
470
-         log_trace "1848 trace (set -x) started"
471
-         set -x
506
+
507
+         bootstrap_dump_env
508
+
509
+         if [ -z "${MULLE_BOOTSTRAP_POSTPONE_TRACE}" ]
510
+         then
511
+            log_trace "1848 trace (set -x) started"
512
+            set -x
513
+            PS4="+ ${ps4string} + "
514
+         fi
472 515
       ;;
473 516
    esac
474 517
 
... ...
@@ -42,7 +42,7 @@ bootstrap_auto_create()
42 42
 {
43 43
    [ -z "${BOOTSTRAP_DIR}" ] && internal_fail "empty bootstrap"
44 44
 
45
-   log_fluff "Creating ${BOOTSTRAP_DIR}.auto from ${BOOTSTRAP_DIR} (`pwd`)"
45
+   log_fluff "Creating ${BOOTSTRAP_DIR}.auto from ${BOOTSTRAP_DIR}"
46 46
 
47 47
    assert_mulle_bootstrap_version
48 48
 
... ...
@@ -54,7 +54,7 @@ bootstrap_auto_create()
54 54
    #
55 55
    if dir_has_files "${BOOTSTRAP_DIR}.local"
56 56
    then
57
-      exekutor cp -Ra "${BOOTSTRAP_DIR}.local/" "${BOOTSTRAP_DIR}.auto/"
57
+      exekutor cp -Ra ${COPYMOVEFLAGS} "${BOOTSTRAP_DIR}.local/" "${BOOTSTRAP_DIR}.auto/" >&2
58 58
    fi
59 59
 
60 60
    #
... ...
@@ -85,7 +85,7 @@ bootstrap_auto_create()
85 85
          ;;
86 86
 
87 87
          *)
88
-            exekutor cp -Ran "${BOOTSTRAP_DIR}/${name}" "${BOOTSTRAP_DIR}.auto/"
88
+            exekutor cp -Ran ${COPYMOVEFLAGS}  "${BOOTSTRAP_DIR}/${name}" "${BOOTSTRAP_DIR}.auto/" >&2
89 89
          ;;
90 90
       esac
91 91
    done
... ...
@@ -275,13 +275,13 @@ _bootstrap_auto_merge_root_settings()
275 275
 
276 276
          log_fluff "Merging \"${settingname}\" from \"${srcfile}\""
277 277
 
278
-         exekutor mv "${dstfile}" "${tmpfile}" || exit 1
278
+         exekutor mv ${COPYMOVEFLAGS}  "${dstfile}" "${tmpfile}" >&2 || exit 1
279 279
          redirect_exekutor "${dstfile}" exekutor merge_settings_in_front "${srcfile}" "${tmpfile}"  || exit 1
280
-         exekutor rm "${tmpfile}" || exit 1
280
+         exekutor rm ${COPYMOVEFLAGS}  "${tmpfile}" >&2 || exit 1
281 281
       else
282 282
          log_fluff "Copying \"${settingname}\" from \"${srcfile}\""
283 283
 
284
-         exekutor cp "${srcfile}" "${dstfile}" || exit 1
284
+         exekutor cp ${COPYMOVEFLAGS}  "${srcfile}" "${dstfile}" >&2 || exit 1
285 285
       fi
286 286
    done
287 287
 
... ...
@@ -360,7 +360,7 @@ bootstrap_create_build_folders()
360 360
    do
361 361
       IFS="${DEFAULT_IFS}"
362 362
 
363
-      dstdir="${BOOTSTRAP_DIR}.auto/.${name}.build"
363
+      dstdir="${BOOTSTRAP_DIR}.auto/${name}.build"
364 364
       if [ ${has_settings} -eq 0 ]
365 365
       then
366 366
          inherit_files "${dstdir}" "${BOOTSTRAP_DIR}.auto/settings"
... ...
@@ -463,6 +463,7 @@ repositories
463 463
 version
464 464
 '
465 465
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
466
+   [ -z "${MULLE_BOOTSTRAP_COPY_SH}" ] && . mulle-bootstrap-copy.sh
466 467
    :
467 468
 }
468 469
 
... ...
@@ -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 ${COPYMOVEFLAGS} "${src}"/* "${dst}" || 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 ${COPYMOVEFLAGS} "${copyflag}" % "${dst}"
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 ${COPYMOVEFLAGS} -f % "${dst}"
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
 
... ...
@@ -42,11 +42,11 @@ tar_remove_extension()
42 42
    then
43 43
       case "${UNAME}" in
44 44
          darwin|freebsd)
45
-            echo "-s/\.$1//"
45
+            echo "-s/\.$1\$//"
46 46
          ;;
47 47
 
48 48
          *)
49
-            echo "--transform /\.$1//"
49
+            echo "--transform /\.$1\$//"
50 50
          ;;
51 51
       esac
52 52
    fi
... ...
@@ -59,20 +59,13 @@ tar_remove_extension()
59 59
 # ext can be empty
60 60
 # noclobber can be empty or YES
61 61
 #
62
-copy_files_stripping_extension()
62
+_copy_files()
63 63
 {
64
-   local srcdir
65
-   local dstdir
66
-   local ext
67
-
68
-   dstdir="$1"
69
-   shift
70
-   srcdir="$1"
71
-   shift
72
-   ext="$1"
73
-   shift
74
-   noclobber="$1"
75
-   shift
64
+   local taroptions="$1" ; shift
65
+   local dstdir="$1" ; shift
66
+   local srcdir="$1" ; shift
67
+   local ext="$1" ; shift
68
+   local noclobber="$1" ; shift
76 69
 
77 70
    [ -d "${srcdir}" ] || internal_fail "${srcdir} does not exist"
78 71
    [ -d "${dstdir}" ] || internal_fail "${dstdir} does not exist"
... ...
@@ -91,25 +84,41 @@ copy_files_stripping_extension()
91 84
       cd "${srcdir}" ;
92 85
       if [ -z "${ext}" ]
93 86
       then
94
-         find . \( -type f -a ! -name "*.*" \) -print
87
+         exekutor find . \( -type f -a ! -name "*.*" \) -print
95 88
       else
96
-         find . \( -type f -a -name "*.${ext}" \) -print
89
+         exekutor find . \( -type f -a -name "*.${ext}" \) -print
97 90
       fi |
98
-         tar -c `tar_remove_extension "${ext}"` -f - -T -
91
+         exekutor tar -c ${taroptions} -f - -T -
99 92
    ) |
100 93
    (
101 94
       cd "${dstdir}" ;
102 95
       if [ -z "${noclobber}" ]
103 96
       then
104
-         tar xf - $*
97
+         exekutor tar xf - ${COPYMOVEFLAGS} $*
105 98
       else
106
-         tar xf - -k 2> /dev/null
99
+         exekutor tar xf - ${COPYMOVEFLAGS} -k 2> /dev/null
107 100
          :
108 101
       fi
109
-   )
102
+   ) >&2
110 103
 }
111 104
 
112 105
 
106
+copy_files_stripping_last_extension()
107
+{
108
+   local ext="$3"
109
+   local lastext="`echo "${ext}" | sed 's/\.[^.]*$//'`"
110
+
111
+   _copy_files "`tar_remove_extension "${lastext}"`" "$@"
112
+}
113
+
114
+
115
+copy_files_keeping_extension()
116
+{
117
+   _copy_files "" "$@"
118
+}
119
+
120
+
121
+
113 122
 #
114 123
 # dstdir need not exist
115 124
 # srcdir must exist
... ...
@@ -120,15 +129,17 @@ inherit_files()
120 129
 
121 130
    dstdir="$1"
122 131
 
132
+   [ $# -eq 2 ] || internal_fail "parameter error"
133
+
123 134
    mkdir_if_missing "${dstdir}"
124 135
 
125 136
    # prefer to copy os-specific first, "-k" won't overwrite
126
-   exekutor copy_files_stripping_extension "$@" "${UNAME}" "YES" || fail "copy"
127
-   exekutor copy_files_stripping_extension "$@" ".sh.${UNAME}" "YES" || fail "copy"
137
+   copy_files_stripping_last_extension "$@" "${UNAME}" "YES" || fail "copy"
138
+   copy_files_stripping_last_extension "$@" "sh.${UNAME}" "YES" || fail "copy"
128 139
 
129 140
    # then to copy generic, again "-k" won't overwrite
130
-   exekutor copy_files_stripping_extension "$@" "" "YES" || fail "copy"
131
-   exekutor copy_files_stripping_extension "$@" ".sh" "YES" || fail "copy"
141
+   copy_files_keeping_extension "$@" "" "YES" || fail "copy"
142
+   copy_files_keeping_extension "$@" "sh" "YES" || fail "copy"
132 143
 }
133 144
 
134 145
 
... ...
@@ -142,15 +153,17 @@ override_files()
142 153
 
143 154
    dstdir="$1"
144 155
 
156
+   [ $# -eq 2 ] || internal_fail "parameter error"
157
+
145 158
    mkdir_if_missing "${dstdir}"
146 159
 
147 160
    # first copy generic, clobber what's there
148
-   exekutor copy_files_stripping_extension "$@"       || fail "copy"
149
-   exekutor copy_files_stripping_extension "$@" ".sh" || fail "copy"
161
+   copy_files_keeping_extension "$@"      || fail "copy"
162
+   copy_files_keeping_extension "$@" "sh" || fail "copy"
150 163
 
151 164
    # then copy os-specific to clobber generics
152
-   exekutor copy_files_stripping_extension "$@" "${UNAME}" || fail "copy"
153
-   exekutor copy_files_stripping_extension "$@" ".sh.${UNAME}" || fail "copy"
165
+   copy_files_stripping_last_extension "$@" "${UNAME}" || fail "copy"
166
+   copy_files_stripping_last_extension "$@" "sh.${UNAME}" || fail "copy"
154 167
 }
155 168
 
156 169
 
... ...
@@ -819,7 +819,7 @@ _operation_walk_embedded_repositories()
819 819
       walk_repositories "embedded_repositories"  \
820 820
                         "${operation}" \
821 821
                         "${permissions}" \
822
-                        "${REPOS_DIR}.embedded"
822
+                        "${REPOS_DIR}/.embedded"
823 823
    ) || exit 1
824 824
 }
825 825
 
... ...
@@ -1034,8 +1034,8 @@ work_clones()
1034 1034
 
1035 1035
    local actionitems
1036 1036
    local fetched
1037
-   local go_deep
1038 1037
    local repotype
1038
+   local oldstashdir
1039 1039
 
1040 1040
    case "${reposdir}" in
1041 1041
       *embedded)
... ...
@@ -1073,23 +1073,12 @@ work_clones()
1073 1073
                                               "${scm}" \
1074 1074
                                               "${tag}" \
1075 1075
                                               "${stashdir}"`" || exit 1
1076
-      if [ -z "${actionitems}" ]
1077
-      then
1078
-         if [ "${autoupdate}" = "YES" ]
1079
-         then
1080
-            bootstrap_auto_update "${stashdir}"
1081
-         fi
1082
-
1083
-         log_fluff "Nothing to do for \"${url}\""
1084
-         continue
1085
-      fi
1086 1076
 
1087 1077
       IFS="
1088 1078
 "
1089 1079
       for item in ${actionitems}
1090 1080
       do
1091 1081
          IFS="${DEFAULT_IFS}"
1092
-         go_deep="${autoupdate}"
1093 1082
 
1094 1083
          case "${item}" in
1095 1084
             "checkout")
... ...
@@ -1119,11 +1108,10 @@ work_clones()
1119 1108
             ;;
1120 1109
 
1121 1110
             "move")
1122
-               log_verbose "Moving ${repotype}stash \"${name}\" to \"`absolutepath ${stashdir}`\""
1123
-
1124 1111
                oldstashdir="`stash_of_repository "${reposdir}" "${name}"`"
1125
-               rmdir_safer "${oldstashdir}"
1126
-               go_deep="NO"
1112
+               log_verbose "Moving ${repotype}stash \"${name}\" from \"${oldstashdir}\" to \"`absolutepath ${stashdir}`\""
1113
+
1114
+               exekutor mv ${COPYMOVEFLAGS} "${oldstashdir}" "${stashdir}"
1127 1115
             ;;
1128 1116
 
1129 1117
             "pull")
... ...
@@ -1143,8 +1131,6 @@ work_clones()
1143 1131
 
1144 1132
                oldstashdir="`stash_of_repository "${reposdir}" "${name}"`"
1145 1133
                rmdir_safer "${oldstashdir}"
1146
-
1147
-               go_deep="NO"
1148 1134
             ;;
1149 1135
 
1150 1136
             "set-remote")
... ...
@@ -1158,50 +1144,54 @@ work_clones()
1158 1144
                   fail "Could not figure out a remote for \"$PWD/${stashdir}\""
1159 1145
                fi
1160 1146
                git_set_url "${stashdir}" "${remote}" "${url}"
1161
-
1162
-               go_deep="NO"
1163 1147
             ;;
1164 1148
 
1165 1149
             *)
1166 1150
                internal_fail "Unknown action item \"${item}\""
1167 1151
             ;;
1168 1152
          esac
1153
+      done
1169 1154
 
1170
-         if [ "${autoupdate}" = "YES" ]
1171
-         then
1172
-            bootstrap_auto_update "${stashdir}"
1173
-         fi
1174
-
1175
-         if [ "${go_deep}" = "YES" ]
1176
-         then
1177
-            if [ ! -L "${stashdir}" -o "${ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
1178
-            then
1179
-               (
1180
-                  local embedded_clones;
1155
+      if [ "${autoupdate}" = "YES" ]
1156
+      then
1157
+         bootstrap_auto_update "${stashdir}"
1158
+      fi
1181 1159
 
1182
-                  ALLOW_CREATING_SYMLINKS="${ALLOW_CREATING_EMBEDDED_SYMLINKS}" ;
1183
-                  MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES" ;
1184
-                  STASHES_DIR=""
1160
+      #
1161
+      # always remember, what we have now
1162
+      #
1163
+      remember_stash_of_repository "${clone}" \
1164
+                                   "${reposdir}" \
1165
+                                   "${name}"  \
1166
+                                   "${url}" \
1167
+                                   "${branch}" \
1168
+                                   "${scm}" \
1169
+                                   "${tag}" \
1170
+                                   "${stashdir}"
1185 1171
 
1186
-                  cd_physical "${stashdir}" &&
1187
-                  embedded_clones="`read_root_setting "embedded_repositories"`" &&
1188
-                  work_clones "${REPOS_DIR}.embedded" "${embedded_clones}" "NO"  > /dev/null
1189
-               ) || exit 1
1190
-            fi
1191
-         fi
1172
+      mark_stash_as_alive "${reposdir}" "${name}"
1192 1173
 
1193
-         #
1194
-         # always remember, what we have now
1195
-         #
1196
-         remember_stash_of_repository "${clone}" \
1197
-                                      "${reposdir}" \
1198
-                                      "${name}"  \
1199
-                                      "${url}" \
1200
-                                      "${branch}" \
1201
-                                      "${scm}" \
1202
-                                      "${tag}" \
1203
-                                      "${stashdir}"
1204
-      done
1174
+      if [ ! -L "${stashdir}" -o "${ALLOW_FOLLOWING_SYMLINKS}" = "YES" ]
1175
+      then
1176
+         (
1177
+            local embedded_clones;
1178
+
1179
+            ALLOW_CREATING_SYMLINKS="${ALLOW_CREATING_EMBEDDED_SYMLINKS}" ;
1180
+            MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES" ;
1181
+            STASHES_DIR=""
1182
+
1183
+            cd_physical "${stashdir}" &&
1184
+            embedded_clones="`read_root_setting "embedded_repositories"`" &&
1185
+            work_clones "${REPOS_DIR}/.embedded" "${embedded_clones}" "NO"  > /dev/null
1186
+         ) || exit 1
1187
+      else
1188
+         log_fluff "Not following \"${stashdir}\" to embedded repositories of \"${name}\" because it's a symlink"
1189
+         # but need to mark them as alive
1190
+         (
1191
+            cd_physical "${stashdir}" &&
1192
+            mark_all_stashes_as_alive "${REPOS_DIR}/.embedded"
1193
+         ) || exit 1
1194
+      fi
1205 1195
    done
1206 1196
 
1207 1197
    IFS="${DEFAULT_IFS}"
... ...
@@ -1274,24 +1264,13 @@ work_all_repositories()
1274 1264
 ### Main fetch loop   #    #    #----#
1275 1265
                       #----#    #----#    #----#
1276 1266
 
1277
-mark_stashes_as_zombies()
1267
+assume_stashes_are_zombies()
1278 1268
 {
1279
-   mark_embedded_repository_stashes
1269
+   zombify_embedded_repository_stashes
1280 1270
    if [ -z "${EMBEDDED_ONLY}" ]
1281 1271
    then
1282
-      mark_repository_stashes
1283
-      mark_deep_embedded_repository_stashes
1284
-   fi
1285
-}
1286
-
1287
-
1288
-unmark_alive_stashes()
1289
-{
1290
-   unmark_embedded_repository_stashes
1291
-   if [ -z "${EMBEDDED_ONLY}" ]
1292
-   then
1293
-      unmark_repository_stashes
1294
-      unmark_deep_embedded_repository_stashes
1272
+      zombify_repository_stashes
1273
+      zombify_deep_embedded_repository_stashes
1295 1274
    fi
1296 1275
 }
1297 1276
 
... ...
@@ -1341,7 +1320,13 @@ fetch_loop()
1341 1320
 {
1342 1321
    local fetched
1343 1322
 
1344
-   mark_stashes_as_zombies
1323
+   if [ ! -z "${MULLE_BOOTSTRAP_POSTPONE_TRACE}" -a "${MULLE_BOOTSTRAP_TRACE}" = "1848" ]
1324
+   then
1325
+      set -x
1326
+      PS4="+ ${ps4string} + "
1327
+   fi
1328
+
1329
+   assume_stashes_are_zombies
1345 1330
 
1346 1331
    bootstrap_auto_create
1347 1332
 
... ...
@@ -1349,7 +1334,6 @@ fetch_loop()
1349 1334
 
1350 1335
    bootstrap_auto_final
1351 1336
 
1352
-   unmark_alive_stashes
1353 1337
    bury_zombies_in_graveyard
1354 1338
 
1355 1339
    echo "${fetched}"
... ...
@@ -985,7 +985,7 @@ mkdir_if_missing()
985 985
 {
986 986
    if [ ! -d "$1" ]
987 987
    then
988
-      log_fluff "Creating \"$1\" (`pwd`)"
988
+      log_fluff "Creating \"$1\""
989 989
       exekutor mkdir -p "$1" || fail "failed to create directory \"$1\""
990 990
    fi
991 991
 }
... ...
@@ -1037,7 +1037,7 @@ create_file_if_missing()
1037 1037
          mkdir_if_missing "${dir}"
1038 1038
       fi
1039 1039
 
1040
-      log_fluff "Creating \"$1\" (`pwd`)"
1040
+      log_fluff "Creating \"$1\""
1041 1041
       exekutor touch "$1" || fail "failed to create \"$1\""
1042 1042
    fi
1043 1043
 }
... ...
@@ -1047,7 +1047,7 @@ remove_file_if_present()
1047 1047
 {
1048 1048
    if [ -e "$1" ]
1049 1049
    then
1050
-      log_fluff "Removing \"$1\" (`pwd`)"
1050
+      log_fluff "Removing \"$1\""
1051 1051
       exekutor chmod u+w "$1" || fail "Failed to make $1 writable"
1052 1052
       exekutor rm -f "$1" || fail "failed to remove \"$1\""
1053 1053
    fi
... ...
@@ -143,7 +143,7 @@ stash_of_repository()
143 143
    then
144 144
       _stash_of_reposdir_file "${reposfilepath}"
145 145
    else
146
-      log_fluff "No stash found for ${name} in ${reposdir} (`pwd -P`)"
146
+      log_fluff "No stash found for ${name} in ${reposdir}"
147 147
    fi
148 148
 }
149 149
 
... ...
@@ -400,7 +400,7 @@ walk_deep_embedded_repositories()
400 400
       (
401 401
          cd "${stashdir}" ;
402 402
          STASHES_DIR="" ;
403
-         walk_repositories "embedded_repositories" "${callback}" "${permissions}" "${REPOS_DIR}.embedded"
403
+         walk_repositories "embedded_repositories" "${callback}" "${permissions}" "${REPOS_DIR}/.embedded"
404 404
       ) || exit 1
405 405
    done
406 406
 
... ...
@@ -479,15 +479,16 @@ _canonical_name_from_clone()
479 479
    _canonical_clone_name "${url}"
480 480
 }
481 481
 
482
+
482 483
 path_relative_to_root_dir()
483 484
 {
484 485
    local relpath="$1"
485 486
 
486
-   local apath
487
-
488 487
    [ -z "${ROOT_DIR}" ] && internal_fail "ROOT_DIR not set"
489 488
    [ -z "${relpath}" ]  && internal_fail "relpath not set"
490 489
 
490
+   local apath
491
+
491 492
    apath="${ROOT_DIR}/${relpath}"
492 493
 
493 494
    # make sure destination doesn't stray outside of project
... ...
@@ -62,7 +62,7 @@ EOF
62 62
 #
63 63
 # ###
64 64
 #
65
-_mark_stashes_as_zombies()
65
+_zombify_stashes()
66 66
 {
67 67
    local reposdir
68 68
 
... ...
@@ -79,47 +79,47 @@ _mark_stashes_as_zombies()
79 79
       zombiepath="${reposdir}/.zombies"
80 80
       mkdir_if_missing "${zombiepath}"
81 81
 
82
-      exekutor cp "${reposdir}/"* "${zombiepath}/"
82
+      exekutor cp ${COPYMOVEFLAGS} "${reposdir}/"* "${zombiepath}/" >&2
83 83
    fi
84 84
 }
85 85
 
86 86
 
87
-_mark_stashes_as_alive()
87
+mark_stash_as_alive()
88 88
 {
89 89
    local reposdir
90 90
 
91 91
    reposdir="$1"
92
+   name="$2"
92 93
 
93
-   [ $# -eq 1 ] || internal_fail "parameter error"
94
+   [ $# -eq 2 ] || internal_fail "parameter error"
94 95
 
95
-   local i
96
-   local name
97
-   local zombie
98
-
99
-   if dir_has_files "${reposdir}"
96
+   zombie="${reposdir}/.zombies/${name}"
97
+   if [ -e "${zombie}" ]
100 98
    then
99
+      log_fluff "Marking \"${name}\" as alive"
101 100
 
102
-      IFS="
103
-"
104
-      for i in `ls -1d "${reposdir}/"*`
105
-      do
106
-         IFS="${DEFAULT_IFS}"
101
+      exekutor rm -f ${COPYMOVEFLAGS} "${zombie}" >&2 || fail "failed to delete zombie ${zombie}"
102
+   else
103
+      log_fluff "Marked \"${name}\" is already alive (`absolutepath "${zombie}"` not present)"
104
+   fi
105
+}
107 106
 
108
-         name="`basename -- "${i}"`"
109
-         zombie="${reposdir}/.zombies/${name}"
110 107
 
111
-         if [ -e "${zombie}" ]
112
-         then
113
-            log_fluff "Mark \"${name}\" as alive"
108
+mark_all_stashes_as_alive()
109
+{
110
+   local reposdir
114 111
 
115
-            exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
116
-         else
117
-            log_fluff "Marked \"${name}\" is already alive"
118
-         fi
119
-      done
120
-   fi
112
+   reposdir="$1"
121 113
 
122
-   IFS="${DEFAULT_IFS}"
114
+   local zombiedir
115
+
116
+   zombiedir="${reposdir}/.zombies"
117
+
118
+   if dir_has_files "${zombiedir}"
119
+   then
120
+      log_fluff "Marking all stashes of \"${reposdir}\" as alive"
121
+      exekutor rm -f ${COPYMOVEFLAGS} "${zombiedir}/"* >&2 || fail "failed to delete zombie ${zombie}"
122
+   fi
123 123
 }
124 124
 
125 125
 
... ...
@@ -140,12 +140,11 @@ _bury_zombies()
140 140
    local zombiepath
141 141
    local gravepath
142 142
 
143
-   # first mark all repos as stale
144 143
    zombiepath="${reposdir}/.zombies"
145 144
 
146 145
    if dir_has_files "${zombiepath}"
147 146
    then
148
-      log_fluff "Burying zombies into graveyard"
147
+      log_fluff "Moving zombies into graveyard"
149 148
 
150 149
       gravepath="${reposdir}/.graveyard"
151 150
       mkdir_if_missing "${gravepath}"
... ...
@@ -159,8 +158,8 @@ _bury_zombies()
159 158
 
160 159
             if [ -L "${stashdir}"  ]
161 160
             then
162
-               log_info "Removed unused symlink ${C_MAGENTA}${C_BOLD}${stashdir}${C_INFO}"
163
-               exekutor rm "${stashdir}"
161
+               log_info "Removing unused symlink ${C_MAGENTA}${C_BOLD}${stashdir}${C_INFO}"
162
+               exekutor rm ${COPYMOVEFLAGS}  "${stashdir}" >&2
164 163
                continue
165 164
             fi
166 165
 
... ...
@@ -168,15 +167,16 @@ _bury_zombies()
168 167
             then
169 168
                if [ -e "${gravepath}/${name}" ]
170 169
                then
171
-                  exekutor rm -rf "${gravepath}/${name}"
172
-                  log_fluff "Repurposed old grave \"${gravepath}/${name}\""
170
+                  log_fluff "Repurposing old grave \"${gravepath}/${name}\""
171
+                  exekutor rm -rf ${COPYMOVEFLAGS}  "${gravepath}/${name}" >&2
173 172
                fi
174 173
 
175
-               exekutor mv "${stashdir}" "${gravepath}/"
176
-               exekutor rm "${i}"
177
-               exekutor rm "${reposdir}/${name}"
174
+               log_info "Removing unused repository ${C_MAGENTA}${C_BOLD}${name}${C_INFO} (\"${stashdir}\")"
175
+
176
+               exekutor mv ${COPYMOVEFLAGS} "${stashdir}" "${gravepath}/" >&2
177
+               exekutor rm ${COPYMOVEFLAGS} "${i}" >&2
178
+               exekutor rm ${COPYMOVEFLAGS} "${reposdir}/${name}" >&2
178 179
 
179
-               log_info "Removed unused repository ${C_MAGENTA}${C_BOLD}${name}${C_INFO} (\"${stashdir}\")"
180 180
             else
181 181
                log_fluff "Zombie \"${stashdir}\" vanished or never existed ($PWD)"
182 182
             fi
... ...
@@ -186,7 +186,7 @@ _bury_zombies()
186 186
 
187 187
    if [ -d "${zombiepath}" ]
188 188
    then
189
-      exekutor rm -rf "${zombiepath}"
189
+      exekutor rm -rf ${COPYMOVEFLAGS} "${zombiepath}" >&2
190 190
    fi
191 191
 }
192 192
 
... ...
@@ -194,23 +194,23 @@ _bury_zombies()
194 194
 #
195 195
 #
196 196
 #
197
-mark_embedded_repository_stashes()
197
+zombify_embedded_repository_stashes()
198 198
 {
199 199
    log_fluff "Marking all embedded repositories as zombies for now"
200 200
 
201
-   _mark_stashes_as_zombies "${REPOS_DIR}/.embedded"
201
+   _zombify_stashes "${REPOS_DIR}/.embedded"
202 202
 }
203 203
 
204 204
 
205
-mark_repository_stashes()
205
+zombify_repository_stashes()
206 206
 {
207 207
    log_fluff "Marking all repositories as zombies for now"
208 208
 
209
-   _mark_stashes_as_zombies "${REPOS_DIR}"
209
+   _zombify_stashes "${REPOS_DIR}"
210 210
 }
211 211
 
212 212
 
213
-mark_deep_embedded_repository_stashes()
213
+zombify_deep_embedded_repository_stashes()
214 214
 {
215 215
    local stashes
216 216
    local stash
... ...
@@ -224,47 +224,10 @@ mark_deep_embedded_repository_stashes()
224 224
    do
225 225
       IFS="${DEFAULT_IFS}"
226 226
 
227
-      _mark_stashes_as_zombies "${stash}/${REPOS_DIR}/.embedded"
228
-   done
229
-
230
-   IFS="${DEFAULT_IFS}"
231
-}
232
-
233
-
234
-#
235
-#
236
-#
237
-unmark_embedded_repository_stashes()
238
-{
239
-   log_fluff "Unmarking alive embedded repositories"
240
-
241
-   _mark_stashes_as_alive "${REPOS_DIR}/.embedded"
242
-}
243
-
244
-
245
-unmark_repository_stashes()
246
-{
247
-   log_fluff "Unmarking alive repositories"
248
-
249
-   _mark_stashes_as_alive "${REPOS_DIR}"
250
-}
251
-
252
-
253
-unmark_deep_embedded_repository_stashes()
254
-{
255
-   local stashes
256
-   local stash
257
-
258
-   log_fluff "Unmarking alive deep embedded repositories"
259
-
260
-   IFS="
261
-"
262
-   stashes="`all_repository_stashes "${REPOS_DIR}"`"
263
-   for stash in ${stashes}
264
-   do
265
-      IFS="${DEFAULT_IFS}"
266
-
267
-      _mark_stashes_as_alive "${stash}/${REPOS_DIR}/.embedded"
227
+      (
228
+         cd "${stash}" &&
229
+         _zombify_stashes "${REPOS_DIR}/.embedded"
230
+      ) || fail "failed to mark stashes"
268 231
    done
269 232
 
270 233
    IFS="${DEFAULT_IFS}"
... ...
@@ -304,7 +267,10 @@ bury_deep_embedded_repository_zombies()
304 267
    do
305 268
       IFS="${DEFAULT_IFS}"
306 269
 
307
-      _bury_zombies "${stash}/${REPOS_DIR}/.embedded"
270
+      (
271
+         cd "${stash}" &&
272
+         _bury_zombies "${REPOS_DIR}/.embedded"
273
+      ) || fail "failed to bury zombies"
308 274
    done
309 275
 
310 276
    IFS="${DEFAULT_IFS}"
... ...
@@ -110,6 +110,7 @@ echo "--| 1 |--------------------------------"
110 110
    :
111 111
 ) || exit 1
112 112
 
113
+
113 114
 #
114 115
 # Make embedded repository appear
115 116
 #
... ...
@@ -125,7 +126,8 @@ echo "--| 2 |--------------------------------"
125 126
 
126 127
 
127 128
 #
128
-# now move embedded repository (c should not touch it)
129
+# now move embedded repository (c should not touch it, because we
130
+# don't allow following symlinks at first)
129 131
 #
130 132
 echo "--| 3 |--------------------------------"
131 133
 (
... ...
@@ -135,12 +137,30 @@ echo "--| 3 |--------------------------------"
135 137
 
136 138
 (
137 139
    cd c ;
138
-   run_mulle_bootstrap "$@" -y fetch  ;  # use symlink
140
+   run_mulle_bootstrap "$@" -y fetch
139 141
 
140
-   [ ! -L stashes/b ]       && fail "failed to symlink b" ;
141
-   [ ! -d stashes/b/src/a ] && fail "superzealously removed a" ;
142
-   [ -d stashes/b/a ]       && fail "superzealously added a" ;
142
+   [ ! -L stashes/b ]     && fail "failed to symlink b" ;
143
+   [ ! -d stashes/b/src/a ] && fail "superzealously removed symlinked src/a" ;
144
+   [ -d stashes/b/a ]   && fail "superzealously embedded a" ;
143 145
    :
144 146
 ) || exit 1
145 147
 
148
+
149
+#
150
+# now move embedded repository (c should not touch it, because we
151
+# don't allow following symlinks at first)
152
+#
153
+echo "--| 4 |--------------------------------"
154
+
155
+(
156
+   cd c ;
157
+   run_mulle_bootstrap "$@" -y fetch --follow-symlinks
158
+
159
+   [ ! -L stashes/b ]     && fail "failed to symlink b" ;
160
+   [ -d stashes/b/src/a ] && fail "failed to remove src/a" ;
161
+   [ ! -d stashes/b/a ]   && fail "failed to embed a" ;
162
+   :
163
+) || exit 1
164
+
165
+
146 166
 echo "--| PASS |-----------------------------"
... ...
@@ -186,6 +186,8 @@ run_mulle_bootstrap "$@" -y fetch --no-symlink-creation
186 186
 # hack
187 187
 rm stashes/a/.bootstrap/embedded_repositories
188 188
 
189
+# ls -a1RF >&2
190
+
189 191
 echo "--| 5 |--------------------------------"
190 192
 run_mulle_bootstrap "$@" -y fetch --no-symlink-creation
191 193
 
... ...
@@ -58,7 +58,7 @@ setup()
58 58
 
59 59
    cd b
60 60
       run_mulle_bootstrap init -n
61
-      echo "../a;src/a_1" > .bootstrap/embedded_repositories
61
+      echo "a;src/a_1" > .bootstrap/embedded_repositories
62 62
       echo "# b" > README.md
63 63
       git init
64 64
       git add README.md .bootstrap/embedded_repositories
... ...
@@ -68,7 +68,7 @@ setup()
68 68
 
69 69
    cd c
70 70
       run_mulle_bootstrap init -n
71
-      echo "../b;src/b_1" > .bootstrap/embedded_repositories
71
+      echo "b;src/b_1" > .bootstrap/embedded_repositories
72 72
       echo "# c" > README.md
73 73
       git init
74 74
       git add README.md .bootstrap/embedded_repositories
... ...
@@ -77,7 +77,7 @@ setup()
77 77
 
78 78
    cd d
79 79
       run_mulle_bootstrap init -n
80
-      echo "../c" > .bootstrap/repositories
80
+      echo "c" > .bootstrap/repositories
81 81
       echo "# d" > README.md
82 82
       git init
83 83
       git add README.md .bootstrap/repositories
... ...
@@ -98,72 +98,82 @@ BOOTSTRAP_FLAGS="$@"
98 98
 
99 99
 setup
100 100
 
101
-echo ""
102
-echo ""
103
-echo "=== setup done ==="
104
-echo ""
105
-echo ""
101
+echo "" >&2
102
+echo "" >&2
103
+echo "=== setup done ===" >&2
104
+echo "" >&2
105
+echo "" >&2
106 106
 
107 107
 (
108 108
    cd c ;
109
-   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} fetch
109
+   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} -y fetch --no-symlink-creation
110 110
 
111
-   [ -d src/b_1 ] || fail "b as src/b_1 failed to be embedded"
112
-   [ -d src/b_1/src/a_1 ] && fail "a was wrongly embedded"
111
+   [ -d src/b_1 ]         || fail "b as src/b_1 failed to be embedded"
112
+   [ -d src/b_1/src/a_1 ] || fail "src/b_1/src/a_1 faile to be embedded"
113 113
    :
114 114
 ) || exit 1
115 115
 
116
-echo ""
117
-echo ""
118
-echo "=== test 1 done ==="
119
-echo ""
120
-echo ""
116
+echo "" >&2
117
+echo "" >&2
118
+echo "=== test 1 done ===" >&2
119
+echo "" >&2
120
+echo "" >&2
121 121
 
122 122
 (
123 123
    cd c ;
124 124
    sleep 1 ;
125
-   echo "../b;src/b_2" > .bootstrap/embedded_repositories ;
126
-   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} fetch
125
+
126
+   # overwrite
127
+   mkdir .bootstrap.local
128
+   echo "b;src/b_2" > .bootstrap.local/embedded_repositories
129
+
130
+   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} -y fetch --no-symlink-creation
127 131
    [ -d src/b_1 ] && fail "b as src/b_1 failed to be removed"
128 132
    [ -d src/b_2 ] || fail "b as src/b_2 failed to be added"
133
+   [ -d src/b_2/src/a_1 ] || fail "src/b_2/src/a_1 failed to be embedded"
129 134
    :
130 135
 ) || exit 1
131 136
 
132
-echo ""
133
-echo ""
134
-echo "=== test 2 done ==="
135
-echo ""
136
-echo ""
137
+echo "" >&2
138
+echo "" >&2
139
+echo "=== test 2 done ===" >&2
140
+echo "" >&2
141
+echo "" >&2
137 142
 
138 143
 
139 144
 (
140 145
    cd d ;
141
-   run_mulle_bootstrap -a ${BOOTSTRAP_FLAGS} fetch
142
-   [ -d .repos/c/src/b_1 ] || fail "b as .repos/c/src/b_1 failed to be fetched"
146
+
147
+   run_mulle_bootstrap -a ${BOOTSTRAP_FLAGS} -y fetch --no-symlink-creation
148
+   [ -d stashes/c/src/b_1 ] || fail "b as stashes/c/src/b_2 failed to be fetched"
149
+   [ -d stashes/c/src/b_1/src/a_1 ] || fail " stashes/c/src/b_2/src/a_1 failed to be embedded"
143 150
    :
144 151
 ) || exit 1
145 152
 
146
-echo ""
147
-echo ""
148
-echo "=== test 3 done ==="
149
-echo ""
150
-echo ""
153
+echo "" >&2
154
+echo "" >&2
155
+echo "=== test 3 done ===" >&2
156
+echo "" >&2
157
+echo "" >&2
151 158
 
152 159
 
153 160
 (
154 161
    cd d ;
155 162
    sleep 1 ;
156
-   echo "../b;src/b_2" > .repos/c/.bootstrap/embedded_repositories ;
157
-   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} fetch
158
-   [ -d .repos/c/src/b_1 ] && fail "b as .repos/c/src/b_1 failed to be removed"
159
-   [ -d .repos/c/src/b_2 ] || fail "b as .repos/c/src/b_2 failed to be added"
163
+
164
+   echo "b;src/b_2" > stashes/c/.bootstrap/embedded_repositories ;
165
+
166
+   run_mulle_bootstrap ${BOOTSTRAP_FLAGS} -y fetch --no-symlink-creation
167
+
168
+   [ -d stashes/c/src/b_1 ] && fail "b as stashes/c/src/b_1 failed to be removed"
169
+   [ -d stashes/c/src/b_2 ] || fail "b as stashes/c/src/b_2 failed to be added"
160 170
    :
161 171
 ) || exit 1
162 172
 
163
-echo ""
164
-echo ""
165
-echo "=== test 4 done ==="
166
-echo ""
167
-echo ""
173
+echo "" >&2
174
+echo "" >&2
175
+echo "=== test 4 done ===" >&2
176
+echo "" >&2
177
+echo "" >&2
168 178
 
169 179
 echo "succeeded" >&2
... ...
@@ -1,4 +1,4 @@
1
-#! /bin/sh -x
1
+#! /bin/sh
2 2
 
3 3
 clear_test_dirs()
4 4
 {
... ...
@@ -31,34 +31,42 @@ run_mulle_bootstrap()
31 31
 }
32 32
 
33 33
 
34
+produce_file()
35
+{
36
+   filename="$1"
37
+
38
+   local where
39
+
40
+   where=`basename -- "${PWD}"`
41
+
42
+   mkdir -p "`dirname -- "${filename}"`"
43
+   echo "# ${where} : ${filename}" > "${filename}"
44
+}
45
+
46
+
34 47
 #
35 48
 #
36 49
 #
37
-
38
-
39 50
 create_settings()
40 51
 {
41 52
    local name
42 53
 
43 54
    name="$1"
44 55
 
45
-   mkdir -p ".bootstrap/settings/${name}"
46
-   mkdir -p ".bootstrap/config/${name}"
47
-   mkdir -p ".bootstrap/public_settings/${name}"
48
-   mkdir -p ".bootstrap/${name}.build"
49
-   mkdir -p ".bootstrap/${name}"
50
-
51
-   echo ".bootstrap/settings/${name}.txt"        > ".bootstrap/settings/${name}.txt"
52
-   echo ".bootstrap/config/${name}.txt"          > ".bootstrap/config/${name}.txt"
53
-   echo ".bootstrap/public_settings/${name}.txt" > ".bootstrap/public_settings/${name}.txt"
54
-
55
-   echo ".bootstrap/settings/${name}/${name}.txt"        > ".bootstrap/settings/${name}/${name}.txt"
56
-   echo ".bootstrap/config/${name}/${name}.txt"          > ".bootstrap/config/${name}/${name}.txt"
57
-   echo ".bootstrap/public_settings/${name}/${name}.txt" > ".bootstrap/public_settings/${name}/${name}.txt"
58
-
59
-   echo ".bootstrap/${name}.build/${name}.txt" > ".bootstrap/${name}.build/${name}.txt"
60
-   echo ".bootstrap/${name}/${name}.txt"      > ".bootstrap/${name}/${name}.txt"
61
-   echo ".bootstrap/${name}.txt"              > ".bootstrap/${name}.txt"
56
+   #  stuff that should not be copied
57
+   produce_file ".bootstrap/settings/${name}.build/${name}"
58
+   produce_file ".bootstrap/settings/${name}.d/${name}"
59
+   produce_file ".bootstrap/settings/${name}"
60
+   produce_file ".bootstrap/config/${name}.build/${name}"
61
+   produce_file ".bootstrap/config/${name}.d/${name}"
62
+   produce_file ".bootstrap/config/${name}"
63
+   produce_file ".bootstrap/${name}.d/${name}"
64
+
65
+   # stuff that should be copied
66
+   produce_file ".bootstrap/${name}"
67
+   produce_file ".bootstrap/bin/${name}.sh"
68
+   produce_file ".bootstrap/${name}.build/${name}"
69
+   produce_file ".bootstrap/${name}.build/bin/${name}.sh"
62 70
 }
63 71
 
64 72
 
... ...
@@ -72,22 +80,27 @@ setup()
72 80
    mkdir b
73 81
    mkdir c
74 82
 
75
-   cd c
76
-      create_settings "c"
77
-      cd ..
83
+   (
84
+      cd a
85
+      mkdir -p .bootstrap
86
+      echo "b" > .bootstrap/repositories
87
+   )
78 88
 
79
-   cd b
89
+   (
90
+      cd b
80 91
       mkdir -p .bootstrap
81 92
       echo "c" > .bootstrap/repositories
93
+
82 94
       create_settings "b"
83
-      mkdir -p ".bootstrap/c"
84
-      echo ".bootstrap/c/b.txt" > ".bootstrap/c/b.txt"
85
-      cd ..
95
+      produce_file ".bootstrap/c.build/override"
96
+   )
86 97
 
87
-   cd a
88
-      mkdir -p .bootstrap
89
-      echo "b" > .bootstrap/repositories
90
-      cd ..
98
+   (
99
+      cd c
100
+      create_settings "c"
101
+      produce_file ".bootstrap/c.build/inherit"
102
+      produce_file ".bootstrap/c.build/override"
103
+   )
91 104
 }
92 105
 
93 106
 
... ...
@@ -102,37 +115,50 @@ BOOTSTRAP_FLAGS="$@"
102 115
 
103 116
 setup
104 117
 
105
-echo ""
106
-echo ""
107
-echo "=== setup done ==="
108
-echo ""
109
-echo ""
110
-
111 118
 (
112 119
    cd a ;
113 120
    mulle-bootstrap -y ${BOOTSTRAP_FLAGS} fetch
114 121
 ) || exit 1
115 122
 
123
+[ -d "b/.bootstrap.auto" ] && fail "only a has a .auto folder"
124
+[ -d "c/.bootstrap.auto" ] && fail "only a has a .auto folder"
125
+
126
+[ "`cat a/.bootstrap.auto/c.build/inherit`" = "# c : .bootstrap/c.build/inherit" ] || fail "inheritance failed"
127
+[ "`cat a/.bootstrap.auto/c.build/override`" = "# b : .bootstrap/c.build/override" ] || fail "override failed"
128
+
129
+
116 130
 expect="`mktemp -t foo.xxxx`"
117 131
 result="`mktemp -t foo.xxxx`"
118
-ls -R1a a | sed '/^[.]*$/d' > "${result}"
132
+ls -R1a a | sed '/^$/d' | sed '/^[.]*$/d' > "${result}"
119 133
 cat <<EOF > "${expect}"
120 134
 .bootstrap
121 135
 .bootstrap.auto
122 136
 .bootstrap.repos
137
+stashes
123 138
 a/.bootstrap:
124 139
 repositories
125 140
 a/.bootstrap.auto:
126 141
 b.build
142
+build_order
127 143
 c.build
128 144
 repositories
129 145
 a/.bootstrap.auto/b.build:
130
-b.txt
146
+b
147
+bin
148
+a/.bootstrap.auto/b.build/bin:
149
+b.sh
131 150
 a/.bootstrap.auto/c.build:
132
-c.txt
151
+bin
152
+c
153
+inherit
154
+override
155
+a/.bootstrap.auto/c.build/bin:
156
+c.sh
133 157
 a/.bootstrap.repos:
134 158
 .bootstrap_fetch_done
135
-.bootstrap_refresh_done
159
+b
160
+c
161
+a/stashes:
136 162
 b
137 163
 c
138 164
 EOF
... ...
@@ -142,9 +168,9 @@ diff "${expect}" "${result}"
142 168
 
143 169
 rm -rf a b c
144 170
 
145
-echo ""
146
-echo ""
147
-echo "=== test done ==="
148
-echo ""
149
-echo ""
171
+echo "" >&2
172
+echo "" >&2
173
+echo "=== test done ===" >&2
174
+echo "" >&2
175
+echo "" >&2
150 176
 
... ...
@@ -1,4 +1,4 @@
1
-#! /bin/sh -x
1
+#! /bin/sh
2 2
 
3 3
 
4 4
 clear_test_dirs()
... ...
@@ -17,7 +17,7 @@ clear_test_dirs()
17 17
 
18 18
 fail()
19 19
 {
20
-   echo "failed" "$@" >&2
20
+   echo "failed:" "$@" >&2
21 21
    exit 1
22 22
 }
23 23
 
... ...
@@ -51,14 +51,14 @@ setup_test_case()
51 51
       git commit -m "bla bla"
52 52
    ) || exit 1
53 53
 
54
-   echo "../b" > a/.bootstrap/repositories
54
+   echo "b" > a/.bootstrap/repositories
55 55
 }
56 56
 
57 57
 
58 58
 
59 59
 move_test_case()
60 60
 {
61
-   echo "../b;b2" > a/.bootstrap/repositories
61
+   echo "b;b2" > a/.bootstrap/repositories
62 62
 }
63 63
 
64 64
 
... ...
@@ -66,34 +66,36 @@ assert_a_1()
66 66
 {
67 67
    result="`cat stashes/b/README.md`"
68 68
    [ "${result}" != "# VfL Bochum 1848" ] && fail "stashes not created ($result)"
69
+   :
69 70
 }
70 71
 
71 72
 
72 73
 assert_a_2()
73 74
 {
74 75
    result="`cat .bootstrap.auto/repositories`"
75
-   [ "../b;b2" != "${result}" ] &&  fail ".bootstrap.auto/repositories ($result)"
76
+   [ "b;b2" != "${result}" ] &&  fail ".bootstrap.auto/repositories ($result)"
76 77
 
77
-   [ ! -e "stashes/b2" ] && fail "stashes not created ($result)"
78
+   [ ! -e "b2" ] && fail "stashes not created ($result)"
78 79
 
79
-   result="`head -1 .bootstrap.repos/b2`"
80
-   [ "stashes/b2" != "${result}" ] && fail "($result)"
80
+   result="`head -1 .bootstrap.repos/b`"
81
+   [ "b2" != "${result}" ] && fail "($result)"
81 82
 
82
-   result="`cat stashes/b2/README.md`"
83
+   result="`cat b2/README.md`"
83 84
    [ "${result}" != "# VfL Bochum 1848" ] && fail "stashes not created ($result)"
85
+   :
84 86
 }
85 87
 
86 88
 
87 89
 _test_a_1()
88 90
 {
89
-   run_mulle_bootstrap "$@" -a fetch
91
+   run_mulle_bootstrap "$@" -y fetch  --no-symlink-creation
90 92
    assert_a_1
91 93
 }
92 94
 
93 95
 
94 96
 _test_a_2()
95 97
 {
96
-   run_mulle_bootstrap "$@" -a fetch
98
+   run_mulle_bootstrap "$@" -y fetch  --no-symlink-creation
97 99
    assert_a_2
98 100
 }
99 101