Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
build: secured CDIR variable, now should work with spaces in path
Browse files Browse the repository at this point in the history
  • Loading branch information
kayrus committed Jul 18, 2016
1 parent e51d940 commit 2fedc85
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

CDIR=$(cd `dirname $0` && pwd)
cd $CDIR
CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"

ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/fleet"
Expand Down
2 changes: 1 addition & 1 deletion build-aci
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tgt=$(mktemp -d)
# Cleanup
trap 'rm -rf "$tgt"' INT TERM EXIT

CDIR=$(cd `dirname $0` && pwd)
CDIR=$(cd `dirname "$0"` && pwd)

# Build fleet inside
docker run --rm -v $CDIR:/opt/fleet -u $(id -u):$(id -g) golang:1.6 /bin/bash -c "cd /opt/fleet && ./build"
Expand Down
4 changes: 2 additions & 2 deletions build-docker
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e

CDIR=$(cd `dirname $0` && pwd)
CDIR=$(cd `dirname "$0"` && pwd)

docker run --rm -v $CDIR:/opt/fleet -u $(id -u):$(id -g) golang:1.6 /bin/bash -c "cd /opt/fleet && ./build"
docker run --rm -v "$CDIR":/opt/fleet -u $(id -u):$(id -g) golang:1.6 /bin/bash -c "cd /opt/fleet && ./build"
10 changes: 6 additions & 4 deletions build-env
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ else
fi
fi

export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
: ${CDIR:=${PWD}}

export GOBIN="${CDIR}/bin"
export GOPATH="${CDIR}/gopath"
export VERSION=$(git describe --dirty)
export GLDFLAGS="-X github.com/coreos/fleet/version.Version=${VERSION}"
eval $(go env)
export PATH="${GOROOT}/bin:${PATH}"
export FLEETD_BIN="$(pwd)/bin/fleetd"
export FLEETCTL_BIN="$(pwd)/bin/fleetctl"
export FLEETD_BIN="${CDIR}/bin/fleetd"
export FLEETCTL_BIN="${CDIR}/bin/fleetctl"
4 changes: 2 additions & 2 deletions functional/run-in-qemu
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ if ! qemu-system-x86_64 --version > /dev/null 2>&1; then
print_error "Please install QEMU first"
fi

CDIR=$(cd `dirname $0` && pwd)
cd $CDIR
CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"

ARGS=`for i in "$@"; do printf '%q ' "$i"; done`

Expand Down
4 changes: 2 additions & 2 deletions functional/run-in-vagrant
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash -e

CDIR=$(cd `dirname $0` && pwd)
cd $CDIR
CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"

if ! vagrant version > /dev/null 2>&1; then
echo "Please install vagrant first"
Expand Down
2 changes: 1 addition & 1 deletion functional/start_etcd
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash -e

CDIR=$(cd `dirname $0` && pwd)
CDIR=$(cd `dirname "$0"` && pwd)
USER_ID=${SUDO_UID:-$(id -u)}
HOME=$(getent passwd "${USER_ID}" | cut -d: -f6)

Expand Down
6 changes: 3 additions & 3 deletions functional/test
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ function print_results() {
echo "# SKIP: $skip"
echo "# FAIL: $fail"
echo ""
echo "See ${CDIR}/functional-tests.log for the detailed output."
echo "See ${CDIR}/functional/functional-tests.log for the detailed output."
if [ "${TESTS_RETURN_CODE_1}" -ne "0" ]; then
exit ${TESTS_RETURN_CODE_1}
else
exit ${TESTS_RETURN_CODE_2}
fi
}

CDIR=$(cd `dirname $0` && pwd)
CDIR=$(cd `dirname "$0"`/.. && pwd)
USER_ID=${SUDO_UID:-$(id -u)}
HOME=$(getent passwd "${USER_ID}" | cut -d: -f6)
TAIL_LOGS=30

cd ${CDIR}/../
cd ${CDIR}
export GOROOT=${HOME}/go
export PATH=${HOME}/go/bin:${PATH}

Expand Down
4 changes: 2 additions & 2 deletions test
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# Invoke ./cover for HTML output
COVER=${COVER:-"-cover"}

CDIR=$(cd `dirname $0` && pwd)
cd $CDIR
CDIR=$(cd `dirname "$0"` && pwd)
cd "$CDIR"

source ./build

Expand Down
4 changes: 2 additions & 2 deletions test-docker
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash -e

CDIR=$(cd `dirname $0` && pwd)
CDIR=$(cd `dirname "$0"` && pwd)

docker run --rm -v $CDIR:/opt/fleet -u $(id -u):$(id -g) golang:1.6 /bin/bash -c "cd /opt/fleet && ./test"
docker run --rm -v "$CDIR":/opt/fleet -u $(id -u):$(id -g) golang:1.6 /bin/bash -c "cd /opt/fleet && ./test"

0 comments on commit 2fedc85

Please sign in to comment.