Browse code

Improve dependency calculation

Nat! authored on 24/10/2016 11:32:07
Showing 6 changed files
... ...
@@ -23,12 +23,12 @@ $ cat MULLE_C11_BRANCH
23 23
 master
24 24
 ```
25 25
 
26
-Changes:
26
+### Changes
27 27
 
28 28
 * clarified the use of options vs. flags some more. e.g. git GITFLAGS command GITOPTIONS.
29 29
 * update will now also refresh
30
-* improved refresh check, should not properly detect edited config files if the
31
-edit is at least a second after the last refresh run. Death of the hidden -fr flag
30
+* improved refresh check, should now properly detect edited config files, except if the
31
+edit is less than a second after the last refresh run. Death of the hidden -fr flag
32 32
 * start version checking bootstrap contents
33 33
 * -f flag will now also try to checkout branches, that are checked out
34 34
 incorrectly
... ...
@@ -38,6 +38,8 @@ incorrectly
38 38
 * mulle-bootstrap now picks up URL changes and corrects them in fetched
39 39
 repositiories, but that does not per se force an update.
40 40
 * try to detect changes in .bootstrap better
41
+* improved retrieval of settings for embedded repositories
42
+* improved dependency code
41 43
 
42 44
 
43 45
 2.2.1
... ...
@@ -215,6 +215,8 @@ bootstrap_auto_create()
215 215
 {
216 216
    log_verbose "Creating .bootstrap.auto from .bootstrap and .bootstrap.local"
217 217
 
218
+   [ -z "${BOOTSTRAP_SUBDIR}" ] && internal_fail "empty bootstrap"
219
+
218 220
    assert_mulle_bootstrap_version
219 221
 
220 222
    mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto"
... ...
@@ -694,13 +694,11 @@ checkout_repository()
694 694
 
695 695
    if [ "${COMMAND}" = "fetch" -a "${DONT_RECURSE}" = "" ]
696 696
    then
697
-      local old_bootstrap
698
-
699
-      old_bootstrap="${BOOTSTRAP_SUBDIR}"
697
+      ROOT_BOOTSTRAP_SUBDIR="${BOOTSTRAP_SUBDIR}"
700 698
 
701 699
       BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
702 700
       clone_embedded_repositories "${dstdir}/"
703
-      BOOTSTRAP_SUBDIR="${old_bootstrap}"
701
+      BOOTSTRAP_SUBDIR="${ROOT_BOOTSTRAP_SUBDIR}"
704 702
    fi
705 703
 
706 704
    if [ $run_script -eq 0 ]
... ...
@@ -951,10 +949,9 @@ update_repository()
951 951
    then
952 952
       if [ $rval -eq 0 -o $rval -eq 2 ]
953 953
       then
954
-         local old_bootstrap
955 954
 #      local old_fetch
956 955
 
957
-         old_bootstrap="${BOOTSTRAP_SUBDIR}"
956
+         ROOT_BOOTSTRAP_SUBDIR="${BOOTSTRAP_SUBDIR}"
958 957
 #      old_fetch="${CLONESFETCH_SUBDIR}"
959 958
 
960 959
          BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
... ...
@@ -962,7 +959,7 @@ update_repository()
962 962
 
963 963
          update_embedded_repositories "${dstdir}/"
964 964
 
965
-         BOOTSTRAP_SUBDIR="${old_bootstrap}"
965
+         BOOTSTRAP_SUBDIR="${ROOT_BOOTSTRAP_SUBDIR}"
966 966
 #      CLONESFETCH_SUBDIR="${old_fetch}"
967 967
       fi
968 968
    fi
... ...
@@ -1488,7 +1485,6 @@ _common_main()
1488 1488
       fi
1489 1489
    fi
1490 1490
 
1491
-   remove_file_if_present "${CLONESFETCH_SUBDIR}/.refresh_done"
1492 1491
    remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_done"
1493 1492
 
1494 1493
    #
... ...
@@ -263,18 +263,10 @@ _expanded_variables()
263 263
 
264 264
 expanded_variables()
265 265
 {
266
-   local memo
267 266
    local value
268 267
 
269
-   # a hack ?
270
-
271
-   memo="${MULLE_BOOTSTRAP_SETTINGS_NO_AUTO}"
272
-   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="NO"
273
-
274 268
    value="`_expanded_variables "$1"`"
275 269
 
276
-   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="${memo}"
277
-
278 270
    if [ "$1" != "${value}" ]
279 271
    then
280 272
       log_fluff "Expanded \"$1\" to \"${value}\""
... ...
@@ -284,6 +276,53 @@ expanded_variables()
284 284
 }
285 285
 
286 286
 
287
+expanded_embedded_variables()
288
+{
289
+   local memo1
290
+   local memo2
291
+
292
+   local value
293
+
294
+   [ -z "${ROOT_BOOTSTRAP_SUBDIR}" ] && internal_fail "root bootstrap"
295
+
296
+   # first search in /.bootstrap.auto
297
+   # a bit hackish
298
+
299
+   memo1="${MULLE_BOOTSTRAP_SETTINGS_NO_AUTO}"
300
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
301
+
302
+      memo2="${BOOTSTRAP_SUBDIR}"
303
+      BOOTSTRAP_SUBDIR="${ROOT_BOOTSTRAP_SUBDIR}"
304
+
305
+         value="`_expanded_variables "$1"`"
306
+
307
+      BOOTSTRAP_SUBDIR="${memo2}"
308
+
309
+      # then search in (embedded).bootstrap
310
+
311
+      if [ "$1" != "${value}" ]
312
+      then
313
+         log_fluff "Expanded \"$1\" to \"${value}\""
314
+      else
315
+         #
316
+         # else don't search in .auto
317
+         #
318
+         MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
319
+         value="`_expanded_variables "$1"`"
320
+
321
+         if [ "$1" != "${value}" ]
322
+         then
323
+            log_fluff "Expanded \"$1\" to \"${value}\""
324
+         fi
325
+      fi
326
+
327
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="${memo1}"
328
+
329
+   echo "$value"
330
+}
331
+
332
+
333
+
287 334
 source_environment_file()
288 335
 {
289 336
    local filename
... ...
@@ -70,7 +70,7 @@ refresh_repositories_settings()
70 70
       stop=1
71 71
 
72 72
       clones="`read_fetch_setting "repositories"`"
73
-      if [ "${clones}" != "" ]
73
+      if [ ! -z "${clones}" ]
74 74
       then
75 75
          IFS="
76 76
 "
... ...
@@ -87,6 +87,11 @@ refresh_repositories_settings()
87 87
             refreshed="${refreshed}
88 88
 ${unexpanded}"
89 89
 
90
+            if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
91
+            then
92
+               log_trace2 "Dealing with ${unexpanded}"
93
+            fi
94
+
90 95
             # avoid superflous updates
91 96
 
92 97
             local branch
... ...
@@ -100,6 +105,8 @@ ${unexpanded}"
100 100
             clone="`expanded_variables "${unexpanded}"`"
101 101
             __parse_expanded_clone "${clone}"
102 102
 
103
+            dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${unexpanded}"`"
104
+
103 105
             dstdir="${CLONESFETCH_SUBDIR}/${name}"
104 106
             if [ ! -d "${dstdir}" ]
105 107
             then
... ...
@@ -111,21 +118,23 @@ ${unexpanded}"
111 111
             # dependency management, it could be nicer, but isn't.
112 112
             # Currently matches only URLs
113 113
             #
114
+
114 115
             local sub_repos
115 116
             local filename
116 117
 
117 118
             filename="${dstdir}/${BOOTSTRAP_SUBDIR}/repositories"
118 119
             if [ -f "${filename}" ]
119 120
             then
121
+
120 122
                sub_repos="`_read_setting "${filename}"`"
121 123
                if [ ! -z "${sub_repos}" ]
122 124
                then
123 125
 #                  unexpanded_url="`url_from_clone "${unexpanded}"`"
124
-                  dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${unexpanded}"`"
125 126
                   dependency_map="`dependency_add_array "${dependency_map}" "${unexpanded}" "${sub_repos}"`"
126 127
                   if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
127 128
                   then
128
-                     log_trace2 "add \"${sub_repos}\" for ${unexpanded} to ${dependency_map}"
129
+                     log_trace2 "add \"${unexpanded}\" to __ROOT__ as dependencies"
130
+                     log_trace2 "add [ ${sub_repos} ] to ${unexpanded} as dependencies"
129 131
                   fi
130 132
                fi
131 133
             else
... ...
@@ -16,7 +16,6 @@ setup_test_case1()
16 16
    echo "b
17 17
 e" > a/.bootstrap/repositories
18 18
 
19
-
20 19
    echo "d
21 20
 c" > b/.bootstrap/repositories
22 21
 
... ...
@@ -30,7 +29,6 @@ setup_test_case2()
30 30
    echo "b
31 31
 e" > a/.bootstrap/repositories
32 32
 
33
-
34 33
    echo "d
35 34
 c" > b/.bootstrap/repositories
36 35
 
... ...
@@ -92,6 +90,7 @@ b"
92 92
 
93 93
 ( setup_test_case2 ; test "d
94 94
 c
95
-b"
95
+b
96
+e"
96 97
 )
97 98