Skip to content

Commit 0982785

Browse files
authored
FOGL-7139 Create CentOS Streams 9 build environment (#69)
* Commented code of rh-postgresql and devtool for scl_source, it does not work in centos stream 9 Signed-off-by: Mohit Tomar <[email protected]> * Added code for using scl_source and Install Redhat packages for postgres and newer g++ only if OS is RedHat/CentOS 7 Signed-off-by: Mohit Tomar <[email protected]> * Refactored code Signed-off-by: Mohit Tomar <[email protected]> Signed-off-by: Mohit Tomar <[email protected]>
1 parent a5e5650 commit 0982785

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

make_rpm

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121

2222
set -e
2323

24-
PKG_ROOT=`pwd` # The script must be executed from the root git directory
24+
PKG_ROOT=$(pwd) # The script must be executed from the root git directory
2525
repo_name="fledge" # Name of the Git repository
2626
branch="main" # Default Git branch to use
2727
pkg_name="fledge" # Name of the package to build
2828
architecture="x86_64" # The architecture for which the rpm should be created
29-
rhpg_pkg="rh-postgresql13" # Name of the Red Hat package for postgres
30-
rhgcc_pkg="devtoolset-7" # Name of the Red Hat package for the newer g++
3129
skip_build=0 # 1=skip Git repo extraction and Fledge build
3230

31+
# Check OS Name and OS Version
32+
os_name=$(grep -o '^NAME=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')
33+
os_version=$(grep -o '^VERSION_ID=.*' /etc/os-release | cut -f2 -d\" | sed 's/"//g')
34+
3335
usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b <branch>]
3436
This script is used to create the RPM package of Fledge
3537
@@ -121,27 +123,31 @@ if [[ $skip_build == 0 ]]; then
121123

122124
cd ${FLEDGE_ROOT}
123125
sudo ./requirements.sh
126+
# Use Red Hat packages and scl_source for postgres and newer g++ only if OS is RedHat/CentOS 7
127+
if [[ ( $os_name == *"Red Hat"* || $os_name == *"CentOS"* ) && $os_version == *"7"* ]]
128+
then
129+
rhpg_pkg="rh-postgresql13" # Name of the Red Hat package for postgres
130+
rhgcc_pkg="devtoolset-7" # Name of the Red Hat package for the newer g++
131+
132+
# Enables/verifies the environment for the build
133+
source scl_source enable ${rhpg_pkg}
134+
status_rh_postgresql=$?
135+
if [[ $status_rh_postgresql != 0 ]]; then
136+
echo "ERROR : it is not possible to enable the ${rhpg_pkg} environment"
137+
exit 1
138+
fi
124139

125-
# Enables/verifies the environment for the build
126-
source scl_source enable ${rhpg_pkg}
127-
status_rh_postgresql=$?
128-
129-
source scl_source enable ${rhgcc_pkg}
130-
status_devtoolset=$?
140+
source scl_source enable ${rhgcc_pkg}
141+
status_devtoolset=$?
142+
if [[ $status_devtoolset != 0 ]]; then
143+
echo "ERROR : it is not possible to enable the ${rhgcc_pkg} environment"
144+
exit 1
145+
fi
146+
fi
131147

132148
command -v pg_isready > /dev/null
133149
status_pg_isready=$?
134150

135-
if [[ $status_rh_postgresql != 0 ]]; then
136-
echo "ERROR : it is not possible to enable the ${rhpg_pkg} environment"
137-
exit 1
138-
fi
139-
140-
if [[ $status_devtoolset != 0 ]]; then
141-
echo "ERROR : it is not possible to enable the ${rhgcc_pkg} environment"
142-
exit 1
143-
fi
144-
145151
if [[ $status_pg_isready != 0 ]]; then
146152
echo "ERROR : the command pg_isready is not available"
147153
exit 1

0 commit comments

Comments
 (0)