2014-12-06 22:59:54 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# Ceph distributed storage system
|
|
|
|
#
|
|
|
|
# Copyright (C) 2014 Red Hat <contact@redhat.com>
|
|
|
|
#
|
|
|
|
# Author: Loic Dachary <loic@dachary.org>
|
|
|
|
#
|
|
|
|
# This library is free software; you can redistribute it and/or
|
|
|
|
# modify it under the terms of the GNU Lesser General Public
|
|
|
|
# License as published by the Free Software Foundation; either
|
|
|
|
# version 2.1 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
2015-01-29 13:18:18 +00:00
|
|
|
# Return true if the working tree is after the release that made
|
2014-12-06 22:59:54 +00:00
|
|
|
# make -j8 check possible
|
|
|
|
#
|
|
|
|
function can_parallel_make_check() {
|
2015-02-05 13:37:38 +00:00
|
|
|
local commit=$(git rev-parse tags/v0.88^{})
|
|
|
|
git rev-list HEAD | grep --quiet $commit
|
2014-12-06 22:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function maybe_parallel_make_check() {
|
|
|
|
if can_parallel_make_check ; then
|
|
|
|
echo -j$(get_processors)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
#
|
|
|
|
# Return MAX(1, (number of processors / 2)) by default or NPROC
|
|
|
|
#
|
|
|
|
function get_processors() {
|
|
|
|
if test -n "$NPROC" ; then
|
|
|
|
echo $NPROC
|
|
|
|
else
|
2015-01-29 13:18:18 +00:00
|
|
|
if test $(nproc) -ge 2 ; then
|
|
|
|
expr $(nproc) / 2
|
2014-12-06 22:59:54 +00:00
|
|
|
else
|
|
|
|
echo 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2015-08-24 03:37:32 +00:00
|
|
|
DEFAULT_MAKEOPTS=${DEFAULT_MAKEOPTS:--j$(get_processors)}
|
|
|
|
BUILD_MAKEOPTS=${BUILD_MAKEOPTS:-$DEFAULT_MAKEOPTS}
|
|
|
|
if can_parallel_make_check ; then
|
|
|
|
CHECK_MAKEOPTS=${CHECK_MAKEOPTS:-$DEFAULT_MAKEOPTS}
|
|
|
|
else
|
|
|
|
CHECK_MAKEOPTS=""
|
|
|
|
fi
|
|
|
|
|
2014-12-06 22:59:54 +00:00
|
|
|
function run() {
|
2015-04-30 07:44:10 +00:00
|
|
|
# Same logic as install-deps.sh for finding package installer
|
|
|
|
local install_cmd
|
|
|
|
test -f /etc/redhat-release && install_cmd="yum install -y"
|
|
|
|
type apt-get > /dev/null 2>&1 && install_cmd="apt-get install -y"
|
|
|
|
type zypper > /dev/null 2>&1 && install_cmd="zypper --gpg-auto-import-keys --non-interactive install"
|
|
|
|
if [ -n "$install_cmd" ]; then
|
|
|
|
sudo $install_cmd ccache jq
|
|
|
|
else
|
|
|
|
echo "WARNING: Don't know how to install packages" >&2
|
|
|
|
fi
|
2014-12-06 22:59:54 +00:00
|
|
|
|
|
|
|
if test -f ./install-deps.sh ; then
|
|
|
|
$DRY_RUN ./install-deps.sh || return 1
|
|
|
|
fi
|
2016-07-05 11:41:49 +00:00
|
|
|
export TMPDIR=$(mktemp -d --tmpdir ceph.XXX)
|
2016-07-02 11:50:34 +00:00
|
|
|
if test -x ./do_cmake.sh ; then
|
2016-08-12 00:11:40 +00:00
|
|
|
$DRY_RUN ./do_cmake.sh $@ || return 1
|
2016-07-02 11:50:34 +00:00
|
|
|
cd build
|
2016-07-13 13:14:30 +00:00
|
|
|
$DRY_RUN make $BUILD_MAKEOPTS tests || return 1
|
2016-07-19 08:20:43 +00:00
|
|
|
$DRY_RUN ctest $CHECK_MAKEOPTS --output-on-failure || return 1
|
2016-07-02 11:50:34 +00:00
|
|
|
else
|
|
|
|
$DRY_RUN ./autogen.sh || return 1
|
|
|
|
$DRY_RUN ./configure "$@" --with-librocksdb-static --disable-static --with-radosgw --with-debug --without-lttng \
|
|
|
|
CC="ccache gcc" CXX="ccache g++" CFLAGS="-Wall -g" CXXFLAGS="-Wall -g" || return 1
|
|
|
|
$DRY_RUN make $BUILD_MAKEOPTS || return 1
|
|
|
|
$DRY_RUN make $CHECK_MAKEOPTS check || return 1
|
|
|
|
$DRY_RUN make dist || return 1
|
|
|
|
fi
|
2016-07-05 11:41:49 +00:00
|
|
|
rm -rf $TMPDIR
|
2014-12-06 22:59:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
2014-12-21 08:47:57 +00:00
|
|
|
if run "$@" ; then
|
2014-12-06 22:59:54 +00:00
|
|
|
echo "make check: successful run on $(git rev-parse HEAD)"
|
2016-05-20 11:19:07 +00:00
|
|
|
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
2014-12-06 22:59:54 +00:00
|
|
|
return 0
|
|
|
|
else
|
2016-05-20 11:19:07 +00:00
|
|
|
rm -fr ${CEPH_BUILD_VIRTUALENV:-/tmp}/*virtualenv*
|
2014-12-06 22:59:54 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-12-21 08:47:57 +00:00
|
|
|
main "$@"
|