File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,12 +33,11 @@ export PROJECT
3333# Otherwise, we build it.
3434if [ -z " $SYSTEM_SSL " ]; then
3535 # We don't bundle OpenSSL on some redhat-derived systems due to incompatability with libpam and our openssl.
36- _OS_MAJOR_VERSION=" $( echo " $OS_VERSION " | cut -d. -f1) "
37- if [ " $OS " = " rhel" ] && expr " $_OS_MAJOR_VERSION " " >=" " 8" > /dev/null; then
36+ if [ " $OS " = " rhel" ] && [ " $OS_VERSION_MAJOR " -ge " 8" ]; then
3837 SYSTEM_SSL=1
3938 fi
4039 if [ " $OS " = " opensuse" ] || [ " $OS " = " sles" ]; then
41- if expr " $_OS_MAJOR_VERSION " " >= " " 15" ; then
40+ if [ " $OS_VERSION_MAJOR " -ge " 15" ] ; then
4241 SYSTEM_SSL=1
4342 fi
4443 fi
Original file line number Diff line number Diff line change 9090esac
9191
9292# RHEL 8 requires an SELinux policy
93- if [ " $OS " = " rhel" ] && [ " ${OS_VERSION % \. * } " -gt " 7 " ]; then
93+ if [ " $OS " = " rhel" ] && [ " $OS_VERSION_MAJOR " -ge " 8 " ]; then
9494 var_append ARGS " --with-selinux-policy"
9595fi
9696
Original file line number Diff line number Diff line change @@ -39,11 +39,12 @@ detect_cross_target() {
3939}
4040
4141# This function exports operating system specific variables:
42- # - OS usually contains a specific distribution (e.g. Debian)
43- # - OS_VERSION operating system version (but is not always defined)
42+ # - OS usually contains a specific distribution (e.g. Debian)
43+ # - OS_VERSION operating system version (but is not always defined)
44+ # - OS_VERSION_MAJOR the major (first part of) operating system version (defined if OS_VERSION is)
4445#
4546# Furthermore, the following variable is set, but it's not exported:
46- # - OS_FAMILY usually contains the kernel name (e.g. Linux)
47+ # - OS_FAMILY usually contains the kernel name (e.g. Linux)
4748detect_os () {
4849 case " $CROSS_TARGET " in
4950 ' ' )
@@ -106,8 +107,13 @@ detect_os() {
106107 ;;
107108 esac
108109
110+ # Extract major version from OS_VERSION (e.g. 16.04 -> 16, 7.0 -> 7, 10.2.3 -> 10)
111+ if [ -n " $OS_VERSION " ]; then
112+ OS_VERSION_MAJOR=" ${OS_VERSION%% .* } "
113+ fi
114+
109115 log_debug " Detected OS $OS $OS_VERSION "
110- export OS OS_VERSION
116+ export OS OS_VERSION OS_VERSION_MAJOR
111117}
112118
113119# The uname command does not reveal the specific distribution on Linux. Hence,
Original file line number Diff line number Diff line change @@ -298,15 +298,12 @@ deb)
298298 log_debug " Development DEB version: $DEB_VERSION "
299299 fi
300300
301- # Extract major version from OS_VERSION (e.g., 16.04 -> 16, 7.0 -> 7)
302- # This is appended to package name for OS-specific builds
303- # TODO: Define this in detect-environment script (CFE-4586)
304- os_version_major=" ${OS_VERSION%% .* } "
305- log_debug " OS version major: $os_version_major "
301+ # The OS major version is appended to package name for OS-specific builds
302+ log_debug " OS version major: $OS_VERSION_MAJOR "
306303
307304 # Generate debian changelog with version info
308305 log_debug " Generating debian changelog"
309- sed -e " s/@@VERSION@@/$DEB_VERSION$safe_prefix .$OS$os_version_major /" " $BASEDIR /$PKG /pkg/debian/changelog.in" > " $BASEDIR /$PKG /pkg/debian/changelog"
306+ sed -e " s/@@VERSION@@/$DEB_VERSION$safe_prefix .$OS$OS_VERSION_MAJOR /" " $BASEDIR /$PKG /pkg/debian/changelog.in" > " $BASEDIR /$PKG /pkg/debian/changelog"
310307
311308 # Generate debian package maintainer scripts
312309 log_debug " Generating debian maintainer scripts"
Original file line number Diff line number Diff line change @@ -59,13 +59,11 @@ chroot)
5959 ubuntu)
6060 # gpg-agent sometimes is spawned on Ubuntu 24 during our tests.
6161 # This happens only in chroot. Ignore that.
62- case " $OS_VERSION " in
63- 24* )
62+ if [ " $OS_VERSION_MAJOR " = " 24" ]; then
6463 if ps -o command --pid " $pid " | grep " gpg-agent --homedir /etc/apt/sources.list.d/.gnupg-temp --use-standard-socket --daemon" ; then
6564 continue
6665 fi
67- ;;
68- esac
66+ fi
6967 ;;
7068 esac
7169
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ mkdir -p %{_builddir}
2424
2525case "$OS" in
2626 rhel|centos)
27- if [ $(echo $OS_VERSION | cut -d. -f1) = 7 ]
27+ if [ "$OS_VERSION_MAJOR" = "7" ]
2828 then
2929 # Fixes the following compilation error on rhel 7:
3030 # 15:05:28 compat/posix.h:159:24: fatal error: sys/random.h: No such file or directory
Original file line number Diff line number Diff line change 5555HACK_FLAGS=
5656if [ $OS = centos ] || [ $OS = rhel ]
5757then
58- if [ `echo $OS_VERSION | cut -d. -f1` = 4 ]
58+ if [ "$OS_VERSION_MAJOR" = "4" ]
5959 then
6060 HACK_FLAGS= -D_GNU_SOURCE # CentOS 4 issue
6161 fi
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ build-stamp:
2727 fi ;\
2828 \
2929 HACK_FLAGS= ;\
30- if [ $$OS = debian ] && [ `echo $$OS_VERSION | cut -d. -f1` = 4 ] ;\
30+ if [ $$OS = debian ] && [ $$OS_VERSION_MAJOR = 4 ] ;\
3131 then \
3232 HACK_FLAGS=-D_GNU_SOURCE ;\
3333 fi ;\
You can’t perform that action at this time.
0 commit comments