summaryrefslogtreecommitdiffstats
path: root/ci/ceph_build.sh
blob: 1e16b2c9ad53b90516a3f7fac3b489572d2cf4a7 (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
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
#!/bin/bash

workspace=/root
build_dir=$workspace/stor4nfv
ceph_src_dir=$build_dir/src/ceph

function show_stage {
    echo
    echo $1
    echo
}

function ceph_build_validate {
    show_stage "validate"
    if [[ -z "$@" ]]; then
        echo "usage: ${0} output_dir pkgtype"
	exit 1
    fi
    output_dir="$1"
    pkgtype="$2"
    if [ ! -d ${output_dir} -o ! -w ${output_dir} ] ; then
        echo "${0}: Output directory '${output_dir}' does not exist or cannot be written"
        exit 1
    fi
    if [ ! -d ${ceph_src_dir} ] ; then
        echo "${0}: Directory '${ceph_src_dir}' does not exist, run this script from the root of stor4nfv source tree"
        exit 1
    fi
    echo
    echo "Build"
    echo
}

# Build ceph
show_stage "compile"
# TODO: use code inside stor4nfv
cd $workspace
git clone https://github.com/ceph/ceph.git
cd ceph
git reset --hard v12.2.2
git submodule update --init --recursive
./install-deps.sh
./do_cmake.sh
cd build
make

ceph_rpm_build() {
    show_stage "ceph rpm build"
}

ceph_deb_build() {
    cd $workspace/ceph
    dpkg-buildpackage
    if [ ${?} -ne 0 ] ; then
        echo "${0}: ceph build failed"
        exit 1
    fi
}

if [ $pkgtype == "centos" ];then
   ceph_rpm_build
elif [ $pkgtype == "ubuntu" ];then
   ceph_deb_build
   latest_ceph_build=`ls -rt $workspace | tail -1`
   cp $workspace/$latest_ceph_build $build_dir/build_output
fi