Skip to content

Commit 460b15d

Browse files
author
Shlomi Noach
committed
rpm and deb
1 parent d20903e commit 460b15d

File tree

1 file changed

+38
-17
lines changed

1 file changed

+38
-17
lines changed

build.sh

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,50 @@
33
#
44

55
RELEASE_VERSION=
6+
buildpath=
7+
builddir=
8+
9+
function setuptree() {
10+
mkdir -p $buildpath
11+
rm -rf ${buildpath:?}/*
12+
b=$( mktemp -d $buildpath/gh-ostXXXXXX ) || return 1
13+
mkdir -p $b/gh-ost
14+
mkdir -p $b/gh-ost/usr/bin
15+
echo $b
16+
}
617

718
function build {
8-
osname=$1
9-
osshort=$2
10-
GOOS=$3
11-
GOARCH=$4
19+
osname=$1
20+
osshort=$2
21+
GOOS=$3
22+
GOARCH=$4
1223

13-
if ! go version | egrep -q 'go(1[.]9|1[.]1[0-9])' ; then
14-
echo "go version is too low. Must use 1.9 or above"
15-
exit 1
16-
fi
24+
builddir=$(setuptree)
25+
26+
27+
if ! go version | egrep -q 'go(1[.]9|1[.]1[0-9])' ; then
28+
echo "go version is too low. Must use 1.9 or above"
29+
exit 1
30+
fi
1731

18-
echo "Building ${osname} binary"
19-
export GOOS
20-
export GOARCH
21-
go build -ldflags "$ldflags" -o $buildpath/$target go/cmd/gh-ost/main.go
32+
echo "Building ${osname} binary"
33+
export GOOS
34+
export GOARCH
35+
go build -ldflags "$ldflags" -o $buildpath/$target go/cmd/gh-ost/main.go
2236

23-
if [ $? -ne 0 ]; then
24-
echo "Build failed for ${osname}"
25-
exit 1
26-
fi
37+
if [ $? -ne 0 ]; then
38+
echo "Build failed for ${osname}"
39+
exit 1
40+
fi
2741

28-
(cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target)
42+
(cd $buildpath && tar cfz ./gh-ost-binary-${osshort}-${timestamp}.tar.gz $target)
43+
44+
if [ "$GOOS" == "linux" ] ; then
45+
echo "Creating Distro full packages"
46+
cp $buildpath/$target $builddir/gh-ost/usr/bin
47+
fpm -v "${RELEASE_VERSION}" --epoch 1 -f -s dir -n gh-ost -m shlomi-noach --description "GitHub's Online Schema Migrations for MySQL " --url "https://github.com/github/gh-ost" --vendor "GitHub" --license "Apache 2.0" -C $builddir/gh-ost --prefix=/ -t rpm .
48+
fpm -v "${RELEASE_VERSION}" --epoch 1 -f -s dir -n gh-ost -m shlomi-noach --description "GitHub's Online Schema Migrations for MySQL " --url "https://github.com/github/gh-ost" --vendor "GitHub" --license "Apache 2.0" -C $builddir/gh-ost --prefix=/ -t deb --deb-no-default-config-files .
49+
fi
2950
}
3051

3152
main() {

0 commit comments

Comments
 (0)