mirror of
https://github.com/ceph/ceph
synced 2024-12-16 08:26:25 +00:00
e71e8654ee
Believe it or not, it's possible (although not necessarily likely) to have both yum and zypper installed on openSUSE. In this case the previous implementation using `which` would return a string containing both commands, which doesn't work. Signed-off-by: Tim Serong <tserong@suse.com>
83 lines
2.3 KiB
Bash
Executable File
83 lines
2.3 KiB
Bash
Executable File
#!/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.
|
|
#
|
|
|
|
#
|
|
# Return true if the working tree is after the release that made
|
|
# make -j8 check possible
|
|
#
|
|
function can_parallel_make_check() {
|
|
local commit=$(git rev-parse tags/v0.88^{})
|
|
git rev-list HEAD | grep --quiet $commit
|
|
}
|
|
|
|
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
|
|
if test $(nproc) -ge 2 ; then
|
|
expr $(nproc) / 2
|
|
else
|
|
echo 1
|
|
fi
|
|
fi
|
|
}
|
|
|
|
function run() {
|
|
# 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
|
|
sudo /sbin/modprobe rbd
|
|
|
|
if test -f ./install-deps.sh ; then
|
|
$DRY_RUN ./install-deps.sh || return 1
|
|
fi
|
|
$DRY_RUN ./autogen.sh || return 1
|
|
$DRY_RUN ./configure "$@" --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 -j$(get_processors) || return 1
|
|
$DRY_RUN make $(maybe_parallel_make_check) check || return 1
|
|
$DRY_RUN make dist || return 1
|
|
}
|
|
|
|
function main() {
|
|
if run "$@" ; then
|
|
echo "make check: successful run on $(git rev-parse HEAD)"
|
|
return 0
|
|
else
|
|
find . -name '*.trs' | xargs grep -l FAIL | while read file ; do
|
|
log=$(dirname $file)/$(basename $file .trs).log
|
|
echo FAIL: $log
|
|
cat $log
|
|
done
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
main "$@"
|