Browse code

Getting into a usable state.

Can now also update previously fetched repositories.
-n dry run, works for fetch and build

Improved usage output.

Nat! authored on 01-10-2015 16:49:31
Showing 11 changed files
... ...
@@ -70,15 +70,67 @@ fi
70 70
 
71 71
 
72 72
 
73
+usage()
74
+{
75
+   cat <<EOF
76
+usage: mulle-bootstrap [-n][-v][-s] [command] [--help]
77
+       version 0.3
78
+
79
+ Specify the -h or --help option after each command to get more help.
80
+
81
+ Flags (must be in this order)
82
+   -n        : do nothing creative or destructive
83
+   -v        : be more verbose
84
+   -s        : be more terse
85
+
86
+ Common user commands:
87
+   bootstrap : does fetch and build recursively [default]
88
+   nomagic   : does fetch and build, but not recursively
89
+   clean     : cleans mulle-bootstrap produced files.
90
+
91
+ Common maintainer commands:
92
+   init      : initializes a bootstrap project
93
+   xcode     : sets up the xcodeproj settings
94
+   tag       : tag this project and fetched repositories
95
+
96
+ Specialized commands:
97
+   build     : builds fetched repositories
98
+   fetch     : fetches required repositories recursively.
99
+   update    : updates repositories (pull).
100
+EOF
101
+}
102
+
103
+
104
+if [ "$1" = "-h" -o "$1" = "--help" ]
105
+then
106
+    check_and_usage_and_help
107
+fi
108
+
73 109
 command=${1:-"bootstrap"}
74 110
 shift
75 111
 
76
-
77 112
 . mulle-bootstrap-warn-scripts.sh
78 113
 
114
+check_and_usage_and_help()
115
+{
116
+   cat <<EOF
117
+usage: bootstrap
118
+   There is nothing more to it.
119
+EOF
120
+}
121
+
79 122
 
80 123
 bootstrap()
81 124
 {
125
+   if [ "$1" = "-h" -o "$1" = "--help" ]
126
+   then
127
+       check_and_usage_and_help >&2
128
+       exit 1
129
+   fi
130
+   #
131
+   # Parameter
132
+   #
133
+
82 134
    if [ ! -d "${BOOTSTRAP_SUBDIR}" ]
83 135
    then
84 136
       echo "there is no ${BOOTSTRAP_SUBDIR} here, can't continue" >&2
... ...
@@ -98,70 +150,59 @@ bootstrap()
98 150
 
99 151
    if [ "${DONT_RECURSE}" = "" ]
100 152
    then
101
-      mulle-bootstrap-fetch.sh "$@" || exit 1
153
+      mulle-bootstrap-fetch.sh || exit 1
102 154
    else
103
-      mulle-bootstrap-fetch.sh nonrecursive "$@" || exit 1
155
+      mulle-bootstrap-fetch.sh nonrecursive  || exit 1
104 156
    fi
105
-   mulle-bootstrap-build.sh "$@" || exit 1
157
+   mulle-bootstrap-build.sh  || exit 1
106 158
 }
107 159
 
108 160
 
109
-case "${command}" in
110
-   bootstrap)
111
-      bootstrap "$@" || exit 1
112
-      ;;
113
-
114
-   nomagic)
115
-      DONT_RECURSE=YES bootstrap "$@" || exit 1
116
-      ;;
117
-
118
-   build)
119
-      mulle-bootstrap-build.sh "$@" || exit 1
120
-      ;;
121
-
122
-   clean)
123
-      mulle-bootstrap-clean.sh "$@" || exit 1
124
-      ;;
125
-
126
-   fetch)
127
-      mulle-bootstrap-fetch.sh "$@" || exit 1
128
-      ;;
129
-
130
-   init)
131
-      mulle-bootstrap-init.sh "$@" || exit 1
132
-      ;;
133
-
134
-   setup-xcode|xcode)
135
-      mulle-bootstrap-xcode.sh "$@"|| exit 1
136
-      ;;
137
-
138
-   tag)
139
-      mulle-bootstrap-tag.sh "$@" || exit 1
140
-      ;;
141
-
142
-   *)
143
-      echo "usage: mulle-bootstrap [-n][-v][-s] [command]" >&2
144
-      echo "version 0.2" >&2
145
-      echo " Flags (must be in this order)" >&2
146
-      echo "   -n        : do nothing creative or destructive" >&2
147
-      echo "   -v        : be more verbose" >&2
148
-      echo "   -s        : be more terse" >&2
149
-      echo ""
150
-      echo " Common user commands:" >&2
151
-      echo "   bootstrap : does fetch and build recursively [default]" >&2
152
-      echo "   nomagic   : does fetch and build, but not recursively" >&2
153
-      echo "" >& 2
154
-      echo " Common maintainer commands:" >&2
155
-      echo "   init      : initializes a bootstrap project" >&2
156
-      echo "   xcode [o] : sets up the xcodeproj settings" >&2
157
-      echo "               with [o=remove] removes settings again." >&2
158
-      echo "   tag       : tag this project and fetched repositories" >&2
159
-      echo "" >& 2
160
-      echo " Specialized commands:" >&2
161
-      echo "   build     : builds fetched repositories" >&2
162
-      echo "   fetch [o] : fetches required repositories recursively." >&2
163
-      echo "               whith [o=nonrecursive] fetches non recursively." >&2
164
-      echo "   clean [o] : cleans intermediate build files." >&2
165
-      echo "               with [o=dist] cleans clones and dependencies too." >&2
166
-      exit 1
167
-esac
161
+main()
162
+{
163
+   case "${command}" in
164
+      bootstrap)
165
+         bootstrap "$@" || exit 1
166
+         ;;
167
+
168
+      nomagic)
169
+         DONT_RECURSE=YES bootstrap "$@" || exit 1
170
+         ;;
171
+
172
+      build)
173
+         mulle-bootstrap-build.sh "$@" || exit 1
174
+         ;;
175
+
176
+      clean)
177
+         mulle-bootstrap-clean.sh "$@" || exit 1
178
+         ;;
179
+
180
+      fetch)
181
+         mulle-bootstrap-fetch.sh "$@" || exit 1
182
+         ;;
183
+
184
+      update)
185
+         COMMAND="update" mulle-bootstrap-fetch.sh "$@" || exit 1
186
+         ;;
187
+
188
+      init)
189
+         mulle-bootstrap-init.sh "$@" || exit 1
190
+         ;;
191
+
192
+      setup-xcode|xcode)
193
+         mulle-bootstrap-xcode.sh "$@"|| exit 1
194
+         ;;
195
+
196
+      tag)
197
+         mulle-bootstrap-tag.sh "$@" || exit 1
198
+         ;;
199
+
200
+      *)
201
+         usage >&2
202
+         exit 1
203
+      esac
204
+}
205
+
206
+main "$@"
207
+
208
+
... ...
@@ -35,14 +35,19 @@
35 35
 
36 36
 check_and_usage_and_help()
37 37
 {
38
-   echo "usage: mulle-bootstrap-build.sh [repos]*" 2>&1
39
-   exit 1
38
+   cat <<EOF
39
+usage: build [repos]*
40
+   You can specify the names of the repositories to build.
41
+   Currently available names are:
42
+EOF
43
+   (cd "${CLONES_SUBDIR}" ; ls -1d ) 2> /dev/null
40 44
 }
41 45
 
42 46
 
43 47
 if [ "$1" = "-h" -o "$1" = "--help" ]
44 48
 then
45
-   check_and_usage_and_help
49
+   check_and_usage_and_help >&2
50
+   exit 1
46 51
 fi
47 52
 
48 53
 
... ...
@@ -568,7 +573,7 @@ fixup_header_path()
568 573
          return 1
569 574
       fi
570 575
 
571
-      headers="`"$create_mangled_header_path "${key}" "${name}" ${default}"`"
576
+      headers="`create_mangled_header_path "${key}" "${name}" "${default}"`"
572 577
    fi
573 578
 
574 579
    log_fluff "${key} set to \"${headers}\""
... ...
@@ -585,7 +590,7 @@ escaped_spaces()
585 590
 
586 591
 combined_escaped_search_path()
587 592
 {
588
-   for i in $*
593
+   for i in "$@"
589 594
    do
590 595
       if [ ! -z "$i" ]
591 596
       then
... ...
@@ -964,7 +969,7 @@ Release"`
964 969
 
965 970
    # need uniform SDK for our builds
966 971
    sdks=`read_build_root_setting "sdks" "Default"`
967
-   [ -z "${sdks}" ] && fail "setting \"sdks\" must at least contain \"Default\" to build anything"
972
+   [ ! -z "${sdks}" ] || fail "setting \"sdks\" must at least contain \"Default\" to build anything"
968 973
 
969 974
    local builddir
970 975
    local relative
... ...
@@ -1067,7 +1072,7 @@ build_wrapper()
1067 1072
 
1068 1073
    if [ -d "${BUILD_DEPENDENCY_SUBDIR}" ]
1069 1074
    then
1070
-      log_info "Cleaning up orphaned ${BUILD_DEPENDENCY_SUBDIR}"
1075
+      log_info "Cleaning up orphaned \"${BUILD_DEPENDENCY_SUBDIR}\""
1071 1076
       rmdir_safer "${BUILD_DEPENDENCY_SUBDIR}"
1072 1077
    fi
1073 1078
 
... ...
@@ -1075,11 +1080,11 @@ build_wrapper()
1075 1080
    # move dependencies we have so far away into safety,
1076 1081
    # need that path for includes though
1077 1082
    #
1078
-   log_fluff "Setting up ${BUILD_DEPENDENCY_SUBDIR}"
1083
+   log_fluff "Setting up \"${BUILD_DEPENDENCY_SUBDIR}\""
1079 1084
 
1080 1085
    build "${clone}"
1081 1086
 
1082
-   log_fluff "Remove ${BUILD_DEPENDENCY_SUBDIR}"
1087
+   log_fluff "Remove \"${BUILD_DEPENDENCY_SUBDIR}\""
1083 1088
 
1084 1089
    rmdir_safer "${BUILD_DEPENDENCY_SUBDIR}"
1085 1090
 
... ...
@@ -1122,15 +1127,6 @@ build_clones()
1122 1127
    local xdone
1123 1128
    local name
1124 1129
 
1125
-   #
1126
-   # START
1127
-   #
1128
-   if [ ! -d "${CLONES_SUBDIR}" ]
1129
-   then
1130
-      log_info "No repos fetched, nothing to do."
1131
-      return 0
1132
-   fi
1133
-
1134 1130
    for clone in ${CLONES_SUBDIR}/*.failed
1135 1131
    do
1136 1132
       if [ -d "${clone}" ]
... ...
@@ -1191,8 +1187,7 @@ install_tars()
1191 1187
 {
1192 1188
    local tarballs
1193 1189
    local tar
1194
-   local cmd
1195
-   cmd="$1"
1190
+
1196 1191
 
1197 1192
    tarballs=`read_fetch_setting "tarballs" | sort | sort -u`
1198 1193
    if [ "${tarballs}" != "" ]
... ...
@@ -1221,6 +1216,8 @@ main()
1221 1216
 {
1222 1217
    local  no_clean
1223 1218
 
1219
+   log_info "Start build"
1220
+
1224 1221
    log_fluff "Setting up ${DEPENDENCY_SUBDIR}"
1225 1222
    no_clean="`read_config_setting "dont_clean_dependencies_before_build"`"
1226 1223
    if [ "${no_clean}" != "YES" ]
... ...
@@ -1228,6 +1225,16 @@ main()
1228 1225
       rmdir_safer "${DEPENDENCY_SUBDIR}"
1229 1226
    fi
1230 1227
 
1228
+
1229
+   #
1230
+   # START
1231
+   #
1232
+   if [ ! -d "${CLONES_SUBDIR}" ]
1233
+   then
1234
+      log_info "No repos fetched, nothing to do."
1235
+      return 0
1236
+   fi
1237
+
1231 1238
    # if present then we didnt't want to clean and we do nothing special
1232 1239
    if [ ! -d "${DEPENDENCY_SUBDIR}" ]
1233 1240
    then
... ...
@@ -12,6 +12,21 @@ DIST_CLEANABLE_SUBDIRS=`read_sane_config_path_setting "dist_clean_folders" "${CL
12 12
 .bootstrap.auto"`
13 13
 
14 14
 
15
+usage()
16
+{
17
+   echo "clean [build|output|dist]"
18
+   echo ""
19
+   echo "   build   : is the default, it cleans
20
+${BUILD_CLEANABLE_SUBDIRS}"
21
+   echo ""
22
+   echo "   output  : cleans additionaly
23
+${OUTPUT_CLEANABLE_SUBDIRS}"
24
+   echo ""
25
+   echo "   dist    : cleans additionaly
26
+${DIST_CLEANABLE_SUBDIRS}"
27
+}
28
+
29
+
15 30
 check_and_usage_and_help()
16 31
 {
17 32
    case "$COMMAND" in
... ...
@@ -23,28 +38,13 @@ check_and_usage_and_help()
23 38
       COMMAND="build"
24 39
       ;;
25 40
       *)
26
-      echo "usage: mulle-bootstrap-clean.sh [build|output|dist]" >&2
27
-      echo "" >&2
28
-      echo "   build   : is the default, it cleans
29
-${BUILD_CLEANABLE_SUBDIRS}" >&2
30
-      echo "" >&2
31
-      echo "   output  : cleans additionaly
32
-${OUTPUT_CLEANABLE_SUBDIRS}" >&2
33
-      echo "" >&2
34
-      echo "   dist    : cleans additionaly
35
-${DIST_CLEANABLE_SUBDIRS}" >&2
41
+      usage >&2
36 42
       exit 1
37 43
       ;;
38 44
    esac
39 45
 }
40 46
 
41 47
 
42
-if [ "$1" = "-h" -o "$1" = "--help" ]
43
-then
44
-   check_and_usage_and_help
45
-fi
46
-
47
-
48 48
 COMMAND=${1:-"build"}
49 49
 shift
50 50
 
... ...
@@ -134,7 +134,7 @@ main()
134 134
    # Also don't change the search paths for read_sane_config_path_setting
135 135
    #
136 136
 
137
-   clean
137
+   clean "$@"
138 138
 }
139 139
 
140
-main
140
+main "$@"
... ...
@@ -39,6 +39,21 @@
39 39
 . mulle-bootstrap-local-environment.sh
40 40
 
41 41
 
42
+usage()
43
+{
44
+   cat <<EOF
45
+usage: fetch <install|nonrecursive|update> [repos]*
46
+   install      : clone or symlink non-exisiting repositories and other resources
47
+   nonrecursive : like above, but ignore .bootstrap folders of repositories
48
+   update       : pull repositories
49
+
50
+   You can specify the names of the repositories to update or fetch.
51
+   Currently available names are:
52
+EOF
53
+   (cd "${CLONES_SUBDIR}" ; ls -1d ) 2> /dev/null
54
+}
55
+
56
+
42 57
 check_and_usage_and_help()
43 58
 {
44 59
    case "$COMMAND" in
... ...
@@ -51,21 +66,27 @@ check_and_usage_and_help()
51 66
       update)
52 67
       ;;
53 68
       *)
54
-      echo "usage: mulle-bootstrap-fetch.sh <install|nonrecursive|update>" 2>&1
69
+      usage >&2
55 70
       exit 1
56 71
       ;;
57 72
    esac
58 73
 }
59 74
 
75
+
60 76
 if [ "$1" = "-h" -o "$1" = "--help" ]
61 77
 then
62
-   check_and_usage_and_help
63
-fi
78
+   COMMAND=help
79
+else
80
+   if [ -z "${COMMAND}" ]
81
+   then
82
+      COMMAND=${1:-"install"}
83
+      shift
84
+   fi
64 85
 
65
-COMMAND=${1:-"install"}
66
-if [ "${MULLE_BOOTSTRAP}" = "mulle-bootstrap" ]
67
-then
68
-   COMMAND="install"
86
+   if [ "${MULLE_BOOTSTRAP}" = "mulle-bootstrap" ]
87
+   then
88
+      COMMAND="install"
89
+   fi
69 90
 fi
70 91
 
71 92
 check_and_usage_and_help
... ...
@@ -90,7 +111,7 @@ link_command()
90 111
 
91 112
    if [ "${COMMAND}" = "install" ]
92 113
    then
93
-      ln -s -f "$src" "$dst" || exit 1
114
+      exekutor ln -s -f "$src" "$dst" || fail "failed to setup symlink \"$dst\" (to \"$src\")"
94 115
       if [ "$tag" != "" ]
95 116
       then
96 117
          name="`basename "${dst}"`"
... ...
@@ -151,24 +172,45 @@ ask_symlink_it()
151 172
 }
152 173
 
153 174
 
175
+run_fetch_settings_script()
176
+{
177
+   local  name
178
+
179
+   name="$1"
180
+   shift
181
+
182
+   [ -z "$name" ] && internal_fail "name is empty"
183
+
184
+   local script
185
+
186
+   script=`read_fetch_setting "bin/${name}.sh"`
187
+   if [ ! -z "${script}" ]
188
+   then
189
+      run_script "${script}" "$@"
190
+   fi
191
+}
192
+
193
+
154 194
 checkout()
155 195
 {
156 196
    local clone
157
-   local cmd
158 197
    local name1
159 198
    local name2
160 199
    local tag
161 200
    local dstname
162 201
 
163 202
    clone="$1"
164
-   cmd="$2"
165
-   name1="$3"
166
-   name2="$4"
203
+   name1="$2"
204
+   name2="$3"
205
+   dstname="$4"
167 206
    tag="$5"
168
-   dstname="$6"
207
+
208
+   [ -z "$clone" ]    && internal_fail "clone is empty"
209
+   [ -z "$name1" ]    && internal_fail "name1 is empty"
210
+   [ -z "$name2" ]    && internal_fail "name2 is empty"
211
+   [ -z "$dstname" ]  && internal_fail "dstname is empty"
169 212
 
170 213
    local srcname
171
-   local script
172 214
    local operation
173 215
    local flag
174 216
    local found
... ...
@@ -187,13 +229,13 @@ checkout()
187 229
    fi
188 230
 
189 231
    srcname="${clone}"
190
-   script=`read_repo_setting "${name1}" bin/"${cmd}.sh"`
191
-   operation="git_command"
232
+   script=`read_repo_setting "${name1}" "bin/${COMMAND}.sh"`
233
+   operation="git_clone"
192 234
 
193 235
    # simplify this crap copy/paste code
194
-   if [ -x "${script}" ]
236
+   if [ ! -z "${script}" ]
195 237
    then
196
-      "${script}" || exit 1
238
+      run_script "${script}" "$@"
197 239
    else
198 240
       case "${clone}" in
199 241
          /*)
... ...
@@ -251,53 +293,40 @@ Use it instead of cloning ${clone} ?"
251 293
          ;;
252 294
       esac
253 295
 
254
-      "${operation}" "${srcname}" "${dstname}" "${tag}" || exit 1
296
+      "${operation}" "${srcname}" "${dstname}" "${tag}"
255 297
        warn_scripts "${dstname}/.bootstrap" "${dstname}" || exit 1 # sic
256 298
    fi
257 299
 
258
-   script=`read_repo_setting "${name1}" "bin/post-${cmd}.sh"`
259
-   if [ -x "${script}" ]
260
-   then
261
-      exekutor "${script}" || exit 1
262
-   fi
300
+   run_fetch_settings_script "post-install"
263 301
 }
264 302
 
265 303
 
266
-update()
304
+git_checkout_tag()
267 305
 {
268
-   local clone
269
-   local cmd
270
-   local name
306
+   local dst
271 307
    local tag
272
-   local dstname
308
+   local cmd
273 309
 
274
-   clone="$1"
275
-   cmd="$2"
276
-   name="$3"
277
-   dstname="$4"
278
-   tag="$5"
310
+   dst="$1"
311
+   tag="$2"
279 312
 
280
-   local script
313
+   log_info "Checking out ${C_MAGENTA}${tag}${C_INFO} ..."
314
+   ( exekutor cd "${dst}" ; exekutor git checkout ${GITFLAGS} "${tag}" )
281 315
 
282
-   if [ ! -L "${dstname}"  ]
316
+   if [ $? -ne 0 ]
283 317
    then
284
-      if [ -x "${script}" ]
285
-      then
286
-         exekutor "${script}" || exit 1
287
-      else
288
-         exekutor git_command ${GITFLAGS} "${clone}" "${dstname}" "${tag}" || exit 1
289
-      fi
318
+      log_error "Checkout failed, moving ${C_CYAN}${dst}${C_ERROR} to {C_CYAN}${dst}.failed${C_ERROR}"
319
+      log_error "You need to fix this manually and then move it back."
320
+      log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename "${dst}"`/TAG" >&2
290 321
 
291
-      script=`read_repo_setting "${name}" "bin/post-${cmd}.sh"`
292
-      if [ -x "${script}" ]
293
-      then
294
-         exekutor "${script}" || exit 1
295
-      fi
322
+      rmdir_safer "${dst}.failed"
323
+      exekutor mv "${dst}" "${dst}.failed"
324
+      exit 1
296 325
    fi
297 326
 }
298 327
 
299 328
 
300
-git_command()
329
+git_clone()
301 330
 {
302 331
    local src
303 332
    local dst
... ...
@@ -307,29 +336,35 @@ git_command()
307 336
    dst="$2"
308 337
    tag="$3"
309 338
 
310
-   if [ "${COMMAND}" = "install" ]
311
-   then
312
-      log_info "Cloning ${C_WHITE}${src}${C_INFO} ..."
313
-      exekutor git clone ${GITFLAGS} "${src}" "${dst}" || exit 1
314
-   else
315
-      ( exekutor cd "${dst}" ; exekutor git pull ) || exit 1
316
-   fi
339
+   [ -z "$src" ] && internal_fail "src is empty"
340
+   [ -z "$dst" ] && internal_fail "dst is empty"
341
+
342
+   log_info "Cloning ${C_WHITE}${src}${C_INFO} ..."
343
+   exekutor git clone ${GITFLAGS} "${src}" "${dst}" || fail "git clone of \"${src}\" into \"${dst}\" failed"
317 344
 
318 345
    if [ "${tag}" != "" ]
319 346
    then
320
-      log_info "Checking out ${C_MAGENTA}${tag}${C_INFO} ..."
321
-      ( exekutor cd "${dst}" ; exekutor git checkout ${GITFLAGS} "${tag}" )
347
+      git_checkout_tag "${dst}" "${tag}"
348
+   fi
349
+}
322 350
 
323
-      if [ $? -ne 0 ]
324
-      then
325
-         log_error "Checkout failed, moving ${C_CYAN}${dst}${C_ERROR} to {C_CYAN}${dst}.failed${C_ERROR}"
326
-         log_error "You need to fix this manually and then move it back."
327
-         log_info "Hint: check ${BOOTSTRAP_SUBDIR}/`basename "${dst}"`/TAG" >&2
328 351
 
329
-         rmdir_safer "${dst}.failed"
330
-         exekutor mv "${dst}" "${dst}.failed"
331
-         exit 1
332
-      fi
352
+git_pull()
353
+{
354
+   local dst
355
+   local tag
356
+
357
+   dst="$1"
358
+   tag="$2"
359
+
360
+   [ -z "$dst" ] && internal_fail "dst is empty"
361
+
362
+   log_info "Updating ${C_WHITE}${dst}${C_INFO} ..."
363
+   ( exekutor cd "${dst}" ; exekutor git pull ${GITFLAGS} ) || fail "git pull of \"${dst}\" failed"
364
+
365
+   if [ "${tag}" != "" ]
366
+   then
367
+      git_checkout_tag "${dst}" "${tag}"
333 368
    fi
334 369
 }
335 370
 
... ...
@@ -350,7 +385,7 @@ bootstrap_recurse()
350 385
    # contains own bootstrap ? and not a symlink
351 386
    if [ ! -d "${dst}/.bootstrap" ] # -a ! -L "${dst}" ]
352 387
    then
353
-      log_fluff "no .bootstrap folder in ${dst} found"
388
+      log_fluff "no .bootstrap folder in \"${dst}\" found"
354 389
       return 1
355 390
    fi
356 391
 
... ...
@@ -417,6 +452,79 @@ bootstrap_recurse()
417 452
 }
418 453
 
419 454
 
455
+ensure_clones_directory()
456
+{
457
+   if [ ! -d "${CLONES_FETCH_SUBDIR}" ]
458
+   then
459
+      if [ "${COMMAND}" = "update" ]
460
+      then
461
+         fail "install first before upgrading"
462
+      fi
463
+      mkdir_if_missing "${CLONES_FETCH_SUBDIR}"
464
+   fi
465
+}
466
+
467
+
468
+mark_all_zombies()
469
+{
470
+   local i
471
+
472
+      # first mark all repos as stale
473
+   if dir_has_files "${CLONES_FETCH_SUBDIR}"
474
+   then
475
+      log_fluff "Marking all repositories as zombies for now"
476
+
477
+      for i in `ls -1d "${CLONES_FETCH_SUBDIR}/"*`
478
+      do
479
+         if [ -d "${i}" -o -L "${i}" ]
480
+         then
481
+            exekutor chmod -h 000 "${i}"
482
+         fi
483
+      done
484
+   fi
485
+}
486
+
487
+
488
+mark_alive()
489
+{
490
+   local dstname
491
+
492
+   dstname="$1"
493
+
494
+   local permission
495
+
496
+   # mark as alive
497
+   if [ -d "${dstname}" -o -L "${dstname}" ] && [ ! -r "${dstname}" ]
498
+   then
499
+      permission=`lso "${CLONES_FETCH_SUBDIR}"`
500
+      [ ! -z "$permission" ] || fail "failed to get permission of ${CLONES_FETCH_SUBDIR}"
501
+      exekutor chmod -h "${permission}" "${dstname}"
502
+
503
+      log_fluff "Marked \${dstname}\" as alive"
504
+   fi
505
+}
506
+
507
+
508
+log_fetch_action()
509
+{
510
+   local dstname
511
+   local clone
512
+
513
+   clone="$1"
514
+   dstname="$2"
515
+
516
+   local info
517
+
518
+   if [ -L "${clone}" ]
519
+   then
520
+      info="symlinked"
521
+   else
522
+      info=" "
523
+   fi
524
+
525
+   log_fluff "$COMMAND ${info}${clone} in ${dstname} ..."
526
+}
527
+
420 528
 #
421 529
 # Use git clones for stuff that gets tagged
422 530
 # if you specify ../ it will assume you have
... ...
@@ -425,31 +533,67 @@ bootstrap_recurse()
425 533
 # convention: .git suffix == repo to clone
426 534
 #          no .git suffix, try to symlink
427 535
 #
428
-clone_repositories()
536
+checkout_repository()
537
+{
538
+   local dstname
539
+
540
+   dstname="$5"
541
+
542
+   if [ ! -e "${dstname}" ]
543
+   then
544
+      checkout "$@"  || fail "checkout failed"
545
+      if [ "${COMMAND}" = "install" -a "${DONT_RECURSE}" = "" ]
546
+      then
547
+         bootstrap_recurse "${dstname}"
548
+         if [ $? -eq 0 ]
549
+         then
550
+            return 1
551
+         fi
552
+      fi
553
+   fi
554
+   return 0
555
+}
556
+
557
+
558
+clone_repository()
429 559
 {
430
-   local stop
431
-   local clones
432 560
    local clone
433
-   local cmd
561
+
562
+   clone="$1"
563
+
434 564
    local name1
435 565
    local name2
436 566
    local tag
437 567
    local dstname
438 568
 
439
-   cmd="$1"
569
+   name1=`basename "${clone}" .git`
570
+   name2=`basename "${clone}"`
571
+   tag=`read_repo_setting "${name1}" "tag"` #repo (sic)
440 572
 
441
-   # first mark all repos as stale
442
-   if dir_has_files "${CLONES_FETCH_SUBDIR}"
573
+   dstname="${CLONES_FETCH_SUBDIR}/${name1}"
574
+
575
+   mark_alive "${dstname}"
576
+   log_fetch_action "${clone}" "${dstname}"
577
+
578
+   checkout_repository "${clone}" "${name1}" "${name2}" "${dstname}" "${tag}"
579
+}
580
+
581
+
582
+clone_repositories()
583
+{
584
+   if [ $# -ne 0 ]
443 585
    then
444
-      for i in `ls -1d "${CLONES_FETCH_SUBDIR}/"*`
445
-      do
446
-         if [ -d "${i}" -o -L "${i}" ]
447
-         then
448
-            exekutor chmod -h 000 "${i}"
449
-         fi
450
-      done
586
+      log_error  "Additional parameters not allowed for install"
587
+      usage >&2
588
+      exit 1
451 589
    fi
452 590
 
591
+   local stop
592
+   local clones
593
+   local clone
594
+
595
+   mark_all_zombies
596
+
453 597
    stop=0
454 598
    while [ $stop -eq 0 ]
455 599
    do
... ...
@@ -458,68 +602,113 @@ clone_repositories()
458 602
       clones=`read_fetch_setting "gits"`
459 603
       if [ "${clones}" != "" ]
460 604
       then
461
-         if [ ! -d "${CLONES_FETCH_SUBDIR}" ]
462
-         then
463
-            if [ "${COMMAND}" = "update" ]
464
-            then
465
-               fail "install first before upgrading"
466
-            fi
467
-            mkdir_if_missing "${CLONES_FETCH_SUBDIR}"
468
-         fi
605
+         ensure_clones_directory
469 606
 
470 607
          for clone in ${clones}
471 608
          do
472
-            name1=`basename "${clone}" .git`
473
-            name2=`basename "${clone}"`
474
-            tag=`read_repo_setting "${name1}" "tag"` #repo (sic)
609
+            clone_repository "${clone}"
610
+            if [ $? -eq 1 ]
611
+            then
612
+               stop=0
613
+               break
614
+            fi
615
+         done
616
+      fi
617
+   done
618
+}
475 619
 
476
-            dstname="${CLONES_FETCH_SUBDIR}/${name1}"
477 620
 
478
-            local permission
621
+update()
622
+{
623
+   local clone
624
+   local name
625
+   local tag
626
+   local dstname
479 627
 
480
-            # mark as alive
481
-            if [ -d "${dstname}" -o -L "${dstname}" ] && [ ! -r "${dstname}" ]
482
-            then
483
-               permission=`lso "${CLONES_FETCH_SUBDIR}"`
484
-               [ ! -z "$permission" ] || fail "failed to get permission of ${CLONES_FETCH_SUBDIR}"
485
-               exekutor chmod -h "${permission}" "${dstname}"
486
-            fi
628
+   clone="$1"
629
+   name="$2"
630
+   dstname="$3"
631
+   tag="$4"
487 632
 
488
-            local info
633
+   [ -z "$clone" ]    && internal_fail "clone is empty"
634
+   [ -z "$name" ]     && internal_fail "name is empty"
635
+   [ -z "$dstname" ]  && internal_fail "dstname is empty"
489 636
 
490
-            if [ -L "${clone}" ]
491
-            then
492
-               info="symlinked"
493
-            else
494
-               info=" "
495
-            fi
637
+   local script
496 638
 
497
-            log_fluff "Checking${info}${clone} in ${dstname} ..."
639
+   log_info "Updating \"${dstname}\""
640
+   if [ ! -L "${dstname}"  ]
641
+   then
642
+      script=`read_repo_setting "${name}" "bin/update.sh"`
643
+      if [ ! -z "${script}" ]
644
+      then
645
+         run_script "${script}" "$@"
646
+      else
647
+         exekutor git_pull "${dstname}" "${tag}"
648
+      fi
498 649
 
499
-            case "${cmd}" in
500
-               install)
501
-                  if [ ! -e "${dstname}" ]
502
-                  then
503
-                     checkout "${clone}" "${cmd}" "${name1}" "${name2}" "${tag}" "${dstname}" || exit 1
504
-                     if [ "${COMMAND}" = "install" -a "${DONT_RECURSE}" = "" ]
505
-                     then
506
-                        bootstrap_recurse "${dstname}"
507
-                        if [ $? -eq 0 ]
508
-                        then
509
-                           stop=0
510
-                           break
511
-                        fi
512
-                     fi
513
-                  fi
514
-                  ;;
650
+      script=`read_repo_setting "${name}" "bin/post-update.sh"`
651
+      if [ ! -z "${script}" ]
652
+      then
653
+         run_script "${script}" "$@"
654
+      fi
655
+   fi
656
+}
657
+
658
+
659
+update_repository()
660
+{
661
+   local clone
662
+
663
+   clone="$1"
664
+
665
+   local name
666
+   local tag
667
+   local dstname
668
+
669
+   name=`basename "${clone}" .git`
670
+   tag=`read_repo_setting "${name}" "tag"` #repo (sic)
671
+
672
+   dstname="${CLONES_FETCH_SUBDIR}/${name}"
673
+   exekutor [ -e "${dstname}" ] || fail "You need to install first, before updating"
674
+   exekutor [ -x "${dstname}" ] || fail "${name} is not anymore in \"gits\""
675
+
676
+   log_fetch_action "${clone}" "${dstname}"
677
+
678
+   update "${clone}" "${name}" "${dstname}" "${tag}"
679
+}
680
+
681
+
682
+#
683
+# Use git clones for stuff that gets tagged
684
+# if you specify ../ it will assume you have
685
+# checked it out yourself, If there is something
686
+# checked out already it will use it, or ask
687
+# convention: .git suffix == repo to clone
688
+#          no .git suffix, try to symlink
689
+#
690
+update_repositories()
691
+{
692
+   local clones
693
+   local clone
694
+   local i
515 695
 
516
-               update)
517
-                  update "${clone}" "${cmd}" "${name1}" "${tag}" "${dstname}" || exit 1
518
-                  ;;
519
-            esac
696
+   if [ $# -ne 0 ]
697
+   then
698
+      for clone in "$@"
699
+      do
700
+         update_repository "${CLONES_FETCH_SUBDIR}/${clone}"
701
+      done
702
+   else
703
+      clones=`read_fetch_setting "gits"`
704
+      if [ "${clones}" != "" ]
705
+      then
706
+         for clone in ${clones}
707
+         do
708
+            update_repository "${clone}"
520 709
          done
521 710
       fi
522
-   done
711
+   fi
523 712
 }
524 713
 
525 714
 
... ...
@@ -588,9 +777,7 @@ install_brews()
588 777
 {
589 778
    local brew
590 779
    local brews
591
-   local cmd
592 780
 
593
-   cmd="$1"
594 781
    install_taps
595 782
 
596 783
    brews=`read_fetch_setting "brews" | sort | sort -u`
... ...
@@ -605,9 +792,9 @@ install_brews()
605 792
 "
606 793
       for brew in ${brews}
607 794
       do
608
-         if [ "${cmd}" != "install" -o "`which "${brew}"`" = "" ]
795
+         if [ "${COMMAND}" != "install" -o "`which "${brew}"`" = "" ]
609 796
          then
610
-            exekutor brew "${cmd}" "${brew}" || exit 1
797
+            exekutor brew "${COMMAND}" "${brew}" || exit 1
611 798
          fi
612 799
       done
613 800
       IFS="${old}"
... ...
@@ -622,9 +809,6 @@ check_tars()
622 809
 {
623 810
    local tarballs
624 811
    local tar
625
-   local cmd
626
-
627
-   cmd="$1"
628 812
 
629 813
    tarballs=`read_fetch_setting "tarballs" | sort | sort -u`
630 814
    if [ "${tarballs}" != "" ]
... ...
@@ -699,30 +883,29 @@ install_pips()
699 883
 
700 884
 main()
701 885
 {
886
+   log_info "Start fetch"
702 887
    #
703 888
    # Run prepare scripts if present
704 889
    #
705
-   script=`read_fetch_setting "bin/pre-${COMMAND}.sh"`
706
-   if [ -x "${script}" ]
707
-   then
708
-      exekutor "${script}" || exit 1
709
-   fi
890
+   run_fetch_settings_script "pre-${COMMAND}"
710 891
 
711
-   clone_repositories "${COMMAND}"
712 892
 
713
-   install_brews "${COMMAND}"
714
-   install_gems
715
-   install_pips
716
-   check_tars
893
+   if [ "${COMMAND}" = "install" ]
894
+   then
895
+      clone_repositories "$@"
896
+
897
+      install_brews "${COMMAND}" # no update for now
898
+      install_gems
899
+      install_pips
900
+      check_tars
901
+   else
902
+      update_repositories "$@"
903
+   fi
717 904
 
718 905
    #
719 906
    # Run prepare scripts if present
720 907
    #
721
-   script=`read_fetch_setting "bin/post-${COMMAND}.sh"`
722
-   if [ -x "${script}" ]
723
-   then
724
-      exekutor "${script}" || exit 1
725
-   fi
908
+   run_fetch_settings_script "post-${COMMAND}"
726 909
 }
727 910
 
728
-main
911
+main "$@"
... ...
@@ -417,3 +417,27 @@ lso()
417 417
    awk '{k=0;for(i=0;i<=8;i++)k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(" %0o ",k);print }' | \
418 418
    awk '{print $1}'
419 419
 }
420
+
421
+
422
+run_script()
423
+{
424
+   local script
425
+
426
+   script="$1"
427
+   shift
428
+
429
+   [ -z "$script" ] && internal_fail "script is empty"
430
+
431
+   if [ -x "${script}" ]
432
+   then
433
+      log_info "Executing script ${script}"
434
+      exekutor "${script}" "$@" || fail "script \"${script}\" did not run successfully"
435
+   else
436
+      if [ ! -e "${script}" ]
437
+      then
438
+         fail "script \"${script}\" not found"
439
+      else
440
+         fail "script \"${script}\" not executable"
441
+      fi
442
+   fi
443
+}
... ...
@@ -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
-. mulle-bootstrap-local-settings.sh
32
+. mulle-bootstrap-local-environment.sh
33 33
 
34 34
 #
35 35
 # this script creates a .bootstrap folder with some
... ...
@@ -37,7 +37,8 @@
37 37
 #
38 38
 if [ "$1" = "-h" -o "$1" = "--help" ]
39 39
 then
40
-   fail "usage: mulle-bootstrap-init"
40
+   echo "usage: init" >&2
41
+   exit 1
41 42
 fi
42 43
 
43 44
 BOOTSTRAP_SUBDIR=.bootstrap
... ...
@@ -56,27 +57,28 @@ then
56 57
    exit 1
57 58
 fi
58 59
 
59
-
60
-project=""
61
-for i in *.xcodeproj/project.pbxproj
62
-do
63
-   if [ -f "$i" ]
60
+main()
61
+{
62
+   project=""
63
+   for i in *.xcodeproj/project.pbxproj
64
+   do
65
+      if [ -f "$i" ]
66
+      then
67
+        if [ "$project" != "" ]
68
+        then
69
+           echo "more than one xcodeproj found, cant' deal with it" >&1
70
+           exit 1
71
+        fi
72
+        project="$i"
73
+      fi
74
+   done
75
+
76
+
77
+   mkdir -p "${BOOTSTRAP_SUBDIR}" || exit 1
78
+
79
+   if [ "${NO_DEFAULT_FILES}" = "" ]
64 80
    then
65
-     if [ "$project" != "" ]
66
-     then
67
-        echo "more than one xcodeproj found, cant' deal with it" >&1
68
-        exit 1
69
-     fi
70
-     project="$i"
71
-   fi
72
-done
73
-
74
-
75
-mkdir -p "${BOOTSTRAP_SUBDIR}" || exit 1
76
-
77
-if [ "${NO_DEFAULT_FILES}" = "" ]
78
-then
79
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/brews"
81
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/brews"
80 82
 # add projects that should be installed by brew
81 83
 # e.g.
82 84
 # zlib
... ...
@@ -88,8 +90,7 @@ EOF
88 90
 # mod-pbxproj
89 91
 #EOF
90 92
 
91
-
92
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/gits"
93
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/gits"
93 94
 # add projects that should be cloned with git in order
94 95
 # of their inter-dependencies
95 96
 #
... ...
@@ -100,46 +101,45 @@ EOF
100 101
 # /Volumes/Source/srcM/MulleScion
101 102
 #
102 103
 EOF
103
-fi
104
-
105
-if [ "${NO_EXAMPLE_FILES}" = "" ]
106
-then
104
+   fi
107 105
 
108
-   mkdir -p "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin" || exit 1
106
+   if [ "${NO_EXAMPLE_FILES}" = "" ]
107
+   then
108
+      mkdir -p "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin" || exit 1
109 109
 
110
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/tag"
110
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/tag"
111 111
 # specify a tag or branch for a project named MulleScion
112 112
 # leave commented out or delete file for default branch (usually master)
113 113
 # v1848.5.p3
114 114
 EOF
115 115
 
116
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/Release.map"
116
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/Release.map"
117 117
 # map configuration Release in project MulleScion to DebugRelease
118 118
 # leave commented out or delete file for no mapping
119 119
 # DebugRelease
120 120
 EOF
121 121
 
122
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/project"
122
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/project"
123 123
 # Specify a xcodeproj to compile in project MulleScion instead of default
124 124
 # leave commented out or delete file for default project
125 125
 # mulle-scion
126 126
 EOF
127 127
 
128
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/scheme"
128
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/scheme"
129 129
 # Specify a scheme to compile in project MulleScion instead of default
130 130
 # Might bite itself with TARGET, so only specify one.
131 131
 # leave commented out or delete file for default scheme
132 132
 # mulle-scion
133 133
 EOF
134 134
 
135
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/target"
135
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/target"
136 136
 # Specify a target to compile in project MulleScion instead of default.
137 137
 # Might bite itself with SCHEME, so only specify one.
138 138
 # leave commented out or delete file for default scheme
139 139
 # mulle-scion
140 140
 EOF
141 141
 
142
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-install.sh"
142
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-install.sh"
143 143
 # Run some commands after installing project MulleScion
144 144
 # leave commented out or delete file for no action
145 145
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh
... ...
@@ -148,7 +148,7 @@ EOF
148 148
 EOF
149 149
 #chmod 755 "${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-install.sh"
150 150
 
151
-   exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-update.sh"
151
+      exekutor cat <<EOF > "${BOOTSTRAP_SUBDIR}/settings/MulleScion.example/bin/post-update.sh"
152 152
 # Run some commands after upgrading project MulleScion
153 153
 # leave commented out or delete file for no action
154 154
 # chmod 755 ${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-update.sh
... ...
@@ -157,12 +157,14 @@ EOF
157 157
 EOF
158 158
 #chmod 755 "${BOOTSTRAP_SUBDIR}/MulleScion.example/bin/post-upgrade.sh"
159 159
 
160
-fi
160
+   fi
161 161
 
162
-echo "${BOOTSTRAP_SUBDIR} folder has been set up. Now add your gits to ${BOOTSTRAP_SUBDIR}/gits"
162
+   echo "${BOOTSTRAP_SUBDIR} folder has been set up. Now add your gits to ${BOOTSTRAP_SUBDIR}/gits"
163 163
 
164
-if [ "${DONT_OPEN_GITS}" = "" -a "${NO_DEFAULT_FILES}" = "" ]
165
-then
166
-    exekutor open -e "${BOOTSTRAP_SUBDIR}/gits"
167
-fi
164
+   if [ "${DONT_OPEN_GITS}" = "" -a "${NO_DEFAULT_FILES}" = "" ]
165
+   then
166
+       exekutor open -e "${BOOTSTRAP_SUBDIR}/gits"
167
+   fi
168
+}
168 169
 
170
+main "$@"
169 171
\ No newline at end of file
... ...
@@ -103,3 +103,7 @@ case "${MULLE_BOOTSTRAP_TRACE}" in
103 103
 	   ;;
104 104
 esac
105 105
 
106
+if [ "${MULLE_BOOTSTRAP_DRY_RUN}" = "YES" ]
107
+then
108
+   log_trace "Dry run is active. Nothing should be modified on the filesystem"
109
+fi
106 110
\ No newline at end of file
... ...
@@ -436,7 +436,7 @@ all_build_flag_keys()
436 436
 
437 437
    package="$1"
438 438
 
439
-   [ "$package" = "" ] && fail "script error"
439
+   [ ! -z "$package" ] || internal_fail "script error"
440 440
 
441 441
    keys1=`(cd "${BOOTSTRAP_SUBDIR}.local/settings/${package}" 2> /dev/null || exit 1; \
442 442
            ls -1 | egrep '\b[A-Z][A-Z_0-9]+\b')`
... ...
@@ -38,19 +38,25 @@
38 38
 . mulle-bootstrap-local-environment.sh
39 39
 
40 40
 
41
-check_and_usage_and_help()
41
+usage()
42 42
 {
43
-   echo "usage: mulle-bootstrap-tag.sh [tag] [vendortag_prefix] [repo]" 2>&1
44
-   exit 1
43
+   cat <<EOF
44
+tag [tag] [vendortag]
45
+
46
+   tag       : the tag for your repository ($PWD)
47
+   vendortag : the tag used for tagging the fetched repositories
48
+EOF
45 49
 }
46 50
 
47
-#
48
-# Parameter
49
-#
50
-if [ "$1" = "-h" -o "$1" = "--help" ]
51
-then
52
-   check_and_usage_and_help
53
-fi
51
+
52
+check_and_usage_and_help()
53
+{
54
+   if [ "$TAG" = "" -o "$TAG" = "-h" -o "$TAG" = "--help" -o "$VENDOR_TAG" = "" ]
55
+   then
56
+      usage >&2
57
+      exit 1
58
+   fi
59
+}
54 60
 
55 61
 
56 62
 name=`basename "${PWD}"`
... ...
@@ -70,24 +76,24 @@ fi
70 76
 
71 77
 TAG=${1:-${AGVTAG}}
72 78
 shift
73
-VENDOR_PREFIX="${1:-${name}}"
74
-shift
75
-REPO=${1:-"."}
79
+
80
+VENDOR_TAG="$1"
76 81
 shift
77 82
 
78
-if [ "$TAG" = "" ]
83
+if [ -z "${VENDOR_TAG}" ]
79 84
 then
80
-   fail "no tag specified"
85
+   local prefix
86
+
87
+   prefix=`basename "${PWD}"`
88
+   prefix="${prefix%%.*}"  # remove vile extension :)
89
+
90
+   VENDOR_TAG="${prefix}-${TAG}"
81 91
 fi
82 92
 
83
-#
84
-# remove file extension from directory, that would
85
-# indicate the "branch" like foo.release vs. foo.dev
86
-#
87
-VENDOR_PREFIX=${VENDOR_PREFIX%%.*}
93
+check_and_usage_and_help
88 94
 
89
-OUR_VENDOR_TAG="${1:-${VENDOR_PREFIX}-${TAG}}"
90
-shift
95
+
96
+REPO="."
91 97
 
92 98
 
93 99
 git_must_be_clean()
... ...
@@ -189,6 +195,8 @@ posttag_script()
189 195
 
190 196
 main()
191 197
 {
198
+   log_info "Start tag"
199
+
192 200
    ensure_repos_clean
193 201
 
194 202
    echo "Tagging `basename "${PWD}"` with ${TAG}" >&2
... ...
@@ -204,4 +212,4 @@ main()
204 212
    posttag_script
205 213
 }
206 214
 
207
-main
215
+main "$@"
... ...
@@ -33,9 +33,19 @@
33 33
 private_dir_has_files()
34 34
 {
35 35
    local empty
36
+   local result
36 37
 
37 38
    empty=`ls "$1"/* 2> /dev/null` 2> /dev/null
38 39
    [ "$empty" != "" ]
40
+   result=$?
41
+
42
+   if [ "$result" -eq 1 ]
43
+   then
44
+      log_fluff "directory \"$1\" has no files"
45
+   else
46
+      log_fluff "directory \"$1\" has files"
47
+   fi
48
+   return "$result"
39 49
 }
40 50
 
41 51
 
... ...
@@ -46,7 +56,7 @@ private_user_say_yes()
46 56
   x="nix"
47 57
   while [ "$x" != "y" -a "$x" != "n" -a "$x" != "" ]
48 58
   do
49
-     echo "$@" "(y/N)" >&2
59
+     echo "${C_YELLOW}$* (${C_WHITE}y${C_YELLOW}/${C_GREEN}N${C_YELLOW})${C_RESET}" >&2
50 60
      read x
51 61
   done
52 62
 
... ...
@@ -81,7 +91,7 @@ warn_scripts()
81 91
 
82 92
    if [ ! -z "$2" ]
83 93
    then
84
-      [ -e "$2" ] ||  fail "internal error, expected directory missing"
94
+       exekutor [ -e "$2" ] || fail "internal error, expected directory missing"
85 95
 
86 96
       if private_dir_has_files "$2"
87 97
       then
... ...
@@ -9,6 +9,17 @@
9 9
 . mulle-bootstrap-local-environment.sh
10 10
 
11 11
 
12
+usage()
13
+{
14
+   cat <<EOF
15
+xcode <add|remove>
16
+
17
+   add      : add settings to Xcode project (default)
18
+   remove   : remove settings from Xcode project
19
+EOF
20
+}
21
+
22
+
12 23
 check_and_usage_and_help()
13 24
 {
14 25
 case "$COMMAND" in
... ...
@@ -17,21 +28,13 @@ case "$COMMAND" in
17 28
    remove)
18 29
    ;;
19 30
    *)
20
-   echo "usage: mulle-bootstrap-setup-xcode.sh [add|remove]" 2>&1
31
+   usage >&2
21 32
    exit 1
22 33
    ;;
23 34
 esac
24 35
 }
25 36
 
26 37
 
27
-#
28
-# Parameter
29
-#
30
-if [ "$1" = "-h" -o "$1" = "--help" ]
31
-then
32
-   check_and_usage_and_help
33
-fi
34
-
35 38
 COMMAND="${1:-add}"
36 39
 shift
37 40
 
... ...
@@ -382,8 +385,11 @@ Release"
382 385
 
383 386
 main()
384 387
 {