Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

install-deps.sh: use DTS on centos if GCC is too old #19398

Merged
merged 3 commits into from Dec 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions ceph.spec.in
Expand Up @@ -126,7 +126,11 @@ BuildRequires: fuse-devel
BuildRequires: devtoolset-7-gcc-c++
%endif
%ifarch aarch64
%if 0%{?centos}
BuildRequires: devtoolset-6-gcc-c++
%else
BuildRequires: devtoolset-7-gcc-c++
%endif
%endif
%else
BuildRequires: gcc-c++
Expand Down Expand Up @@ -798,7 +802,11 @@ python-rbd, python-rgw or python-cephfs instead.
. /opt/rh/devtoolset-7/enable
%endif
%ifarch aarch64
%if 0%{?centos}
. /opt/rh/devtoolset-6/enable
%else
. /opt/rh/devtoolset-7/enable
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktdreyer this reflects the different support of DTS from RHEL and CentOS.

%endif
%endif
%endif

Expand Down
60 changes: 54 additions & 6 deletions install-deps.sh
Expand Up @@ -26,11 +26,11 @@ function munge_ceph_spec_in {
sed -e 's/@//g' -e 's/%bcond_with make_check/%bcond_without make_check/g' < ceph.spec.in > $OUTFILE
}

function ensure_decent_gcc {
function ensure_decent_gcc_on_deb {
# point gcc to the one offered by g++-7 if the used one is not
# new enough
old=$(gcc -dumpversion)
new=$1
local old=$(gcc -dumpversion)
local new=$1
if dpkg --compare-versions $old ge 5.1; then
return
fi
Expand All @@ -50,6 +50,38 @@ function ensure_decent_gcc {
$SUDO ln -nsf /usr/bin/g++ /usr/bin/x86_64-linux-gnu-g++
}

function version_lt {
test $1 != $(echo -e "$1\n$2" | sort -rV | head -n 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

}

function ensure_decent_gcc_on_rh {
local old=$(gcc -dumpversion)
local expected=5.1
local dts_ver=$1
if version_lt $old $expected; then
case $- in
*i*)
# interactive shell
cat <<EOF
Your GCC is too old. Please run following command to add DTS to your environment:

scl enable devtoolset-7 bash

Or add following line to the end of ~/.bashrc to add it permanently:

source scl_source enable devtoolset-7

see https://www.softwarecollections.org/en/scls/rhscl/devtoolset-7/ for more details.
EOF
;;
*)
# non-interactive shell
source /opt/rh/devtoolset-$dts_ver/enable
;;
esac
fi
}

if [ x`uname`x = xFreeBSDx ]; then
$SUDO pkg install -yq \
devel/babeltrace \
Expand Down Expand Up @@ -111,7 +143,7 @@ else
$SUDO add-apt-repository ppa:ubuntu-toolchain-r/test
$SUDO apt-get update
$SUDO apt-get install -y gcc-7
ensure_decent_gcc 7
ensure_decent_gcc_on_deb 7
;;
*)
$SUDO apt-get install -y gcc
Expand Down Expand Up @@ -148,6 +180,12 @@ else
builddepcmd="dnf -y builddep --allowerasing"
fi
echo "Using $yumdnf to install dependencies"
if [ $(lsb_release -si) = CentOS -a $(uname -m) = aarch64 ]; then
$SUDO yum-config-manager --disable centos-sclo-sclo || true
$SUDO yum-config-manager --disable centos-sclo-rh || true
$SUDO yum remove centos-release-scl || true
fi

$SUDO $yumdnf install -y redhat-lsb-core
case $(lsb_release -si) in
Fedora)
Expand All @@ -169,19 +207,29 @@ else
$SUDO yum-config-manager --enable cr
case $(uname -m) in
x86_64)
$SUDO yum install centos-release-scl;;
$SUDO yum -y install centos-release-scl
dts_ver=7
;;
aarch64)
$SUDO yum install centos-release-scl-rh;;
$SUDO yum -y install centos-release-scl-rh
$SUDO yum-config-manager --disable centos-sclo-rh
$SUDO yum-config-manager --enable centos-sclo-rh-testing
dts_ver=6
;;
esac
elif test $(lsb_release -si) = RedHatEnterpriseServer -a $MAJOR_VERSION = 7 ; then
$SUDO yum-config-manager --enable rhel-server-rhscl-7-rpms
dts_ver=7
elif test $(lsb_release -si) = VirtuozzoLinux -a $MAJOR_VERSION = 7 ; then
$SUDO yum-config-manager --enable cr
fi
;;
esac
munge_ceph_spec_in $DIR/ceph.spec
$SUDO $builddepcmd $DIR/ceph.spec 2>&1 | tee $DIR/yum-builddep.out
if [ -n dts_ver ]; then
ensure_decent_gcc_on_rh $dts_ver
fi
! grep -q -i error: $DIR/yum-builddep.out || exit 1
;;
opensuse|suse|sles)
Expand Down
2 changes: 1 addition & 1 deletion run-make-check.sh
Expand Up @@ -60,7 +60,7 @@ function run() {
fi

if test -f ./install-deps.sh ; then
$DRY_RUN ./install-deps.sh || return 1
$DRY_RUN source ./install-deps.sh || return 1
fi

# Init defaults after deps are installed. get_processors() depends on coreutils nproc.
Expand Down