Browse code

Use required code for embedded repositories too. Generally improve the code there a bit. Make the burying of symlinks more silent. Rename MULLE_FLAG_...EXECUTOR to MULLE_FLAG_... EXEKUTOR. Fix some bugs.

Nat! authored on 31/03/2017 12:04:43
Showing 16 changed files
... ...
@@ -1,3 +1,12 @@
1
+### 3.1.0
2
+
3
+You can allow optional fetches to fail my listing repository-names, that
4
+are required. (embeded_repositories <-> embedded_required)
5
+Fixes some bugs.
6
+
7
+Still alpha though.
8
+
9
+
1 10
 # 3.0
2 11
 
3 12
 #### New commands: defer, emancipate, flags, status
... ...
@@ -29,8 +29,8 @@
29 29
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 MULLE_EXECUTABLE_VERSION_MAJOR=3
32
-MULLE_EXECUTABLE_VERSION_MINOR=0
33
-MULLE_EXECUTABLE_VERSION_PATCH=2
32
+MULLE_EXECUTABLE_VERSION_MINOR=1
33
+MULLE_EXECUTABLE_VERSION_PATCH=0
34 34
 
35 35
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
36 36
 
... ...
@@ -259,14 +259,13 @@ bootstrap_main()
259 259
    local MULLE_FLAG_VERBOSE_BUILD="NO"
260 260
 
261 261
    # technical flags
262
-   local MULLE_FLAG_EXECUTOR_DRY_RUN="NO"
262
+   local MULLE_FLAG_DONT_DEFER="NO"
263
+   local MULLE_FLAG_EXEKUTOR_DRY_RUN="NO"
263 264
    local MULLE_FLAG_FOLLOW_SYMLINKS="YES"
264 265
    local MULLE_FLAG_LOG_CACHE="NO"
265 266
    local MULLE_FLAG_LOG_DEBUG="NO"
266
-   local MULLE_FLAG_LOG_EXECUTOR="NO"
267
-   local MULLE_FLAG_LOG_EXECUTOR="NO"
267
+   local MULLE_FLAG_LOG_EXEKUTOR="NO"
268 268
    local MULLE_FLAG_LOG_FLUFF="NO"
269
-   local MULLE_FLAG_DONT_DEFER="NO"
270 269
    local MULLE_FLAG_LOG_SCRIPTS="NO"
271 270
    local MULLE_FLAG_LOG_SETTINGS="NO"
272 271
    local MULLE_FLAG_LOG_VERBOSE="NO"
... ...
@@ -29,8 +29,8 @@
29 29
 #   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 MULLE_EXECUTABLE_VERSION_MAJOR=3
32
-MULLE_EXECUTABLE_VERSION_MINOR=0
33
-MULLE_EXECUTABLE_VERSION_PATCH=2
32
+MULLE_EXECUTABLE_VERSION_MINOR=1
33
+MULLE_EXECUTABLE_VERSION_PATCH=0
34 34
 
35 35
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
36 36
 
... ...
@@ -189,11 +189,11 @@ brew_main()
189 189
    local ps4string
190 190
 
191 191
    # technical flags
192
-   local MULLE_FLAG_EXECUTOR_DRY_RUN="NO"
192
+   local MULLE_FLAG_EXEKUTOR_DRY_RUN="NO"
193 193
    local MULLE_FLAG_LOG_CACHE="NO"
194 194
    local MULLE_FLAG_LOG_DEBUG="NO"
195
-   local MULLE_FLAG_LOG_EXECUTOR="NO"
196
-   local MULLE_FLAG_LOG_EXECUTOR="NO"
195
+   local MULLE_FLAG_LOG_EXEKUTOR="NO"
196
+   local MULLE_FLAG_LOG_EXEKUTOR="NO"
197 197
    local MULLE_FLAG_LOG_FLUFF="NO"
198 198
    local MULLE_FLAG_LOG_SCRIPTS="NO"
199 199
    local MULLE_FLAG_LOG_SETTINGS="NO"
... ...
@@ -235,7 +235,7 @@ brew_main()
235 235
 
236 236
    bootstrap_setup_trace "${MULLE_TRACE}"
237 237
 
238
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" ]
238
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" ]
239 239
    then
240 240
       log_trace "Dry run is active."
241 241
    fi
... ...
@@ -141,14 +141,15 @@ _bootstrap_auto_copy()
141 141
 _bootstrap_create_required_if_needed()
142 142
 {
143 143
    dst="$1"
144
+   prefix="$2"
144 145
 
145 146
    #
146 147
    # if there is no required file add all names from repositories
147 148
    # which ought to have been expanded already
148 149
    #
149
-   if [ ! -f "${dst}/required" -a -f "${dst}/repositories" ]
150
+   if [ ! -f "${dst}/${prefix}required" -a -f "${dst}/${prefix}repositories" ]
150 151
    then
151
-      redirect_exekutor "${dst}/required" names_from_repository_file "${dst}/repositories"
152
+      redirect_exekutor "${dst}/${prefix}required" names_from_repository_file "${dst}/${prefix}repositories"
152 153
    fi
153 154
 }
154 155
 
... ...
@@ -192,6 +193,7 @@ _bootstrap_auto_create()
192 192
    fi
193 193
 
194 194
    _bootstrap_create_required_if_needed "${dst}"
195
+   _bootstrap_create_required_if_needed "${dst}" "embedded_"
195 196
 }
196 197
 
197 198
 
... ...
@@ -307,6 +309,7 @@ _bootstrap_auto_merge_root_settings()
307 307
    done
308 308
 
309 309
    _bootstrap_create_required_if_needed "${dst}"
310
+   _bootstrap_create_required_if_needed "${dst}" "embedded_"
310 311
 }
311 312
 
312 313
 
... ...
@@ -337,6 +340,7 @@ _bootstrap_auto_special_copy()
337 337
       STASHES_DEFAULT_DIR=""
338 338
       STASHES_ROOT_DIR="${directory}"
339 339
       merge_repository_files "${filepath}" "${dstfilepath}" "NO"
340
+
340 341
    )
341 342
 }
342 343
 
... ...
@@ -346,6 +350,8 @@ _bootstrap_auto_embedded_copy()
346 346
    log_debug ":_bootstrap_auto_embedded_copy:"
347 347
 
348 348
    _bootstrap_auto_special_copy "embedded_repositories" "$@"
349
+
350
+   _bootstrap_create_required_if_needed "${BOOTSTRAP_DIR}.auto/.deep/${name}.d" "embedded_"
349 351
 }
350 352
 
351 353
 
... ...
@@ -552,6 +558,9 @@ bootstrap_auto_final()
552 552
       fi
553 553
    done
554 554
 
555
+   # get rid of temporary file now
556
+   remove_file_if_present "${REPOS_DIR}/.missing"
557
+
555 558
    IFS="${DEFAULT_IFS}"
556 559
 
557 560
    redirect_exekutor "${BOOTSTRAP_DIR}.auto/build_order" echo "${order}"
... ...
@@ -962,7 +962,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
962 962
          logfile1="`tty`"
963 963
          logfile2="$logfile1"
964 964
       fi
965
-      if [ "$MULLE_FLAG_EXECUTOR_DRY_RUN" = "YES" ]
965
+      if [ "$MULLE_FLAG_EXEKUTOR_DRY_RUN" = "YES" ]
966 966
       then
967 967
          logfile1="/dev/null"
968 968
          logfile2="/dev/null"
... ...
@@ -1208,7 +1208,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
1208 1208
          logfile1="`tty`"
1209 1209
          logfile2="$logfile1"
1210 1210
       fi
1211
-      if [ "$MULLE_FLAG_EXECUTOR_DRY_RUN" = "YES" ]
1211
+      if [ "$MULLE_FLAG_EXEKUTOR_DRY_RUN" = "YES" ]
1212 1212
       then
1213 1213
          logfile1="/dev/null"
1214 1214
          logfile2="/dev/null"
... ...
@@ -1509,7 +1509,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1509 1509
    local owd
1510 1510
    local command
1511 1511
 
1512
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" ]
1512
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" ]
1513 1513
    then
1514 1514
       command=-showBuildSettings
1515 1515
    else
... ...
@@ -1599,7 +1599,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO}${info} in \
1599 1599
       then
1600 1600
          logfile="`tty`"
1601 1601
       fi
1602
-      if [ "$MULLE_FLAG_EXECUTOR_DRY_RUN" = "YES" ]
1602
+      if [ "$MULLE_FLAG_EXEKUTOR_DRY_RUN" = "YES" ]
1603 1603
       then
1604 1604
          logfile="/dev/null"
1605 1605
       fi
... ...
@@ -1817,7 +1817,7 @@ build_script()
1817 1817
       then
1818 1818
          logfile="`tty`"
1819 1819
       fi
1820
-      if [ "$MULLE_FLAG_EXECUTOR_DRY_RUN" = "YES" ]
1820
+      if [ "$MULLE_FLAG_EXEKUTOR_DRY_RUN" = "YES" ]
1821 1821
       then
1822 1822
          logfile="/dev/null"
1823 1823
       fi
... ...
@@ -580,27 +580,7 @@ clone_or_symlink()
580 580
                        "${tag}" \
581 581
                        "${stashdir}"
582 582
    then
583
-      #
584
-      # check if clone is an optional install component
585
-      # it is if it doesn't show up in "required"
586
-      # required is built by mulle-bootstrap usually
587
-      # you specify optionals, by specifying the required
588
-      # clones and leaving the optional out
589
-      #
590
-      local required
591
-
592
-      required="`read_root_setting "required"`"
593
-      [ -z "${required}" ] && internal_fail "required missing"
594
-
595
-      if ! echo "${required}" | fgrep -s -q -x "${name}" > /dev/null
596
-      then
597
-         log_info "${C_MAGENTA}${C_BOLD}${name}${C_INFO} is missing, but it's not required."
598
-
599
-         merge_line_into_file "${REPOS_DIR}/.missing" "${name}"
600
-         return 1  # means just skip
601
-      fi
602
-
603
-      return  # means exit
583
+      return 1
604 584
    fi
605 585
 
606 586
    if [ "${DONT_WARN_SCRIPTS}" != "YES" ]
... ...
@@ -1092,7 +1072,8 @@ work_clones()
1092 1092
 {
1093 1093
    local reposdir="$1"
1094 1094
    local clones="$2"
1095
-   local autoupdate="$3"
1095
+   local required_clones="$3"
1096
+   local autoupdate="$4"
1096 1097
 
1097 1098
    local clone
1098 1099
    local name
... ...
@@ -1177,6 +1158,9 @@ work_clones()
1177 1177
 
1178 1178
          log_debug "${C_INFO}Actions for \"${name}\": ${actionitems:-none}"
1179 1179
 
1180
+         local skip
1181
+
1182
+         skip="NO"
1180 1183
          IFS="
1181 1184
 "
1182 1185
          for item in ${actionitems}
... ...
@@ -1207,17 +1191,29 @@ work_clones()
1207 1207
 
1208 1208
                   case "$?" in
1209 1209
                      1)
1210
-                        # skipped
1211
-                        continue
1210
+                        #
1211
+                        # check if clone is an optional install component
1212
+                        # it is if it doesn't show up in "required"
1213
+                        # required is built by mulle-bootstrap usually
1214
+                        # you specify optionals, by specifying the required
1215
+                        # clones and leaving the optional out
1216
+                        #
1217
+                        if ! echo "${required_clones}" | fgrep -s -q -x "${name}" > /dev/null
1218
+                        then
1219
+                           log_info "${C_MAGENTA}${C_BOLD}${name}${C_INFO} is missing, but it's not required."
1220
+
1221
+                           merge_line_into_file "${REPOS_DIR}/.missing" "${name}"
1222
+                           skip="YES"
1223
+                           continue
1224
+                        fi
1225
+
1226
+                        exit 1  # means exit
1212 1227
                      ;;
1228
+
1213 1229
                      2)
1214 1230
                         # if we used a symlink, we want to memorize that
1215 1231
                         scm="symlink"
1216 1232
                      ;;
1217
-
1218
-                     3)
1219
-                        exit 1
1220
-                     ;;
1221 1233
                   esac
1222 1234
                ;;
1223 1235
 
... ...
@@ -1284,6 +1280,11 @@ work_clones()
1284 1284
          clone="`echo "${url};${dstdir};${branch};${scm};${tag}" | sed 's/;*$//'`"
1285 1285
       fi
1286 1286
 
1287
+      if [ "${skip}" = "YES" ]
1288
+      then
1289
+         continue
1290
+      fi
1291
+
1287 1292
       #
1288 1293
       # always remember, what we have now (except if its a minion)
1289 1294
       #
... ...
@@ -1317,9 +1318,11 @@ fetch_once_embedded_repositories()
1317 1317
       OPTION_ALLOW_CREATING_SYMLINKS="${OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS}" ;
1318 1318
 
1319 1319
       local clones
1320
+      local required_clones
1320 1321
 
1321 1322
       clones="`read_root_setting "embedded_repositories"`" ;
1322
-      work_clones "${EMBEDDED_REPOS_DIR}" "${clones}" "NO"
1323
+      required_clones="`read_root_setting "embedded_required"`" ;
1324
+      work_clones "${EMBEDDED_REPOS_DIR}" "${clones}" "${required_clones}" "NO"
1323 1325
    ) || exit 1
1324 1326
 }
1325 1327
 
... ...
@@ -1370,9 +1373,11 @@ fetch_once_minions_embedded_repositories()
1370 1370
          OPTION_ALLOW_CREATING_SYMLINKS="${OPTION_ALLOW_CREATING_EMBEDDED_SYMLINKS}" ;
1371 1371
 
1372 1372
          local clones
1373
+         local required_clones
1373 1374
 
1374 1375
          clones="`read_setting "${autodir}/embedded_repositories"`" ;
1375
-         work_clones "${reposdir}" "${clones}" "NO"
1376
+         required_clones="`read_setting "${autodir}/embedded_required"`" ;
1377
+         work_clones "${reposdir}" "${clones}" "${required_clones}" "NO"
1376 1378
       ) || exit 1
1377 1379
    done
1378 1380
 
... ...
@@ -1409,10 +1414,12 @@ _fetch_once_deep_embedded_repository()
1409 1409
       PARENT_CLONE="${clone}"
1410 1410
 
1411 1411
       local clones
1412
+      local required_clones
1412 1413
 
1413 1414
       # ugliness
1414 1415
       clones="`read_setting "${autodir}/embedded_repositories"`" ;
1415
-      work_clones "${reposdir}" "${clones}" "NO"
1416
+      required_clones="`read_setting "${autodir}/embedded_required"`" ;
1417
+      work_clones "${reposdir}" "${clones}" "${required_clones}" "NO"
1416 1418
    ) || exit 1
1417 1419
 }
1418 1420
 
... ...
@@ -1445,6 +1452,7 @@ fetch_loop_repositories()
1445 1445
    local loops
1446 1446
    local before
1447 1447
    local after
1448
+   local required
1448 1449
 
1449 1450
    log_debug "fetch_loop_repositories"
1450 1451
 
... ...
@@ -1477,7 +1485,8 @@ fetch_loop_repositories()
1477 1477
 
1478 1478
       __REFRESHED__=""
1479 1479
 
1480
-      work_clones "${REPOS_DIR}" "${before}" "YES"
1480
+      required="`read_root_setting "required"`"
1481
+      work_clones "${REPOS_DIR}" "${before}" "${required}" "YES"
1481 1482
 
1482 1483
       __IGNORE__="`add_line "${__IGNORE__}" "${__REFRESHED__}"`"
1483 1484
 
... ...
@@ -46,7 +46,7 @@ MULLE_BOOTSTRAP_FUNCTIONS_VERSION="3.0"
46 46
 
47 47
 exekutor_trace()
48 48
 {
49
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" -o "${MULLE_FLAG_LOG_EXECUTOR}" = "YES" ]
49
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" -o "${MULLE_FLAG_LOG_EXEKUTOR}" = "YES" ]
50 50
    then
51 51
       local arrow
52 52
 
... ...
@@ -59,11 +59,11 @@ exekutor_trace()
59 59
          arrow="==>"
60 60
       fi
61 61
 
62
-      if [ -z "${MULLE_EXECUTOR_LOG_DEVICE}" ]
62
+      if [ -z "${MULLE_EXEKUTOR_LOG_DEVICE}" ]
63 63
       then
64 64
          echo "${arrow}" "$@" >&2
65 65
       else
66
-         echo "${arrow}" "$@" > "${MULLE_EXECUTOR_LOG_DEVICE}"
66
+         echo "${arrow}" "$@" > "${MULLE_EXEKUTOR_LOG_DEVICE}"
67 67
       fi
68 68
    fi
69 69
 }
... ...
@@ -73,7 +73,7 @@ exekutor_trace_output()
73 73
 {
74 74
    local output="$1"; shift
75 75
 
76
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" -o "${MULLE_FLAG_LOG_EXECUTOR}" = "YES" ]
76
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" -o "${MULLE_FLAG_LOG_EXEKUTOR}" = "YES" ]
77 77
    then
78 78
       local arrow
79 79
 
... ...
@@ -86,11 +86,11 @@ exekutor_trace_output()
86 86
          arrow="==>"
87 87
       fi
88 88
 
89
-      if [ -z "${MULLE_EXECUTOR_LOG_DEVICE}" ]
89
+      if [ -z "${MULLE_EXEKUTOR_LOG_DEVICE}" ]
90 90
       then
91 91
          echo "${arrow}" "$@" ">" "${output}" >&2
92 92
       else
93
-         echo "${arrow}" "$@" ">" "${output}" > "${MULLE_EXECUTOR_LOG_DEVICE}"
93
+         echo "${arrow}" "$@" ">" "${output}" > "${MULLE_EXEKUTOR_LOG_DEVICE}"
94 94
       fi
95 95
    fi
96 96
 }
... ...
@@ -101,7 +101,7 @@ exekutor()
101 101
 {
102 102
    exekutor_trace "$@"
103 103
 
104
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
104
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" != "YES" ]
105 105
    then
106 106
       "$@"
107 107
    fi
... ...
@@ -112,7 +112,7 @@ eval_exekutor()
112 112
 {
113 113
    exekutor_trace "$@"
114 114
 
115
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
115
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" != "YES" ]
116 116
    then
117 117
       ( eval "$@" )
118 118
    fi
... ...
@@ -125,7 +125,7 @@ redirect_exekutor()
125 125
 
126 126
    exekutor_trace_output "${output}" "$@"
127 127
 
128
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
128
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" != "YES" ]
129 129
    then
130 130
       ( "$@" ) > "${output}"
131 131
    fi
... ...
@@ -138,7 +138,7 @@ redirect_append_exekutor()
138 138
 
139 139
    exekutor_trace_output "${output}" "$@"
140 140
 
141
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
141
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" != "YES" ]
142 142
    then
143 143
       ( "$@" ) >> "${output}"
144 144
    fi
... ...
@@ -151,7 +151,7 @@ _redirect_append_eval_exekutor()
151 151
 
152 152
    exekutor_trace_output "${output}" "$@"
153 153
 
154
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
154
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" != "YES" ]
155 155
    then
156 156
       ( eval "$@" ) >> "${output}"
157 157
    fi
... ...
@@ -57,12 +57,12 @@ bootstrap_setup_trace()
57 57
       FLUFF)
58 58
          MULLE_FLAG_LOG_FLUFF="YES"
59 59
          MULLE_FLAG_LOG_VERBOSE="YES"
60
-         MULLE_FLAG_LOG_EXECUTOR="YES"
60
+         MULLE_FLAG_LOG_EXEKUTOR="YES"
61 61
       ;;
62 62
 
63 63
       TRACE)
64 64
          MULLE_FLAG_LOG_SETTINGS="YES"
65
-         MULLE_FLAG_LOG_EXECUTOR="YES"
65
+         MULLE_FLAG_LOG_EXEKUTOR="YES"
66 66
          MULLE_FLAG_LOG_FLUFF="YES"
67 67
          MULLE_FLAG_LOG_VERBOSE="YES"
68 68
          bootstrap_dump_env
... ...
@@ -113,7 +113,7 @@ bootstrap_technical_flags()
113 113
 {
114 114
    case "$1" in
115 115
       -n|--dry-run)
116
-         MULLE_FLAG_EXECUTOR_DRY_RUN="YES"
116
+         MULLE_FLAG_EXEKUTOR_DRY_RUN="YES"
117 117
       ;;
118 118
 
119 119
       -lc|--log-cache)
... ...
@@ -125,7 +125,7 @@ bootstrap_technical_flags()
125 125
       ;;
126 126
 
127 127
       -le|--log-execution)
128
-         MULLE_FLAG_LOG_EXECUTOR="YES"
128
+         MULLE_FLAG_LOG_EXEKUTOR="YES"
129 129
       ;;
130 130
 
131 131
       -lm|--log-merge)
... ...
@@ -831,7 +831,7 @@ local_environment_main()
831 831
    log_debug ":local_environment_main:"
832 832
    # source_environment
833 833
 
834
-   if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" ]
834
+   if [ "${MULLE_FLAG_EXEKUTOR_DRY_RUN}" = "YES" ]
835 835
    then
836 836
       log_trace "Dry run is active."
837 837
    fi
... ...
@@ -40,11 +40,11 @@ MULLE_BOOTSTRAP_LOGGING_VERSION="3.0"
40 40
 #
41 41
 log_printf()
42 42
 {
43
-   if [ -z "${MULLE_EXECUTOR_LOG_DEVICE}" ]
43
+   if [ -z "${MULLE_EXEKUTOR_LOG_DEVICE}" ]
44 44
    then
45 45
       printf "$@" >&2
46 46
    else
47
-      printf "$@" > "${MULLE_EXECUTOR_LOG_DEVICE}"
47
+      printf "$@" > "${MULLE_EXEKUTOR_LOG_DEVICE}"
48 48
    fi
49 49
 }
50 50
 
... ...
@@ -34,7 +34,7 @@ paths_usage()
34 34
 {
35 35
     cat <<EOF >&2
36 36
 usage:
37
-   mulle-bootstrap paths [options] <type>
37
+   mulle-bootstrap paths [options] <type>+
38 38
 
39 39
    Options:
40 40
       -1             : output is a one-liner
... ...
@@ -65,12 +65,14 @@ EOF
65 65
 __collect_libraries()
66 66
 {
67 67
    local i
68
+   local name
68 69
 
69 70
    for i in "$1/"*
70 71
    do
71
-      case "$i" in
72
-         *.a|*.so|*.dylib|*.lib)
73
-            echo "$i" | 's/\.[^.]*$//'
72
+      name="`basename "$i"`"
73
+      case "${name}" in
74
+         lib*.a|lib*.lib)
75
+            echo "${name}" | sed 's/\.[^.]*$//' | sed 's/^lib//'
74 76
          ;;
75 77
       esac
76 78
    done
... ...
@@ -80,12 +82,14 @@ __collect_libraries()
80 80
 __collect_frameworks()
81 81
 {
82 82
    local i
83
+   local name
83 84
 
84 85
    for i in "$1/"*
85 86
    do
86
-      case "$i" in
87
+      name="`basename "$i"`"
88
+      case "${name}" in
87 89
          *.framework)
88
-            echo "$i" | 's/\.[^.]*$//'
90
+            basename "${name}" | sed 's/\.[^.]*$//'
89 91
          ;;
90 92
       esac
91 93
    done
... ...
@@ -173,7 +177,7 @@ _flags_emit_option()
173 173
       then
174 174
          directory="`absolutepath "${directory}"`"
175 175
       fi
176
-      echo "${prefix}'${directory}'"
176
+      echo "${prefix}${OPTION_QUOTE}${directory}${OPTION_QUOTE}"
177 177
    fi
178 178
 }
179 179
 
... ...
@@ -241,7 +245,7 @@ _flags_ldflags_value()
241 241
       for i in `collect_libraries`
242 242
       do
243 243
          IFS="${DEFAULT_IFS}"
244
-         echo "'-l$i'"
244
+         echo "${OPTION_QUOTE}-l$i${OPTION_QUOTE}"
245 245
       done
246 246
       IFS="${DEFAULT_IFS}"
247 247
    fi
... ...
@@ -256,13 +260,20 @@ _flags_ldflags_value()
256 256
       for i in `collect_frameworks`
257 257
       do
258 258
          IFS="${DEFAULT_IFS}"
259
-         echo "-framework '$i'"
259
+         echo "-framework ${OPTION_QUOTE}$i${OPTION_QUOTE}"
260 260
       done
261 261
       IFS="${DEFAULT_IFS}"
262 262
    fi
263 263
 }
264 264
 
265 265
 
266
+_flags_cflags_value()
267
+{
268
+   _flags_cppflags_value "$@"
269
+   _flags_ldflags_value "$@"
270
+}
271
+
272
+
266 273
 #
267 274
 # Construct search paths
268 275
 #
... ...
@@ -471,7 +482,6 @@ _flags_do_environment()
471 471
 paths_main()
472 472
 {
473 473
    local types
474
-   local separator
475 474
 
476 475
    # semi-local
477 476
    local OPTION_SUPPRESS_FRAMEWORK_CFLAGS="NO"
... ...
@@ -486,6 +496,8 @@ paths_main()
486 486
    local OPTION_WITH_LIBRARYPATHS="YES"
487 487
    local OPTION_WITH_MISSING_PATHS="NO"
488 488
    local OPTION_PATH_SEPARATOR=":"
489
+   local OPTION_QUOTE="'"
490
+   local OPTION_LINE_SEPERATOR="\n"
489 491
 
490 492
    log_debug ":paths_main:"
491 493
 
... ...
@@ -508,7 +520,6 @@ paths_main()
508 508
       OPTION_WITH_DEPENDENCIES="YES"
509 509
    fi
510 510
 
511
-   separator="\n"
512 511
    while [ $# -ne 0 ]
513 512
    do
514 513
       case "$1" in
... ...
@@ -517,7 +528,14 @@ paths_main()
517 517
          ;;
518 518
 
519 519
          -1|--one-line)
520
-            separator=" "
520
+            OPTION_LINE_SEPERATOR=" "
521
+         ;;
522
+
523
+         -q|--quote)
524
+            shift
525
+            [ $# -eq 0 ] && fail "quote missing"
526
+
527
+            OPTION_QUOTE="$1"
521 528
          ;;
522 529
 
523 530
          -s|--separator)
... ...
@@ -614,7 +632,7 @@ paths_main()
614 614
             result="`add_line "${result}" "${values}"`"
615 615
          ;;
616 616
 
617
-         "cppflags"|"ldflags"|"binpath"|"frameworkpath"|"headerpath"|"librarypath")
617
+         "cflags"|"cppflags"|"ldflags"|"binpath"|"frameworkpath"|"headerpath"|"librarypath")
618 618
             values="`_flags_${type}_value`"
619 619
             result="`add_line "${result}" "${values}"`"
620 620
          ;;
... ...
@@ -646,7 +664,7 @@ paths_main()
646 646
 
647 647
    if [ ! -z "${result}" ]
648 648
    then
649
-      if [ "${separator}" = " " ]
649
+      if [ "${OPTION_LINE_SEPERATOR}" = " " ]
650 650
       then
651 651
          printf "%s" "${result}" | tr '\012' ' '  | sed 's/ *$//'
652 652
          printf "\n"
... ...
@@ -888,7 +888,7 @@ names_from_repository_file()
888 888
    local scm
889 889
    local tag
890 890
 
891
-   clones="`read_setting "${dst}/repositories"`"
891
+   clones="`read_setting "${filename}"`"
892 892
 
893 893
    IFS="
894 894
 "
... ...
@@ -195,6 +195,8 @@ _git_clone()
195 195
    [ ! -z "${url}" ]      || internal_fail "url is empty"
196 196
    [ ! -z "${stashdir}" ] || internal_fail "stashdir is empty"
197 197
 
198
+   [ -e "${stashdir}" ] && internal_fail "${stashdir} already exists"
199
+
198 200
    local options
199 201
 
200 202
    options="$*"
... ...
@@ -218,8 +220,20 @@ _git_clone()
218 218
       *:*)
219 219
          if [ ! -z "${CLONE_CACHE}" ]
220 220
          then
221
+            local cachedir
222
+
221 223
             mkdir_if_missing "${CLONE_CACHE}"
222
-            dstdir="${CLONE_CACHE}/`basename ${url}`" # try to keep it global
224
+            cachedir="${CLONE_CACHE}/`basename ${url}`" # try to keep it global
225
+
226
+            if [ ! -d "${cachedir}" ]
227
+            then
228
+               if ! exekutor git ${GITFLAGS} clone --bare ${options} ${GITOPTIONS} -- "${url}" "${cachedir}" >&2
229
+               then
230
+                  log_error "git clone of \"${url}\" into \"${cachedir}\" failed"
231
+                  return 1
232
+               fi
233
+            fi
234
+            url="${cachedir}"
223 235
          fi
224 236
       ;;
225 237
    esac
... ...
@@ -232,22 +246,18 @@ _git_clone()
232 232
 #    parent="`dirname -- "${stashdir}"`"
233 233
 #   mkdir_if_missing "${parent}"
234 234
 
235
-   if [ ! -d "${dstdir}" ]
235
+   if [ "${stashdir}" = "${url}" ]
236 236
    then
237
-      if ! exekutor git ${GITFLAGS} clone ${options} ${GITOPTIONS} -- "${url}" "${dstdir}" >&2
238
-      then
239
-         log_error "git clone of \"${url}\" into \"${dstdir}\" failed"
240
-         return 1
241
-      fi
237
+      # since we know that stash dir does not exist, this
238
+      # message is a bit less confusing
239
+      log_error "Clone source \"${url}\" does not exist."
240
+      return 1
242 241
    fi
243 242
 
244
-   if [ ! -z "${CLONE_CACHE}" -a "${stashdir}" != "${CLONE_CACHE}" ]
243
+   if ! exekutor git ${GITFLAGS} clone ${options} ${GITOPTIONS} -- "${url}" "${stashdir}"  >&2
245 244
    then
246
-      if ! exekutor git ${GITFLAGS} clone ${options} ${GITOPTIONS} -- "${dstdir}" "${stashdir}"  >&2
247
-      then
248
-         log_error "git clone of \"${dstdir}\" into \"${stashdir}\" failed"
249
-         return 1
250
-      fi
245
+      log_error "git clone of \"${url}\" into \"${stashdir}\" failed"
246
+      return 1
251 247
    fi
252 248
 
253 249
    if [ ! -z "${tag}" ]
... ...
@@ -588,7 +598,7 @@ git_main()
588 588
 
589 589
    if dir_has_files "${REPOS_DIR}"
590 590
    then
591
-      log_fluff "Will git $* clones " >&2
591
+      log_fluff "Will run \"git $*\" over clones" >&2
592 592
    else
593 593
       log_verbose "There is nothing to run git over."
594 594
       return 0
... ...
@@ -119,6 +119,13 @@ bury_stash()
119 119
 
120 120
    gravepath="${reposdir}/.graveyard/${name}"
121 121
 
122
+   if [ -L "${stashdir}" ]
123
+   then
124
+      log_verbose "Removing old symlink \"${stashdir}\""
125
+      exekutor rm -f ${COPYMOVEFLAGS} "${stashdir}" >&2
126
+      return
127
+   fi
128
+
122 129
    if [ -e "${gravepath}" ]
123 130
    then
124 131
       log_fluff "Repurposing old grave \"${gravepath}\""
... ...
@@ -145,6 +145,7 @@ b.build
145 145
 build_order
146 146
 c.build
147 147
 repositories
148
+required
148 149
 a/.bootstrap.auto/b.build:
149 150
 b
150 151
 bin
... ...
@@ -167,7 +168,7 @@ c
167 167
 EOF
168 168
 
169 169
 diff "${expect}" "${result}"
170
-[ $? -ne 0 ] && fail "unexpected result"
170
+[ $? -ne 0 ] && fail "unexpected result \"${result}\""
171 171
 
172 172
 rm -rf a b c
173 173
 
174 174
new file mode 100755
... ...
@@ -0,0 +1,94 @@
0
+#! /bin/sh
1
+
2
+
3
+clear_test_dirs()
4
+{
5
+   local i
6
+
7
+   for i in "$@"
8
+   do
9
+      if [ -d "$i" ]
10
+      then
11
+         rm -rf "$i"
12
+      fi
13
+   done
14
+}
15
+
16
+
17
+fail()
18
+{
19
+   echo "failed:" "$@" >&2
20
+   exit 1
21
+}
22
+
23
+
24
+run_mulle_bootstrap()
25
+{
26
+   echo "####################################" >&2
27
+   echo mulle-bootstrap "$@"  >&2
28
+   echo "####################################" >&2
29
+
30
+   mulle-bootstrap "$@"
31
+}
32
+
33
+
34
+#
35
+#
36
+#
37
+
38
+setup_test_case()
39
+{
40
+   clear_test_dirs a b
41
+
42
+   mkdir -p a/.bootstrap
43
+   mkdir -p b
44
+
45
+   (
46
+      cd b ;
47
+      git init ;
48
+      echo "VfL Bochum 1848" > README.md ;
49
+      git add README.md ;
50
+      git commit -m "bla bla"
51
+   ) || exit 1
52
+
53
+   echo "b" >  a/.bootstrap/repositories
54
+   echo "c" >> a/.bootstrap/repositories
55
+}
56
+
57
+
58
+test_a()
59
+{
60
+   (
61
+      cd a ;
62
+      if run_mulle_bootstrap "$@" fetch
63
+      then
64
+         fail "mulle-bootstrap did not fail, though c is required"
65
+      fi
66
+   ) || exit 1
67
+
68
+   echo "b" > a/.bootstrap/required
69
+
70
+   (
71
+      cd a ;
72
+      if ! run_mulle_bootstrap -f "$@" fetch
73
+      then
74
+         fail "mulle-bootstrap failed, although c is not required"
75
+      fi
76
+   ) || exit 1
77
+}
78
+
79
+
80
+#
81
+# not that much of a test
82
+#
83
+echo "mulle-bootstrap: `mulle-bootstrap version`(`mulle-bootstrap library-path`)" >&2
84
+
85
+MULLE_BOOTSTRAP_CACHES_PATH="`pwd -P`"
86
+export MULLE_BOOTSTRAP_CACHES_PATH
87
+
88
+setup_test_case
89
+test_a "$@"
90
+clear_test_dirs a b
91
+
92
+echo "succeeded" >&2
93
+
0 94
new file mode 100755
... ...
@@ -0,0 +1,110 @@
0
+#! /bin/sh
1
+
2
+
3
+clear_test_dirs()
4
+{
5
+   local i
6
+
7
+   for i in "$@"
8
+   do
9
+      if [ -d "$i" ]
10
+      then
11
+         rm -rf "$i"
12
+      fi
13
+   done
14
+}
15
+
16
+
17
+fail()
18
+{
19
+   echo "failed:" "$@" >&2
20
+   exit 1
21
+}
22
+
23
+
24
+run_mulle_bootstrap()
25
+{
26
+   echo "####################################" >&2
27
+   echo mulle-bootstrap "$@"  >&2
28
+   echo "####################################" >&2
29
+
30
+   mulle-bootstrap "$@"
31
+}
32
+
33
+
34
+#
35
+#
36
+#
37
+
38
+setup_test_case()
39
+{
40
+   clear_test_dirs a b c
41
+
42
+   mkdir -p a/.bootstrap
43
+   mkdir -p b
44
+
45
+   (
46
+      cd b ;
47
+      git init ;
48
+      echo "b) VfL Bochum 1848" > README.md ;
49
+      git add README.md ;
50
+      git commit -m "bla bla"
51
+   ) || exit 1
52
+
53
+   mkdir -p c
54
+
55
+   (
56
+      cd c ;
57
+      git init ;
58
+      echo "c) VfL Bochum 1848" > README.md ;
59
+      git add README.md ;
60
+      git commit -m "bla bla"
61
+   ) || exit 1
62
+
63
+   #
64
+   # one of the required is in "repositories" just to make
65
+   # it difficult
66
+   #
67
+   echo "b" >  a/.bootstrap/repositories
68
+   echo "c" >  a/.bootstrap/embedded_repositories
69
+   echo "d" >> a/.bootstrap/embedded_repositories
70
+}
71
+
72
+
73
+test_a()
74
+{
75
+   (
76
+      cd a ;
77
+      if run_mulle_bootstrap "$@" fetch
78
+      then
79
+         fail "mulle-bootstrap did not fail, though d is required"
80
+      fi
81
+   ) || exit 1
82
+
83
+
84
+   echo "c" > a/.bootstrap/embedded_required
85
+
86
+   (
87
+      cd a ;
88
+      if ! run_mulle_bootstrap -f "$@" fetch
89
+      then
90
+         fail "mulle-bootstrap failed, although d is not required"
91
+      fi
92
+   ) || exit 1
93
+}
94
+
95
+
96
+#
97
+# not that much of a test
98
+#
99
+echo "mulle-bootstrap: `mulle-bootstrap version`(`mulle-bootstrap library-path`)" >&2
100
+
101
+MULLE_BOOTSTRAP_CACHES_PATH="`pwd -P`"
102
+export MULLE_BOOTSTRAP_CACHES_PATH
103
+
104
+setup_test_case
105
+test_a "$@"
106
+clear_test_dirs a b
107
+
108
+echo "succeeded" >&2
109
+