/
build
executable file
·68 lines (56 loc) · 1.77 KB
/
build
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
#!/bin/bash -eu
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/rocket"
if [ ! -h gopath/src/${REPO_PATH} ]; then
mkdir -p gopath/src/${ORG_PATH}
ln -s ../../../.. gopath/src/${REPO_PATH} || exit 255
fi
export GOBIN=${PWD}/bin
export GOPATH=${PWD}/gopath
eval $(go env)
# set default stage1 usr style and validate potential override
RKT_STAGE1_USR_FROM="${RKT_STAGE1_USR_FROM:-coreos}"
case "${RKT_STAGE1_USR_FROM}" in
coreos|src)
;;
*)
echo "RKT_STAGE1_USR_FROM=${RKT_STAGE1_USR_FROM} unsupported"
exit 255
esac
export RKT_STAGE1_USR_FROM
echo "Building rkt (stage0)..."
go build -o ${GOBIN}/rkt \
${RKT_STAGE1_IMAGE:+-ldflags "-X main.defaultStage1Image '${RKT_STAGE1_IMAGE}'"} \
${REPO_PATH}/rkt
if [[ "$OSTYPE" == "linux-gnu" ]]; then
echo "Building network plugins..."
for d in networking/net/* networking/ipam/*; do
if [ -d $d ]; then
plugin=$(basename $d)
echo " " $plugin
go install ${REPO_PATH}/$d
fi
done
echo "Building actool..."
go build -o ${GOBIN}/actool github.com/coreos/rocket/Godeps/_workspace/src/github.com/appc/spec/actool
export ACTOOL=${GOBIN}/actool
echo "Building init (stage1)..."
go install ${REPO_PATH}/stage1/init
# symlink plugin binaries into stage1 rootfs
mkdir -p stage1/rootfs/net-plugins/bin
# make sure the bin dir doesn't have old links
rm -f stage1/rootfs/net-plugins/bin/*
for d in networking/net/* networking/ipam/*; do
if [ -d $d ]; then
plugin=$(basename $d)
ln -sf ${GOBIN}/$plugin stage1/rootfs/net-plugins/bin
fi
done
# symlink init into stage1 rootfs
mkdir -p stage1/rootfs/init/bin
ln -sf ${GOBIN}/init stage1/rootfs/init/bin
JOBS=1
which lscpu >&/dev/null && JOBS=$(lscpu --parse=CPU | grep -c ^[^#])
echo "Building rootfs (stage1) using ${JOBS} CPUs..."
make -C stage1/rootfs -j ${JOBS}
fi