Browse code

Moved bootstrap_auto_update into separate file, as it is now shared with fetch and refresh. Refresh is always used ahead of build to ascertain, that the settings are up to date.

Nat! authored on 29-02-2016 16:51:52
Showing 6 changed files
... ...
@@ -1,3 +1,9 @@
1
+0.18
2
+===
3
+   Refixed: Fix old favorite bug build_ignore became a directory bug) again ...
4
+   Added refresh, which will be called before build and update automatically
5
+   to rebuild .bootstrap.auto.
6
+
1 7
 0.17
2 8
 ===
3 9
    Fixed the broken inheritance. The "Always redo bootstrap.auto folder
... ...
@@ -1,3 +1,3 @@
1 1
 Use different build dir than just build.
2 2
 Write "doctor" command to find common problems.
3
-
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.17
32
+VERSION=0.18
33 33
 
34 34
 #
35 35
 # This is the main user interface to mulle-bootstrap
... ...
@@ -153,6 +153,7 @@ cat <<EOF
153 153
    build     : builds fetched repositories
154 154
    fetch     : fetches required repositories recursively.
155 155
    update    : updates repositories (pull).
156
+   refresh   : rebuild .bootstrap.auto
156 157
 
157 158
  Specify the -h or --help option after each command to get more help.
158 159
 EOF
... ...
@@ -224,18 +225,26 @@ main()
224 225
          ;;
225 226
 
226 227
       build)
228
+         COMMAND="refresh" mulle-bootstrap-refresh.sh  || exit 1
227 229
          COMMAND="${command}" mulle-bootstrap-build.sh "$@" || exit 1
228 230
          ;;
229 231
 
230 232
       ibuild)
233
+         COMMAND="refresh" mulle-bootstrap-refresh.sh || exit 1
231 234
          COMMAND="${command}" mulle-bootstrap-build.sh "$@" || exit 1
232 235
          ;;
233 236
 
237
+      refresh)
238
+         COMMAND="${command}" mulle-bootstrap-refresh.sh || exit 1
239
+         ;;
240
+
234 241
       clean)
242
+         COMMAND="refresh" mulle-bootstrap-refresh.sh || exit 1
235 243
          mulle-bootstrap-clean.sh "$@" || exit 1
236 244
          ;;
237 245
 
238 246
       dist-clean)
247
+         COMMAND="refresh" mulle-bootstrap-refresh.sh || exit 1
239 248
          mulle-bootstrap-clean.sh "dist"  || exit 1
240 249
          ;;
241 250
 
... ...
@@ -244,6 +253,7 @@ main()
244 253
          ;;
245 254
 
246 255
       update)
256
+         COMMAND="refresh" mulle-bootstrap-refresh.sh "$@" || exit 1
247 257
          COMMAND="${command}" mulle-bootstrap-fetch.sh "$@" || exit 1
248 258
          ;;
249 259
 
250 260
new file mode 100755
... ...
@@ -0,0 +1,190 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2015 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
+#   POSSIBILITY OF SUCH DAMAGE.
31
+
32
+#
33
+# this script installs the proper git clones into "clones"
34
+# it does not to git subprojects.
35
+# You can also specify a list of "brew" dependencies. That
36
+# will be third party libraries, you don't tag or debug
37
+#
38
+INHERIT_SETTINGS='taps
39
+brews
40
+repositories
41
+pips
42
+gems
43
+settings/build_order
44
+settings/build_ignore'
45
+
46
+
47
+bootstrap_auto_update()
48
+{
49
+   local name
50
+   local url
51
+   local directory
52
+   local settings
53
+
54
+
55
+   name="$1"
56
+   url="$2"
57
+   directory="$3"
58
+   settings="$4"
59
+
60
+   [ ! -z "${directory}" ]        || internal_fail "src was empty"
61
+   [ "${PWD}" != "${directory}" ] || internal_fail "configuration error"
62
+
63
+
64
+   # contains own bootstrap ? and not a symlink
65
+   if [ ! -d "${directory}/.bootstrap" ] # -a ! -L "${dst}" ]
66
+   then
67
+      log_fluff "no .bootstrap folder in \"${directory}\" found"
68
+      return 1
69
+   fi
70
+
71
+   log_fluff "Recursively acquiring ${directory} .bootstrap settings ..."
72
+
73
+   local old
74
+
75
+   old="${IFS:-" "}"
76
+
77
+   #
78
+   # prepare auto folder if it doesn't exist yet
79
+   # means copy our own files to .auto first,
80
+   #
81
+   if [ ! -d "${BOOTSTRAP_SUBDIR}.auto" ]
82
+   then
83
+      log_fluff "Found a .bootstrap folder for \"${name}\" will set up ${BOOTSTRAP_SUBDIR}.auto"
84
+
85
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.tmp/settings"
86
+
87
+      IFS="
88
+"
89
+      for i in $settings
90
+      do
91
+         IFS="${old}"
92
+         if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
93
+         then
94
+            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
95
+         else
96
+            if [ -f "${BOOTSTRAP_SUBDIR}/${i}" ]
97
+            then
98
+               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
99
+            else
100
+               local  settingname
101
+
102
+               settingname="`basename -- "${i}"`"
103
+               log_fluff "Setting \"${settingname}\" is not specified, so not inherited"
104
+            fi
105
+         fi
106
+      done
107
+      IFS="${old}"
108
+
109
+      # now move it
110
+      exekutor mv "${BOOTSTRAP_SUBDIR}.tmp" "${BOOTSTRAP_SUBDIR}.auto" || exit 1
111
+
112
+      # leave .scm files behind
113
+   fi
114
+
115
+   #
116
+   # prepend new contents to old contents
117
+   # of a few select and known files
118
+   #
119
+   local srcfile
120
+   local dstfile
121
+   local i
122
+   local settingname
123
+
124
+   IFS="
125
+"
126
+   for i in $settings
127
+   do
128
+      IFS="{old}"
129
+      srcfile="${directory}/.bootstrap/${i}"
130
+      dstfile="${BOOTSTRAP_SUBDIR}.auto/${i}"
131
+      settingname="`basename -- "${i}"`"
132
+
133
+      if [ -f "${srcfile}" ]
134
+      then
135
+         log_fluff "Inheriting \"${settingname}\" from \"${srcfile}\""
136
+
137
+         mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/`dirname -- "${i}"`"
138
+         if [ -f "${BOOTSTRAP_SUBDIR}.auto/${i}" ]
139
+         then
140
+            local tmpfile
141
+
142
+            tmpfile="${BOOTSTRAP_SUBDIR}.auto/${i}.tmp"
143
+
144
+            exekutor mv "${dstfile}" "${tmpfile}" || exit 1
145
+            exekutor cat "${srcfile}" "${tmpfile}" > "${dstfile}"  || exit 1
146
+            exekutor rm "${tmpfile}" || exit 1
147
+         else
148
+            exekutor cp "${srcfile}" "${dstfile}" || exit 1
149
+         fi
150
+      else
151
+         log_fluff "Setting \"${settingname}\" is not specified, so not inherited"
152
+      fi
153
+   done
154
+   IFS="{old}"
155
+
156
+   # link scm files over, that we find
157
+   local relative
158
+
159
+   relative="`compute_relative "${BOOTSTRAP_SUBDIR}"`"
160
+   exekutor find "${directory}/.bootstrap" -xdev -mindepth 1 -maxdepth 1 -name "*.scm" -type f -print0 | \
161
+         exekutor xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/${name}"
162
+
163
+   #
164
+   # link up other non-inheriting settings
165
+   #
166
+   if dir_has_files "${directory}/.bootstrap/settings"
167
+   then
168
+      local relative
169
+
170
+      log_fluff "Link up build settings of \"${name}\" to \"${BOOTSTRAP_SUBDIR}.auto/settings/${name}\""
171
+
172
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings"
173
+      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type f -print0 | \
174
+         exekutor xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
175
+
176
+      if [ -e "${directory}/.bootstrap/settings/bin"  ]
177
+      then
178
+         exekutor ln -s -f "${relative}/../../${directory}/.bootstrap/settings/bin" "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
179
+      fi
180
+
181
+      # flatten other folders into our own settings
182
+      # don't force though, keep first
183
+      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type d -print0 | \
184
+         exekutor xargs -0 -I % ln -s "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings"
185
+   fi
186
+
187
+   return 0
188
+}
189
+
190
+
... ...
@@ -39,6 +39,7 @@
39 39
 . mulle-bootstrap-brew.sh
40 40
 . mulle-bootstrap-scm.sh
41 41
 . mulle-bootstrap-scripts.sh
42
+. mulle-bootstrap-auto-update.sh
42 43
 
43 44
 
44 45
 usage()
... ...
@@ -371,143 +372,6 @@ settings/build_order
371 372
 settings/build_ignore'
372 373
 
373 374
 
374
-bootstrap_auto_update()
375
-{
376
-   local name
377
-   local url
378
-   local directory
379
-
380
-   name="$1"
381
-   url="$2"
382
-   directory="$3"
383
-
384
-   [ ! -z "${directory}" ]        || internal_fail "src was empty"
385
-   [ "${PWD}" != "${directory}" ] || internal_fail "configuration error"
386
-
387
-
388
-   # contains own bootstrap ? and not a symlink
389
-   if [ ! -d "${directory}/.bootstrap" ] # -a ! -L "${dst}" ]
390
-   then
391
-      log_fluff "no .bootstrap folder in \"${directory}\" found"
392
-      return 1
393
-   fi
394
-
395
-   log_info "Recursively acquiring ${directory} .bootstrap settings ..."
396
-
397
-   local old
398
-   local name
399
-
400
-   old="${IFS:-" "}"
401
-
402
-   #
403
-   # prepare auto folder if it doesn't exist yet
404
-   # means copy our own files to .auto first,
405
-   #
406
-   if [ ! -d "${BOOTSTRAP_SUBDIR}.auto" ]
407
-   then
408
-      log_info "Found a .bootstrap folder for \"${name}\" will set up ${BOOTSTRAP_SUBDIR}.auto"
409
-
410
-      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.tmp/settings"
411
-
412
-      IFS="
413
-"
414
-      for i in $INHERIT_SETTINGS
415
-      do
416
-         IFS="${old}"
417
-         if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
418
-         then
419
-            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
420
-         else
421
-            if [ -f "${BOOTSTRAP_SUBDIR}/${i}" ]
422
-            then
423
-               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
424
-            else
425
-               name="`basename -- "${i}"`"
426
-               log_fluff "Setting \"${name}\" is not specified, so not inherited"
427
-            fi
428
-         fi
429
-      done
430
-      IFS="${old}"
431
-
432
-      # now move it
433
-      exekutor mv "${BOOTSTRAP_SUBDIR}.tmp" "${BOOTSTRAP_SUBDIR}.auto" || exit 1
434
-
435
-      # leave .scm files behind
436
-   fi
437
-
438
-   #
439
-   # prepend new contents to old contents
440
-   # of a few select and known files
441
-   #
442
-   local srcfile
443
-   local dstfile
444
-   local i
445
-
446
-   IFS="
447
-"
448
-   for i in $INHERIT_SETTINGS
449
-   do
450
-      IFS="{old}"
451
-      srcfile="${directory}/.bootstrap/${i}"
452
-      dstfile="${BOOTSTRAP_SUBDIR}.auto/${i}"
453
-      name="`basename -- "${i}"`"
454
-
455
-      if [ -f "${srcfile}" ]
456
-      then
457
-         log_fluff "Inheriting \"${name}\" from \"${srcfile}\""
458
-
459
-         mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/`dirname -- "${i}"`"
460
-         if [ -f "${BOOTSTRAP_SUBDIR}.auto/${i}" ]
461
-         then
462
-            local tmpfile
463
-
464
-            tmpfile="${BOOTSTRAP_SUBDIR}.auto/${i}.tmp"
465
-
466
-            exekutor mv "${dstfile}" "${tmpfile}" || exit 1
467
-            exekutor cat "${srcfile}" "${tmpfile}" > "${dstfile}"  || exit 1
468
-            exekutor rm "${tmpfile}" || exit 1
469
-         else
470
-            exekutor cp "${srcfile}" "${dstfile}" || exit 1
471
-         fi
472
-      else
473
-         log_fluff "Setting \"${name}\" is not specified, so not inherited"
474
-      fi
475
-   done
476
-   IFS="{old}"
477
-
478
-   # link scm files over, that we find
479
-   local relative
480
-
481
-   relative="`compute_relative "${BOOTSTRAP_SUBDIR}"`"
482
-   exekutor find "${directory}/.bootstrap" -xdev -mindepth 1 -maxdepth 1 -name "*.scm" -type f -print0 | \
483
-         exekutor xargs -0 -I % ln -s -f "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/${name}"
484
-
485
-   #
486
-   # link up other non-inheriting settings
487
-   #
488
-   if dir_has_files "${directory}/.bootstrap/settings"
489
-   then
490
-      local relative
491
-
492
-      log_fluff "Link up build settings of \"${name}\" to \"${BOOTSTRAP_SUBDIR}.auto/settings/${name}\""
493
-
494
-      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
495
-      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type f -print0 | \
496
-         exekutor xargs -0 -I % ln -s -f "${relative}/../../"% "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
497
-
498
-      if [ -e "${directory}/.bootstrap/settings/bin"  ]
499
-      then
500
-         exekutor ln -s -f "${relative}/../../${directory}/.bootstrap/settings/bin" "${BOOTSTRAP_SUBDIR}.auto/settings/${name}"
501
-      fi
502
-
503
-      # flatten other folders into our own settings
504
-      # don't force though, keep first
505
-      exekutor find "${directory}/.bootstrap/settings" -xdev -mindepth 1 -maxdepth 1 -type d -print0 | \
506
-         exekutor xargs -0 -I % ln -s "${relative}/../"% "${BOOTSTRAP_SUBDIR}.auto/settings"
507
-   fi
508
-
509
-   return 0
510
-}
511 375
 
512 376
 
513 377
 ensure_clones_directory()
... ...
@@ -770,7 +634,7 @@ checkout_repository()
770 634
          install_embedded_repositories "${dstdir}/"
771 635
          BOOTSTRAP_SUBDIR="${old}"
772 636
 
773
-         bootstrap_auto_update "${name}" "${url}" "${dstdir}"
637
+         bootstrap_auto_update "${name}" "${url}" "${dstdir}" "$INHERIT_SETTINGS"
774 638
          flag=$?
775 639
       fi
776 640
 
777 641
new file mode 100755
... ...
@@ -0,0 +1,144 @@
1
+#! /bin/sh
2
+#
3
+#   Copyright (c) 2015 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
+#   POSSIBILITY OF SUCH DAMAGE.
31
+
32
+#
33
+# this script installs the proper git clones into "clones"
34
+# it does not to git subprojects.
35
+# You can also specify a list of "brew" dependencies. That
36
+# will be third party libraries, you don't tag or debug
37
+#
38
+. mulle-bootstrap-local-environment.sh
39
+. mulle-bootstrap-auto-update.sh
40
+
41
+
42
+usage()
43
+{
44
+   cat <<EOF
45
+usage: refresh <refresh|nonrecursive>
46
+   install      : default, install settings into .bootstrap.auto
47
+   nonrecursive : ignore .bootstrap folders of fetched repositories
48
+EOF
49
+}
50
+
51
+
52
+check_and_usage_and_help()
53
+{
54
+   case "$COMMAND" in
55
+      nonrecursive)
56
+        DONT_RECURSE="YES"
57
+         ;;
58
+      refresh)
59
+         ;;
60
+      *)
61
+         usage >&2
62
+         exit 1
63
+         ;;
64
+   esac
65
+}
66
+
67
+
68
+if [ "$1" = "-h" -o "$1" = "--help" ]
69
+then
70
+   COMMAND=help
71
+else
72
+   if [ -z "${COMMAND}" ]
73
+   then
74
+      COMMAND=${1:-"refresh"}
75
+      [ $# -eq 0 ] || shift
76
+   fi
77
+
78
+   if [ "${MULLE_BOOTSTRAP}" = "mulle-bootstrap" ]
79
+   then
80
+      COMMAND="refresh"
81
+   fi
82
+fi
83
+
84
+
85
+check_and_usage_and_help
86
+
87
+
88
+
89
+refresh_repositories_settings()
90
+{
91
+   local stop
92
+   local clones
93
+   local clone
94
+   local old
95
+
96
+   old="${IFS:-" "}"
97
+
98
+   clones="`read_fetch_setting "repositories"`"
99
+   if [ "${clones}" != "" ]
100
+   then
101
+      IFS="
102
+"
103
+      for clone in ${clones}
104
+      do
105
+         IFS="${old}"
106
+
107
+         local name
108
+         local url
109
+         local tag
110
+         local dstdir
111
+
112
+         name="`canonical_name_from_clone "${clone}"`"
113
+         url="`url_from_clone "${clone}"`"
114
+         tag="`read_repo_setting "${name}" "tag"`" #repo (sic)
115
+         dstdir="${CLONES_FETCH_SUBDIR}/${name}"
116
+
117
+         bootstrap_auto_update "${name}" "${url}" "${dstdir}" "$INHERIT_SETTINGS"
118
+      done
119
+   fi
120
+
121
+   IFS="${old}"
122
+}
123
+
124
+
125
+
126
+main()
127
+{
128
+   log_fluff "::: refresh :::"
129
+
130
+   #
131
+   # remove .auto because it's contents are stale now
132
+   #
133
+   if [ -d "${BOOTSTRAP_SUBDIR}.auto" ]
134
+   then
135
+      exekutor rm -rf "${BOOTSTRAP_SUBDIR}.auto"
136
+   fi
137
+
138
+   if [ "${DONT_RECURSE}" = "" ]
139
+   then
140
+      refresh_repositories_settings
141
+   fi
142
+}
143
+
144
+main "$@"