Files
Alban Crequy 70120a4b55 build: fix on OpenSUSE
$OSTYPE is "linux" on OpenSUSE 13.2. uname should be more reliable.

$OSTYPE was introduced for OS X in commit cb78269. Also, disable
functional tests on non-Linux.

Fixes: https://github.com/coreos/rkt/issues/1005
2015-06-08 15:31:02 +02:00

95 lines
2.6 KiB
Python
Executable File

#!/bin/bash -eu
ORG_PATH="github.com/coreos"
REPO_PATH="${ORG_PATH}/rkt"
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
export RKT_STAGE1_USR_FROM="${RKT_STAGE1_USR_FROM:-coreos}"
case "${RKT_STAGE1_USR_FROM}" in
none)
echo "stage1 build disabled"
;;
usr-from-host)
echo "stage1 will pick binaries from the host at run-time"
;;
coreos)
echo "stage1 will reuse coreos image"
;;
src)
export RKT_STAGE1_SYSTEMD_SRC="${RKT_STAGE1_SYSTEMD_SRC:-https://github.com/systemd/systemd.git}"
export RKT_STAGE1_SYSTEMD_VER="${RKT_STAGE1_SYSTEMD_VER:-v220}"
echo "stage1 will be built from sources: $RKT_STAGE1_SYSTEMD_SRC $RKT_STAGE1_SYSTEMD_VER"
;;
*)
echo "RKT_STAGE1_USR_FROM=${RKT_STAGE1_USR_FROM} unsupported"
exit 255
esac
echo "Building rkt (stage0)..."
go build -o ${GOBIN}/rkt \
${RKT_STAGE1_IMAGE:+-ldflags "-X main.defaultStage1Image '${RKT_STAGE1_IMAGE}'"} \
${REPO_PATH}/rkt
if [[ "$(uname)" == "Linux" ]]; then
echo "Building network plugins..."
cni_plugins="Godeps/_workspace/src/github.com/appc/cni/plugins/main/* "
cni_plugins="$cni_plugins Godeps/_workspace/src/github.com/appc/cni/plugins/ipam/* "
for d in $cni_plugins; 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/rkt/Godeps/_workspace/src/github.com/appc/spec/actool
export ACTOOL=${GOBIN}/actool
echo "Building init (stage1)..."
go install ${REPO_PATH}/stage1/init
echo "Building gc (stage1)..."
go install ${REPO_PATH}/stage1/gc
# 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 $cni_plugins; 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
# symlink gc into stage1 rootfs
mkdir -p stage1/rootfs/gc/bin
ln -sf ${GOBIN}/gc stage1/rootfs/gc/bin
if [ "$RKT_STAGE1_USR_FROM" != "none" ] ; then
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
echo "Building functional tests..."
(cd tests && ./build)
fi