Add collectd build & installation
[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       rm -rf ${DIR}/repositories/ubuntu; mkdir -p ${DIR}/repositories/ubuntu
17      
18       rm -rf ${DIR}/build; mkdir -p ${DIR}/build; cd ${DIR}/build;
19   
20       git clone https://github.com/openstack/collectd-ceilometer-plugin
21       cd  collectd-ceilometer-plugin
22       git checkout 3a4a1087566d1f9e8dd2d8d2e0608cb975942446
23       cat << EOF > collectd_ceilometer/__init__.py
24 """Collectd Ceilometer plugin implementation"""
25 EOF
26       tar cfvz ${DIR}/repositories/ubuntu/collectd-ceilometer.tgz . --exclude=collectd-ceilometer.tgz
27
28       cd ${DIR}/build; ../build-collectd.sh
29       cp *.deb ${DIR}/repositories/ubuntu
30
31       rm -rf ${DIR}/build
32       ;;
33     *) echo "Not supported system"; exit 1;;
34   esac
35 }
36
37 for system in $BUILD_FOR
38 do
39   build_pkg $system
40 done