build package
[stor4nfv.git] / ci / ceph_build.sh
1 #!/bin/bash
2
3 workspace=/root
4 build_dir=$workspace/stor4nfv
5 ceph_src_dir=$build_dir/src/ceph
6
7 function show_stage {
8     echo
9     echo $1
10     echo
11 }
12
13 function ceph_build_validate {
14     show_stage "validate"
15     if [[ -z "$@" ]]; then
16         echo "usage: ${0} output_dir pkgtype"
17         exit 1
18     fi
19     output_dir="$1"
20     pkgtype="$2"
21     if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
22         echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
23         exit 1
24     fi
25     if [ ! -d ${ceph_src_dir} ] ; then
26         echo "${0}: Directory '${ceph_src_dir}' does not exist, run this script from the root of stor4nfv source tree"
27         exit 1
28     fi
29     echo
30     echo "Build"
31     echo
32 }
33
34 # Build ceph
35 show_stage "compile"
36 # TODO: use code inside stor4nfv
37 cd $workspace
38 git clone https://github.com/ceph/ceph.git
39 cd ceph
40 git reset --hard v12.2.2
41 git submodule update --init --recursive
42 ./install-deps.sh
43 ./do_cmake.sh
44 cd build
45 make
46
47 ceph_rpm_build() {
48     show_stage "ceph rpm build"
49 }
50
51 ceph_deb_build() {
52     cd $workspace/ceph
53     dpkg-buildpackage
54     if [ ${?} -ne 0 ] ; then
55         echo "${0}: ceph build failed"
56         exit 1
57     fi
58 }
59
60 if [ $pkgtype == "centos" ];then
61    ceph_rpm_build
62 elif [ $pkgtype == "ubuntu" ];then
63    ceph_deb_build
64    latest_ceph_build=`ls -rt $workspace | tail -1`
65    cp $workspace/$latest_ceph_build $build_dir/build_output
66 fi