Browse code

Cleanup etcd install

Clayton Coleman authored on 2015/08/23 00:14:50
Showing 6 changed files
... ...
@@ -1,4 +1,5 @@
1 1
 /_output
2
+/_tools
2 3
 /openshift.local.*
3 4
 /.project
4 5
 /.vagrant
... ...
@@ -8,7 +8,7 @@ env:
8 8
  - TEST_ASSETS=false
9 9
 
10 10
 install:
11
-  - export PATH=$GOPATH/bin:./third_party/etcd:$PATH
11
+  - export PATH=$GOPATH/bin:./_tools/etcd/bin:$PATH
12 12
   - make install-travis
13 13
 
14 14
 script:
... ...
@@ -2,29 +2,39 @@
2 2
 
3 3
 set -e
4 4
 
5
-OS_ROOT=$(dirname "${BASH_SOURCE}")/..
6
-source "${OS_ROOT}/hack/common.sh"
5
+set -o errexit
6
+set -o nounset
7
+set -o pipefail
7 8
 
8
-mkdir -p "${OS_ROOT}/_output"
9
-cd "${OS_ROOT}/_output"
9
+OS_ROOT=$(dirname "${BASH_SOURCE}")/..
10
+source "${OS_ROOT}/hack/util.sh"
11
+os::log::install_errexit
10 12
 
11
-if [ -d etcd ]; then
12
-    pushd etcd >/dev/null
13
-    ./build
14
-    popd >/dev/null
15
-    exit
16
-fi
13
+etcd_version=$(go run ${OS_ROOT}/hack/version.go ${OS_ROOT}/Godeps/Godeps.json github.com/coreos/etcd/etcdserver)
17 14
 
18
-etcd_version=$(go run ${OS_ROOT}/hack/version.go ${OS_ROOT}/Godeps/Godeps.json \
19
-  github.com/coreos/etcd/etcdserver)
15
+mkdir -p "${OS_ROOT}/_tools"
16
+cd "${OS_ROOT}/_tools"
20 17
 
21
-mkdir -p etcd && cd etcd
18
+if [ ! -d etcd ]; then
19
+  mkdir -p etcd
20
+  pushd etcd >/dev/null
22 21
 
23
-curl -s -L https://github.com/coreos/etcd/tarball/${etcd_version} | \
24
-  tar xz --strip-components 1 2>/dev/null
22
+  curl -s -L https://github.com/coreos/etcd/tarball/${etcd_version} | \
23
+    tar xz --strip-components 1 2>/dev/null
25 24
 
26
-if [ "$?" != "0" ]; then
27
-  echo "Failed to download coreos/etcd." && exit 1
25
+  if [ "$?" != "0" ]; then
26
+    echo "Failed to download coreos/etcd."
27
+    exit 1
28
+  fi
29
+else
30
+  pushd etcd >/dev/null
28 31
 fi
29 32
 
30 33
 ./build
34
+
35
+echo
36
+echo Installed coreos/etcd ${etcd_version} into:
37
+echo export PATH=$(pwd):\$PATH
38
+
39
+popd >/dev/null
40
+exit 0
31 41
\ No newline at end of file
... ...
@@ -23,13 +23,12 @@ find_test_dirs() {
23 23
   find . -not \( \
24 24
       \( \
25 25
         -wholename './Godeps' \
26
-        -o -wholename './release' \
27
-        -o -wholename './target' \
28
-        -o -wholename '*/Godeps/*' \
29
-        -o -wholename '*/_output/*' \
26
+        -o -wholename './_output' \
27
+        -o -wholename './_tools' \
30 28
         -o -wholename './.git' \
31
-        -o -wholename './assets/node_modules' \
32 29
         -o -wholename './openshift.local.*' \
30
+        -o -wholename '*/Godeps/*' \
31
+        -o -wholename './assets/node_modules' \
33 32
         -o -wholename './test/extended' \
34 33
       \) -prune \
35 34
     \) -name '*_test.go' -print0 | xargs -0n1 dirname | sort -u | xargs -n1 printf "${OS_GO_PACKAGE}/%s\n"
... ...
@@ -28,7 +28,7 @@ tags="${OS_TEST_TAGS:-integration !docker etcd}"
28 28
 
29 29
 export GOMAXPROCS="$(grep "processor" -c /proc/cpuinfo 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || 1)"
30 30
 TMPDIR=${TMPDIR:-/tmp}
31
-export BASETMPDIR=${BASETMPDIR:-"${TMPDIR}/openshift-integration"}
31
+export BASETMPDIR=${BASETMPDIR:-${TMPDIR}/openshift-integration}
32 32
 
33 33
 echo
34 34
 echo "Test ${package} -tags='${tags}' ..."
... ...
@@ -308,8 +308,11 @@ function start_etcd {
308 308
   set +e
309 309
 
310 310
   if [ "$(which etcd)" == "" ]; then
311
-    echo "etcd must be in your PATH"
312
-    exit 1
311
+    if [[ ! -f ${OS_ROOT}/_tools/etcd/bin/etcd ]]; then
312
+      echo "etcd must be in your PATH or installed in _tools/etcd/bin/ with hack/install-etcd.sh"
313
+      exit 1
314
+    fi
315
+    export PATH="${OS_ROOT}/_tools/etcd/bin:$PATH"
313 316
   fi
314 317
 
315 318
   running_etcd=$(ps -ef | grep etcd | grep -c name)
... ...
@@ -527,14 +530,12 @@ os::log::status() {
527 527
 find_files() {
528 528
   find . -not \( \
529 529
       \( \
530
-        -wholename './output' \
531
-        -o -wholename './_output' \
530
+        -wholename './_output' \
531
+        -o -wholename './_tools' \
532 532
         -o -wholename './.*' \
533
-        -o -wholename './release' \
534 533
         -o -wholename './pkg/assets/bindata.go' \
535 534
         -o -wholename './pkg/assets/*/bindata.go' \
536
-        -o -wholename './target' \
537
-        -o -wholename '*/third_party/*' \
535
+        -o -wholename './openshift.local.*' \
538 536
         -o -wholename '*/Godeps/*' \
539 537
       \) -prune \
540 538
     \) -name '*.go' | sort -u