Browse code

Resurrect "secret" clone command, that was lost somewhere. Fix a few bugs and uglies

Nat! authored on 21-09-2016 16:17:41
Showing 6 changed files
... ...
@@ -9,6 +9,8 @@ your projects**
9 9
 project tree
10 10
 * changes in deeply embedded repositories are now better tracked
11 11
 * fixed some as of yet unknown bugs, by improving some path functions
12
+* resurrected the clone command for **mulle-aba**
13
+
12 14
 
13 15
 2.0
14 16
 ===
... ...
@@ -104,6 +104,60 @@ Well, do ya, punk?"
104 104
 }
105 105
 
106 106
 
107
+bootstrap_nomagic_main()
108
+{
109
+   local command
110
+
111
+   command="$1"
112
+   shift
113
+
114
+   if [ "${command}" = "nomagic" ]
115
+   then
116
+      DONT_RECURSE=YES
117
+   fi
118
+
119
+   . mulle-bootstrap-fetch.sh
120
+   . mulle-bootstrap-build.sh
121
+   . mulle-bootstrap-warn-scripts.sh
122
+
123
+   if [ "${DONT_RECURSE}" = "" ]
124
+   then
125
+      fetch_main "$@" || exit 1
126
+      refresh_main    || exit 1
127
+  else
128
+      fetch_main --non-recursive "$@" || exit 1
129
+      refresh_main nonrecursive       || exit 1
130
+   fi
131
+
132
+   warn_scripts_main "${BOOTSTRAP_SUBDIR}" || exit 1
133
+
134
+   # do it again now!
135
+   build_main "$@" || exit 1
136
+}
137
+
138
+
139
+clone_main()
140
+{
141
+   local url
142
+
143
+   url="$1"
144
+   [ $# -ne 0 ] && shift
145
+
146
+   name="`basename -- "${url}"`"
147
+   name="`basename -- "${name}" .git`"
148
+
149
+   if [ ! -e "${name}" ]
150
+   then
151
+      git clone ${GITFLAGS} "${url}" "${name}" || exit 1
152
+   else
153
+      log_info "Directory ${name} already exists."
154
+   fi
155
+
156
+   ( cd "${name}"; refresh_main ) || exit 1
157
+   ( cd "${name}"; bootstrap_nomagic_main "$@" ) || exit 1
158
+}
159
+
160
+
107 161
 bootstrap_main()
108 162
 {
109 163
    local command
... ...
@@ -335,7 +389,7 @@ bootstrap_main()
335 389
             refresh_main refresh_if_bare || exit 1
336 390
          ;;
337 391
 
338
-         update|refresh)
392
+         update|refresh|clone)
339 393
            . mulle-bootstrap-refresh.sh
340 394
 
341 395
            # 4 laters
... ...
@@ -344,29 +398,12 @@ bootstrap_main()
344 398
    fi
345 399
 
346 400
    case "${command}" in
347
-      bootstrap|nomagic)
348
-         if [ "${command}" = "nomagic" ]
349
-         then
350
-            DONT_RECURSE=YES
351
-         fi
352
-
353
-         . mulle-bootstrap-fetch.sh
354
-         . mulle-bootstrap-build.sh
355
-         . mulle-bootstrap-warn-scripts.sh
356
-
357
-         if [ "${DONT_RECURSE}" = "" ]
358
-         then
359
-            fetch_main "$@"     || exit 1
360
-            refresh_main                  || exit 1
361
-        else
362
-            fetch_main --non-recursive "$@" || exit 1
363
-            refresh_main nonrecursive    || exit 1
364
-         fi
365
-
366
-         warn_scripts_main "${BOOTSTRAP_SUBDIR}" || exit 1
401
+      clone)
402
+         clone_main "$@"
403
+      ;;
367 404
 
368
-         # do it again now!
369
-         build_main "$@" || exit 1
405
+      bootstrap|nomagic)
406
+         bootstrap_nomagic_main "${command}" "$@"
370 407
       ;;
371 408
 
372 409
       # experimental stuff
... ...
@@ -421,7 +458,7 @@ bootstrap_main()
421 458
       init)
422 459
          . mulle-bootstrap-init.sh
423 460
 
424
-        init_main "$@" || exit 1
461
+         init_main "$@" || exit 1
425 462
       ;;
426 463
 
427 464
       setup-xcode|xcode)
... ...
@@ -164,7 +164,9 @@ bootstrap_auto_update_repo_settings()
164 164
 }
165 165
 
166 166
 
167
-
167
+#
168
+# return 0, if nothing changed
169
+#
168 170
 bootstrap_auto_update()
169 171
 {
170 172
    local name
... ...
@@ -187,7 +189,7 @@ bootstrap_auto_update()
187 189
    if [ ! -d "${directory}/.bootstrap" ] # -a ! -L "${dst}" ]
188 190
    then
189 191
       log_fluff "No .bootstrap folder in \"${directory}\" found"
190
-      return 1
192
+      return 0
191 193
    fi
192 194
 
193 195
    log_verbose "Updating .bootstrap.auto with ${directory}"
... ...
@@ -202,7 +204,7 @@ bootstrap_auto_update()
202 204
    bootstrap_auto_update_repo_settings "${directory}"
203 205
 
204 206
    log_fluff "Acquisiton of \"${name}\" complete"
205
-   return 0
207
+   return 1
206 208
 }
207 209
 
208 210
 #
... ...
@@ -350,7 +350,7 @@ link_command()
350 350
          name="`basename -- "${dst}"`"
351 351
          log_warning "tag ${tag} will be ignored, due to symlink" >&2
352 352
          log_warning "if you want to checkout this tag do:" >&2
353
-         log_warning "${C_RESET}${C_BOLD}(cd .repos/${name}; git ${GITFLAGS} checkout \"${tag}\" )${C_WARNING}" >&2
353
+         log_warning "${C_RESET}${C_BOLD}(cd .repos/${name}; git checkout ${GITFLAGS} \"${tag}\" )${C_WARNING}" >&2
354 354
       fi
355 355
    fi
356 356
 
... ...
@@ -709,7 +709,7 @@ checkout_repository()
709 709
       BOOTSTRAP_SUBDIR="${old_bootstrap}"
710 710
    fi
711 711
 
712
-   if $run_script
712
+   if [ $run_script -eq 0 ]
713 713
    then
714 714
       fetch__run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
715 715
    fi
... ...
@@ -748,6 +748,7 @@ clone_repository()
748 748
    fi
749 749
 
750 750
    flag=0
751
+
751 752
    if [ $doit -ne 0 ]
752 753
    then
753 754
       log_fetch_action "${url}" "${dstdir}"
... ...
@@ -771,22 +772,24 @@ clone_repository()
771 772
 
772 773
 clone_repositories()
773 774
 {
774
-   local branch
775 775
    local clone
776 776
    local clones
777 777
    local fetched
778 778
    local match
779
-   local name
780 779
    local old
781 780
    local rval
782
-   local scm
783 781
    local stop
784
-   local tag
785
-   local url
786 782
 
787 783
    old="${IFS:-" "}"
788 784
    fetched=""
789 785
 
786
+   # __parse_expanded_clone variables
787
+   local name
788
+   local url
789
+   local branch
790
+   local scm
791
+   local tag
792
+
790 793
    stop=0
791 794
    while [ $stop -eq 0 ]
792 795
    do
... ...
@@ -101,6 +101,11 @@ ${clone}"
101 101
                __parse_expanded_clone "${clone}"
102 102
 
103 103
                dstdir="${CLONESFETCH_SUBDIR}/${name}"
104
+               if [ ! -d "${dstdir}" ]
105
+               then
106
+                  log_fluff "${name} has not been fetched yet"
107
+                  continue
108
+               fi
104 109
 
105 110
                #
106 111
                # dependency management, it could be nicer, but isn't.
... ...
@@ -264,7 +269,7 @@ bury_zombies()
264 269
       gravepath="${CLONESFETCH_SUBDIR}/.graveyard"
265 270
       mkdir_if_missing "${gravepath}"
266 271
 
267
-      for i in `ls -1 "${zombiepath}/"*`
272
+      for i in `ls -1 "${zombiepath}/"* 2> /dev/null`
268 273
       do
269 274
          if [ -e "${i}" ]
270 275
          then
... ...
@@ -366,7 +371,7 @@ bury_embedded_zombies()
366 371
       gravepath="${CLONESFETCH_SUBDIR}/.embedded/.graveyard"
367 372
       mkdir_if_missing "${gravepath}"
368 373
 
369
-      for i in `ls -1 "${zombiepath}/"*`
374
+      for i in `ls -1 "${zombiepath}/"* 2> /dev/null`
370 375
       do
371 376
          if [ -f "${i}" ]
372 377
          then
373 378
deleted file mode 100644
... ...
@@ -1 +0,0 @@
1
-I am **a**