From 1397ddaf3a9c75717677b6ee7ca2c7ec096e7f66 Mon Sep 17 00:00:00 2001
From: Niels de Vos <ndevos@redhat.com>
Date: Wed, 10 Jun 2015 10:09:02 +0200
Subject: [PATCH 40/57] build: fix compiling on older distributions
data-tiering is disabled on RHEL-5 because it depends on a too new
SQLite version.
This change also prevents installing some of files that are used by
geo-replication, which is also not available on RHEL-5. geo-replication
depends on a too recent version of Python.
Due to an older version of OpenSSL, some of the newer functions can not
be used. A fallback to previous functions is done. Unfortunately RHEL-5
does not seem to have TLSv1.2 support, so only older versions can be
used.
Backport of the upstream commits from http://review.gluster.org/11096:
> Cherry picked from commit 0209b18fd65f9df5ebd0a8764ebf864d0d392998:
> > Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913
> > BUG: 1222317
> > Signed-off-by: Niels de Vos <ndevos@redhat.com>
> > Reviewed-on: http://review.gluster.org/10803
> > Tested-by: NetBSD Build System <jenkins@build.gluster.org>
> > Tested-by: Gluster Build System <jenkins@build.gluster.com>
> > Reviewed-by: Kaleb KEITHLEY <kkeithle@redhat.com>
> > Reviewed-by: Vijay Bellur <vbellur@redhat.com>
>
> Also including the changes from http://review.gluster.org/11140:
>
> > build: improve detection of new OpenSSL features
> >
> > Building on Mac OS X revealed that the current check for
> > CRYPTO_THREADID_set_callback() availability in OpenSSL is not correct.
> >
> > There also does not seem to be a guarantee that TLSv1_2_method() is
> > available when TLS1_2_VERSION is #define'd.
> >
> > Change-Id: I21508065fc181a1c74bee4fd6d23bb5bdf7cea7a
> > BUG: 1222317
> > Reviewed-on: http://review.gluster.org/11140
> > Original-author: Kaleb KEITHLEY <kkeithle@redhat.com>
> > Signed-off-by: Niels de Vos <ndevos@redhat.com>
>
> Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913
> BUG: 1228510
> Signed-off-by: Niels de Vos <ndevos@redhat.com>
Change-Id: I672264a673f5432358d2e83b17e2a34efd9fd913
BUG: 1230114
Signed-off-by: Niels de Vos <ndevos@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/50445
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
Makefile.am | 5 ++-
configure.ac | 50 ++++++++++++++++++++------------
extras/Makefile.am | 4 +-
extras/geo-rep/Makefile.am | 2 +-
extras/hook-scripts/Makefile.am | 2 +
geo-replication/src/Makefile.am | 2 +-
glusterfs.spec.in | 47 +++++++++++++++++++++++++------
rpc/rpc-transport/socket/src/socket.c | 18 ++++++++++++
8 files changed, 97 insertions(+), 33 deletions(-)
diff --git a/Makefile.am b/Makefile.am
index 82175ee..628bc48 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,7 +15,10 @@ SUBDIRS = $(ARGP_STANDALONE_DIR) libglusterfs rpc api xlators glusterfsd \
@UMOUNTD_SUBDIR@ tools
pkgconfigdir = @pkgconfigdir@
-pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc libgfdb.pc
+pkgconfig_DATA = glusterfs-api.pc libgfchangelog.pc
+if USE_GFDB
+pkgconfig_DATA += libgfdb.pc
+endif
CLEANFILES =
CONFIG_CLEAN_FILES = $(CONTRIB_BUILDDIR)/uuid/uuid_types.h
diff --git a/configure.ac b/configure.ac
index 1a09854..a93c1cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -388,14 +388,7 @@ AC_CHECK_HEADERS([sys/ioctl.h], AC_DEFINE(HAVE_IOCTL_IN_SYS_IOCTL_H, 1, [have sy
AC_CHECK_HEADERS([sys/extattr.h])
dnl Math library
-case $host_os in
- linux*)
- MATH_LIB=''
- ;;
- *)
- MATH_LIB='-lm'
- ;;
-esac
+AC_CHECK_LIB([m], [pow], [MATH_LIB='-lm'], [MATH_LIB=''])
AC_SUBST(MATH_LIB)
dnl use libuuid.so or fall-back to contrib/uuid
@@ -406,6 +399,16 @@ PKG_CHECK_MODULES([UUID], [uuid],
[HAVE_LIBUUID=no
UUID_CFLAGS='-I$(CONTRIBDIR)/uuid'])
AM_CONDITIONAL([HAVE_LIBUUID], [test x$HAVE_LIBUUID = xyes])
+
+dnl older version of libuuid (from e2fsprogs) require including uuid/uuid.h
+saved_CFLAGS=${CFLAGS}
+CFLAGS="${CFLAGS} ${UUID_CFLAGS}"
+AC_CHECK_HEADER([uuid.h], [], [AC_CHECK_HEADER([uuid/uuid.h])])
+CFLAGS=${saved_CFLAGS}
+if test "x$ac_cv_header_uuid_uuid_h" = "xyes"; then
+ UUID_CFLAGS="${UUID_CFLAGS} -I$(pkg-config --variable=includedir uuid)/uuid"
+fi
+
dnl libglusterfs needs uuid.h, practically everything depends on it
GF_CPPFLAGS="${GF_CPPFLAGS} ${UUID_CFLAGS}"
dnl PKGCONFIG_UUID is used for the dependency in *.pc.in files
@@ -530,6 +533,11 @@ fi
AM_CONDITIONAL([ENABLE_BD_XLATOR], [test x$BUILD_BD_XLATOR = xyes])
+dnl check for old openssl
+AC_CHECK_LIB([crypto], CRYPTO_THREADID_set_callback, [AC_DEFINE([HAVE_CRYPTO_THREADID], [1], [use new OpenSSL functions])])
+
+AC_CHECK_LIB([ssl], TLSv1_2_method, [AC_DEFINE([HAVE_TLSV1_2_METHOD], [1], [use new OpenSSL functions])])
+
# start encryption/crypt section
AC_CHECK_HEADERS([openssl/cmac.h], [have_cmac_h=yes], [have_cmac_h=no])
@@ -705,6 +713,7 @@ if test "x$enable_georeplication" != "xno"; then
GEOREP_EXTRAS_SUBDIR=geo-rep
fi
AC_SUBST(GEOREP_EXTRAS_SUBDIR)
+AM_CONDITIONAL(USE_GEOREP, test "x$enable_georeplication" != "xno")
# CDC xlator - check if libz is present if so enable HAVE_LIB_Z
BUILD_CDC=yes
@@ -808,11 +817,8 @@ AC_SUBST(HAVE_BACKTRACE)
if test "x${have_backtrace}" != "xyes"; then
AC_TRY_COMPILE([#include <math.h>], [double x=0.0; x=ceil(0.0);],
- [have_math_h=yes],
+ [],
AC_MSG_ERROR([need math library for libexecinfo]))
-if test "x${have_math_h}" = "xyes"; then
- LIBS="$LIBS -lm"
-fi
fi
dnl glusterfs prints memory usage to stderr by sending it SIGUSR1
@@ -905,26 +911,29 @@ GF_HOST_OS=""
GF_LDFLAGS="-rdynamic"
dnl check for gcc -Werror=format-security
-saved_GF_CFLAGS="-Wformat -Werror=format-security"
+saved_CFLAGS=$CFLAGS
+CFLAGS="-Wformat -Werror=format-security"
AC_MSG_CHECKING([whether $CC accepts -Werror=format-security])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_format_security=yes], [cc_werror_format_security=no])
echo $cc_werror_format_security
if test "x$cc_werror_format_security" = "xno"; then
- GF_CFLAGS="$GF_CFLAGS"
+ CFLAGS="$saved_CFLAGS"
else
- GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS"
+ CFLAGS="$saved_CFLAGS $CFLAGS"
+ GF_CFLAGS="$GF_CFLAGS $CFLAGS"
fi
dnl check for gcc -Werror=implicit-function-declaration
-saved_GF_CFLAGS=$GF_CFLAGS
-GF_CFLAGS="-Werror=implicit-function-declaration"
+saved_CFLAGS=$CFLAGS
+CFLAGS="-Werror=implicit-function-declaration"
AC_MSG_CHECKING([whether $CC accepts -Werror=implicit-function-declaration])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], [cc_werror_implicit=yes], [cc_werror_implicit=no])
echo $cc_werror_implicit
if test "x$cc_werror_implicit" = "xno"; then
- GF_CFLAGS="$saved_GF_CFLAGS"
+ CFLAGS="$saved_CFLAGS"
else
- GF_CFLAGS="$saved_GF_CFLAGS $GF_CFLAGS"
+ CFLAGS="$saved_CFLAGS $CFLAGS"
+ GF_CFLAGS="$GF_CFLAGS $CFLAGS"
fi
dnl clang is mostly GCC-compatible, but its version is much lower,
@@ -1242,6 +1251,9 @@ AC_SUBST(UNITTEST_LDFLAGS)
AC_SUBST(CFLAGS)
# end enable debug section
+dnl libglusterfs.so uses math functions
+GF_LDADD="${GF_LDADD} ${MATH_LIB}"
+
AC_SUBST(GF_HOST_OS)
AC_SUBST(GF_CFLAGS)
AC_SUBST(GF_LDFLAGS)
diff --git a/extras/Makefile.am b/extras/Makefile.am
index d54f750..ba2bef3 100644
--- a/extras/Makefile.am
+++ b/extras/Makefile.am
@@ -1,5 +1,5 @@
-gsyncddir = $(libexecdir)/glusterfs
-gsyncd_SCRIPTS = peer_add_secret_pub
+addonexecdir = $(libexecdir)/glusterfs
+addonexec_SCRIPTS = peer_add_secret_pub
EditorModedir = $(docdir)
EditorMode_DATA = glusterfs-mode.el glusterfs.vim
diff --git a/extras/geo-rep/Makefile.am b/extras/geo-rep/Makefile.am
index e0aab77..7ebede3 100644
--- a/extras/geo-rep/Makefile.am
+++ b/extras/geo-rep/Makefile.am
@@ -5,7 +5,7 @@ scripts_DATA = gsync-upgrade.sh generate-gfid-file.sh get-gfid.sh \
scripts_PROGRAMS = gsync-sync-gfid
gsync_sync_gfid_CFLAGS = $(GF_CFLAGS) -Wall -I$(top_srcdir)/libglusterfs/src
gsync_sync_gfid_LDFLAGS = $(GF_LDFLAGS)
-gsync_sync_gfid_LDADD = $(GF_LIBS) $(top_builddir)/libglusterfs/src/libglusterfs.la
+gsync_sync_gfid_LDADD = $(GF_LDADD) $(top_builddir)/libglusterfs/src/libglusterfs.la
gsync_sync_gfid_SOURCES = gsync-sync-gfid.c
gsync_sync_gfid_CPPFLAGS = $(GF_CPPFLAGS) -I$(top_srcdir)/libglusterfs/src
diff --git a/extras/hook-scripts/Makefile.am b/extras/hook-scripts/Makefile.am
index fa126f9..771b37e 100644
--- a/extras/hook-scripts/Makefile.am
+++ b/extras/hook-scripts/Makefile.am
@@ -2,4 +2,6 @@ EXTRA_DIST = S40ufo-stop.py S56glusterd-geo-rep-create-post.sh
SUBDIRS = add-brick set start stop reset
scriptsdir = $(GLUSTERD_WORKDIR)/hooks/1/gsync-create/post/
+if USE_GEOREP
scripts_SCRIPTS = S56glusterd-geo-rep-create-post.sh
+endif
diff --git a/geo-replication/src/Makefile.am b/geo-replication/src/Makefile.am
index e9d6bc1..1572698 100644
--- a/geo-replication/src/Makefile.am
+++ b/geo-replication/src/Makefile.am
@@ -11,7 +11,7 @@ gsyncd_PROGRAMS = gsyncd
gsyncd_SOURCES = gsyncd.c procdiggy.c
-gsyncd_LDADD = $(top_builddir)/libglusterfs/src/libglusterfs.la
+gsyncd_LDADD = $(GF_LDADD) $(top_builddir)/libglusterfs/src/libglusterfs.la
gsyncd_LDFLAGS = $(GF_LDFLAGS)
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index dc87e83..0e69bc6 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -89,6 +89,11 @@
%global _without_extra_xlators 1
%global _without_regression_tests 1
+# Disable data-tiering on EL5, sqlite is too old
+%if ( 0%{?rhel} && 0%{?rhel} < 6 )
+%global _without_tiering --disable-tiering
+%endif
+
##-----------------------------------------------------------------------------
## All %global definitions should be placed here and keep them sorted
##
@@ -213,11 +218,17 @@ BuildRequires: libaio-devel libacl-devel
BuildRequires: python-devel
BuildRequires: python-ctypes
BuildRequires: userspace-rcu-devel >= 0.7
+%if ( 0%{?rhel} && 0%{?rhel} <= 5 )
+BuildRequires: e2fsprogs-devel
+%else
BuildRequires: libuuid-devel
+%endif
%if ( 0%{?_with_cmocka:1} )
BuildRequires: libcmocka-devel >= 1.0.1
%endif
+%if ( 0%{!?_without_tiering:1} )
BuildRequires: sqlite-devel
+%endif
%if ( 0%{!?_without_systemtap:1} )
BuildRequires: systemtap-sdt-devel
%endif
@@ -604,17 +615,19 @@ This package provides the translators needed on any GlusterFS client.
# there is no need to run ./autogen or have a BuildRequires for automake.
./autogen.sh
%configure \
+./autogen.sh && %configure \
+ %{?_with_cmocka} \
%{?_with_tmpfilesdir} \
- %{?_without_rdma} \
+ %{?_without_bd} \
%{?_without_epoll} \
%{?_without_fusermount} \
%{?_without_georeplication} \
%{?_without_ocf} \
- %{?_without_syslog} \
- %{?_without_bd} \
%{?_without_qemu_block} \
+ %{?_without_rdma} \
+ %{?_without_syslog} \
%{?_without_systemtap} \
- %{?_with_cmocka}
+ %{?_without_tiering}
# fix hardening and remove rpath in shlibs
%if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
@@ -1032,7 +1045,10 @@ fi
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/error-gen.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/io-stats.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/debug/trace.so
+%if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 ) )
+# RHEL-5 based distributions have a too old openssl
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/encryption/crypt.so
+%endif
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/access-control.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/barrier.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/cdc.so
@@ -1063,8 +1079,6 @@ fi
%files api-devel
%{_libdir}/pkgconfig/glusterfs-api.pc
-%{_libdir}/pkgconfig/libgfchangelog.pc
-%{_libdir}/pkgconfig/libgfdb.pc
%{_libdir}/libgfapi.so
%{_includedir}/glusterfs/api/*
@@ -1083,12 +1097,18 @@ fi
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/debug-trace.*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/helloworld.*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/glupy/negative.*
+%{_libdir}/pkgconfig/libgfchangelog.pc
+%if ( 0%{!?_without_tiering:1} )
+%{_libdir}/pkgconfig/libgfdb.pc
+%endif
%files client-xlators
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/*.so
%exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/cluster/pump.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/ganesha.so
+%if ( 0%{!?_without_qemu_block:1} )
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/qemu-block.so
+%endif
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/client.so
%if ( 0%{!?_without_extra_xlators:1} )
@@ -1151,18 +1171,18 @@ fi
%{_datadir}/glusterfs/scripts/generate-gfid-file.sh
%{_datadir}/glusterfs/scripts/gsync-sync-gfid
%ghost %attr(0644,-,-) %{_sharedstatedir}/glusterd/geo-replication/gsyncd_template.conf
+%endif
%{_libexecdir}/glusterfs/gfind_missing_files
%{_sbindir}/gfind_missing_files
-%exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyo
-%exclude %{_libexecdir}/glusterfs/gfind_missing_files/gfid_to_path.pyc
-%endif
%endif
%files libs
%{_libdir}/*.so.*
%exclude %{_libdir}/libgfapi.*
+%if ( 0%{!?_without_tiering:1} )
# libgfdb is only needed server-side
%exclude %{_libdir}/libgfdb.*
+%endif
%files -n python-gluster
# introducing glusterfs module in site packages.
@@ -1234,7 +1254,9 @@ fi
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/arbiter.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bit-rot.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/bitrot-stub.so
+%if ( 0%{!?_without_tiering:1} )
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/changetimerecorder.so
+%endif
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/index.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/locks.so
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/posix*
@@ -1247,7 +1269,9 @@ fi
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/nfs*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/protocol/server*
%{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/storage*
+%if ( 0%{!?_without_tiering:1} )
%{_libdir}/libgfdb.so.*
+%endif
#snap_scheduler
%{_sbindir}/snap_scheduler.py
@@ -1709,6 +1733,11 @@ end
%endif
%changelog
+* Wed Jun 10 2015 Niels de Vos <ndevos@redhat.com>
+- Fix building on RHEL-5 based distributions
+
+* Wed Jun 3 2015 Kaleb S. KEITHLEY <kkeithle@redhat.com>
+- move libgf{db,changelog}.pc from -api-devel to -devel (#1223390)
* Sun May 31 2015 Milind Changire <mchangir@redhat.com>
- Move file peer_add_secret_pub to the server RPM to support glusterfind (#1225552)
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index e30e231..a39c16d 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -3714,6 +3714,7 @@ locking_func (int mode, int type, const char *file, int line)
}
}
+#if HAVE_CRYPTO_THREADID
static void
threadid_func (CRYPTO_THREADID *id)
{
@@ -3729,6 +3730,14 @@ threadid_func (CRYPTO_THREADID *id)
*/
CRYPTO_THREADID_set_numeric (id, (unsigned long)pthread_self());
}
+#else /* older openssl */
+static unsigned long
+legacy_threadid_func (void)
+{
+ /* See comments above, it applies here too. */
+ return (unsigned long)pthread_self();
+}
+#endif
static void __attribute__((constructor))
init_openssl_mt (void)
@@ -3743,7 +3752,11 @@ init_openssl_mt (void)
pthread_mutex_init (&lock_array[i], NULL);
}
CRYPTO_set_locking_callback (locking_func);
+#if HAVE_CRYPTO_THREADID
CRYPTO_THREADID_set_callback (threadid_func);
+#else /* older openssl */
+ CRYPTO_set_id_callback (legacy_threadid_func);
+#endif
constructor_ok = _gf_true;
}
@@ -3992,7 +4005,12 @@ socket_init (rpc_transport_t *this)
goto err;
}
+#if HAVE_TLSV1_2_METHOD
priv->ssl_meth = (SSL_METHOD *)TLSv1_2_method();
+#else /* old openssl */
+#warning TLSv1.2 is not available, using insecure TLSv1 support
+ priv->ssl_meth = (SSL_METHOD *)TLSv1_method();
+#endif
priv->ssl_ctx = SSL_CTX_new(priv->ssl_meth);
if (SSL_CTX_set_cipher_list(priv->ssl_ctx, cipher_list) == 0) {
--
1.7.1