...
1#!/bin/bash
2#
3# Copyright (c) SAS Institute Inc.
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16#
17
18module=github.com/sassoftware/relic
19
20set -e
21WORKDIR=$(pwd)
22export PATH=$GOROOT/bin:$PATH
23rm -rf $WORKDIR/build
24mkdir -p $WORKDIR/build
25
26if [ -n "${VENDORIZER:-}" ]
27then
28 curl -sOz ./vendorizer "$VENDORIZER/vendorizer"
29 chmod a+rx vendorizer
30 vz="$WORKDIR/vendorizer ensure -u $VENDORIZER"
31else
32 type -P dep >/dev/null || go get -v github.com/golang/dep/cmd/dep
33 vz="dep ensure -vendor-only"
34fi
35
36# Setup GOPATH
37SRCDIR=$(cd $(dirname $0) && pwd)
38export GOPATH=$WORKDIR/build/go
39version=$(cd "$SRCDIR" && git describe --tags |sed -e 's/-\([0-9]*\).*/.\1/')
40[ -n "$version" ] || { echo Unable to determine version; exit 1; }
41ldflags="-X ${module}/config.Version=$version"
42echo "Version: $version"
43echo "Go version: $(go version)"
44mkdir -p $GOPATH/src/$(dirname $module)
45ln -sfn $SRCDIR $GOPATH/src/$module
46
47echo setting up build directory
48cd $GOPATH/src/$module
49$vz
50# Block access to unvendored libs from this point on
51export GIT_ALLOW_PROTOCOL=none
52
53# Make sure version gets updated
54echo building
55touch $GOPATH/src/$module/config/config.go
56GOOS=linux go build -v -ldflags "$ldflags" -o $WORKDIR/build/relic $module
57GOOS=windows go build -v -ldflags "$ldflags" -o $WORKDIR/build/relic.exe -tags clientonly $module
58
59cd $WORKDIR/build
60rhname=relic-redhat-$version
61mkdir relic-redhat-$version
62cp -a $SRCDIR/distro/linux/* relic $rhname/
63sed -i -e "s/^Version:.*/Version: $version/" $rhname/relic.spec
64tar -czf ${rhname}.tar.gz $rhname
65
66rm -rf $rhname
View as plain text