d264d0bfdd9f5a12dd536682995ae939f5ce3939
[barometer.git] / src / fuel-plugin / pre_build_hook
1 #!/bin/bash
2
3 # Add here any the actions which are required before plugin build
4 # like packages building, packages downloading from mirrors and so on.
5 # The script should return 0 if there were no errors.
6 #!/bin/bash
7
8 set -eux
9
10 BUILD_FOR=${BUILD_FOR:-ubuntu}
11 DIR="$(dirname `readlink -f $0`)"
12
13 function build_pkg {
14   case $1 in
15     ubuntu)
16       sudo rm -rf ${DIR}/build; mkdir -p ${DIR}/build
17
18       cd ${DIR}/build
19       git clone https://github.com/openstack/collectd-ceilometer-plugin
20       cd  collectd-ceilometer-plugin
21       git checkout 73372f2eb86c81f12bc10b392f75050a401107db
22
23       # build collectd
24       cd ${DIR}
25       sudo docker build -t collectd_build .
26       sudo docker run -v ${DIR}:/fuel-plugin -t collectd_build /fuel-plugin/build-collectd.sh
27
28       rm -rf ${DIR}/repositories/ubuntu; mkdir -p ${DIR}/repositories/ubuntu
29       cd ${DIR}/build
30       mv *.deb ${DIR}/repositories/ubuntu
31       tar cfvz ${DIR}/repositories/ubuntu/collectd-ceilometer.tgz .
32       cd ..; sudo rm -rf ${DIR}/build
33       ;;
34     *) echo "Not supported system"; exit 1;;
35   esac
36 }
37
38 for system in $BUILD_FOR
39 do
40   build_pkg $system
41 done