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 144
 "
145 145
       for brew in ${brews}
146 146
       do
147
+         IFS="${old}"
147 148
          if [ "`which "${brew}"`" = "" ]
148 149
          then
149 150
             brew_update_if_needed "${brew}"
... ...
@@ -182,6 +185,7 @@ check_tars()
182 182
 "
183 183
       for tar in ${tarballs}
184 184
       do
185
+         IFS="${old}"
185 186
          if [ ! -f "$tar" ]
186 187
          then
187 188
             fail "tarball \"$tar\" not found"
... ...
@@ -215,6 +219,7 @@ install_gems()
215 215
 "
216 216
       for gem in ${gems}
217 217
       do
218
+         IFS="${old}"
218 219
          log_fluff "gem install \"${gem}\""
219 220
 
220 221
          echo "gem needs sudo to install ${gem}" >&2
... ...
@@ -247,6 +252,7 @@ install_pips()
247 247
 "
248 248
       for pip in ${pips}
249 249
       do
250
+         IFS="${old}"
250 251
          log_fluff "pip install \"${gem}\""
251 252
 
252 253
          echo "pip needs sudo to install ${pip}" >&2
... ...
@@ -382,26 +388,32 @@ bootstrap_auto_update()
382 382
 
383 383
    #
384 384
    # prepare auto folder if it doesn't exist yet
385
-   # means copy our own files to .auto first
385
+   # means copy our own files to .auto first,
386 386
    #
387 387
    if [ ! -d "${BOOTSTRAP_SUBDIR}.auto" ]
388 388
    then
389 389
       log_info "Found a .bootstrap folder for \"${name}\" will set up ${BOOTSTRAP_SUBDIR}.auto"
390 390
 
391
-      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.auto/settings"
391
+      mkdir_if_missing "${BOOTSTRAP_SUBDIR}.tmp/settings"
392
+
392 393
       for i in $INHERIT_SETTINGS
393 394
       do
394 395
          if [ -f "${BOOTSTRAP_SUBDIR}.local/${i}" ]
395 396
          then
396
-            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
397
+            exekutor cp "${BOOTSTRAP_SUBDIR}.local/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
397 398
          else
398 399
             if [ -f "${BOOTSTRAP_SUBDIR}/${i}" ]
399 400
             then
400
-               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.auto/${i}" || exit 1
401
+               exekutor cp "${BOOTSTRAP_SUBDIR}/${i}" "${BOOTSTRAP_SUBDIR}.tmp/${i}" || exit 1
402
+            else
403
+               log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
401 404
             fi
402 405
          fi
403 406
       done
404 407
 
408
+      # now move it
409
+      exekutor mv "${BOOTSTRAP_SUBDIR}.tmp" "${BOOTSTRAP_SUBDIR}.auto" || exit 1
410
+
405 411
       # leave .scm files behind
406 412
    fi
407 413
 
... ...
@@ -434,6 +446,8 @@ bootstrap_auto_update()
434 434
          else
435 435
             exekutor cp "${srcfile}" "${dstfile}" || exit 1
436 436
          fi
437
+      else
438
+         log_fluff "Setting \"`basename -- ${i}`\" is not specified, so not inherited"
437 439
       fi
438 440
    done
439 441
 
... ...
@@ -1153,7 +1167,6 @@ main()
1153 1153
          log_warning "Folder \"${BOOTSTRAP_SUBDIR}.auto\" already exists!"
1154 1154
       fi
1155 1155
 
1156
-
1157 1156
       clone_repositories
1158 1157
 
1159 1158
       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