build.sh 3.68 KB
Newer Older
1
2
#!/usr/bin/env bash

3
4
5
6
7
8
9
10
11
# Copyright (c) 2020, Irish Centre for High End Computing (ICHEC), NUI Galway
# Authors:
#    Pádraig Ó Conbhuí <padraig.oconbhui@ichec.ie>,
#    Sophie Wenzel-Teuber <sophie.wenzel-teuber@ichec.ie>,
#    Ciarán O'Rourke <ciaran.orourke@ichec.ie>
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.

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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# Exit on any errors
set -o errexit

script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
external_dir="${script_dir}/../../external"

source "${script_dir}/../build-common.sh"


#
# Install dependencies
#
print_section "Installing system dependencies"

if should_build system_packages
then
    # Regular packages
    yum install -y \
        make \
        autoconf automake libtool \
        glib2-devel \
        jansson-devel \
        libattr-devel \
        libini_config-devel \
        openssl-devel \
        protobuf-c-devel \
        python-devel \
        sg3_utils-devel \
        which \
        python-psycopg2 \
        PyYAML


    # EPEL Packages
    yum install -y \
        epel-release

    yum install -y \
        clustershell


    # SCL packages for postgresql
    # Centos-7 provides 9.2 by default
    # Phobos needs 9.4 for jsonb
    yum install -y \
        rh-postgresql95-postgresql-devel \
        rh-postgresql95-postgresql-libs \
        rh-postgresql95-postgresql-server \
        rh-postgresql95-postgresql-contrib

fi


# Enable rh-postgresql
# Temporarily disable printing and error checking
set_bash_verbosity false
set +o errexit
source scl_source enable rh-postgresql95
set -o errexit
set_bash_verbosity


#
# Set build flags
#
export LIBPQ_CFLAGS=$(pg_config --cflags)
export LIBPQ_LIBS=-lpq


#
# Build Phobos
#
print_section "Build phobos"

phobos_source_dir=${external_dir}/phobos
phobos_build_dir=${build_dir}/phobos
phobos_install_dir=$(install_dir phobos)

echo phobos_install_dir: ${phobos_install_dir}

if should_build phobos
then
    mkdir -p "${phobos_build_dir}"
    pushd "${phobos_build_dir}"

    mkdir -p source/
    cp -u -r "${phobos_source_dir}"/* source

    pushd source/

    #
    # Configure phobos
    #

    ./autogen.sh
    ./configure \
        --prefix="${phobos_install_dir}" \
        ${CONFIGURE_FLAGS[@]} \
        LDFLAGS="${LDFLAGS} -ldl"

    #
    # Make phobos
    #
Sophie Wenzel-Teuber's avatar
Sophie Wenzel-Teuber committed
115
    make ${MAKE_FLAGS[@]} -j 1
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132

    #
    # Some pre-test installation
    #
    cp src/tests/phobos.conf /etc/
    sed -i '/lrs/ a default_family = dir' /etc/phobos.conf


    #
    # Test phobos
    #
    if should_run_stage phobos:test phobos:run:test
    then
        # Patch test scripts
        sed -i 's/\$PHO_LAYOUTLIB_PATH/$PHO_LAYOUTLIB_PATH:$LD_LIBRARY_PATH/' src/cli/tests/run_tests.sh
        sed -i 's/\$PHO_PYTHON_PATH/$PHO_PYTHON_PATH:$PYTHONPATH/' src/cli/tests/run_tests.sh

Sophie Wenzel-Teuber's avatar
Sophie Wenzel-Teuber committed
133
134
        source "${script_dir}"/testdb-setup.sh

135
136
        # Setup test db dir
        phobos_test_dir="${build_dir}"/phobos/test
Sophie Wenzel-Teuber's avatar
Sophie Wenzel-Teuber committed
137
        create_database ${phobos_test_dir}
138

Sophie Wenzel-Teuber's avatar
Sophie Wenzel-Teuber committed
139
        setup_phobos_db ./scripts
140
141
142
143
144
145
146
147

        # Run tests
        # TODO: enable errexit
        set +o errexit
        make check
        set -o errexit

        # Shutdown postgres
Sophie Wenzel-Teuber's avatar
Sophie Wenzel-Teuber committed
148
        stop_postgres
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
    fi


    #
    # Install phobos
    #

    make install

    pushd src/cli
    python setup.py install \
        --prefix="${phobos_install_dir}" \
        --install-lib="${phobos_install_dir}"/lib/python2.7/site-packages
    popd # src/cli


    popd # source/

    popd # phobos_build_dir
fi

export PYTHONPATH="${phobos_install_dir}"/lib/python2.7/site-packages:"${PYTHONPATH}"
export LD_LIBRARY_PATH="${phobos_install_dir}"/lib:"${LD_LIBRARY_PATH}"
export PATH="${phobos_install_dir}"/bin:"${phobos_install_dir}"/sbin:${PATH}