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 949
    then
952 950
       if [ $rval -eq 0 -o $rval -eq 2 ]
953 951
       then
954
-         local old_bootstrap
955 952
 #      local old_fetch
956 953
 
957
-         old_bootstrap="${BOOTSTRAP_SUBDIR}"
954
+         ROOT_BOOTSTRAP_SUBDIR="${BOOTSTRAP_SUBDIR}"
958 955
 #      old_fetch="${CLONESFETCH_SUBDIR}"
959 956
 
960 957
          BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
... ...
@@ -962,7 +959,7 @@ update_repository()
962 959
 
963 960
          update_embedded_repositories "${dstdir}/"
964 961
 
965
-         BOOTSTRAP_SUBDIR="${old_bootstrap}"
962
+         BOOTSTRAP_SUBDIR="${ROOT_BOOTSTRAP_SUBDIR}"
966 963
 #      CLONESFETCH_SUBDIR="${old_fetch}"
967 964
       fi
968 965
    fi
... ...
@@ -1488,7 +1485,6 @@ _common_main()
1488 1485
       fi
1489 1486
    fi
1490 1487
 
1491
-   remove_file_if_present "${CLONESFETCH_SUBDIR}/.refresh_done"
1492 1488
    remove_file_if_present "${CLONESFETCH_SUBDIR}/.fetch_done"
1493 1489
 
1494 1490
    #
... ...
@@ -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 276
 }
285 277
 
286 278
 
279
+expanded_embedded_variables()
280
+{
281
+   local memo1
282
+   local memo2
283
+
284
+   local value
285
+
286
+   [ -z "${ROOT_BOOTSTRAP_SUBDIR}" ] && internal_fail "root bootstrap"
287
+
288
+   # first search in /.bootstrap.auto
289
+   # a bit hackish
290
+
291
+   memo1="${MULLE_BOOTSTRAP_SETTINGS_NO_AUTO}"
292
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO=
293
+
294
+      memo2="${BOOTSTRAP_SUBDIR}"
295
+      BOOTSTRAP_SUBDIR="${ROOT_BOOTSTRAP_SUBDIR}"
296
+
297
+         value="`_expanded_variables "$1"`"
298
+
299
+      BOOTSTRAP_SUBDIR="${memo2}"
300
+
301
+      # then search in (embedded).bootstrap
302
+
303
+      if [ "$1" != "${value}" ]
304
+      then
305
+         log_fluff "Expanded \"$1\" to \"${value}\""
306
+      else
307
+         #
308
+         # else don't search in .auto
309
+         #
310
+         MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="YES"
311
+         value="`_expanded_variables "$1"`"
312
+
313
+         if [ "$1" != "${value}" ]
314
+         then
315
+            log_fluff "Expanded \"$1\" to \"${value}\""
316
+         fi
317
+      fi
318
+
319
+   MULLE_BOOTSTRAP_SETTINGS_NO_AUTO="${memo1}"
320
+
321
+   echo "$value"
322
+}
323
+
324
+
325
+
287 326
 source_environment_file()
288 327
 {
289 328
    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 105
             clone="`expanded_variables "${unexpanded}"`"
101 106
             __parse_expanded_clone "${clone}"
102 107
 
108
+            dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${unexpanded}"`"
109
+
103 110
             dstdir="${CLONESFETCH_SUBDIR}/${name}"
104 111
             if [ ! -d "${dstdir}" ]
105 112
             then
... ...
@@ -111,21 +118,23 @@ ${unexpanded}"
111 118
             # dependency management, it could be nicer, but isn't.
112 119
             # Currently matches only URLs
113 120
             #
121
+
114 122
             local sub_repos
115 123
             local filename
116 124
 
117 125
             filename="${dstdir}/${BOOTSTRAP_SUBDIR}/repositories"
118 126
             if [ -f "${filename}" ]
119 127
             then
128
+
120 129
                sub_repos="`_read_setting "${filename}"`"
121 130
                if [ ! -z "${sub_repos}" ]
122 131
                then
123 132
 #                  unexpanded_url="`url_from_clone "${unexpanded}"`"
124
-                  dependency_map="`dependency_add "${dependency_map}" "__ROOT__" "${unexpanded}"`"
125 133
                   dependency_map="`dependency_add_array "${dependency_map}" "${unexpanded}" "${sub_repos}"`"
126 134
                   if [ "$MULLE_BOOTSTRAP_TRACE_SETTINGS" = "YES" -o "$MULLE_BOOTSTRAP_TRACE_MERGE" = "YES"  ]
127 135
                   then
128
-                     log_trace2 "add \"${sub_repos}\" for ${unexpanded} to ${dependency_map}"
136
+                     log_trace2 "add \"${unexpanded}\" to __ROOT__ as dependencies"
137
+                     log_trace2 "add [ ${sub_repos} ] to ${unexpanded} as dependencies"
129 138
                   fi
130 139
                fi
131 140
             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 29
    echo "b
31 30
 e" > a/.bootstrap/repositories
32 31
 
33
-
34 32
    echo "d
35 33
 c" > b/.bootstrap/repositories
36 34
 
... ...
@@ -92,6 +90,7 @@ b"
92 90
 
93 91
 ( setup_test_case2 ; test "d
94 92
 c
95
-b"
93
+b
94
+e"
96 95
 )
97 96