1
0
mirror of https://github.com/rancher/os.git synced 2025-08-31 22:32:14 +00:00
Files
os/scripts/build

59 lines
1.2 KiB
Plaintext
Raw Normal View History

2015-02-08 21:38:37 -07:00
#!/bin/bash -e
2015-03-18 06:28:05 -07:00
set -x
2015-02-08 21:38:37 -07:00
cd $(dirname $0)/..
2015-03-20 11:35:21 -07:00
source scripts/version
2015-04-06 07:17:03 -07:00
while [ "$#" -gt 0 ]; do
case $1 in
--custom)
IN_DOCKER=true
ROS_CUSTOM_GOPATH=true
;;
*)
break
;;
esac
shift 1
done
2015-03-18 06:28:05 -07:00
if [ "$IN_DOCKER" != "true" ]; then
cat > .dockerfile << "EOF"
FROM rancher/dind:v0.5.0
2015-03-18 06:28:05 -07:00
COPY ./scripts/bootstrap /scripts/bootstrap
RUN /scripts/bootstrap
WORKDIR /source
ENV IN_DOCKER true
EOF
docker build -t rancher-os-go-build -f .dockerfile .
docker run --rm -v $(pwd):/source -it rancher-os-go-build ./scripts/build
exit 0
fi
if [[ ! -x "$(which go)" && -x /usr/local/go/bin/go ]]; then
PATH=/usr/local/go/bin:${PATH}
2015-02-08 21:38:37 -07:00
fi
2015-02-14 09:35:46 -07:00
if [ -z "$ROS_CUSTOM_GOPATH" ]; then
export GOPATH=$(pwd)/Godeps/_workspace:$(pwd)/gopath
fi
2015-02-08 21:38:37 -07:00
PACKAGE=./gopath/src/$(<.package)
if [ -L ${PACKAGE} ]; then
rm ${PACKAGE}
fi
if [ ! -e ${PACKAGE} ]; then
mkdir -p $(dirname $PACKAGE)
ln -s $(pwd) $PACKAGE
fi
echo export GOPATH=$GOPATH
mkdir -p bin
2015-03-20 11:35:21 -07:00
go build -tags netgo -ldflags "-X github.com/rancherio/os/config.VERSION ${VERSION:-v0.0.0-dev} -linkmode external -extldflags -static" -o bin/rancheros
2015-02-22 20:57:19 -07:00
strip --strip-all bin/rancheros