From: John Mulligan Date: Mon, 31 Oct 2022 14:54:53 +0000 (-0400) Subject: script: reorganize build scripts X-Git-Tag: v18.2.5~81^2~16 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=339e5bc62f8e964b65a8283439a845422b2c5c8e;p=ceph.git script: reorganize build scripts In preparation for running builds and tests in containers, make some organizational changes to the run-make-*.sh scripts. Original version of the patch can be found at https://github.com/ceph/ceph/pull/46071 Original-version-by: Ernesto Puerta Co-authored-by: Ernesto Puerta Co-authored-by: John Mulligan Signed-off-by: Ernesto Puerta Signed-off-by: John Mulligan (cherry picked from commit 70bf755f9e62e4bb373e5082876a37b2a89abbc9) --- diff --git a/run-make-check.sh b/run-make-check.sh index 096e3c6c8e1cd..0ebe2b5de6bdf 100755 --- a/run-make-check.sh +++ b/run-make-check.sh @@ -22,10 +22,6 @@ source src/script/run-make.sh set -e -function in_jenkins() { - test -n "$JENKINS_HOME" -} - function run() { # to prevent OSD EMFILE death on tests, make sure ulimit >= 1024 $DRY_RUN ulimit -n $(ulimit -Hn) @@ -75,43 +71,13 @@ function main() { fi # uses run-make.sh to install-deps FOR_MAKE_CHECK=1 prepare - local cxx_compiler=g++ - local c_compiler=gcc - for i in $(seq 14 -1 10); do - if type -t clang-$i > /dev/null; then - cxx_compiler="clang++-$i" - c_compiler="clang-$i" - break - fi - done - # Init defaults after deps are installed. - local cmake_opts - cmake_opts+=" -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler" - cmake_opts+=" -DCMAKE_CXX_FLAGS_DEBUG=-Werror" - cmake_opts+=" -DENABLE_GIT_VERSION=OFF" - cmake_opts+=" -DWITH_GTEST_PARALLEL=ON" - cmake_opts+=" -DWITH_FIO=ON" - cmake_opts+=" -DWITH_CEPHFS_SHELL=ON" - cmake_opts+=" -DWITH_GRAFANA=ON" - cmake_opts+=" -DWITH_SPDK=ON" - cmake_opts+=" -DWITH_RBD_MIRROR=ON" - if [ $WITH_SEASTAR ]; then - cmake_opts+=" -DWITH_SEASTAR=ON" - fi - if [ $WITH_ZBD ]; then - cmake_opts+=" -DWITH_ZBD=ON" - fi - if [ $WITH_RBD_RWL ]; then - cmake_opts+=" -DWITH_RBD_RWL=ON" - fi - cmake_opts+=" -DWITH_RBD_SSD_CACHE=ON" - in_jenkins && echo "CI_DEBUG: Our cmake_opts are: $cmake_opts - CI_DEBUG: Running ./configure" - configure "$cmake_opts" "$@" + configure "$@" in_jenkins && echo "CI_DEBUG: Running 'build tests'" build tests echo "make check: successful build on $(git rev-parse HEAD)" FOR_MAKE_CHECK=1 run } -main "$@" +if [ "$0" = "$BASH_SOURCE" ]; then + main "$@" +fi diff --git a/src/script/run-make.sh b/src/script/run-make.sh index 683272666a9d9..c746cf752b7e8 100755 --- a/src/script/run-make.sh +++ b/src/script/run-make.sh @@ -67,7 +67,11 @@ function do_install() { pkgs=$@ shift ret=0 - $DRY_RUN sudo $install_cmd $pkgs || ret=$? + SUDO="" + if [ "$EUID" -ne 0 ]; then + SUDO="sudo" + fi + $DRY_RUN $SUDO $install_cmd $pkgs || ret=$? if test $ret -eq 0 ; then return fi @@ -75,9 +79,9 @@ function do_install() { if [[ $install_cmd == *"apt-get"* ]]; then if test $ret -eq 100 ; then # dpkg was interrupted - $DRY_RUN sudo dpkg --configure -a - in_jenkins && echo "CI_DEBUG: Running 'sudo $install_cmd $pkgs'" - $DRY_RUN sudo $install_cmd $pkgs + $DRY_RUN $SUDO dpkg --configure -a + in_jenkins && echo "CI_DEBUG: Running '$SUDO $install_cmd $pkgs'" + $DRY_RUN $SUDO $install_cmd $pkgs else return $ret fi @@ -88,11 +92,7 @@ function prepare() { local which_pkg="which" source /etc/os-release if test -f /etc/redhat-release ; then - if ! type bc > /dev/null 2>&1 ; then - echo "Please install bc and re-run." - exit 1 - fi - if test "$(echo "$VERSION_ID >= 22" | bc)" -ne 0; then + if [ "$VERSION_ID" -ge "22" ]; then install_cmd="dnf -y install" else install_cmd="yum install -y" @@ -104,14 +104,14 @@ function prepare() { which_pkg="debianutils" fi - if ! type sudo > /dev/null 2>&1 ; then + if [ "$EUID" -ne 0 ] && ! type sudo > /dev/null 2>&1 ; then echo "Please install sudo and re-run. This script assumes it is running" - echo "as a normal user with the ability to run commands as root via sudo." + echo "as a normal user with the ability to run commands as root via sudo." exit 1 fi if [ -n "$install_cmd" ]; then in_jenkins && echo "CI_DEBUG: Running '$install_cmd ccache $which_pkg clang'" - do_install "$install_cmd" ccache $which_pkg clang + do_install "$install_cmd" ccache git $which_pkg clang else echo "WARNING: Don't know how to install packages" >&2 echo "This probably means distribution $ID is not supported by run-make-check.sh" >&2 @@ -127,7 +127,9 @@ function prepare() { $DRY_RUN source ./install-deps.sh || return 1 trap clean_up_after_myself EXIT fi +} +function configure() { cat < /dev/null; then + cxx_compiler="clang++-$i" + c_compiler="clang-$i" + break + fi + done + local cmake_opts + cmake_opts+=" -DCMAKE_CXX_COMPILER=$cxx_compiler -DCMAKE_C_COMPILER=$c_compiler" + cmake_opts+=" -DCMAKE_CXX_FLAGS_DEBUG=-Werror" + cmake_opts+=" -DENABLE_GIT_VERSION=OFF" + cmake_opts+=" -DWITH_GTEST_PARALLEL=ON" + cmake_opts+=" -DWITH_FIO=ON" + cmake_opts+=" -DWITH_CEPHFS_SHELL=ON" + cmake_opts+=" -DWITH_GRAFANA=ON" + cmake_opts+=" -DWITH_SPDK=ON" + cmake_opts+=" -DWITH_RBD_MIRROR=ON" + if [ $WITH_SEASTAR ]; then + cmake_opts+=" -DWITH_SEASTAR=ON" + fi + if [ $WITH_ZBD ]; then + cmake_opts+=" -DWITH_ZBD=ON" + fi + if [ $WITH_RBD_RWL ]; then + cmake_opts+=" -DWITH_RBD_RWL=ON" + fi + cmake_opts+=" -DWITH_RBD_SSD_CACHE=ON" + + cmake_opts+=$(detect_ceph_dev_pkgs) + + in_jenkins && echo "CI_DEBUG: Our cmake_opts are: $cmake_opts + CI_DEBUG: Running ./configure" in_jenkins && echo "CI_DEBUG: Running do_cmake.sh" - $DRY_RUN ./do_cmake.sh $cmake_build_opts $@ || return 1 + + $DRY_RUN ./do_cmake.sh $cmake_opts $@ || return 1 } function build() {