2121#
2222# The following variables are assumed to be defined by certain functions:
2323#
24- # - ``GIT_DEPTH``
2524# - ``ENABLED_SERVICES``
2625# - ``ERROR_ON_CLONE``
2726# - ``FILES``
@@ -43,6 +42,8 @@ declare -A GITREPO
4342declare -A GITBRANCH
4443declare -A GITDIR
4544
45+ TRACK_DEPENDS=${TRACK_DEPENDS:- False}
46+
4647# Config Functions
4748# ================
4849
@@ -243,7 +244,8 @@ function trueorfalse {
243244 local xtrace=$( set +o | grep xtrace)
244245 set +o xtrace
245246 local default=$1
246- local testval=$2
247+ local literal=$2
248+ local testval=${! literal}
247249
248250 [[ -z " $testval " ]] && { echo " $default " ; return ; }
249251 [[ " 0 no No NO false False FALSE" =~ " $testval " ]] && { echo " False" ; return ; }
@@ -252,6 +254,14 @@ function trueorfalse {
252254 $xtrace
253255}
254256
257+ function isset {
258+ nounset=$( set +o | grep nounset)
259+ set +o nounset
260+ [[ -n " ${! 1+x} " ]]
261+ result=$?
262+ $nounset
263+ return $result
264+ }
255265
256266# Control Functions
257267# =================
@@ -381,7 +391,11 @@ function warn {
381391# ``os_UPDATE`` - update: ex. the ``5`` in ``RHEL6.5``
382392# ``os_PACKAGE`` - package type: ``deb`` or ``rpm``
383393# ``os_CODENAME`` - vendor's codename for release: ``snow leopard``, ``trusty``
384- declare os_VENDOR os_RELEASE os_UPDATE os_PACKAGE os_CODENAME
394+ os_VENDOR=" "
395+ os_RELEASE=" "
396+ os_UPDATE=" "
397+ os_PACKAGE=" "
398+ os_CODENAME=" "
385399
386400# GetOSVersion
387401function GetOSVersion {
@@ -577,8 +591,7 @@ function get_release_name_from_branch {
577591# Set global ``RECLONE=yes`` to simulate a clone when dest-dir exists
578592# Set global ``ERROR_ON_CLONE=True`` to abort execution with an error if the git repo
579593# does not exist (default is False, meaning the repo will be cloned).
580- # Set global ``GIT_DEPTH=<number>`` to limit the history depth of the git clone
581- # Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``, ``GIT_DEPTH``
594+ # Uses globals ``ERROR_ON_CLONE``, ``OFFLINE``, ``RECLONE``
582595# git_clone remote dest-dir branch
583596function git_clone {
584597 local git_remote=$1
@@ -587,8 +600,7 @@ function git_clone {
587600 local orig_dir=$( pwd)
588601 local git_clone_flags=" "
589602
590- RECLONE=$( trueorfalse False $RECLONE )
591-
603+ RECLONE=$( trueorfalse False RECLONE)
592604 if [[ -n " ${GIT_DEPTH} " ]]; then
593605 git_clone_flags=" $git_clone_flags --depth $GIT_DEPTH "
594606 fi
@@ -978,9 +990,10 @@ function apt_get {
978990 [[ " $( id -u) " = " 0" ]] && sudo=" env"
979991
980992 $xtrace
993+
981994 $sudo DEBIAN_FRONTEND=noninteractive \
982- http_proxy=$http_proxy https_proxy=$https_proxy \
983- no_proxy=$no_proxy \
995+ http_proxy=${ http_proxy:- } https_proxy=${ https_proxy:- } \
996+ no_proxy=${ no_proxy:- } \
984997 apt-get --option " Dpkg::Options::=--force-confold" --assume-yes " $@ "
985998}
986999
@@ -999,10 +1012,10 @@ function get_packages {
9991012 set +o xtrace
10001013 local services=$@
10011014 local package_dir=$( _get_package_dir)
1002- local file_to_parse
1003- local service
1015+ local file_to_parse= " "
1016+ local service= " "
10041017
1005- INSTALL_TESTONLY_PACKAGES=$( trueorfalse False $ INSTALL_TESTONLY_PACKAGES)
1018+ INSTALL_TESTONLY_PACKAGES=$( trueorfalse False INSTALL_TESTONLY_PACKAGES)
10061019
10071020 if [[ -z " $package_dir " ]]; then
10081021 echo " No package directory supplied"
@@ -1112,6 +1125,10 @@ function get_packages {
11121125# Uses globals ``NO_UPDATE_REPOS``, ``REPOS_UPDATED``, ``RETRY_UPDATE``
11131126# install_package package [package ...]
11141127function update_package_repo {
1128+ NO_UPDATE_REPOS=${NO_UPDATE_REPOS:- False}
1129+ REPOS_UPDATED=${REPOS_UPDATED:- False}
1130+ RETRY_UPDATE=${RETRY_UPDATE:- False}
1131+
11151132 if [[ " $NO_UPDATE_REPOS " = " True" ]]; then
11161133 return 0
11171134 fi
@@ -1321,7 +1338,7 @@ function screen_process {
13211338
13221339 SCREEN_NAME=${SCREEN_NAME:- stack}
13231340 SERVICE_DIR=${SERVICE_DIR:- ${DEST} / status}
1324- USE_SCREEN=$( trueorfalse True $ USE_SCREEN)
1341+ USE_SCREEN=$( trueorfalse True USE_SCREEN)
13251342
13261343 # Append the process to the screen rc file
13271344 screen_rc " $name " " $command "
@@ -1394,7 +1411,7 @@ function screen_stop_service {
13941411
13951412 SCREEN_NAME=${SCREEN_NAME:- stack}
13961413 SERVICE_DIR=${SERVICE_DIR:- ${DEST} / status}
1397- USE_SCREEN=$( trueorfalse True $ USE_SCREEN)
1414+ USE_SCREEN=$( trueorfalse True USE_SCREEN)
13981415
13991416 if is_service_enabled $service ; then
14001417 # Clean up the screen window
@@ -1412,7 +1429,7 @@ function stop_process {
14121429 local service=$1
14131430
14141431 SERVICE_DIR=${SERVICE_DIR:- ${DEST} / status}
1415- USE_SCREEN=$( trueorfalse True $ USE_SCREEN)
1432+ USE_SCREEN=$( trueorfalse True USE_SCREEN)
14161433
14171434 if is_service_enabled $service ; then
14181435 # Kill via pid if we have one available
@@ -1462,7 +1479,7 @@ function tail_log {
14621479 local name=$1
14631480 local logfile=$2
14641481
1465- USE_SCREEN=$( trueorfalse True $ USE_SCREEN)
1482+ USE_SCREEN=$( trueorfalse True USE_SCREEN)
14661483 if [[ " $USE_SCREEN " = " True" ]]; then
14671484 screen_process " $name " " sudo tail -f $logfile "
14681485 fi
@@ -1572,7 +1589,8 @@ function get_python_exec_prefix {
15721589function pip_install {
15731590 local xtrace=$( set +o | grep xtrace)
15741591 set +o xtrace
1575- if [[ " $OFFLINE " = " True" || -z " $@ " ]]; then
1592+ local offline=${OFFLINE:- False}
1593+ if [[ " $offline " == " True" || -z " $@ " ]]; then
15761594 $xtrace
15771595 return
15781596 fi
@@ -1601,20 +1619,20 @@ function pip_install {
16011619
16021620 $xtrace
16031621 $sudo_pip \
1604- http_proxy=$http_proxy \
1605- https_proxy=$https_proxy \
1606- no_proxy=$no_proxy \
1622+ http_proxy=${ http_proxy:- } \
1623+ https_proxy=${ https_proxy:- } \
1624+ no_proxy=${ no_proxy:- } \
16071625 $cmd_pip install \
16081626 $@
16091627
1610- INSTALL_TESTONLY_PACKAGES=$( trueorfalse False $ INSTALL_TESTONLY_PACKAGES)
1628+ INSTALL_TESTONLY_PACKAGES=$( trueorfalse False INSTALL_TESTONLY_PACKAGES)
16111629 if [[ " $INSTALL_TESTONLY_PACKAGES " == " True" ]]; then
16121630 local test_req=" $@ /test-requirements.txt"
16131631 if [[ -e " $test_req " ]]; then
16141632 $sudo_pip \
1615- http_proxy=$http_proxy \
1616- https_proxy=$https_proxy \
1617- no_proxy=$no_proxy \
1633+ http_proxy=${ http_proxy:- } \
1634+ https_proxy=${ https_proxy:- } \
1635+ no_proxy=${ no_proxy:- } \
16181636 $cmd_pip install \
16191637 -r $test_req
16201638 fi
@@ -2084,13 +2102,13 @@ function cp_it {
20842102# http_proxy=http://proxy.example.com:3128/ no_proxy=repo.example.net ./stack.sh
20852103
20862104function export_proxy_variables {
2087- if [[ -n " $ http_proxy" ]] ; then
2105+ if isset http_proxy ; then
20882106 export http_proxy=$http_proxy
20892107 fi
2090- if [[ -n " $ https_proxy" ]] ; then
2108+ if isset https_proxy ; then
20912109 export https_proxy=$https_proxy
20922110 fi
2093- if [[ -n " $ no_proxy" ]] ; then
2111+ if isset no_proxy ; then
20942112 export no_proxy=$no_proxy
20952113 fi
20962114}
0 commit comments