|
21 | 21 |
|
22 | 22 | set -e
|
23 | 23 |
|
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 |
25 | 25 | repo_name="fledge" # Name of the Git repository
|
26 | 26 | branch="main" # Default Git branch to use
|
27 | 27 | pkg_name="fledge" # Name of the package to build
|
28 | 28 | 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++ |
31 | 29 | skip_build=0 # 1=skip Git repo extraction and Fledge build
|
32 | 30 |
|
| 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 | + |
33 | 35 | usage="$(basename "$0") [-h] [-c] [-a] [-s] [-b <branch>]
|
34 | 36 | This script is used to create the RPM package of Fledge
|
35 | 37 |
|
@@ -121,27 +123,31 @@ if [[ $skip_build == 0 ]]; then
|
121 | 123 |
|
122 | 124 | cd ${FLEDGE_ROOT}
|
123 | 125 | 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 |
124 | 139 |
|
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 |
131 | 147 |
|
132 | 148 | command -v pg_isready > /dev/null
|
133 | 149 | status_pg_isready=$?
|
134 | 150 |
|
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 |
| - |
145 | 151 | if [[ $status_pg_isready != 0 ]]; then
|
146 | 152 | echo "ERROR : the command pg_isready is not available"
|
147 | 153 | exit 1
|
|
0 commit comments