Browse code

make .auto creation somwhat safer (paranoia). Explain inherit copying more Fixes to color output

Nat! authored on 04-01-2016 00:34:19
Showing 3 changed files
... ...
@@ -3,18 +3,25 @@
3 3
 # (c) 2015, coded by Nat!, Mulle KybernetiK
4 4
 #
5 5
 
6
-# Escape sequence and resets
7
-C_RESET="\033[0m"
6
+if [ "${MULLE_BOOTSTRAP_NO_COLOR}" != "YES" ]
7
+then
8
+   case `uname` in
9
+      Darwin|Linux)
10
+         # Escape sequence and resets
11
+         C_RESET="\033[0m"
8 12
 
9
-# Foreground colours
10
-C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
11
-C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
12
-C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
13
+         # Foreground colours
14
+         C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
15
+         C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
16
+         C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
13 17
 
14
-#
15
-# restore colors if stuff gets wonky
16
-#
17
-trap 'printf "${C_RESET}"' TERM EXIT
18
+         #
19
+         # restore colors if stuff gets wonky
20
+         #
21
+         trap 'printf "${C_RESET}"' TERM EXIT
22
+         ;;
23
+   esac
24
+fi
18 25
 
19 26
 #
20 27
 # https://github.com/hoelzro/useful-scripts/blob/master/decolorize.pl
... ...
@@ -117,8 +117,10 @@ install_taps()
117 117
 "
118 118
       for tap in ${taps}
119 119
       do
120
+         IFS="${old}"
120 121
          exekutor brew tap "${tap}" > /dev/null || exit 1
121 122
       done
123
+      IFS="${old}"
122 124
    else
123 125
       log_fluff "No taps found"
124 126
    fi
... ...
@@ -144,6 +146,7 @@ install_brews()
144 146
 "
145 147
       for brew in ${brews}
146 148
       do
149
+         IFS="${old}"
147 150
          if [ "`which "${brew}"`" = "" ]
148 151
          then
149 152
             brew_update_if_needed "${brew}"
... ...
@@ -182,6 +185,7 @@ check_tars()
182 185
 "
183 186
       for tar in ${tarballs}
184 187
       do
188
+         IFS="${old}"
185 189
          if [ ! -f "$tar" ]
186 190
          then
187 191
             fail "tarball \"$tar\" not found"
... ...
@@ -215,6 +219,7 @@ install_gems()
215 219
 "
216 220
       for gem in ${gems}
217 221
       do
222
+         IFS="${old}"
218 223
          log_fluff "gem install \"${gem}\""
219 224
 
220 225
          echo "gem needs sudo to install ${gem}" >&2
... ...
@@ -247,6 +252,7 @@ install_pips()
247 252
 "
248 253
       for pip in ${pips}
249 254
       do
255
+         IFS="${old}"
250 256
          log_fluff "pip install \"${gem}\""
251 257
 
252 258
          echo "pip needs sudo to install ${pip}" >&2
... ...
@@ -382,26 +388,32 @@ bootstrap_auto_update()
382 388
 
383 389
    #
384 390
    # prepare auto folder if it doesn't exist yet
385
-   # means copy our own files to .auto first
391
+   # means copy our own files to .auto first,
386 392
    #
387 393
    if [ ! -d "${BOOTSTRAP_SUBDIR}.auto" ]
388 394
    then
389 395
       log_info "Found a .bootstrap folder for \"${name}\" will set up ${BOOTSTRAP_SUBDIR}.auto"
390 396
 
391
-      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings"
397
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.tmp/settings"
398
+
392 399
       for i in $INHERIT_SETTINGS
393 400
       do
394 401
          if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
395 402
          then
396
-            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
403
+            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
397 404
          else
398 405
             if [ -f "${BOOTSTRAP_SUBDIR}/${i}" ]
399 406
             then
400
-               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
407
+               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
408
+            else
409
+               log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
401 410
             fi
402 411
          fi
403 412
       done
404 413
 
414
+      # now move it
415
+      exekutor mv "${BOOTSTRAP_SUBDIR}.tmp" "${BOOTSTRAP_SUBDIR}.auto" || exit 1
416
+
405 417
       # leave .scm files behind
406 418
    fi
407 419
 
... ...
@@ -434,6 +446,8 @@ bootstrap_auto_update()
434 446
          else
435 447
             exekutor cp "${srcfile}" "${dstfile}" || exit 1
436 448
          fi
449
+      else
450
+         log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
437 451
       fi
438 452
    done
439 453
 
... ...
@@ -1153,7 +1167,6 @@ main()
1153 1167
          log_warning "Folder \"${BOOTSTRAP_SUBDIR}.auto\" already exists!"
1154 1168
       fi
1155 1169
 
1156
-
1157 1170
       clone_repositories
1158 1171
 
1159 1172
       install_embedded_repositories
... ...
@@ -29,19 +29,24 @@
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
-# Escape sequence and resets
32
+# Escape sequence and resets, should use tput here instead of ANSI
33
+
33 34
 if [ "${MULLE_BOOTSTRAP_NO_COLOR}" != "YES" ]
34 35
 then
35
-   C_RESET="\033[0m"
36
+   case `uname` in
37
+      Darwin|Linux)
38
+         C_RESET="\033[0m"
36 39
 
37
-   # Foreground colours
38
-   C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
39
-   C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
40
-   C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
40
+         # Foreground colours
41
+         C_BLACK="\033[0;30m"   C_RED="\033[0;31m"    C_GREEN="\033[0;32m"
42
+         C_YELLOW="\033[0;33m"  C_BLUE="\033[0;34m"   C_MAGENTA="\033[0;35m"
43
+         C_CYAN="\033[0;36m"    C_WHITE="\033[0;37m"  C_BR_BLACK="\033[0;90m"
41 44
 
42
-   C_BR_RED="\033[0;91m" C_BR_YELLOW="\033[0;93m"
45
+         C_BR_RED="\033[0;91m" C_BR_YELLOW="\033[0;93m"
43 46
 
44
-   trap 'printf "${C_RESET}"' TERM EXIT
47
+         trap 'printf "${C_RESET}"' TERM EXIT
48
+         ;;
49
+   esac
45 50
 fi
46 51
 
47 52