Skip to content

Commit

Permalink
MINIFICPP-2423 Fix RHEL8 bootstrap issues
Browse files Browse the repository at this point in the history
Also: fix cmake version check

Signed-off-by: Ferenc Gerlits <[email protected]>
This closes #1834
  • Loading branch information
szaszm authored and fgerlits committed Jul 11, 2024
1 parent f70a44a commit 1759c41
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 16 deletions.
20 changes: 13 additions & 7 deletions bootstrap.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -511,3 +515,5 @@ fi


popd || exit 2

# vim: shiftwidth=2 tabstop=2 expandtab
22 changes: 21 additions & 1 deletion bstrp_functions.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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
20 changes: 12 additions & 8 deletions rheldistro.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,25 @@ 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++
}
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}"
Expand All @@ -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
Expand Down

0 comments on commit 1759c41

Please sign in to comment.