diff --git a/bootstrap.sh b/bootstrap.sh index d45b0c924b..b2df109da2 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -232,9 +232,7 @@ if [ -n "${CMAKE_COMMAND}" ]; then fi if [ -z "${CMAKE_COMMAND}" ] || - [ "$CMAKE_MAJOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" ] || - [ "$CMAKE_MINOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MINOR" ] || - [ "$CMAKE_REVISION" -lt "$CMAKE_GLOBAL_MIN_VERSION_REVISION" ]; then + version_is_less_than "$CMAKE_MAJOR" "$CMAKE_MINOR" "$CMAKE_REVISION" "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" "$CMAKE_GLOBAL_MIN_VERSION_MINOR" "$CMAKE_GLOBAL_MIN_VERSION_REVISION"; then echo "CMake is not installed or too old, attempting to install it..." bootstrap_cmake if [ -x "$(command -v cmake3)" ]; then @@ -246,9 +244,15 @@ if [ -z "${CMAKE_COMMAND}" ] || get_cmake_version fi -if [ "$CMAKE_MAJOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" ] || - [ "$CMAKE_MINOR" -lt "$CMAKE_GLOBAL_MIN_VERSION_MINOR" ] || - [ "$CMAKE_REVISION" -lt "$CMAKE_GLOBAL_MIN_VERSION_REVISION" ]; then +# RHEL8: If cmake3 is too old, try cmake +if [ "$CMAKE_COMMAND" = "cmake3" ] && + version_is_less_than "$CMAKE_MAJOR" "$CMAKE_MINOR" "$CMAKE_REVISION" "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" "$CMAKE_GLOBAL_MIN_VERSION_MINOR" "$CMAKE_GLOBAL_MIN_VERSION_REVISION" && + [ -x "$(command -v cmake)" ]; then + CMAKE_COMMAND="cmake" + get_cmake_version +fi + +if version_is_less_than "$CMAKE_MAJOR" "$CMAKE_MINOR" "$CMAKE_REVISION" "$CMAKE_GLOBAL_MIN_VERSION_MAJOR" "$CMAKE_GLOBAL_MIN_VERSION_MINOR" "$CMAKE_GLOBAL_MIN_VERSION_REVISION"; then echo "Failed to install or update CMake, exiting..." exit fi @@ -511,3 +515,5 @@ fi popd || exit 2 + +# vim: shiftwidth=2 tabstop=2 expandtab diff --git a/bstrp_functions.sh b/bstrp_functions.sh index b51d9b6dfb..08a20eb7dd 100755 --- a/bstrp_functions.sh +++ b/bstrp_functions.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -26,6 +26,24 @@ get_cmake_version(){ CMAKE_REVISION=$(echo "$CMAKE_VERSION" | cut -d. -f3) } +# Checks if a version is smaller than another +version_is_less_than() { + # Parameters: + local lhs_major=$1 + local lhs_minor=$2 + local lhs_patch=$3 + local rhs_major=$4 + local rhs_minor=$5 + local rhs_patch=$6 + # Return: true (0) if left hand side (lhs) is smaller than right hand side (rhs), otherwise return false + if [ "$lhs_major" -lt "$rhs_major" ]; then return 0; fi + if [ "$lhs_minor" -lt "$rhs_minor" ]; then return 0; fi + if [ "$lhs_patch" -lt "$rhs_patch" ]; then return 0; fi + + # otherwise return + false +} + add_cmake_option(){ eval "$1=$2" } @@ -449,3 +467,5 @@ read_feature_options(){ *) echo -e "${RED}Please enter an option A-Z or AA-AF or 1-7...${NO_COLOR}" && sleep 2 esac } + +# vim: shiftwidth=2 tabstop=2 expandtab diff --git a/rheldistro.sh b/rheldistro.sh index 8c70d33a12..9ba794880d 100644 --- a/rheldistro.sh +++ b/rheldistro.sh @@ -60,10 +60,14 @@ install_bison() { } bootstrap_cmake(){ - sudo yum -y install wget patch - wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - sudo yum -y install epel-release-latest-7.noarch.rpm - sudo yum -y install cmake3 + if [ "$OS_MAJOR" -lt 8 ]; then + sudo yum -y install wget patch + wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm + sudo yum -y install epel-release-latest-7.noarch.rpm + sudo yum -y install cmake3 + else + sudo dnf -y install cmake + fi } bootstrap_compiler() { sudo yum -y install gcc gcc-c++ @@ -71,10 +75,10 @@ bootstrap_compiler() { build_deps(){ # Install epel-release so that cmake3 will be available for installation sudo yum -y install wget - wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm - sudo yum -y install epel-release-latest-7.noarch.rpm + wget "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${OS_MAJOR}.noarch.rpm" + sudo yum -y install "epel-release-latest-${OS_MAJOR}.noarch.rpm" - COMMAND="sudo yum install cmake3 libuuid libuuid-devel perl bzip2-devel" + COMMAND="sudo yum install libuuid libuuid-devel perl bzip2-devel" INSTALLED=() for option in "${OPTIONS[@]}" ; do option_value="${!option}" @@ -99,7 +103,7 @@ build_deps(){ elif [ "$FOUND_VALUE" = "libtool" ]; then INSTALLED+=("libtool") elif [ "$FOUND_VALUE" = "python" ]; then - INSTALLED+=("python34-devel") + INSTALLED+=("python3-devel") elif [ "$FOUND_VALUE" = "gpsd" ]; then INSTALLED+=("gpsd-devel") elif [ "$FOUND_VALUE" = "libarchive" ]; then