|
35 | 35 | # Keep track of the current devstack directory. |
36 | 36 | TOP_DIR=$(cd $(dirname "$0") && pwd) |
37 | 37 |
|
| 38 | +# Import common functions |
| 39 | +. $TOP_DIR/functions |
| 40 | + |
38 | 41 | # stack.sh keeps the list of **apt** and **pip** dependencies in external |
39 | 42 | # files, along with config templates and other useful files. You can find these |
40 | 43 | # in the ``files`` directory (next to this script). We will reference this |
@@ -86,16 +89,6 @@ source ./stackrc |
86 | 89 | # Destination path for installation ``DEST`` |
87 | 90 | DEST=${DEST:-/opt/stack} |
88 | 91 |
|
89 | | -# apt-get wrapper to just get arguments set correctly |
90 | | -function apt_get() { |
91 | | - [[ "$OFFLINE" = "True" ]] && return |
92 | | - local sudo="sudo" |
93 | | - [ "$(id -u)" = "0" ] && sudo="env" |
94 | | - $sudo DEBIAN_FRONTEND=noninteractive \ |
95 | | - http_proxy=$http_proxy https_proxy=$https_proxy \ |
96 | | - apt-get --option "Dpkg::Options::=--force-confold" --assume-yes "$@" |
97 | | -} |
98 | | - |
99 | 92 | # Check to see if we are already running a stack.sh |
100 | 93 | if screen -ls | egrep -q "[0-9].stack"; then |
101 | 94 | echo "You are already running a stack.sh session." |
@@ -155,18 +148,6 @@ else |
155 | 148 | sudo mv $TEMPFILE /etc/sudoers.d/stack_sh_nova |
156 | 149 | fi |
157 | 150 |
|
158 | | -# Normalize config values to True or False |
159 | | -# VAR=`trueorfalse default-value test-value` |
160 | | -function trueorfalse() { |
161 | | - local default=$1 |
162 | | - local testval=$2 |
163 | | - |
164 | | - [[ -z "$testval" ]] && { echo "$default"; return; } |
165 | | - [[ "0 no false False FALSE" =~ "$testval" ]] && { echo "False"; return; } |
166 | | - [[ "1 yes true True TRUE" =~ "$testval" ]] && { echo "True"; return; } |
167 | | - echo "$default" |
168 | | -} |
169 | | - |
170 | 151 | # Set True to configure stack.sh to run cleanly without Internet access. |
171 | 152 | # stack.sh must have been previously run with Internet access to install |
172 | 153 | # prerequisites and initialize $DEST. |
@@ -542,63 +523,13 @@ function get_packages() { |
542 | 523 | done |
543 | 524 | } |
544 | 525 |
|
545 | | -function pip_install { |
546 | | - [[ "$OFFLINE" = "True" ]] && return |
547 | | - sudo PIP_DOWNLOAD_CACHE=/var/cache/pip \ |
548 | | - HTTP_PROXY=$http_proxy \ |
549 | | - HTTPS_PROXY=$https_proxy \ |
550 | | - pip install --use-mirrors $@ |
551 | | -} |
552 | | - |
553 | 526 | # install apt requirements |
554 | 527 | apt_get update |
555 | 528 | apt_get install $(get_packages) |
556 | 529 |
|
557 | 530 | # install python requirements |
558 | 531 | pip_install `cat $FILES/pips/* | uniq` |
559 | 532 |
|
560 | | -# git clone only if directory doesn't exist already. Since ``DEST`` might not |
561 | | -# be owned by the installation user, we create the directory and change the |
562 | | -# ownership to the proper user. |
563 | | -function git_clone { |
564 | | - [[ "$OFFLINE" = "True" ]] && return |
565 | | - |
566 | | - GIT_REMOTE=$1 |
567 | | - GIT_DEST=$2 |
568 | | - GIT_BRANCH=$3 |
569 | | - |
570 | | - if echo $GIT_BRANCH | egrep -q "^refs"; then |
571 | | - # If our branch name is a gerrit style refs/changes/... |
572 | | - if [ ! -d $GIT_DEST ]; then |
573 | | - git clone $GIT_REMOTE $GIT_DEST |
574 | | - fi |
575 | | - cd $GIT_DEST |
576 | | - git fetch $GIT_REMOTE $GIT_BRANCH && git checkout FETCH_HEAD |
577 | | - else |
578 | | - # do a full clone only if the directory doesn't exist |
579 | | - if [ ! -d $GIT_DEST ]; then |
580 | | - git clone $GIT_REMOTE $GIT_DEST |
581 | | - cd $GIT_DEST |
582 | | - # This checkout syntax works for both branches and tags |
583 | | - git checkout $GIT_BRANCH |
584 | | - elif [[ "$RECLONE" == "yes" ]]; then |
585 | | - # if it does exist then simulate what clone does if asked to RECLONE |
586 | | - cd $GIT_DEST |
587 | | - # set the url to pull from and fetch |
588 | | - git remote set-url origin $GIT_REMOTE |
589 | | - git fetch origin |
590 | | - # remove the existing ignored files (like pyc) as they cause breakage |
591 | | - # (due to the py files having older timestamps than our pyc, so python |
592 | | - # thinks the pyc files are correct using them) |
593 | | - find $GIT_DEST -name '*.pyc' -delete |
594 | | - git checkout -f origin/$GIT_BRANCH |
595 | | - # a local branch might not exist |
596 | | - git branch -D $GIT_BRANCH || true |
597 | | - git checkout -b $GIT_BRANCH |
598 | | - fi |
599 | | - fi |
600 | | -} |
601 | | - |
602 | 533 | # compute service |
603 | 534 | git_clone $NOVA_REPO $NOVA_DIR $NOVA_BRANCH |
604 | 535 | # python client library to nova that horizon (and others) use |
|
0 commit comments