Browse code

Rename mulle-bootstrap flags to mulle-bootstrap paths, because it irked me. Fix some code where the function rename broke stuff.

Nat! authored on 27-03-2017 00:37:19
Showing 11 changed files
... ...
@@ -30,7 +30,7 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 MULLE_EXECUTABLE_VERSION_MAJOR=3
32 32
 MULLE_EXECUTABLE_VERSION_MINOR=0
33
-MULLE_EXECUTABLE_VERSION_PATCH=1
33
+MULLE_EXECUTABLE_VERSION_PATCH=2
34 34
 
35 35
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
36 36
 
... ...
@@ -71,7 +71,7 @@ EOF
71 71
    clean         : cleans mulle-bootstrap produced files.
72 72
    defer         : join a master mulle-bootstrap project
73 73
    emancipate    : emancipate from a master mulle-bootstrap project
74
-   flags         : produces CFLAGS for cc invocation and more
74
+   paths         : get include and library paths
75 75
    init          : initializes a bootstrap project
76 76
    update        : updates repositories (fetch).
77 77
    upgrade       : updates and checks out repositories (pull).
... ...
@@ -347,6 +347,9 @@ bootstrap_main()
347 347
 
348 348
    #
349 349
    # some commands only run when we have a .bootstrap folder
350
+   # we do it somewhat like git, and progress up the directory
351
+   # hierarchy until we find a .bootstrap or .bootstrap.local folder
352
+   # this is useful for `mulle-bootstrap paths` (with absolute paths)
350 353
    #
351 354
    command="${1:-bootstrap}"
352 355
 
... ...
@@ -356,37 +359,47 @@ bootstrap_main()
356 359
       set_build_needed
357 360
    fi
358 361
 
359
-   if ! is_bootstrap_project
362
+   local previous
363
+
364
+   case "${command}" in
365
+      -h|--help|init|help)
366
+      ;;
367
+
368
+      *)
369
+         local  orgpwd
370
+
371
+         orgpwd="$PWD"
372
+
373
+         while ! is_bootstrap_project
374
+         do
375
+            local old
376
+
377
+            old="$PWD"
378
+            cd ..
379
+
380
+            if [ "$PWD" = "${old}" ]
381
+            then
382
+               fail "There is no ${BOOTSTRAP_DIR} or ${BOOTSTRAP_DIR}.local folder here ($orgpwd), can't continue"
383
+            fi
384
+         done
385
+      ;;
386
+   esac
387
+
388
+   if bootstrap_should_defer_to_master "$@"
360 389
    then
361
-      case "$1" in
362
-         -h|--help)
390
+      return 1
391
+   fi
392
+
393
+   if [ "${MULLE_FLAG_MAGNUM_FORCE}" = "NO" ]
394
+   then
395
+      case "${command}" in
396
+         clean|dist-clean|init|status|show|config|setting)
363 397
          ;;
364 398
 
365 399
          *)
366
-            case "${command}" in
367
-               bootstrap|build|clean|defer|dist|dist-clean|emancipate|fetch|install|syteminstall|upgrade|update|setup-xcode|show|status|tag|xcode)
368
-                  fail "There is no ${BOOTSTRAP_DIR} or ${BOOTSTRAP_DIR}.local folder here (${C_RESET_BOLD}$PWD${C_ERROR})"
369
-               ;;
370
-            esac
400
+            bootstrap_ensure_consistency
371 401
          ;;
372 402
       esac
373
-   else
374
-      if bootstrap_should_defer_to_master "$@"
375
-      then
376
-         return 1
377
-      fi
378
-
379
-      if [ "${MULLE_FLAG_MAGNUM_FORCE}" = "NO" ]
380
-      then
381
-         case "${command}" in
382
-            clean|dist-clean|init|status|show|config|setting)
383
-            ;;
384
-
385
-            *)
386
-               bootstrap_ensure_consistency
387
-            ;;
388
-         esac
389
-      fi
390 403
    fi
391 404
 
392 405
    MULLE_EXECUTABLE_FAIL_PREFIX="${MULLE_EXECUTABLE} ${command}"
... ...
@@ -441,10 +454,10 @@ bootstrap_main()
441 454
          expansion_main "$@" || exit 1
442 455
       ;;
443 456
 
444
-      flags)
445
-         . mulle-bootstrap-flags.sh
457
+      paths)
458
+         . mulle-bootstrap-paths.sh
446 459
 
447
-         flags_main "$@" || exit 1
460
+         paths_main "$@" || exit 1
448 461
       ;;
449 462
 
450 463
       git)
... ...
@@ -30,7 +30,7 @@
30 30
 #   POSSIBILITY OF SUCH DAMAGE.
31 31
 MULLE_EXECUTABLE_VERSION_MAJOR=3
32 32
 MULLE_EXECUTABLE_VERSION_MINOR=0
33
-MULLE_EXECUTABLE_VERSION_PATCH=1
33
+MULLE_EXECUTABLE_VERSION_PATCH=2
34 34
 
35 35
 MULLE_EXECUTABLE_VERSION="${MULLE_EXECUTABLE_VERSION_MAJOR}.${MULLE_EXECUTABLE_VERSION_MINOR}.${MULLE_EXECUTABLE_VERSION_PATCH}"
36 36
 
... ...
@@ -74,7 +74,7 @@ EOF
74 74
 
75 75
    local  repositories
76 76
 
77
-   repositories="`all_repository_directories_from_repos`"
77
+   repositories="`all_repository_stashes`"
78 78
    if [ -z "${repositories}" ]
79 79
    then
80 80
       echo "Currently available repositories are:"
... ...
@@ -2400,7 +2400,7 @@ build_main()
2400 2400
       exekutor chmod -R u+w "${DEPENDENCIES_DIR}"
2401 2401
       if have_tars
2402 2402
       then
2403
-         log_warning "Tars have not been installed, as \"${DEPENDENCIES_DIR}\" already exists."
2403
+         log_verbose "Tars have not been installed, as \"${DEPENDENCIES_DIR}\" already exists."
2404 2404
       fi
2405 2405
    else
2406 2406
       install_tars "$@"
... ...
@@ -51,7 +51,7 @@ usage:
51 51
    mulle-bootstrap defer
52 52
 
53 53
    Share and defer builds to master. The master will be used
54
-   to fetch dependencies and build them. Use mulle-bootstrap flags
54
+   to fetch dependencies and build them. Use mulle-bootstrap paths
55 55
    to get paths to addictions and dependencies.
56 56
 EOF
57 57
   exit 1
... ...
@@ -44,7 +44,7 @@ MULLE_BOOTSTRAP_FUNCTIONS_VERSION="3.0"
44 44
 # Execution
45 45
 #
46 46
 
47
-eval_trace()
47
+exekutor_trace()
48 48
 {
49 49
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" = "YES" -o "${MULLE_FLAG_LOG_EXECUTOR}" = "YES" ]
50 50
    then
... ...
@@ -69,7 +69,7 @@ eval_trace()
69 69
 }
70 70
 
71 71
 
72
-eval_trace_output()
72
+exekutor_trace_output()
73 73
 {
74 74
    local output="$1"; shift
75 75
 
... ...
@@ -99,7 +99,7 @@ eval_trace_output()
99 99
 
100 100
 exekutor()
101 101
 {
102
-   eval_trace "$@"
102
+   exekutor_trace "$@"
103 103
 
104 104
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
105 105
    then
... ...
@@ -110,7 +110,7 @@ exekutor()
110 110
 
111 111
 eval_exekutor()
112 112
 {
113
-   eval_trace "$@"
113
+   exekutor_trace "$@"
114 114
 
115 115
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
116 116
    then
... ...
@@ -123,7 +123,7 @@ redirect_exekutor()
123 123
 {
124 124
    local output="$1"; shift
125 125
 
126
-   eval_trace_output "${output}" "$@"
126
+   exekutor_trace_output "${output}" "$@"
127 127
 
128 128
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
129 129
    then
... ...
@@ -136,7 +136,7 @@ redirect_append_exekutor()
136 136
 {
137 137
    local output="$1"; shift
138 138
 
139
-   eval_trace_output "${output}" "$@"
139
+   exekutor_trace_output "${output}" "$@"
140 140
 
141 141
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
142 142
    then
... ...
@@ -149,7 +149,7 @@ _redirect_append_eval_exekutor()
149 149
 {
150 150
    local output="$1"; shift
151 151
 
152
-   eval_trace_output "${output}" "$@"
152
+   exekutor_trace_output "${output}" "$@"
153 153
 
154 154
    if [ "${MULLE_FLAG_EXECUTOR_DRY_RUN}" != "YES" ]
155 155
    then
156 156
similarity index 98%
157 157
rename from src/mulle-bootstrap-flags.sh
158 158
rename to src/mulle-bootstrap-paths.sh
... ...
@@ -28,13 +28,13 @@
28 28
 #   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
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
-MULLE_BOOTSTRAP_FLAGS_SH="included"
31
+MULLE_BOOTSTRAP_PATHS_SH="included"
32 32
 
33
-flags_usage()
33
+paths_usage()
34 34
 {
35 35
     cat <<EOF >&2
36 36
 usage:
37
-   mulle-bootstrap flags [options] <type>
37
+   mulle-bootstrap paths [options] <type>
38 38
 
39 39
    Options:
40 40
       -1             : output is a one-liner
... ...
@@ -42,7 +42,7 @@ usage:
42 42
       -l             : emit link directives for libraries
43 43
       -f             : emit link directives for Frameworks
44 44
 
45
-   Output flags for various tool types. You can specify multiple types.
45
+   Output paths for various tool types. You can specify multiple types.
46 46
 
47 47
    Types:
48 48
       addictions     : output "addictions" path
... ...
@@ -468,7 +468,7 @@ _flags_do_environment()
468 468
 }
469 469
 
470 470
 
471
-flags_main()
471
+paths_main()
472 472
 {
473 473
    local types
474 474
    local separator
... ...
@@ -487,7 +487,7 @@ flags_main()
487 487
    local OPTION_WITH_MISSING_PATHS="NO"
488 488
    local OPTION_PATH_SEPARATOR=":"
489 489
 
490
-   log_debug ":flags_main:"
490
+   log_debug ":paths_main:"
491 491
 
492 492
    [ -z "${MULLE_BOOTSTRAP_FUNCTIONS_SH}" ] && . mulle-bootstrap-functions.sh
493 493
 
... ...
@@ -513,7 +513,7 @@ flags_main()
513 513
    do
514 514
       case "$1" in
515 515
          -h|-help|--help)
516
-            flags_usage
516
+            paths_usage
517 517
          ;;
518 518
 
519 519
          -1|--one-line)
... ...
@@ -571,7 +571,7 @@ flags_main()
571 571
 
572 572
          -*)
573 573
             log_error "${MULLE_EXECUTABLE_FAIL_PREFIX}: Unknown option $1"
574
-            flags_usage
574
+            paths_usage
575 575
          ;;
576 576
 
577 577
          *)
... ...
@@ -637,7 +637,7 @@ flags_main()
637 637
 
638 638
          *)
639 639
             log_error "${MULLE_EXECUTABLE_FAIL_PREFIX}: Unknown type \"$type\""
640
-            flags_usage
640
+            paths_usage
641 641
          ;;
642 642
       esac
643 643
 
... ...
@@ -147,7 +147,7 @@ parentclone_of_repository()
147 147
 
148 148
 all_repository_names()
149 149
 {
150
-   ls -1 "${REPOS_DIR}/" 2> /dev/null
150
+   ( cd "${REPOS_DIR}" ; ls -1 ) 2> /dev/null
151 151
 }
152 152
 
153 153
 
... ...
@@ -166,6 +166,7 @@ _all_repository_stashes()
166 166
    do
167 167
       IFS="${DEFAULT_IFS}"
168 168
 
169
+      # somewhat a hack, since name is actually a subpath
169 170
       stash="`stash_of_repository "${reposdir}" "${name}"`"
170 171
       if [ ! -z "${stash}" ]
171 172
       then
... ...
@@ -180,6 +181,41 @@ _all_repository_stashes()
180 181
 }
181 182
 
182 183
 
184
+_all_deep_embedded_repository_stashes()
185
+{
186
+   local reposdir="$1"
187
+
188
+   [ -z "${reposdir}" ] && internal_fail "repos is empty"
189
+
190
+   local name
191
+   local stash
192
+   local deep
193
+
194
+   IFS="
195
+"
196
+   for deep in `ls -1d "${reposdir}/.deep"/*.d 2> /dev/null`
197
+   do
198
+      for name in `ls -1 "${reposdir}/${deep}"/* 2> /dev/null`
199
+      do
200
+         IFS="${DEFAULT_IFS}"
201
+
202
+         # somewhat a hack, since name is actually a subpath
203
+         stash="`stash_of_repository "${reposdir}" "${name}"`"
204
+         if [ ! -z "${stash}" ]
205
+         then
206
+           if [ -d "${stash}" ]
207
+           then
208
+              echo "${stash}"
209
+           fi
210
+         fi
211
+      done
212
+   done
213
+
214
+   IFS="${DEFAULT_IFS}"
215
+}
216
+
217
+
218
+
183 219
 all_repository_stashes()
184 220
 {
185 221
    _all_repository_stashes "${REPOS_DIR}"
... ...
@@ -192,6 +228,12 @@ all_embedded_repository_stashes()
192 228
 }
193 229
 
194 230
 
231
+all_deep_embedded_repository_stashes()
232
+{
233
+   _all_deep_embedded_repository_stashes "${REPOS_DIR}"
234
+}
235
+
236
+
195 237
 _get_all_repos_headers()
196 238
 {
197 239
    local reposdir="$1"
... ...
@@ -516,6 +516,59 @@ append_dir_to_gitignore_if_needed()
516 516
 }
517 517
 
518 518
 
519
+#
520
+# will this run over embedded too ?
521
+#
522
+_run_git_on_stash()
523
+{
524
+   local i="$1" ; shift
525
+
526
+   if [ -d "${i}/.git" -o -d "${i}/refs" ]
527
+   then
528
+      log_info "### $i:"
529
+      (
530
+         cd "$i" ;
531
+         exekutor git ${GITFLAGS} "$@" ${GITOPTIONS}  >&2
532
+      ) || fail "git failed"
533
+      log_info
534
+   fi
535
+}
536
+
537
+
538
+#
539
+# todo: let user select what repositories are affected
540
+#
541
+run_git()
542
+{
543
+   local i
544
+
545
+   IFS="
546
+"
547
+   for i in `all_repository_stashes`
548
+   do
549
+      IFS="${DEFAULT_IFS}"
550
+
551
+      _run_git_on_stash "$i" "$@"
552
+   done
553
+
554
+   for i in `all_embedded_repository_stashes`
555
+   do
556
+      IFS="${DEFAULT_IFS}"
557
+
558
+      _run_git_on_stash "$i" "$@"
559
+   done
560
+
561
+   for i in `all_deep_embedded_repository_stashes`
562
+   do
563
+      IFS="${DEFAULT_IFS}"
564
+
565
+      _run_git_on_stash "$i" "$@"
566
+   done
567
+
568
+   IFS="${DEFAULT_IFS}"
569
+}
570
+
571
+
519 572
 git_main()
520 573
 {
521 574
    log_debug "::: git :::"
... ...
@@ -523,7 +576,6 @@ git_main()
523 576
    [ -z "${MULLE_BOOTSTRAP_LOCAL_ENVIRONMENT_SH}" ] && . mulle-bootstrap-local-environment.sh
524 577
    [ -z "${MULLE_BOOTSTRAP_SCRIPTS_SH}" ]           && . mulle-bootstrap-scripts.sh
525 578
 
526
-
527 579
    while :
528 580
    do
529 581
       if [ "$1" = "-h" -o "$1" = "--help" ]
... ...
@@ -546,31 +598,6 @@ git_main()
546 598
 }
547 599
 
548 600
 
549
-run_git()
550
-{
551
-   local i
552
-
553
-   IFS="
554
-"
555
-   for i in `all_repository_directories_from_repos`
556
-   do
557
-      IFS="${DEFAULT_IFS}"
558
-
559
-      if [ -d "${i}/.git" -o -d "${i}/refs" ]
560
-      then
561
-         log_info "### $i:"
562
-         (
563
-            cd "$i" ;
564
-            exekutor git ${GITFLAGS} "$@" ${GITOPTIONS}  >&2
565
-         ) || fail "git failed"
566
-         log_info
567
-      fi
568
-   done
569
-
570
-   IFS="${DEFAULT_IFS}"
571
-}
572
-
573
-
574 601
 _validate_download()
575 602
 {
576 603
    local filename="$1"
... ...
@@ -100,6 +100,17 @@ git_must_be_clean()
100 100
 }
101 101
 
102 102
 
103
+_ensure_repos_clean()
104
+{
105
+   local i="$1" ; shift
106
+
107
+   # only tag what looks like a git repo
108
+   if [ -d "${i}/.git" -o -d "${i}/refs" ]
109
+   then
110
+      (cd "${i}" ; git_must_be_clean "${i}" ) || exit 1
111
+   fi
112
+}
113
+
103 114
 ensure_repos_clean()
104 115
 {
105 116
    #
... ...
@@ -110,25 +121,48 @@ ensure_repos_clean()
110 121
 
111 122
    IFS="
112 123
 "
113
-   for i in `all_repository_directories_from_repos`
124
+   for i in `all_repository_stashes`
114 125
    do
115 126
       IFS="${DEFAULT_IFS}"
116 127
 
117
-      # only tag what looks like a git repo
118
-      if [ -d "${i}/.git" -o -d "${i}/refs" ]
119
-      then
120
-         (cd "${i}" ; git_must_be_clean "${i}" ) || exit 1
121
-      fi
128
+      _ensure_repos_clean "$i"
122 129
    done
130
+
131
+   for i in `all_embedded_repository_stashes`
132
+   do
133
+      IFS="${DEFAULT_IFS}"
134
+
135
+      _ensure_repos_clean "$i"
136
+   done
137
+
138
+   for i in `all_deep_embedded_repository_stashes`
139
+   do
140
+      IFS="${DEFAULT_IFS}"
141
+
142
+      _ensure_repos_clean "$i"
143
+   done
144
+
123 145
    IFS="${DEFAULT_IFS}"
124 146
 }
125 147
 
126 148
 
127
-ensure_tags_unknown()
149
+_ensure_tags_unknown()
128 150
 {
129
-   local tag
151
+   local i="$1" ; shift
152
+   local tag="$1" ; shift
153
+
154
+   # only tag what looks like a git repo
155
+   # make it scm_tag sometimes
156
+   if [ -d "${i}/.git" -o -d "${i}/refs" ]
157
+   then
158
+      (cd "${i}" ; git_tag_unknown "${i}" "${tag}" ) || exit 1
159
+   fi
160
+}
130 161
 
131
-   tag="$1"
162
+
163
+ensure_tags_unknown()
164
+{
165
+   local tag="$1"
132 166
 
133 167
    #
134 168
    # Make sure that tagging is OK
... ...
@@ -138,22 +172,51 @@ ensure_tags_unknown()
138 172
 
139 173
    IFS="
140 174
 "
141
-   for i in `all_repository_directories_from_repos`
175
+   for i in `all_repository_stashes`
142 176
    do
143 177
       IFS="${DEFAULT_IFS}"
144 178
 
145
-      # only tag what looks like a git repo
146
-      # make it scm_tag sometimes
147
-      if [ -d "${i}/.git" -o -d "${i}/refs" ]
148
-      then
149
-         (cd "${i}" ; git_tag_unknown "${i}" "${tag}" ) || exit 1
150
-      fi
179
+      _ensure_tags_unknown "$i" "${tag}"
180
+   done
181
+
182
+   for i in `all_embedded_repository_stashes`
183
+   do
184
+      IFS="${DEFAULT_IFS}"
185
+
186
+      _ensure_tags_unknown "$i" "${tag}"
187
+   done
188
+
189
+   for i in `all_deep_embedded_repository_stashes`
190
+   do
191
+      IFS="${DEFAULT_IFS}"
192
+
193
+      _ensure_tags_unknown "$i" "${tag}"
151 194
    done
152 195
 
153 196
    IFS="${DEFAULT_IFS}"
154 197
 }
155 198
 
156 199
 
200
+_tag()
201
+{
202
+   local i="$1" ; shift
203
+   local tag="$1" ; shift
204
+
205
+   if [ -d "${i}/.git" -o -d "${i}/refs" ]
206
+   then
207
+      name="`basename -- "${i}"`"
208
+      if [ -z "${tag}" ]
209
+      then
210
+         log_info "### ${name}:"
211
+         (cd "$i" ; exekutor git ${GITFLAGS} tag ${GITOPTIONS} "$@" ) || fail "tag failed"
212
+      else
213
+         log_info "Tagging \"${name}\" with \"${tag}\""
214
+         (cd "$i" ; exekutor git ${GITFLAGS} tag ${GITOPTIONS} "$@" "${tag}" ) || fail "tag failed"
215
+      fi
216
+   fi
217
+}
218
+
219
+
157 220
 tag()
158 221
 {
159 222
    local tag
... ...
@@ -166,22 +229,25 @@ tag()
166 229
 
167 230
    IFS="
168 231
 "
169
-   for i in `all_repository_directories_from_repos`
232
+   for i in `all_repository_stashes`
170 233
    do
171 234
       IFS="${DEFAULT_IFS}"
172 235
 
173
-      if [ -d "${i}/.git" -o -d "${i}/refs" ]
174
-      then
175
-         name="`basename -- "${i}"`"
176
-         if [ -z "${tag}" ]
177
-         then
178
-            log_info "### ${name}:"
179
-            (cd "$i" ; exekutor git ${GITFLAGS} tag ${GITOPTIONS} "$@" ) || fail "tag failed"
180
-         else
181
-            log_info "Tagging \"${name}\" with \"${tag}\""
182
-            (cd "$i" ; exekutor git ${GITFLAGS} tag ${GITOPTIONS} "$@" "${tag}" ) || fail "tag failed"
183
-         fi
184
-      fi
236
+      _tag "$i" "${tag}"
237
+   done
238
+
239
+   for i in `all_embedded_repository_stashes`
240
+   do
241
+      IFS="${DEFAULT_IFS}"
242
+
243
+      _tag "$i" "${tag}"
244
+   done
245
+
246
+   for i in `all_deep_embedded_repository_stashes`
247
+   do
248
+      IFS="${DEFAULT_IFS}"
249
+
250
+      _tag "$i" "${tag}"
185 251
    done
186 252
 
187 253
    IFS="${DEFAULT_IFS}"
... ...
@@ -250,8 +250,8 @@ Release"
250 250
    local framework_search_paths
251 251
 
252 252
    # grab values from master if needed
253
-   DEPENDENCIES_DIR="`mulle-bootstrap flags dependencies`"
254
-   ADDICTIONS_DIR="`mulle-bootstrap flags addictions`"
253
+   DEPENDENCIES_DIR="`mulle-bootstrap paths dependencies`"
254
+   ADDICTIONS_DIR="`mulle-bootstrap paths addictions`"
255 255
 
256 256
    relpath="`symlink_relpath "${DEPENDENCIES_DIR}" "${projectdir}"`"
257 257
    dependencies_dir='$(PROJECT_DIR)'/"${relpath}"
... ...
@@ -82,7 +82,7 @@ test_a()
82 82
 
83 83
    (
84 84
       cd master/a ;
85
-      run_mulle_bootstrap "$@" flags -m
85
+      run_mulle_bootstrap "$@" paths -m
86 86
    )
87 87
 
88 88
    (