forked from CodisLabs/codis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhack.sh
More file actions
executable file
·71 lines (56 loc) · 1.41 KB
/
hack.sh
File metadata and controls
executable file
·71 lines (56 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# Wrapper around printf - clobber print since it's not POSIX anyway
print() { printf "%s\n" "$*"; }
die() {
print "
Doing error:
$1" 1>&2
exit ${2:-1}
}
set_var() {
local var=$1
shift
local value="$*"
eval "export $var=\"\${$var-$value}\""
}
vars_setup() {
# Try to locate a 'vars' file in order of location preference.
# If one is found, source it
local vars=
# set up program path
local prog_vars="${0%/*}/vars"
set_var CODIS_BASE "$(dirname $BASH_SOURCE[0])/.."
set_var CODIS_BRANCH "release3.1"
set_var GOLANG_PKG "go1.6.2.linux-amd64.tar.gz"
set_var DOCKERFILE_SUFFIX "debian:jessie"
set_var IMAGE_NS "tangfeixiong"
}
while :; do
# Separate option from value:
opt="${1%%=*}"
val="${1#*=}"
empty_ok= # Empty values are not allowed unless excepted
case "$opt" in
--image-os)
empty_ok=1
export DOCKERFILE_SUFFIX="$val"
;;
*)
break ;;
esac
# fatal error when no value was provided
if [ ! $empty_ok ] && { [ "$val" = "$1" ] || [ -z "$val" ]; }; then
die "Missing value to option: $opt"
fi
shift
done
export IMAGE_NS="$1"
vars_setup
case $DOCKERFILE_SUFFIX in
debian:jessie)
docker build --no-cache -t $IMAGE_NS/codis:v3.1 -f $CODIS_BASE/hack/Dockerfile.${CODIS_BRANCH//\./%2E}.${GOLANG_PKG//\./%2E}.debian%3Ajessie $CODIS_BASE
;;
*)
die "Unknown command '$cmd'. Run without commands for usage help."
;;
esac