Blob Blame History Raw
From 39ac83a05926ebe06cbb49a7fe1716d7809adc4a Mon Sep 17 00:00:00 2001
From: Milind Changire <mchangir@redhat.com>
Date: Fri, 8 Mar 2019 18:52:17 +0530
Subject: [PATCH 511/512] build: changes for rhel-8 build

configure.ac and spec file changes for rhel-8 build

Label: DOWNSTREAM ONLY

Change-Id: I4b942f8a06a357c49a26064c76467f07a1bef488
Signed-off-by: Milind Changire <mchangir@redhat.com>
---
 configure.ac      | 39 ++++++++++++++++++++++++
 glusterfs.spec.in | 77 ++++++++++++++++++++++++++---------------------
 2 files changed, 81 insertions(+), 35 deletions(-)

diff --git a/configure.ac b/configure.ac
index b388a1376..9a498724b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,6 +293,21 @@ else
         CFLAGS="${CFLAGS} -g -rdynamic"
 fi
 
+dnl When possible, prefer libtirpc over glibc rpc.
+dnl
+dnl On newer linux with only libtirpc, use libtirpc. (Specifying
+dnl --without-libtirpc is an error.)
+dnl
+dnl on older linux with glibc rpc and WITH libtirpc, use libtirpc
+dnl by default except when configured with --without-libtirpc.
+dnl
+dnl on old linux with glibc rpc and WITHOUT libtirpc, default to
+dnl use glibc rpc.
+dnl
+AC_ARG_WITH([libtirpc],
+        [AC_HELP_STRING([--without-libtirpc], [Use legacy glibc RPC.])],
+        [with_libtirpc="no"], [with_libtirpc="yes"])
+
 AC_ARG_ENABLE([privport_tracking],
               AC_HELP_STRING([--disable-privport_tracking],
                              [Disable internal tracking of privileged ports.]))
@@ -1037,6 +1052,29 @@ AC_SUBST(GF_DISTRIBUTION)
 GF_HOST_OS=""
 GF_LDFLAGS="-rdynamic"
 
+dnl see --with-libtirpc option check above, libtirpc(-devel) is required for
+dnl ipv6-default
+if test "x${with_libtirpc}" = "xyes" ; then
+    PKG_CHECK_MODULES([TIRPC], [libtirpc],
+       [with_libtirpc="yes"; GF_CFLAGS="$GF_CFLAGS $TIRPC_CFLAGS"; GF_LDFLAGS="$GF_LDFLAGS $TIRPC_LIBS";],
+       [with_libtirpc="missing"; with_ipv6_default="no"])
+fi
+
+if test "x${with_libtirpc}" = "xmissing" ; then
+    AC_CHECK_HEADERS([rpc/rpc.h],[
+        AC_MSG_WARN([
+            ---------------------------------------------------------------------------------
+            libtirpc (and/or ipv6-default) were enabled but libtirpc-devel is not installed.
+            Disabling libtirpc and ipv6-default and falling back to legacy glibc rpc headers.
+            This is a transitional warning message. Eventually it will be an error message.
+            ---------------------------------------------------------------------------------])],[
+        AC_MSG_ERROR([
+            ---------------------------------------------------------------------------------
+            libtirpc (and/or ipv6-default) were enabled but libtirpc-devel is not installed
+            and there were no legacy glibc rpc headers and library to fall back to.
+            ---------------------------------------------------------------------------------])])
+fi
+
 dnl check for gcc -Werror=format-security
 saved_CFLAGS=$CFLAGS
 CFLAGS="-Wformat -Werror=format-security"
@@ -1563,4 +1601,5 @@ echo "Events               : $BUILD_EVENTS"
 echo "EC dynamic support   : $EC_DYNAMIC_SUPPORT"
 echo "Use memory pools     : $USE_MEMPOOL"
 echo "Nanosecond m/atimes  : $BUILD_NANOSECOND_TIMESTAMPS"
+echo "Use TIRPC            : $with_libtirpc"
 echo
diff --git a/glusterfs.spec.in b/glusterfs.spec.in
index 0ad4ffc50..87c1c1db2 100644
--- a/glusterfs.spec.in
+++ b/glusterfs.spec.in
@@ -25,6 +25,17 @@
 # rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --without rdma
 %{?_without_rdma:%global _without_rdma --disable-ibverbs}
 
+# libtirpc
+# if you wish to compile an rpm without TIRPC (i.e. use legacy glibc rpc)
+# rpmbuild -ta @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz --without libtirpc
+%{?_without_libtirpc:%global _without_libtirpc --without-libtirpc}
+
+# Do not use libtirpc on EL6, it does not have xdr_uint64_t() and xdr_uint32_t
+# Do not use libtirpc on EL7, it does not have xdr_sizeof()
+%if ( 0%{?rhel} && 0%{?rhel} <= 7 )
+%global _without_libtirpc --without-libtirpc
+%endif
+
 # No RDMA Support on s390(x)
 %ifarch s390 s390x armv7hl
 %global _without_rdma --disable-ibverbs
@@ -195,7 +206,6 @@ Version:          @PACKAGE_VERSION@
 Release:          @PACKAGE_RELEASE@%{?dist}
 %endif
 License:          GPLv2 or LGPLv3+
-Group:            System Environment/Base
 URL:              http://gluster.readthedocs.io/en/latest/
 %if ( 0%{_for_fedora_koji_builds} )
 Source0:          http://bits.gluster.org/pub/gluster/glusterfs/src/glusterfs-%{version}%{?prereltag}.tar.gz
@@ -208,8 +218,6 @@ Source8:          glusterfsd.init
 Source0:          @PACKAGE_NAME@-@PACKAGE_VERSION@.tar.gz
 %endif
 
-BuildRoot:        %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
-
 Requires(pre):    shadow-utils
 %if ( 0%{?rhel} && 0%{?rhel} <= 5 )
 BuildRequires:    python-simplejson
@@ -228,9 +236,15 @@ BuildRequires:    ncurses-devel readline-devel
 BuildRequires:    libxml2-devel openssl-devel
 BuildRequires:    libaio-devel libacl-devel
 BuildRequires:    python2-devel
-%if ( 0%{?fedora} && 0%{?fedora} < 26 ) || ( 0%{?rhel} )
+%if ( 0%{?fedora} && 0%{?fedora} < 26 ) || ( 0%{?rhel} && (0%{?rhel} < 8) )
 BuildRequires:    python-ctypes
 %endif
+%if ( 0%{!?_without_libtirpc:1} )
+BuildRequires:    libtirpc-devel
+%endif
+%if ( 0%{?fedora} && ( 0%{?fedora} >= 28 ) ) || ( 0%{?rhel} && ( 0%{?rhel} >= 8 ) )
+BuildRequires:    rpcgen libtirpc-devel
+%endif
 BuildRequires:    userspace-rcu-devel >= 0.7
 %if ( 0%{?rhel} && 0%{?rhel} <= 6 )
 BuildRequires:    automake
@@ -279,7 +293,6 @@ and client framework.
 
 %package api
 Summary:          GlusterFS api library
-Group:            System Environment/Daemons
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 Requires:         %{name}-client-xlators%{?_isa} = %{version}-%{release}
 Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
@@ -297,7 +310,6 @@ This package provides the glusterfs libgfapi library.
 
 %package api-devel
 Summary:          Development Libraries
-Group:            Development/Libraries
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 Requires:         %{name}-devel%{?_isa} = %{version}-%{release}
 Requires:         libacl-devel
@@ -316,7 +328,6 @@ This package provides the api include files.
 
 %package cli
 Summary:          GlusterFS CLI
-Group:            Applications/File
 Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
 
 %description cli
@@ -332,7 +343,6 @@ This package provides the GlusterFS CLI application and its man page
 
 %package devel
 Summary:          Development Libraries
-Group:            Development/Libraries
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 # Needed for the Glupy examples to work
 %if ( 0%{!?_without_extra_xlators:1} )
@@ -357,12 +367,11 @@ This package provides the development libraries and include files.
 %if ( 0%{!?_without_extra_xlators:1} )
 %package extra-xlators
 Summary:          Extra Gluster filesystem Translators
-Group:            Applications/File
 # We need python-gluster rpm for gluster module's __init__.py in Python
 # site-packages area
 Requires:         python2-gluster = %{version}-%{release}
 Requires:         python2
-%if ( 0%{?fedora} && 0%{?fedora} < 26 ) || ( 0%{?rhel} )
+%if ( 0%{?fedora} && ( 0%{?fedora} < 26 ) ) || ( 0%{?rhel} && ( 0%{?rhel} < 8 ) )
 BuildRequires:    python-ctypes
 %endif
 
@@ -381,7 +390,6 @@ for GlusterFS.
 
 %package fuse
 Summary:          Fuse client
-Group:            Applications/File
 BuildRequires:    fuse-devel
 Requires:         attr
 Requires:         psmisc
@@ -408,7 +416,6 @@ glusterfs(d) binary.
 %if ( 0%{?_build_server} )
 %package ganesha
 Summary:          NFS-Ganesha configuration
-Group:            Applications/File
 
 Requires:         %{name}-server%{?_isa} = %{version}-%{release}
 Requires:         nfs-ganesha-gluster >= 2.4.1
@@ -450,12 +457,15 @@ NFS-Ganesha as the NFS server using GlusterFS
 %if ( 0%{!?_without_georeplication:1} )
 %package geo-replication
 Summary:          GlusterFS Geo-replication
-Group:            Applications/File
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 Requires:         %{name}-server%{?_isa} = %{version}-%{release}
 Requires:         python2
+%if ( 0%{?fedora} && ( 0%{?fedora} < 28 ) ) || ( 0%{?rhel} && ( 0%{?rhel} < 8 ) )
 Requires:         python-prettytable
-%if ( 0%{?fedora} && 0%{?fedora} < 26 ) || ( 0%{?rhel} )
+%else
+Requires:         python2-prettytable
+%endif
+%if ( 0%{?fedora} && 0%{?fedora} < 26 ) || ( 0%{?rhel} < 8 )
 BuildRequires:    python-ctypes
 %endif
 Requires:         python2-gluster = %{version}-%{release}
@@ -478,7 +488,6 @@ This package provides support to geo-replication.
 
 %package libs
 Summary:          GlusterFS common libraries
-Group:            Applications/File
 
 %description libs
 GlusterFS is a distributed file-system capable of scaling to several
@@ -493,7 +502,6 @@ This package provides the base GlusterFS libraries
 
 %package -n python-gluster
 Summary:          GlusterFS python library
-Group:            Development/Tools
 %if ( ! ( 0%{?rhel} && 0%{?rhel} < 6 || 0%{?sles_version} ) )
 # EL5 does not support noarch sub-packages
 BuildArch:        noarch
@@ -515,7 +523,6 @@ namespace.
 
 %package -n python2-gluster
 Summary:          GlusterFS python library
-Group:            Development/Tools
 %{?python_provide:%python_provide python2-gluster}
 Requires:         python2
 Provides:         python-gluster = %{version}-%{release}
@@ -526,7 +533,6 @@ Obsoletes:        python-gluster < 3.10
 %if ( 0%{!?_without_rdma:1} )
 %package rdma
 Summary:          GlusterFS rdma support for ib-verbs
-Group:            Applications/File
 %if ( 0%{?fedora} && 0%{?fedora} > 26 )
 BuildRequires:    rdma-core-devel
 %else
@@ -552,7 +558,6 @@ This package provides support to ib-verbs library.
 %if ( 0%{!?_without_regression_tests:1} )
 %package regression-tests
 Summary:          Development Tools
-Group:            Development/Tools
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 Requires:         %{name}-fuse%{?_isa} = %{version}-%{release}
 Requires:         %{name}-server%{?_isa} = %{version}-%{release}
@@ -577,12 +582,6 @@ License:          GPLv3+
 # EL5 does not support noarch sub-packages
 BuildArch:        noarch
 %endif
-# this Group handling comes from the Fedora resource-agents package
-%if ( 0%{?fedora} || 0%{?centos_version} || 0%{?rhel} )
-Group:            System Environment/Base
-%else
-Group:            Productivity/Clustering/HA
-%endif
 # for glusterd
 Requires:         %{name}-server = %{version}-%{release}
 # depending on the distribution, we need pacemaker or resource-agents
@@ -606,7 +605,6 @@ like Pacemaker.
 %if ( 0%{?_build_server} )
 %package server
 Summary:          Clustered file-system server
-Group:            System Environment/Daemons
 Requires:         %{name}%{?_isa} = %{version}-%{release}
 Requires:         %{name}-cli%{?_isa} = %{version}-%{release}
 Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
@@ -664,7 +662,6 @@ This package provides the glusterfs server daemon.
 
 %package client-xlators
 Summary:          GlusterFS client-side translators
-Group:            Applications/File
 Requires:         %{name}-libs%{?_isa} = %{version}-%{release}
 
 %description client-xlators
@@ -682,11 +679,15 @@ This package provides the translators needed on any GlusterFS client.
 %if ( 0%{!?_without_events:1} )
 %package events
 Summary:          GlusterFS Events
-Group:            Applications/File
 Requires:         %{name}-server%{?_isa} = %{version}-%{release}
-Requires:         python2 python-prettytable
+Requires:         python2
+%if ( 0%{?fedora} && ( 0%{?fedora} < 28 ) ) || ( 0%{?rhel} && ( 0%{?rhel} < 8 ) )
+Requires:         python-prettytable
+%else
+Requires:         python2-prettytable
+%endif
 Requires:         python2-gluster = %{version}-%{release}
-%if ( 0%{?rhel} )
+%if ( 0%{?rhel} && ( 0%{?rhel} < 8 ) )
 Requires:         python-requests
 %else
 Requires:         python2-requests
@@ -731,6 +732,8 @@ export CFLAGS
 export LDFLAGS
 %endif
 
+export RHEL_ALLOW_PYTHON2_FOR_BUILD=1
+
 ./autogen.sh && %configure \
         %{?_with_cmocka} \
         %{?_with_debug} \
@@ -745,7 +748,8 @@ export LDFLAGS
         %{?_without_rdma} \
         %{?_without_syslog} \
         %{?_without_tiering} \
-        %{?_without_events}
+        %{?_without_events} \
+        %{?_without_libtirpc}
 
 # fix hardening and remove rpath in shlibs
 %if ( 0%{?fedora} && 0%{?fedora} > 17 ) || ( 0%{?rhel} && 0%{?rhel} > 6 )
@@ -754,12 +758,18 @@ sed -i 's| \\\$compiler_flags |&\\\$LDFLAGS |' libtool
 sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|' libtool
 sed -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|' libtool
 
+# Fix python shebangs
+for i in `find . -type f -exec bash -c "if file {} | grep 'Python script, ASCII text executable' >/dev/null; then echo {}; fi" ';'`; do
+    sed -i -e 's|^#!/usr/bin/python.*|#!%{__python3}|' -e 's|^#!/usr/bin/env python.*|#!%{__python3}|' $i
+done
+
 make %{?_smp_mflags}
 
 %check
 make check
 
 %install
+export RHEL_ALLOW_PYTHON2_FOR_BUILD=1
 rm -rf %{buildroot}
 make install DESTDIR=%{buildroot}
 # Install include directory
@@ -879,9 +889,6 @@ install -p -m 0744 -D extras/command-completion/gluster.bash \
 echo "RHGS 3.4" > %{buildroot}%{_datadir}/glusterfs/release
 %endif
 
-%clean
-rm -rf %{buildroot}
-
 ##-----------------------------------------------------------------------------
 ## All %%post should be placed here and keep them sorted
 ##
@@ -1094,7 +1101,7 @@ exit 0
 %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/features/selinux.so
 %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/features/template.so
 %exclude %{_libdir}/glusterfs/%{version}%{?prereltag}/xlator/testing/performance/symlink-cache.so
-%exclude %{python_sitelib}/*
+%exclude %{python2_sitelib}/*
 %endif
 # exclude regression-tests files
 %if ( ! 0%{!?_without_regression_tests:1} )
-- 
2.20.1