Browse code

Added a test for refresh. Added mulle-bootstrap project. Fix some bugs.

Nat! authored on 14-03-2016 14:03:01
Showing 12 changed files
... ...
@@ -1,10 +1,10 @@
1 1
 # mulle-bootstrap, yet another dependency manager for developers
2 2
 
3
-* downloads [github](http://rants.arantius.com/github-sucks) repositories
4
-(called here the "dependents")
5
-* can deal with [cmake](http://blog.cppcms.com/post/54),
6
-[xcodebuild](http://devcodehack.com/xcode-sucks-and-heres-why/) and
7
-[configure](http://quetzalcoatal.blogspot.de/2011/06/why-autoconf-sucks.html)
3
+* checkout [git]](//enux.pl/article/en/2014-01-21/why-git-sucks) repositories
4
+(called here the "dependents"). In times of need, it can also checkout [svn](//andreasjacobsen.com/2008/10/26/subversion-sucks-get-over-it/).
5
+* can deal with [cmake](//blog.cppcms.com/post/54),
6
+[xcodebuild](//devcodehack.com/xcode-sucks-and-heres-why/) and
7
+[configure](//quetzalcoatal.blogspot.de/2011/06/why-autoconf-sucks.html)
8 8
 projects
9 9
 * instead of installing headers and libraries to `/usr/local`, mulle-bootstrap
10 10
 installs to `./dependencies`
... ...
@@ -12,7 +12,8 @@ installs to `./dependencies`
12 12
 * installs brew taps and formulae
13 13
 * installs gems and pips
14 14
 * compiles dependents using the output of previous dependents
15
-* written in portable shell script, will run eventually also on Linux
15
+* written in portable shell script, runs also on Linux
16
+
16 17
 
17 18
 ## How to install (OS X)
18 19
 
... ...
@@ -22,7 +23,7 @@ brew install mulle-bootstrap
22 23
 ```
23 24
 
24 25
 > If that doesn't work for some reason, try to
25
-> `brew untap mulle-kybernetik/software` it and then retry. 
26
+> `brew untap mulle-kybernetik/software` and then retry.
26 27
 
27 28
 
28 29
 ## What mulle-bootstrap can do for you
... ...
@@ -58,17 +59,17 @@ Your Xcode project can be optionally massaged by
58 59
 search paths.
59 60
 
60 61
 
61
-## Commands for a project user 
62
+## Commands for a project user
62 63
 
63
-#### mulle-bootstrap 
64
+#### mulle-bootstrap
64 65
 
65
-Download a project which is mulle-bootstrap enabled. Execute mulle-bootstrap 
66
+Download a project which is mulle-bootstrap enabled. Execute mulle-bootstrap
66 67
 in it and you are all set:
67 68
 
68 69
 ```console
69 70
 mulle-bootstrap
70 71
 ```
71
-`mulle-bootstrap` is a the shortened command of `mulle-bootstrap bootstrap`, which 
72
+`mulle-bootstrap` is a the shortened command of `mulle-bootstrap bootstrap`, which
72 73
 in turn executes:
73 74
 
74 75
 #### mulle-bootstrap fetch
... ...
@@ -1,175 +1,184 @@
1
+0.20
2
+===
3
+*  Replace CLONES_FETCH_SUBDIR with CLONESFETCH_SUBDIR
4
+*  mulle-bootstrap now uses the zombie repository detection to actually bury
5
+   unused repositories. Check out "tests/refresh/refresh.sh" how this
6
+   actually works. The upshot is, all changes in the repositories settings
7
+   are now reflected on refresh.
8
+*  Fix a bug in `combined_escaped_search_path`, which produced ugly and
9
+   wrong search paths (that didn't matter).
10
+*  Pass DEPENDENCIES_DIR via command line, which fixes some subtle problems
11
+   with missing libraries, due to -force_load and friends.
12
+*  Started mulle-bootstrap project. The general idea is to do also manage
13
+   the project that contains the .bootstrap folder (at least a little bit). So
14
+   `mulle-bootstrap clone` is now `mulle-bootstrap project clone
15
+
1 16
 0.19
2 17
 ===
3
-   Forgot a -f on a ln -s , which could result in an irritating output.
4
-   Now also refresh before fetching. mulle-bootstrap will now be able to
18
+*  Forgot a -f on a ln -s , which could result in an irritating output.
19
+*  Now also refresh before fetching. mulle-bootstrap will now be able to
5 20
    pick up changes in recursive repositories. And fetch additional repos as
6 21
    needed, so you don't need to clean dist.
7
-   Produce more helpful output if cmake is missing.
8
-   Experimental support for "mulle-bootstrap clone", which will clone and build
22
+*  Produce more helpful output if cmake is missing.
23
+*  Experimental support for "mulle-bootstrap clone", which will clone and build
9 24
    a remote repository.
25
+*  Nicer markup for RELEASENOTES.md
10 26
 
11 27
 0.18
12 28
 ===
13
-   Refixed: Fix old favorite bug build_ignore became a directory bug) again ...
14
-   Added refresh, which will be called before build and update automatically
29
+*  Refixed: Fix old favorite bug build_ignore became a directory bug) again ...
30
+*  Added refresh, which will be called before build and update automatically
15 31
    to rebuild .bootstrap.auto.
16 32
 
17 33
 0.17
18 34
 ===
19
-   Fixed the broken inheritance. The "Always redo bootstrap.auto folder
35
+*  Fixed the broken inheritance. The "Always redo bootstrap.auto folder
20 36
    on fetch" fix in 0.15, was in the wrong position. So 0.15 and 0.16 are
21 37
    totally broken releases. Sorry.
22 38
 
23 39
 0.16
24 40
 ===
25
-   Fixed misnamed exekutor.
26
-   Fix old favorite bug build_ignore became a directory bug) again ...
41
+*  Fixed misnamed exekutor.
42
+*  Fix old favorite bug build_ignore became a directory bug) again ...
27 43
 
28 44
 0.15
29 45
 ===
30
-   `tag` checks in all repositories, that a tag does not exist.
31
-   Remove some fluff from regular output.
32
-   Fix a bug involving settings copy  (build_ignore became a directory bug)
33
-   Executed commands are now prefixed with ==> for better readability.
34
-   Always redo bootstrap.auto folder on fetch, which means that you don't need
46
+*  `tag` checks in all repositories, that a tag does not exist.
47
+*  Remove some fluff from regular output.
48
+*  Fix a bug involving settings copy  (build_ignore became a directory bug)
49
+*  Executed commands are now prefixed with ==> for better readability.
50
+*  Always redo bootstrap.auto folder on fetch, which means that you don't need
35 51
    to clean dist anymore after editing .bootstrap files.
36
-   Forgot to write-protect dependencies, when only partial builds were done.
52
+*  Forgot to write-protect dependencies, when only partial builds were done.
37 53
 
38 54
 0.14
39 55
 ===
40
-   Fix various uglies.
41
-   Make white terminals more happening with color choices.
42
-   -v circumvents building into a logfile, which is sometimes more convenient.
56
+*  Fix various uglies.
57
+*  Make white terminals more happening with color choices.
58
+*  -v circumvents building into a logfile, which is sometimes more convenient.
43 59
 
44 60
 0.13
45 61
 ===
46
-   Fix colorization by using printf, instead of echo.
62
+*  Fix colorization by using printf, instead of echo.
47 63
 
48 64
 0.12
49 65
 ===
50
-   Run post-install.sh also on embedded repositories. Sometimes useful, when
66
+*  Run post-install.sh also on embedded repositories. Sometimes useful, when
51 67
    you need ./configure to produce some headers.
52
-   Add parameters to "Executing script" line.
53
-   Add "checkout" git flags, to fine tune the clone. But use --recursive
68
+*  Add parameters to "Executing script" line.
69
+*  Add "checkout" git flags, to fine tune the clone. But use --recursive
54 70
    per default.
55 71
 
56 72
 0.11
57 73
 ===
58
-   Fixes another stale headers problem. Project is creeping towards a 1.0.
74
+*  Fixes another stale headers problem. Project is creeping towards a 1.0.
59 75
 
60 76
 0.10
61 77
 ===
62
-   Fetch settings can be platform specific by using the `uname` as a file
78
+*  Fetch settings can be platform specific by using the `uname` as a file
63 79
    extension. e.g. repositories.Darwin. Other settings may follow, if the need
64 80
    arises. So far it hasn't.
65
-
66
-   Added "embedded_repositories" for those special moments, where you don't want
81
+*  Added "embedded_repositories" for those special moments, where you don't want
67 82
    to link another project, but just steal a few files. These gits are installed
68 83
    in your projects root and they are not built. You can not symlink them into
69 84
    your project, just clone them.
70
-
71
-   Because I needed ancient and dying svn for MulleScion,  you can now remap
85
+*  Because I needed ancient and dying svn for MulleScion,  you can now remap
72 86
    from the default git to svn, by creating a file <reponame>.scm. That contains
73
-   the string "svn" then.
74
-
75
-   *** Renamed "gits" to "repositories" ***
76
-
77
-   Use mulle-bootstrap convert-pre.0.10 ~/src to convert all .bootstrap folders
78
-   that `find` can find.
79
-
80
-   Do `mulle-bootstrap -n -v convert-pre-0.10 ${HOME}` to check what it's doing.
81
-
82
-   Install dummy dirs for xcodebuild too, to avoid boring compiler warnings.
83
-
84
-   Always overwrite headers, otherwise old and stale headers make life
87
+  the string "svn" then.
88
+*  *** Renamed "gits" to "repositories" ***
89
+*  Use mulle-bootstrap convert-pre.0.10 ~/src to convert all .bootstrap folders
90
+  that `find` can find.
91
+*  Do `mulle-bootstrap -n -v convert-pre-0.10 ${HOME}` to check what it's doing.
92
+*  Install dummy dirs for xcodebuild too, to avoid boring compiler warnings.
93
+*  Always overwrite headers, otherwise old and stale headers make life
85 94
    unnecessarily more complicated.
86 95
 
87 96
 0.9.8
88 97
 ===
89
-   Brings more Linux fixes
98
+*  Brings more Linux fixes
90 99
 
91 100
 0.9.7
92 101
 ===
93
-   Allow mulle-bootstrap version to work everywhere.
102
+*  Allow mulle-bootstrap version to work everywhere.
94 103
 
95 104
 0.9.6
96 105
 ===
97
-   Figured out that some terminal windows have a white background (duh).
98
-   Fixed shifts for Ubuntu's hated dash.
99
-   Fixed some other Linux problems.
106
+*  Figured out that some terminal windows have a white background (duh).
107
+*  Fixed shifts for Ubuntu's hated dash.
108
+*  Fixed some other Linux problems.
100 109
 
101 110
 0.9.5
102 111
 ===
103
-   Messed up the tagging somewhat... 0.9.1 and 0.9.2 were the same and
104
-   0.9.3 doesn't even exist. So now 0.9.5 is the one.
112
+*  Messed up the tagging somewhat... 0.9.1 and 0.9.2 were the same and
113
+*  0.9.3 doesn't even exist. So now 0.9.5 is the one.
105 114
 
106
-   Don't trace environment reads of MULLE_BOOTSTRAP_ANSWER and
107
-   MULLE_BOOTSTRAP_VERBOSE.
108
-   Fix xcodebuild log filename generation
109
-   Fix dry run some more.
110
-   Less output during dispensal, when not using -v.
111
-   Reduce usage output to 25 lines.
115
+*  Don't trace environment reads of MULLE_BOOTSTRAP_ANSWER and
116
+*  MULLE_BOOTSTRAP_VERBOSE.
117
+*  Fix xcodebuild log filename generation
118
+*  Fix dry run some more.
119
+*  Less output during dispensal, when not using -v.
120
+*  Reduce usage output to 25 lines.
112 121
 
113 122
 0.9.1
114 123
 ===
115
-   Fix cmake and configure build.
124
+*  Fix cmake and configure build.
116 125
 
117 126
 0.9
118 127
 ===
119
-   Specifying repos with mulle-bootstrap build <repos> was broken.
120
-   Added -y option, so everything is answered YES. I use this all the time.
121
-   Log xcodebuild command line into logfile.
122
-   Fix useless errors during dry run.
123
-   ** Changed the way custom "build.sh" scripts are executed. **
124
-   You can give a xcodeproj to mulle-bootstrap xcode directly, nice for
128
+*  Specifying repos with mulle-bootstrap build <repos> was broken.
129
+*  Added -y option, so everything is answered YES. I use this all the time.
130
+*  Log xcodebuild command line into logfile.
131
+*  Fix useless errors during dry run.
132
+*  ** Changed the way custom "build.sh" scripts are executed. **
133
+*  You can give a xcodeproj to mulle-bootstrap xcode directly, nice for
125 134
    sharing  dependencies with many subprojects.
126
-   Fixes the collection and dispensal of built frameworks.
127
-   Added logging to various 'cd' commands.
128
-   Collect and dispense symbolic links for directories too (not just for files)
129
-   Beautified output a little bit.
130
-   Respect the terse flag (-s) during mulle-bootstrap xcode add.
131
-   Add VENDOR_PREFIX to mulle-bootstrap-tag as third parameter.
135
+*  Fixes the collection and dispensal of built frameworks.
136
+*  Added logging to various 'cd' commands.
137
+*  Collect and dispense symbolic links for directories too (not just for files)
138
+*  Beautified output a little bit.
139
+*  Respect the terse flag (-s) during mulle-bootstrap xcode add.
140
+*  Add VENDOR_PREFIX to mulle-bootstrap-tag as third parameter.
132 141
 
133 142
 
134 143
 0.8.1
135 144
 ===
136
-   And the fix, just minutes after the "release". warn scripts didn't
145
+*  And the fix, just minutes after the "release". warn scripts didn't
137 146
    find a function, and now I have cleaned this up properly, I think.
138
-   No more duplicate functions.
147
+*  No more duplicate functions.
139 148
 
140 149
 0.8
141 150
 ===
142
-   Added dist shortcut, because I always like to type "dist-clean".
143
-   Allow upper-case user input for yes/no questions.
144
-   Write protect dependencies folder, because I have a tendency to edit
151
+*  Added dist shortcut, because I always like to type "dist-clean".
152
+*  Allow upper-case user input for yes/no questions.
153
+*  Write protect dependencies folder, because I have a tendency to edit
145 154
    the headers.
146
-   Automatically append boring directories to .gitignore after fetch.
147
-   Inverted script default answer, because it pains me. Also it's not
155
+*  Automatically append boring directories to .gitignore after fetch.
156
+*  Inverted script default answer, because it pains me. Also it's not
148 157
    useful when using -a to just "breeze" through.
149
-   Redirect build logs to "build/.repos/.logs", because especially
158
+*  Redirect build logs to "build/.repos/.logs", because especially
150 159
    xcodebuild is just too verbose.
151 160
 
152 161
 0.7.1
153 162
 ===
154
-   Fixed an internal error, when using mulle-bootstrap update.
163
+*  Fixed an internal error, when using mulle-bootstrap update.
155 164
 
156 165
 0.7
157 166
 ===
158
-   Added version command
167
+*  Added version command
159 168
 
160 169
 0.6
161 170
 ===
162
-   Improve scripts handling and add a some new phases to
171
+*  Improve scripts handling and add a some new phases to
163 172
    the proceedings. Actually the whole script stuff didn't work before...
164
-   Scripts in general aren't documented yet, because it's still very much
173
+*  Scripts in general aren't documented yet, because it's still very much
165 174
    in fluctuation.
166 175
 
167
-   More output during setting inheritance. Fix proper inheritance of
168
-   build_order and build_ignore.
176
+*  More output during setting inheritance. Fix proper inheritance of
177
+*  build_order and build_ignore.
169 178
 
170
-   Lots of en-passant bug fixes. Should be in general better than 0.5
179
+*  Lots of en-passant bug fixes. Should be in general better than 0.5
171 180
 
172
-   Add -V option.
181
+*  Add -V option.
173 182
 
174
-   Added new did-install script phase. Depending on actual usage, I'll
183
+*  Added new did-install script phase. Depending on actual usage, I'll
175 184
    probably ditch some of the other phases again. This is all in flux.
176 185
\ No newline at end of file
... ...
@@ -1,3 +1,2 @@
1 1
 Use different build dir than just build.
2 2
 Write "doctor" command to find common problems.
3
-Rebuild .auto before each command.
... ...
@@ -29,7 +29,7 @@
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
 
32
-VERSION=0.19
32
+VERSION=0.20
33 33
 
34 34
 #
35 35
 # This is the main user interface to mulle-bootstrap
... ...
@@ -171,10 +171,6 @@ EOF
171 171
 }
172 172
 
173 173
 
174
-command=${1:-"bootstrap"}
175
-[ $# -eq 0 ] || shift
176
-
177
-
178 174
 bootstrap()
179 175
 {
180 176
    if [ "$1" = "-h" -o "$1" = "--help" ]
... ...
@@ -206,17 +202,29 @@ bootstrap()
206 202
 }
207 203
 
208 204
 
205
+
209 206
 main()
210 207
 {
208
+   local command
211 209
 
212
-   if [ ! -d "${BOOTSTRAP_SUBDIR}" -a \
213
-      "${command}" != "init" -a \
214
-      "${command}" != "clone" -a \
215
-      "${command}" != "version"  -a \
216
-      "${command}" != "convert-pre-0.10" ]
210
+   command=${1:-"bootstrap"}
211
+   [ $# -eq 0 ] || shift
212
+
213
+   #
214
+   # some commands only run when we have a .bootstrap folder
215
+   #
216
+   if [ ! -d "${BOOTSTRAP_SUBDIR}" ]
217 217
    then
218
-      echo "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue" >&2
219
-      exit 1
218
+      case "${command}" in
219
+         bootstrap|nomagic|build|ibuild|refresh)
220
+            echo "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue" >&2
221
+            exit 1
222
+         ;;
223
+         dist-clean|fetch|update|setup-xcode|xcode|tag)
224
+            echo "There is no ${BOOTSTRAP_SUBDIR} folder here, can't continue" >&2
225
+            exit 1
226
+         ;;
227
+      esac
220 228
    fi
221 229
 
222 230
    case "${command}" in
... ...
@@ -228,17 +236,8 @@ main()
228 236
          DONT_RECURSE=YES bootstrap "$@" || exit 1
229 237
          ;;
230 238
 
231
-      clone)
232
-         set -e
233
-         git clone "$1"
234
-         cd "`basename "$1"`"
235
-         mulle-bootstrap-fetch.sh || exit 1
236
-         if [ -x "./build.sh" ]
237
-         then
238
-            ./build.sh
239
-         else
240
-            COMMAND="install" mulle-bootstrap-build.sh || exit 1
241
-         fi
239
+      project)
240
+         mulle-bootstrap-project.sh "$@" || exit 1
242 241
          ;;
243 242
 
244 243
       build)
... ...
@@ -186,5 +186,3 @@ bootstrap_auto_update()
186 186
 
187 187
    return 0
188 188
 }
189
-
190
-
... ...
@@ -478,6 +478,7 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
478 478
 
479 479
       logging_exekutor cmake "-DCMAKE_BUILD_TYPE=${mapped}" \
480 480
 "${sdkparameter}" \
481
+"-DDEPENDENCIES_DIR=${owd}/${REFERENCE_DEPENDENCY_SUBDIR}" \
481 482
 "-DCMAKE_INSTALL_PREFIX:PATH=${owd}/${BUILD_DEPENDENCY_SUBDIR}/usr/local"  \
482 483
 "-DCMAKE_C_FLAGS=\
483 484
 -I${relative}/${REFERENCE_DEPENDENCY_SUBDIR}/${HEADER_DIR_NAME} \
... ...
@@ -589,7 +590,8 @@ ${C_MAGENTA}${C_BOLD}${sdk}${C_INFO} in \"${builddir}\" ..."
589 590
       fi
590 591
 
591 592
       # use absolute paths for configure, safer (and easier to read IMO)
592
-       echo "CFLAGS=\"\
593
+       echo "DEPENDENCIES_DIR=\"'${owd}/${REFERENCE_DEPENDENCY_SUBDIR}'\" \
594
+      CFLAGS=\"\
593 595
 -I${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${HEADER_DIR_NAME} \
594 596
 -F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}${suffix} \
595 597
 -F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}/${configuration} \
... ...
@@ -614,6 +616,7 @@ ${other_ldflags} \
614 616
 -isysroot ${sdkpath}\"" >> "${logfile1}"
615 617
 
616 618
 
619
+       DEPENDENCIES_DIR="'${owd}/${REFERENCE_DEPENDENCY_SUBDIR}'" \
617 620
        CFLAGS="\
618 621
 -I${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${HEADER_DIR_NAME} \
619 622
 -F${owd}/${REFERENCE_DEPENDENCY_SUBDIR}/${FRAMEWORK_DIR_NAME}${suffix} \
... ...
@@ -1063,6 +1066,7 @@ DSTROOT='${owd}/${BUILD_DEPENDENCY_SUBDIR}' \
1063 1066
 INSTALL_PATH='/${LIBRARY_DIR_NAME}${suffix}' \
1064 1067
 SYMROOT='${owd}/${builddir}/' \
1065 1068
 OBJROOT='${owd}/${builddir}/obj' \
1069
+DEPENDENCIES_DIR='${owd}/${REFERENCE_DEPENDENCY_SUBDIR}' \
1066 1070
 ONLY_ACTIVE_ARCH=NO \
1067 1071
 ${skip_install} \
1068 1072
 ${other_cflags} \
... ...
@@ -53,7 +53,7 @@ usage: fetch <install|nonrecursive|update>
53 53
    You can specify the names of the repositories to update.
54 54
    Currently available names are:
55 55
 EOF
56
-   (cd "${CLONES_FETCH_SUBDIR}" ; ls -1 ) 2> /dev/null
56
+   (cd "${CLONESFETCH_SUBDIR}" ; ls -1 ) 2> /dev/null
57 57
 }
58 58
 
59 59
 
... ...
@@ -372,79 +372,6 @@ settings/build_order
372 372
 settings/build_ignore'
373 373
 
374 374
 
375
-
376
-
377
-ensure_clones_directory()
378
-{
379
-   if [ ! -d "${CLONES_FETCH_SUBDIR}" ]
380
-   then
381
-      if [ "${COMMAND}" = "update" ]
382
-      then
383
-         fail "install first before upgrading"
384
-      fi
385
-      mkdir_if_missing "${CLONES_FETCH_SUBDIR}"
386
-   fi
387
-}
388
-
389
-
390
-#
391
-# used to do this with chmod -h, alas Linux can't do that
392
-# So we create a special directory .zombies
393
-# and create files there
394
-#
395
-mark_all_zombies()
396
-{
397
-   local i
398
-   local name
399
-
400
-      # first mark all repos as stale
401
-   if dir_has_files "${CLONES_FETCH_SUBDIR}"
402
-   then
403
-      log_fluff "Marking all repositories as zombies for now"
404
-
405
-      mkdir_if_missing "${CLONES_FETCH_SUBDIR}/.zombies"
406
-
407
-      for i in `ls -1d "${CLONES_FETCH_SUBDIR}/"*`
408
-      do
409
-         if [ -d "${i}" -o -L "${i}" ]
410
-         then
411
-            name="`basename -- "${i}"`"
412
-            exekutor touch "${CLONES_FETCH_SUBDIR}/.zombies/${name}"
413
-         fi
414
-      done
415
-   fi
416
-}
417
-
418
-
419
-mark_alive()
420
-{
421
-   local dstdir
422
-   local name
423
-
424
-   name="$1"
425
-   dstdir="$2"
426
-
427
-   local zombie
428
-
429
-   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
430
-
431
-   # mark as alive
432
-   if [ -d "${dstdir}" -o -L "${dstdir}" ]
433
-   then
434
-      if [ -e "${zombie}" ]
435
-      then
436
-         log_fluff "Mark \"${dstdir}\" as alive"
437
-
438
-         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
439
-      else
440
-         log_fluff "Marked \"${dstdir}\" is already alive"
441
-      fi
442
-   else
443
-      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
444
-   fi
445
-}
446
-
447
-
448 375
 log_fetch_action()
449 376
 {
450 377
    local dstdir
... ...
@@ -666,14 +593,12 @@ clone_repository()
666 593
    local flag
667 594
 
668 595
    tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
669
-   dstdir="${CLONES_FETCH_SUBDIR}/${name}"
596
+   dstdir="${CLONESFETCH_SUBDIR}/${name}"
670 597
    log_fetch_action "${name}" "${dstdir}"
671 598
 
672 599
    checkout_repository "${name}" "${url}" "${dstdir}" "${tag}"
673 600
    flag=$?
674 601
 
675
-   mark_alive "${name}" "${dstdir}"
676
-
677 602
    return $flag
678 603
 }
679 604
 
... ...
@@ -688,7 +613,7 @@ did_clone_repository()
688 613
 
689 614
    local dstdir
690 615
 
691
-   dstdir="${CLONES_FETCH_SUBDIR}/${name}"
616
+   dstdir="${CLONESFETCH_SUBDIR}/${name}"
692 617
    run_build_settings_script "${name}" "${url}" "${dstdir}" "did-install" "${dstdir}" "${name}"
693 618
 }
694 619
 
... ...
@@ -704,8 +629,6 @@ clone_repositories()
704 629
 
705 630
    old="${IFS:-" "}"
706 631
 
707
-   mark_all_zombies
708
-
709 632
    stop=0
710 633
    while [ $stop -eq 0 ]
711 634
    do
... ...
@@ -799,8 +722,21 @@ install_embedded_repositories()
799 722
                fi
800 723
             fi
801 724
 
802
-            run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
725
+            # memo that we did this with a symlink
726
+            # store it inside the possibly recursed dstprefix dependency
727
+            local symlinkcontent
728
+            local symlinkdir
729
+            local symlinkrelative
730
+
731
+            symlinkrelative=`compute_relative "${CLONESFETCH_SUBDIR}/.embedded"`
732
+            symlinkdir="${dstprefix}${CLONESFETCH_SUBDIR}/.embedded"
733
+            mkdir_if_missing "${symlinkdir}"
734
+            symlinkcontent="${symlinkrelative}/${dstdir}"
803 735
 
736
+            log_fluff "Remember embedded repository \"${name}\" via \"${symlinkdir}/${name}\""
737
+            exekutor ln -s "${symlinkcontent}" "${symlinkdir}/${name}"
738
+
739
+            run_build_settings_script "${name}" "${url}" "${dstdir}" "post-${COMMAND}" "$@"
804 740
          else
805 741
             log_fluff "\"${dstdir}\" already exists"
806 742
          fi
... ...
@@ -878,7 +814,7 @@ update_repository()
878 814
 
879 815
    tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
880 816
 
881
-   dstdir="${CLONES_FETCH_SUBDIR}/${name}"
817
+   dstdir="${CLONESFETCH_SUBDIR}/${name}"
882 818
    exekutor [ -e "${dstdir}" ] || fail "You need to fetch \"${name}\" first, before updating"
883 819
    exekutor [ -x "${dstdir}" ] || fail "\"${name}\" is not anymore in \"repositories\""
884 820
 
... ...
@@ -893,6 +829,8 @@ update_repository()
893 829
       old="${BOOTSTRAP_SUBDIR}"
894 830
 
895 831
       BOOTSTRAP_SUBDIR="${dstdir}/.bootstrap"
832
+      CLONESFETCH_SUBDIR="${dstdir}/.repos"
833
+
896 834
       update_embedded_repositories "${dstdir}/"
897 835
       BOOTSTRAP_SUBDIR="${old}"
898 836
    fi
... ...
@@ -909,7 +847,7 @@ did_update_repository()
909 847
 
910 848
    local dstdir
911 849
 
912
-   dstdir="${CLONES_FETCH_SUBDIR}/${name}"
850
+   dstdir="${CLONESFETCH_SUBDIR}/${name}"
913 851
 
914 852
    run_build_settings_script "${name}" "${url}" "${dstdir}" "did-update" "${dstdir}" "${name}"
915 853
 }
... ...
@@ -940,7 +878,7 @@ update_repositories()
940 878
       for name in "$@"
941 879
       do
942 880
          IFS="${old}"
943
-         update_repository "${name}" "${CLONES_FETCH_SUBDIR}/${name}"
881
+         update_repository "${name}" "${CLONESFETCH_SUBDIR}/${name}"
944 882
       done
945 883
 
946 884
       IFS="
... ...
@@ -948,7 +886,7 @@ update_repositories()
948 886
       for name in "$@"
949 887
       do
950 888
          IFS="${old}"
951
-         did_update_repository "${name}" "${CLONES_FETCH_SUBDIR}/${name}"
889
+         did_update_repository "${name}" "${CLONESFETCH_SUBDIR}/${name}"
952 890
       done
953 891
    else
954 892
       clones="`read_fetch_setting "repositories"`"
... ...
@@ -360,6 +360,9 @@ escaped_spaces()
360 360
 
361 361
 combined_escaped_search_path()
362 362
 {
363
+   local i
364
+   local path
365
+
363 366
    for i in "$@"
364 367
    do
365 368
       if [ ! -z "$i" ]
... ...
@@ -492,6 +495,9 @@ find_xcodeproj()
492 495
    depth=1000
493 496
    #     IFS='\0'
494 497
 
498
+   local match
499
+   local new_depth
500
+
495 501
    for i in `find . -name "*.xcodeproj" -print`
496 502
    do
497 503
       match=`basename -- "${i}" .xcodeproj`
... ...
@@ -594,3 +600,16 @@ run_log_script()
594 600
    echo "$@"
595 601
    run_script "$@"
596 602
 }
603
+
604
+
605
+ensure_clones_directory()
606
+{
607
+   if [ ! -d "${CLONESFETCH_SUBDIR}" ]
608
+   then
609
+      if [ "${COMMAND}" = "update" ]
610
+      then
611
+         fail "install first before upgrading"
612
+      fi
613
+      mkdir_if_missing "${CLONESFETCH_SUBDIR}"
614
+   fi
615
+}
... ...
@@ -33,7 +33,7 @@
33 33
 # read local environment
34 34
 # source this file
35 35
 #
36
-if [ "${BOOTSTRAP_SUBDIR}" = "" ]
36
+if [ -z "${BOOTSTRAP_SUBDIR}" ]
37 37
 then
38 38
    BOOTSTRAP_SUBDIR=.bootstrap
39 39
 fi
... ...
@@ -71,15 +71,22 @@ then
71 71
    log_trace "Dry run is active."
72 72
 fi
73 73
 
74
-CLONES_SUBDIR=`read_sane_config_path_setting "repos_foldername" ".repos"`
74
+# can't rename this because of embedded reposiories
75
+CLONES_SUBDIR=.repos
76
+
75 77
 CLONESBUILD_SUBDIR=`read_sane_config_path_setting "build_foldername" "build/.repos"`
76 78
 DEPENDENCY_SUBDIR=`read_sane_config_path_setting "output_foldername" "dependencies"`
77 79
 BUILDLOG_SUBDIR=`read_sane_config_path_setting "build_log_foldername" "${CLONESBUILD_SUBDIR}/.logs"`
78 80
 
79 81
 
80
-if [ "${CLONES_FETCH_SUBDIR}" = "" ]
82
+if [ "${CLONESFETCH_SUBDIR}" = "" ]
83
+then
84
+   CLONESFETCH_SUBDIR="${CLONES_SUBDIR}"
85
+fi
86
+
87
+if [ "${CLONESFETCH_RELATIVE}" = "" ]
81 88
 then
82
-   CLONES_FETCH_SUBDIR="${CLONES_SUBDIR}"
89
+   CLONESFETCH_RELATIVE=`compute_relative "${CLONESFETCH_SUBDIR}"`
83 90
 fi
84 91
 
85 92
 #
... ...
@@ -118,7 +125,7 @@ FRAMEWORK_DIR_NAME="`read_config_setting "framework_dir_name" "Frameworks"`"
118 125
 # export stuff for scripts
119 126
 #
120 127
 export CLONES_SUBDIR
121
-export CLONES_FETCH_SUBDIR
128
+export CLONESFETCH_SUBDIR
122 129
 export CLONESBUILD_SUBDIR
123 130
 export BUILDLOG_SUBDIR
124 131
 export DEPENDENCY_SUBDIR
125 132
new file mode 100644
... ...
@@ -0,0 +1,124 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2016 Nat! - Mulle kybernetiK
4
+#   All rights reserved.
5
+#
6
+#   Redistribution and use in source and binary forms, with or without
7
+#   modification, are permitted provided that the following conditions are met:
8
+#
9
+#   Redistributions of source code must retain the above copyright notice, this
10
+#   list of conditions and the following disclaimer.
11
+#
12
+#   Redistributions in binary form must reproduce the above copyright notice,
13
+#   this list of conditions and the following disclaimer in the documentation
14
+#   and/or other materials provided with the distribution.
15
+#
16
+#   Neither the name of Mulle kybernetiK nor the names of its contributors
17
+#   may be used to endorse or promote products derived from this software
18
+#   without specific prior written permission.
19
+#
20
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
24
+#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25
+#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26
+#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27
+#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28
+#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29
+#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30
+#
31
+
32
+# tag this project, and all cloned dependencies
33
+# the dependencies will get a different vendor tag
34
+# based on the tag
35
+#
36
+
37
+. mulle-bootstrap-local-environment.sh
38
+. mulle-bootstrap-scripts.sh
39
+
40
+
41
+name=`basename -- "${PWD}"`
42
+
43
+
44
+usage()
45
+{
46
+   cat <<EOF
47
+usage: project <clone|build|install> <options>
48
+
49
+   clone   : clone a remote git repoistory and try to build something
50
+   build   : execute ./build.sh, if missing do a mulle-bootstrap build
51
+   install : execute ./install.sh, if missing execute ./build.sh install
52
+EOF
53
+}
54
+
55
+
56
+check_and_usage_and_help()
57
+{
58
+   if [ "$1" = "" -o "$1" = "-h" -o "$1" = "--help" ]
59
+   then
60
+      usage >&2
61
+      exit 1
62
+   fi
63
+}
64
+
65
+
66
+project()
67
+{
68
+   local command
69
+
70
+   command="$1"
71
+   case  "${command}" in
72
+      http:*|https:*)
73
+         command="clone";
74
+         ;;
75
+      *)
76
+         [ $# -eq 0 ] || shift
77
+         ;;
78
+   esac
79
+
80
+   case  "${command}" in
81
+   clone)
82
+      set -e
83
+      git clone "$1"
84
+      cd "`basename "$1"`"
85
+      mulle-bootstrap-fetch.sh || exit 1
86
+      if [ -x "./build.sh" ]
87
+      then
88
+         ./build.sh
89
+      else
90
+         COMMAND="install" mulle-bootstrap-build.sh || exit 1
91
+      fi
92
+      ;;
93
+
94
+   build)
95
+      if [ -x "./build.sh" ]
96
+      then
97
+         ./build.sh
98
+      fi
99
+      ;;
100
+
101
+   install)
102
+      if [ -x "./install.sh" ]
103
+      then
104
+         ./install.sh
105
+      else
106
+         if [ -x "./build.sh" ]
107
+         then
108
+            ./build.sh install
109
+         fi
110
+      fi
111
+      ;;
112
+
113
+   *)
114
+      usage >&2
115
+      exit 1
116
+      ;;
117
+
118
+   esac
119
+}
120
+
121
+
122
+check_and_usage_and_help "$@"
123
+
124
+project "$@"
... ...
@@ -43,7 +43,7 @@ usage()
43 43
 {
44 44
    cat <<EOF
45 45
 usage: refresh <refresh|nonrecursive>
46
-   install      : default, install settings into .bootstrap.auto
46
+   refresh      : update settings, remove unused repositories (default)
47 47
    nonrecursive : ignore .bootstrap folders of fetched repositories
48 48
 EOF
49 49
 }
... ...
@@ -112,7 +112,7 @@ refresh_repositories_settings()
112 112
          name="`canonical_name_from_clone "${clone}"`"
113 113
          url="`url_from_clone "${clone}"`"
114 114
          tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
115
-         dstdir="${CLONES_FETCH_SUBDIR}/${name}"
115
+         dstdir="${CLONESFETCH_SUBDIR}/${name}"
116 116
 
117 117
          bootstrap_auto_update "${name}" "${url}" "${dstdir}" "$INHERIT_SETTINGS"
118 118
       done
... ...
@@ -122,6 +122,348 @@ refresh_repositories_settings()
122 122
 }
123 123
 
124 124
 
125
+# ----------------
126
+
127
+#
128
+# used to do this with chmod -h, alas Linux can't do that
129
+# So we create a special directory .zombies
130
+# and create files there
131
+#
132
+mark_all_repositories_zombies()
133
+{
134
+   local i
135
+   local name
136
+
137
+      # first mark all repos as stale
138
+   if dir_has_files "${CLONESFETCH_SUBDIR}"
139
+   then
140
+      log_fluff "Marking all repositories as zombies for now"
141
+
142
+      mkdir_if_missing "${CLONESFETCH_SUBDIR}/.zombies"
143
+
144
+      for i in `ls -1d "${CLONESFETCH_SUBDIR}/"*`
145
+      do
146
+         if [ -d "${i}" -o -L "${i}" ]
147
+         then
148
+            name="`basename -- "${i}"`"
149
+            exekutor touch "${CLONESFETCH_SUBDIR}/.zombies/${name}"
150
+         fi
151
+      done
152
+   fi
153
+}
154
+
155
+
156
+mark_repository_alive()
157
+{
158
+   local dstdir
159
+   local name
160
+
161
+   name="$1"
162
+   dstdir="$2"
163
+
164
+   local zombie
165
+
166
+   zombie="`dirname -- "${dstdir}"`/.zombies/${name}"
167
+
168
+   # mark as alive
169
+   if [ -d "${dstdir}" -o -L "${dstdir}" ]
170
+   then
171
+      if [ -e "${zombie}" ]
172
+      then
173
+         log_fluff "Mark \"${dstdir}\" as alive"
174
+
175
+         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
176
+      else
177
+         log_fluff "Marked \"${dstdir}\" is already alive"
178
+      fi
179
+   else
180
+      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
181
+   fi
182
+}
183
+
184
+
185
+bury_zombies()
186
+{
187
+   local i
188
+   local name
189
+   local dstdir
190
+   local zombiepath
191
+   local gravepath
192
+
193
+      # first mark all repos as stale
194
+   zombiepath="${CLONESFETCH_SUBDIR}/.zombies"
195
+   if dir_has_files "${zombiepath}"
196
+   then
197
+      log_fluff "Burying zombies into graveyard"
198
+
199
+      gravepath="${CLONESFETCH_SUBDIR}/.graveyard"
200
+      mkdir_if_missing "${gravepath}"
201
+
202
+      for i in `ls -1 "${zombiepath}/"*`
203
+      do
204
+         if [ -e "${i}" ]
205
+         then
206
+            name="`basename -- "${i}"`"
207
+            dstdir="${CLONESFETCH_SUBDIR}/${name}"
208
+            if [ -d "${dstdir}" ]
209
+            then
210
+               log_info "Removing unused repository ${C_MAGENTA_BOLD}${name}${C_INFO}"
211
+
212
+               if [ -e "${gravepath}/${name}" ]
213
+               then
214
+                  exekutor rm -rf "${gravepath}/${name}"
215
+                  log_fluff "Made for a new grave at \"${gravepath}/${name}\""
216
+               fi
217
+
218
+               exekutor mv "${dstdir}" "${gravepath}"
219
+               exekutor rm "${i}"
220
+            else
221
+               log_fluff "\"${dstdir}\" zombie vanished or never existed"
222
+            fi
223
+         fi
224
+      done
225
+   fi
226
+
227
+   if [ -d "${zombiepath}" ]
228
+   then
229
+      exekutor rm -rf "${zombiepath}"
230
+   fi
231
+}
232
+
233
+#
234
+# ###
235
+#
236
+
237
+mark_all_embedded_repositories_zombies()
238
+{
239
+   local i
240
+   local name
241
+   local symlink
242
+   local path
243
+   local zombiepath
244
+
245
+      # first mark all repos as stale
246
+   path="${CLONESFETCH_SUBDIR}/.embedded"
247
+   if dir_has_files "${CLONESFETCH_SUBDIR}/.embedded"
248
+   then
249
+      log_fluff "Marking all embedded repositories as zombies for now"
250
+
251
+      zombiepath="${CLONESFETCH_SUBDIR}/.embedded/.zombies"
252
+      mkdir_if_missing "${zombiepath}"
253
+
254
+      for symlink in `ls -1d "${path}/"*`
255
+      do
256
+         i="`readlink "$symlink"`"
257
+         name="`basename "$i"`"
258
+         exekutor touch "${zombiepath}/${name}"
259
+      done
260
+   fi
261
+}
262
+
263
+
264
+mark_embedded_repository_alive()
265
+{
266
+   local dstdir
267
+   local name
268
+
269
+   name="$1"
270
+   dstdir="$2"
271
+
272
+   local zombie
273
+
274
+   zombie="${CLONESFETCH_SUBDIR}/.embedded/.zombies/${name}"
275
+
276
+   # mark as alive
277
+   if [ -d "${dstdir}" -o -L "${dstdir}" ]
278
+   then
279
+      if [ -e "${zombie}" ]
280
+      then
281
+         log_fluff "Mark \"${dstdir}\" as alive"
282
+
283
+         exekutor rm -f "${zombie}" || fail "failed to delete zombie ${zombie}"
284
+      else
285
+         log_fluff "Marked \"${dstdir}\" is already alive"
286
+      fi
287
+   else
288
+      log_fluff "\"${dstdir}\" is neither a symlink nor a directory"
289
+   fi
290
+}
291
+
292
+
293
+bury_embedded_zombies()
294
+{
295
+   local i
296
+   local name
297
+   local dstdir
298
+   local path
299
+   local zombiepath
300
+   local gravepath
301
+   local path2
302
+
303
+      # first mark all repos as stale
304
+   zombiepath="${CLONESFETCH_SUBDIR}/.embedded/.zombies"
305
+   if dir_has_files "${zombiepath}"
306
+   then
307
+      log_fluff "Burying embedded zombies into graveyard"
308
+
309
+      gravepath="${CLONESFETCH_SUBDIR}/.embedded/.graveyard"
310
+      mkdir_if_missing "${gravepath}"
311
+
312
+      for i in `ls -1 "${zombiepath}/"*`
313
+      do
314
+         if [ -f "${i}" ]
315
+         then
316
+            name="`basename -- "${i}"`"
317
+            dstdir="${name}"
318
+            log_info "Removing unused embedded repository ${C_MAGENTA_BOLD}${name}${C_INFO}"
319
+
320
+            if [ -d "${dstdir}" ]
321
+            then
322
+               if [ -e "${gravepath}/${name}" ]
323
+               then
324
+                  exekutor rm -rf "${gravepath}/${name}"
325
+                  log_fluff "Made for a new grave at \"${gravepath}/${name}\""
326
+               fi
327
+               exekutor mv "${dstdir}" "${gravepath}"
328
+               exekutor rm "${i}"
329
+               exekutor rm "${CLONESFETCH_SUBDIR}/.embedded/${name}"
330
+            else
331
+               log_fluff "\"${dstdir}\" embedded zombie vanished or never existed"
332
+            fi
333
+         fi
334
+      done
335
+   fi
336
+
337
+   if [ -d "${zombiepath}" ]
338
+   then
339
+      exekutor rm -rf "${zombiepath}"
340
+   fi
341
+}
342
+
343
+#
344
+# ###
345
+#
346
+
347
+refresh_repositories()
348
+{
349
+   local clones
350
+   local clone
351
+   local old
352
+   local name
353
+   local url
354
+   local dstdir
355
+
356
+   mark_all_repositories_zombies
357
+
358
+   old="${IFS:-" "}"
359
+
360
+   clones="`read_fetch_setting "repositories"`"
361
+   if [ "${clones}" != "" ]
362
+   then
363
+      ensure_clones_directory
364
+
365
+      IFS="
366
+"
367
+      for clone in ${clones}
368
+      do
369
+         IFS="${old}"
370
+         name="`canonical_name_from_clone "${clone}"`"
371
+         dstdir="${CLONESFETCH_SUBDIR}/${name}"
372
+
373
+         # if it's not there it's not fetched yet, that's OK
374
+         mark_repository_alive "${name}" "${dstdir}"
375
+      done
376
+   fi
377
+
378
+   IFS="${old}"
379
+
380
+   bury_zombies
381
+}
382
+
383
+
384
+_refresh_embedded_repositories()
385
+{
386
+   local clones
387
+   local clone
388
+   local old
389
+   local name
390
+   local dstdir
391
+
392
+   old="${IFS:-" "}"
393
+
394
+   clones="`read_fetch_setting "embedded_repositories"`"
395
+   if [ "${clones}" != "" ]
396
+   then
397
+      IFS="
398
+"
399
+      for clone in ${clones}
400
+      do
401
+         IFS="${old}"
402
+
403
+         ensure_clones_directory
404
+
405
+         name="`canonical_name_from_clone "${clone}"`"
406
+         dstdir="${name}"
407
+         mark_embedded_repository_alive "${name}" "${dstdir}"
408
+      done
409
+   fi
410
+
411
+   IFS="${old}"
412
+}
413
+
414
+
415
+refresh_embedded_repositories()
416
+{
417
+   mark_all_embedded_repositories_zombies
418
+
419
+   _refresh_embedded_repositories
420
+
421
+   bury_embedded_zombies
422
+}
423
+
424
+
425
+refresh_deeply_embedded_repositories()
426
+{
427
+   local clones
428
+   local clone
429
+   local old
430
+   local name
431
+   local url
432
+   local dstprefix
433
+   local previous_bootstrap
434
+   local previous_clones
435
+
436
+   old="${IFS:-" "}"
437
+
438
+   clones="`read_fetch_setting "repositories"`"
439
+   if [ "${clones}" != "" ]
440
+   then
441
+      IFS="
442
+"
443
+      for clone in ${clones}
444
+      do
445
+         IFS="${old}"
446
+         name="`canonical_name_from_clone "${clone}"`"
447
+         dstprefix="${CLONESFETCH_SUBDIR}/${name}/"
448
+
449
+         previous_bootstrap="${BOOTSTRAP_SUBDIR}"
450
+         previous_clones="${CLONESFETCH_SUBDIR}"
451
+         BOOTSTRAP_SUBDIR="${dstprefix}.bootstrap"
452
+         CLONESFETCH_SUBDIR="${dstprefix}${CLONESFETCH_SUBDIR}"
453
+
454
+         refresh_embedded_repositories
455
+
456
+         BOOTSTRAP_SUBDIR="${previous_bootstrap}"
457
+         CLONESFETCH_SUBDIR="${previous_clones}"
458
+      done
459
+   fi
460
+
461
+   IFS="${old}"
462
+}
463
+
464
+
465
+
466
+# -------------------
125 467
 
126 468
 main()
127 469
 {
... ...
@@ -137,8 +479,21 @@ main()
137 479
 
138 480
    if [ "${DONT_RECURSE}" = "" ]
139 481
    then
482
+      log_fluff "Refreshing repository settings"
140 483
       refresh_repositories_settings
141 484
    fi
485
+
486
+   log_fluff "Detect zombie repositories"
487
+   refresh_repositories
488
+
489
+   log_fluff "Detect embedded zombie repositories"
490
+   refresh_embedded_repositories
491
+
492
+   if [ "${DONT_RECURSE}" = "" ]
493
+   then
494
+      log_fluff "Detect deeply embedded zombie repositories"
495
+      refresh_deeply_embedded_repositories
496
+   fi
142 497
 }
143 498
 
144 499
 main "$@"
145 500
new file mode 100755
... ...
@@ -0,0 +1,158 @@
1
+#! /bin/sh -x
2
+
3
+create_demo_repo()
4
+{
5
+   local name
6
+
7
+   name="$1"
8
+
9
+   set -e
10
+   mkdir "${name}"
11
+   cd "${name}"
12
+   echo "# ${name}" > README.md
13
+   git init
14
+   git add README.md
15
+   git commit -m "Mercyful Release" README.md
16
+   cd ..
17
+   set +e
18
+}
19
+
20
+
21
+##
22
+## Setup test environment
23
+##
24
+
25
+rm -rf a b c d e f g h main 2> /dev/null
26
+
27
+create_demo_repo a
28
+create_demo_repo b
29
+create_demo_repo c
30
+
31
+create_demo_repo d
32
+
33
+create_demo_repo e
34
+create_demo_repo f
35
+create_demo_repo g
36
+create_demo_repo h
37
+
38
+set -e
39
+
40
+# one subdirectory has an embedded dir
41
+(
42
+   cd a;
43
+   mkdir .bootstrap
44
+   cat <<EOF > .bootstrap/embedded_repositories
45
+../d
46
+EOF
47
+   git add .bootstrap/embedded_repositories
48
+   git commit -m "embedded added"
49
+)
50
+
51
+# one project depends on a another unknown
52
+(
53
+   cd b;
54
+   mkdir .bootstrap
55
+   cat <<EOF > .bootstrap/repositories
56
+../h
57
+EOF
58
+   git add .bootstrap/repositories
59
+   git commit -m "repository added"
60
+)
61
+
62
+# one project depends on a another known
63
+(
64
+   cd c;
65
+   mkdir .bootstrap
66
+   cat <<EOF > .bootstrap/repositories
67
+../a
68
+EOF
69
+   git add .bootstrap/repositories
70
+   git commit -m "repository added"
71
+)
72
+
73
+
74
+mkdir "main"
75
+cd "main"
76
+
77
+mkdir .bootstrap
78
+cat <<EOF > .bootstrap/repositories
79
+../b
80
+../c
81
+EOF
82
+cat <<EOF > .bootstrap/embedded_repositories
83
+../e
84
+../f
85
+../g
86
+EOF
87
+
88
+##
89
+## Now test
90
+##
91
+mulle-bootstrap -a fetch
92
+
93
+[ ! -d .repos/a ]   && echo "failed to fetch a" && exit 1
94
+[ ! -d .repos/b ]   && echo "failed to fetch b" && exit 1
95
+[ ! -d .repos/c ]   && echo "failed to fetch c" && exit 1
96
+[ ! -d .repos/a/d ] && echo "failed to fetch a/d" && exit 1
97
+[ ! -d e ]          && echo "failed to fetch d" && exit 1
98
+[ ! -d f ]          && echo "failed to fetch e" && exit 1
99
+[ ! -d g ]          && echo "failed to fetch f" && exit 1
100
+[ ! -d .repos/h ]   && echo "failed to fetch h" && exit 1
101
+
102
+mulle-bootstrap refresh
103
+
104
+[ ! -d .repos/a ]   && echo "wrongly removed a" && exit 1
105
+[ ! -d .repos/b ]   && echo "wrongly removed b" && exit 1
106
+[ ! -d .repos/c ]   && echo "wrongly removed c" && exit 1
107
+[ ! -d .repos/a/d ] && echo "wrongly removed a/d" && exit 1
108
+[ ! -d e ]          && echo "wrongly removed e" && exit 1
109
+[ ! -d f ]          && echo "wrongly removed f" && exit 1
110
+[ ! -d g ]          && echo "wrongly removed g" && exit 1
111
+[ ! -d .repos/h ]   && echo "wrongly removed h" && exit 1
112
+
113
+
114
+cat <<EOF > .bootstrap/embedded_repositories
115
+../e
116
+../g
117
+EOF
118
+
119
+mulle-bootstrap refresh
120
+
121
+[ ! -d .repos/a ]   && echo "wrongly removed a" && exit 1
122
+[ ! -d .repos/b ]   && echo "wrongly removed b" && exit 1
123
+[ ! -d .repos/c ]   && echo "wrongly removed c" && exit 1
124
+[ ! -d .repos/a/d ] && echo "wrongly removed a/d" && exit 1
125
+[ ! -d e ]          && echo "wrongly removed e" && exit 1
126
+[   -d f ]          && echo "failed to remove f" && exit 1
127
+[ ! -d g ]          && echo "wrongly removed g" && exit 1
128
+[ ! -d .repos/h ]   && echo "wrongly removed h" && exit 1
129
+
130
+cat <<EOF > .bootstrap/repositories
131
+../a
132
+../c
133
+EOF
134
+
135
+mulle-bootstrap refresh
136
+
137
+[ ! -d .repos/a ]   && echo "wrongly removed a" && exit 1
138
+[   -d .repos/b ]   && echo "failed to remove b" && exit 1
139
+[ ! -d .repos/c ]   && echo "wrongly removed c" && exit 1
140
+[ ! -d .repos/a/d ] && echo "wrongly removed a/d" && exit 1
141
+[ ! -d e ]          && echo "wrongly removed e" && exit 1
142
+[   -d f ]          && echo "failed to remove f" && exit 1
143
+[ ! -d g ]          && echo "wrongly removed g" && exit 1
144
+[   -d .repos/h ]   && echo "mistakenly refetched h" && exit 1
145
+
146
+# hack
147
+rm .repos/a/.bootstrap/embedded_repositories
148
+
149
+mulle-bootstrap refresh
150
+
151
+[ ! -d .repos/a ]   && echo "wrongly removed a" && exit 1
152
+[   -d .repos/b ]   && echo "mistakenly refetched b" && exit 1
153
+[ ! -d .repos/c ]   && echo "wrongly removed c" && exit 1
154
+[   -d .repos/a/d ] && echo "failed to remove a/d" && exit 1
155
+[ ! -d e ]          && echo "wrongly removed e" && exit 1
156
+[   -d f ]          && echo "mistakenly refetched f" && exit 1
157
+[ ! -d g ]          && echo "wrongly removed g" && exit 1
158
+[   -d .repos/h ]   && echo "mistakenly refetched h" && exit 1