Browse code

Improvement to fetch option handling

Nat! authored on 07-09-2016 15:04:27
Showing 3 changed files
... ...
@@ -220,10 +220,6 @@ bootstrap_main()
220 220
       shift
221 221
    done
222 222
 
223
-  command=${1:-"bootstrap"}
224
-   [ $# -eq 0 ] || shift
225
-
226
-
227 223
    case "${MULLE_BOOTSTRAP_TRACE}" in
228 224
       VERBOSE)
229 225
          MULLE_BOOTSTRAP_FLUFF="NO"
... ...
@@ -278,6 +274,9 @@ bootstrap_main()
278 274
    #
279 275
    # some commands only run when we have a .bootstrap folder
280 276
    #
277
+   command=${1:-"bootstrap"}
278
+   [ $# -eq 0 ] || shift
279
+
281 280
    if [ ! -d "${BOOTSTRAP_SUBDIR}" ]
282 281
    then
283 282
       case "${command}" in
... ...
@@ -343,7 +342,7 @@ bootstrap_main()
343 342
             fetch_main install "$@"      || exit 1
344 343
             refresh_main                 || exit 1
345 344
         else
346
-            fetch_main nonrecursive "$@" || exit 1
345
+            fetch_main install --non-recursive "$@" || exit 1
347 346
             refresh_main nonrecursive    || exit 1
348 347
          fi
349 348
 
... ...
@@ -391,14 +390,14 @@ bootstrap_main()
391 390
       fetch)
392 391
          . mulle-bootstrap-fetch.sh
393 392
 
394
-         DONT_ASK_AFTER_WARNING=YES fetch_main "install" "$@" || exit 1
393
+         DONT_ASK_AFTER_WARNING=YES fetch_main install "$@" || exit 1
395 394
          refresh_main || exit 1
396 395
       ;;
397 396
 
398 397
       update)
399 398
          . mulle-bootstrap-fetch.sh
400 399
 
401
-         fetch_main "${command}" "$@" || exit 1
400
+         fetch_main update "$@" || exit 1
402 401
          refresh_main || exit 1
403 402
       ;;
404 403
 
... ...
@@ -2171,7 +2171,7 @@ build_main()
2171 2171
 
2172 2172
    log_fluff "::: build begin :::"
2173 2173
 
2174
-   while :
2174
+   while [ $# -ne 0 ]
2175 2175
    do
2176 2176
       case "$1" in
2177 2177
          -K)
... ...
@@ -44,7 +44,7 @@ fetch_usage()
44 44
 usage:
45 45
    mulle-bootstrap fetch [-f] <install|nonrecursive|update>
46 46
    -f           :  override dirty harry check
47
-
47
+   -u           :  update also symlinked folders
48 48
    install      :  clone or symlink non-exisiting repositories and other resources
49 49
    nonrecursive :  like above, but ignore .bootstrap folders of repositories
50 50
    update       :  execute `git pull` in fetched repositories
... ...
@@ -883,7 +883,7 @@ update()
883 883
    before_e=`modification_timestamp "${dstdir}/.bootstrap/embedded_repositories" 2> /dev/null`
884 884
 
885 885
    rval=0
886
-   if [ ! -L "${dstdir}" ]
886
+   if [ ! -L "${dstdir}" -o "${MULLE_BOOTSTRAP_UPDATE_SYMLINKS}" = "YES" ]
887 887
    then
888 888
       fetch__run_repo_settings_script "${name}" "${dstdir}" "pre-update" "$@"
889 889
 
... ...
@@ -1292,17 +1292,38 @@ fetch_main()
1292 1292
 {
1293 1293
    log_fluff "::: fetch begin :::"
1294 1294
 
1295
-   while :
1295
+   COMMAND="${1:-install}"
1296
+   [ $# -ne 0 ] && shift
1297
+
1298
+   case "$COMMAND" in
1299
+      install|update)
1300
+         ;;
1301
+      *)
1302
+         log_error "unknown command \"$COMMAND\""
1303
+         fetch_usage
1304
+         ;;
1305
+   esac
1306
+
1307
+
1308
+   while [ $# -ne 0 ]
1296 1309
    do
1297 1310
       case "$1" in
1298 1311
          -h|-help|--help)
1299 1312
             fetch_usage
1300 1313
          ;;
1301 1314
 
1315
+         -nr|--no-recursion)
1316
+            DONT_RECURSE="YES"
1317
+         ;;
1318
+
1302 1319
          -f)
1303 1320
             MULLE_BOOTSTRAP_DIRTY_HARRY="NO"
1304 1321
          ;;
1305 1322
 
1323
+         -u|--update-symlinks)
1324
+            MULLE_BOOTSTRAP_UPDATE_SYMLINKS="YES"
1325
+         ;;
1326
+
1306 1327
 
1307 1328
          -*)
1308 1329
             log_error "unknown option $1"
... ...
@@ -1315,27 +1336,8 @@ fetch_main()
1315 1336
       esac
1316 1337
 
1317 1338
       shift
1318
-      continue
1319 1339
    done
1320 1340
 
1321
-   COMMAND=${1:-"install"}
1322
-   [ $# -eq 0 ] || shift
1323
-
1324
-   case "$COMMAND" in
1325
-      install)
1326
-         ;;
1327
-      nonrecursive)
1328
-        COMMAND=install
1329
-        DONT_RECURSE="YES"
1330
-         ;;
1331
-      update)
1332
-         ;;
1333
-      *)
1334
-         log_error "unknown command \"$COMMAND\""
1335
-         fetch_usage
1336
-         ;;
1337
-   esac
1338
-
1339 1341
    [ -z "${MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH}" ] && . mulle-bootstrap-local-environment.sh
1340 1342
    [ -z "${MULLE_BOOTSTRAP_SETTINGS_SH}" ] && . mulle-bootstrap-settings.sh
1341 1343