summaryrefslogtreecommitdiffstats
path: root/src/fuel-plugin/pre_build_hook
blob: d264d0bfdd9f5a12dd536682995ae939f5ce3939 (plain)
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
#!/bin/bash

# Add here any the actions which are required before plugin build
# like packages building, packages downloading from mirrors and so on.
# The script should return 0 if there were no errors.
#!/bin/bash

set -eux

BUILD_FOR=${BUILD_FOR:-ubuntu}
DIR="$(dirname `readlink -f $0`)"

function build_pkg {
  case $1 in
    ubuntu)
      sudo rm -rf ${DIR}/build; mkdir -p ${DIR}/build

      cd ${DIR}/build
      git clone https://github.com/openstack/collectd-ceilometer-plugin
      cd  collectd-ceilometer-plugin
      git checkout 73372f2eb86c81f12bc10b392f75050a401107db

      # build collectd
      cd ${DIR}
      sudo docker build -t collectd_build .
      sudo docker run -v ${DIR}:/fuel-plugin -t collectd_build /fuel-plugin/build-collectd.sh

      rm -rf ${DIR}/repositories/ubuntu; mkdir -p ${DIR}/repositories/ubuntu
      cd ${DIR}/build
      mv *.deb ${DIR}/repositories/ubuntu
      tar cfvz ${DIR}/repositories/ubuntu/collectd-ceilometer.tgz .
      cd ..; sudo rm -rf ${DIR}/build
      ;;
    *) echo "Not supported system"; exit 1;;
  esac
}

for system in $BUILD_FOR
do
  build_pkg $system
done