From 963ddd3043745f9176a3283e1ba6d5ad72deeb11 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Fri, 1 Sep 2023 13:02:01 +1000 Subject: [PATCH 1/5] build.sh: RET already defined Mirror of upstream https://github.com/codership/galera/pull/644 --- scripts/build.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 4c6a612fa..500c65908 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -313,7 +313,6 @@ build_packages() else # build RPM ./rpm.sh $GALERA_VER fi - local RET=$? set -e From 1fd7b5e8ae7c62ef1049c84e32a5a921640584dc Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Mon, 4 Sep 2023 12:14:31 +1000 Subject: [PATCH 2/5] Debian build - requires dpkg-buildpackage --- scripts/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index 500c65908..7611840b9 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -217,7 +217,7 @@ done # check whether sudo accepts -E to preserve environment if [ "$PACKAGE" == "yes" ] then - if which dpkg >/dev/null 2>&1 + if which dpkg-buildpackage >/dev/null 2>&1 then echo "Error: Package build not supported on Debian, use dpkg-buildpackage" exit 1 From 503cad61095ac17a20f2349fbb4cffdb252b064e Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 6 Sep 2023 11:19:01 +1000 Subject: [PATCH 3/5] Galera.spec: remove scons The building of RPMs assumes the code is already built. This may have been done with CMake. Having the build depends here can fail if scons isn't installed, despite is never used. Adjust rpm.sh to use teh galera-obs.spec file. --- scripts/packages/galera-obs.spec | 7 ------- scripts/packages/rpm.sh | 2 +- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/scripts/packages/galera-obs.spec b/scripts/packages/galera-obs.spec index 7ee4dd3d6..267815527 100644 --- a/scripts/packages/galera-obs.spec +++ b/scripts/packages/galera-obs.spec @@ -90,13 +90,6 @@ BuildRequires: boost-devel >= 1.41 BuildRequires: check-devel BuildRequires: glibc-devel BuildRequires: %{ssl_package_devel} -%if 0%{?rhel} >= 8 || 0%{?centos} >= 8 -BuildRequires: python3-scons -%define scons_cmd scons-3 -%else -BuildRequires: scons -%define scons_cmd scons -%endif %if 0%{?suse_version} == 1110 # On SLES11 SPx use the linked gcc47 to build instead of default gcc43 BuildRequires: gcc47 gcc47-c++ diff --git a/scripts/packages/rpm.sh b/scripts/packages/rpm.sh index d5e7c64a9..ae6e83558 100755 --- a/scripts/packages/rpm.sh +++ b/scripts/packages/rpm.sh @@ -21,7 +21,7 @@ fast_cflags="-O3 -fno-omit-frame-pointer" uname -m | grep -q i686 && \ cpu_cflags="-mtune=i686" || cpu_cflags="-mtune=core2" RPM_OPT_FLAGS="$fast_cflags $cpu_cflags" -GALERA_SPEC=$SCRIPT_ROOT/galera.spec +GALERA_SPEC=$SCRIPT_ROOT/galera-obs.spec RELEASE=${RELEASE:-"1"} From 97867895f0985b06c91240818f01af3c6268b132 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 24 Oct 2023 11:34:20 +1100 Subject: [PATCH 4/5] CMake cannot handle -DCMAKE_CXX_COMPILER="ccache gcc" Handle with -DCMAKE_CXX_COMPILER_LAUNCHER=ccache --- scripts/build.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 7611840b9..cb305fb92 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -100,11 +100,6 @@ else CXX=${CXX:-"g++"} fi -if ccache -V > /dev/null 2>&1 -then - echo "$CC" | grep "ccache" > /dev/null || CC="ccache $CC" - echo "$CXX" | grep "ccache" > /dev/null || CXX="ccache $CXX" -fi export CC CXX LD_LIBRARY_PATH CFLAGS=${CFLAGS:-"-O2"} @@ -384,6 +379,10 @@ fi if [ "$CMAKE" == "yes" ] # Build using CMake then cmake_args="$CMAKE_OPTS -DGALERA_REVISION=$GALERA_REV" + if ccache -V > /dev/null 2>&1 + then + cmake_args="$cmake_args -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" + fi [ -n "$TARGET" ] && \ echo "WARN: TARGET=$TARGET ignored by CMake build" [ -n "$RELEASE" ] && \ From d735eda8a8449f7f057e911c09253be24d3fbdbc Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Tue, 24 Oct 2023 13:01:20 +1100 Subject: [PATCH 5/5] rpm: distro detection Detection is just for the detection of sles. Remove other RPM distros. Use this where the distro cannot be queried with rpm. From /etc/SuSE-release SUSE Linux Enterprise Server 12 (s390x) VERSION = 12 PATCHLEVEL = 5 # This file is deprecated and will be removed in a future service pack or release. # Please check /etc/os-release for details about this release. On SLES12: rpm --eval '%{dist}' %{dist} /etc/os-release NAME="SLES" VERSION="12-SP5" VERSION_ID="12.5" PRETTY_NAME="SUSE Linux Enterprise Server 12 SP5" ID="sles" ANSI_COLOR="0;32" CPE_NAME="cpe:/o:suse:sles:12:sp5" So we use NAME/ID/VERSION_ID to form the required distro tag. --- scripts/packages/rpm.sh | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/scripts/packages/rpm.sh b/scripts/packages/rpm.sh index ae6e83558..13018cf1d 100755 --- a/scripts/packages/rpm.sh +++ b/scripts/packages/rpm.sh @@ -24,21 +24,43 @@ RPM_OPT_FLAGS="$fast_cflags $cpu_cflags" GALERA_SPEC=$SCRIPT_ROOT/galera-obs.spec RELEASE=${RELEASE:-"1"} +DISTRO_VERSION= -if [ -r /etc/fedora-release ] +if [ -r /etc/os-release ] then - DISTRO_VERSION=fc$(rpm -qf --qf '%{version}\n' /etc/fedora-release) -elif [ -r /etc/redhat-release ] -then - DISTRO_VERSION=rhel$(rpm -qf --qf '%{version}\n' /etc/redhat-release) + source /etc/os-release elif [ -r /etc/SuSE-release ] then DISTRO_VERSION=sles$(rpm -qf --qf '%{version}\n' /etc/SuSE-release | cut -d. -f1) -else - DISTRO_VERSION= fi -[ -n "$DISTRO_VERSION" ] && RELEASE=$RELEASE.$DISTRO_VERSION +DIST_TAG= +# %dist does not return a value for sles12 +# https://bugs.centos.org/view.php?id=3239 +if [ "${DISTRO_VERSION}" = "sles12" ] +then + DIST_TAG=".sles12" +fi + +if [ "${DISTRO_VERSION}" = "sles42" ] +then + DIST_TAG=".sles42" +fi + +if [ -z "$DIST_TAG" ] +then + DIST_TAG=$(rpm --eval "%{dist}") + if [ "$DIST_TAG" = "%{dist}" ] + then + DIST_TAG= + fi +fi + +# from /etc/os-release +if [ -z "$DIST_TAG" ] +then + DIST_TAG=".${ID}${VERSION_ID%%.*}" +fi $(which rpmbuild) --clean --define "_topdir $RPM_TOP_DIR" \ --define "optflags $RPM_OPT_FLAGS" \