-
Notifications
You must be signed in to change notification settings - Fork 13
/
build-release.sh
executable file
·78 lines (67 loc) · 2.18 KB
/
build-release.sh
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
69
70
71
72
73
74
75
76
77
78
#!/bin/bash
if [ -z "$1" ]
then
echo "No argument supplied, requires build version"
exit 1
fi
set -euo pipefail
distro=$1
path=`pwd`
echo "About to launch $distro container"
container="bynar-build-$RANDOM"
#function finish {
# echo "Cleaning up: ($?)!"
# docker kill ${container}
# sleep 5
# docker rm ${container}
# echo "finished cleaning up"
#}
#trap finish EXIT
echo "Named container: ${container}"
docker run --name ${container} -d -i -t -v $path:/build -w /build $distro
echo "Launched ${container}"
echo "Installing deps"
if [[ "$distro" == centos* ]]
then
docker exec ${container} yum update -y
docker exec ${container} yum install --nogpgcheck -y epel-release
echo "installing"
packages="libatasmart-devel openssl-devel librados2-devel centos-release-scl"
docker exec ${container} yum install -y $packages
docker exec ${container} yum install -y llvm-toolset-7
fi
if [[ "$distro" == ubuntu* ]]
then
docker exec ${container} apt update
echo "installing "
packages="gcc curl libblkid-dev liblvm2-dev liblvm2app2.2 libdevmapper-dev libzmq5 libatasmart-dev libssl-dev librados-dev libudev-dev libzmq3-dev make pkg-config"
docker exec ${container} apt-get install -y $packages
fi
echo "About to install rust"
docker exec ${container} curl https://sh.rustup.rs -o /root/rustup.sh
echo "chmod"
docker exec ${container} chmod +x /root/rustup.sh
echo "installing rust"
docker exec ${container} /root/rustup.sh -y
echo "Building"
if [[ "$distro" == centos* ]]
then
docker exec ${container} scl enable llvm-toolset-7 '/root/.cargo/bin/cargo build --release --all'
else
docker exec ${container} /root/.cargo/bin/cargo build --release --all
fi
echo "Packaging"
if [[ "$distro" == centos* ]]
then
docker exec ${container} rpmbuild --define "_builddir $path" -bb gluster-collector.spec
docker cp ${container}:/root/rpmbuild/RPMS/x86_64/* target/release/
ls $path/target/release/
elif [[ "$distro" == ubuntu* ]]
then
echo "Installing cargo deb"
docker exec ${container} /root/.cargo/bin/cargo install cargo-deb
docker exec ${container} /root/.cargo/bin/cargo deb
echo "cp /build/target/debian/*.deb target/release/"
docker cp ${container}:/build/target/debian .
fi
# finish