thrift/thrift.spec
2023-09-12 13:16:08 +00:00

346 lines
9.7 KiB
RPMSpec

%{?perl_default_filter}
%global __provides_exclude_from ^(%{python3_sitearch}/.*\\.so)$
# Can't do anything with java with all the build deps in modules
%global want_java 0
%if 0%{?want_java} == 0
%global java_configure --without-java
%else
%global java_configure --with-java
%endif
# Thrift's GO support doesn't build under Fedora
%global want_golang 0
%global golang_configure --without-go
# ROSA: w/a problems with interlinking
%define _disable_ld_no_undefined 1
%define devname %mklibname %{name} -d
# Thrift's Lua support has not yet been worked on
%global want_lua 0
%global lua_configure --without-lua
# NOTE: thrift versions their libraries by package version, so each version
# change is a SONAME change and dependencies need to be rebuilt
Name: thrift
Version: 0.14.2
Release: 1
Summary: Software framework for cross-language services development
Group: System/Libraries
# Parts of the source are used under the BSD and zlib licenses, but
# these are OK for inclusion in an Apache 2.0-licensed whole:
# https://www.apache.org/legal/3party.html
# Here's the breakdown:
# ./lib/py/compat/win32/stdint.h is 2-clause BSD
# ./compiler/cpp/src/md5.[ch] are zlib
License: ASL 2.0 and BSD and zlib
URL: https://thrift.apache.org
Source0: https://archive.apache.org/dist/%{name}/%{version}/%{name}-%{version}.tar.gz
Source1: https://repo1.maven.org/maven2/org/apache/thrift/lib%{name}/%{version}/lib%{name}-%{version}.pom
Source4: %{name}.rpmlintrc
Patch1: thrift-install-path.patch
# fix configure.ac insistence on using /usr/local/lib for JAVA_PREFIX
Patch2: configure-java-prefix.patch
# BuildRequires for language-specific bindings are listed under these
# subpackages, to facilitate enabling or disabling individual language
# bindings in the future
%if 0%{?want_java} > 0
BuildRequires: ant >= 1.7
%endif
BuildRequires: cmake
BuildRequires: bison
BuildRequires: boost-devel
BuildRequires: boost-static-devel
BuildRequires: flex
BuildRequires: gcc-c++
BuildRequires: glib2-devel
BuildRequires: libevent-devel
BuildRequires: libstdc++-devel
BuildRequires: libtool
BuildRequires: openssl-devel
BuildRequires: qt5-devel
BuildRequires: texlive
BuildRequires: zlib-devel
%if 0%{?want_golang} > 0
BuildRequires: golang
Requires: golang
%endif
%description
The Apache Thrift software framework for cross-language services
development combines a software stack with a code generation engine to
build services that work efficiently and seamlessly between C++, Java,
Python, and other languages.
%files
%doc LICENSE NOTICE
%{_bindir}/thrift
%{_libdir}/libthrift.so.%{version}
%{_libdir}/libthriftz.so.%{version}
%{_libdir}/libthriftnb.so.%{version}
#-----------------------------------------------------
%package -n %{devname}
Summary: Development files for %{name}
Requires: %{name}%{?_isa} = %{EVRD}
Requires: pkgconfig
Requires: boost-devel
# compat with Fedora
Provides: %{name}-devel
%description -n %{devname}
This package contains libraries and header files for
developing applications that use %{name}.
%files -n %{devname}
%{_includedir}/thrift
%{_libdir}/*.so
%{_libdir}/pkgconfig/thrift-z.pc
%{_libdir}/pkgconfig/thrift-qt5.pc
%{_libdir}/pkgconfig/thrift-nb.pc
%{_libdir}/pkgconfig/thrift.pc
%{_libdir}/cmake/thrift
%doc LICENSE NOTICE
#-----------------------------------------------------
%package qt
Summary: Qt support for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description qt
The %{name}-qt package contains Qt bindings for %{name}.
%files qt
%{_libdir}/libthriftqt5.so.%{version}
#-----------------------------------------------------
%package glib
Summary: GLib support for %{name}
Requires: %{name}%{?_isa} = %{version}-%{release}
%description glib
The %{name}-qt package contains GLib bindings for %{name}.
%files glib
%{_libdir}/libthrift_c_glib*.so.*
#-----------------------------------------------------
%package -n python3-%{name}
Summary: Python 3 support for %{name}
BuildRequires: python3-devel
Requires: %{name}%{?_isa} = %{EVRD}
Requires: python3
Obsoletes: python-%{name} < 0.10.0-1%{?dist}
Obsoletes: python2-%{name} < 0.10.0-14%{?dist}
%description -n python3-%{name}
The python3-%{name} package contains Python bindings for %{name}.
%files -n python3-%{name}
%{python3_sitearch}/%{name}
%{python3_sitearch}/%{name}-%{version}-py%{python3_version}.egg-info
%doc LICENSE NOTICE
#-----------------------------------------------------
%package -n perl-%{name}
Summary: Perl support for %{name}
Provides: perl(Thrift) = %{version}-%{release}
BuildRequires: perl(Bit::Vector)
BuildRequires: perl(Class::Accessor)
BuildRequires: perl(ExtUtils::MakeMaker)
#BuildRequires: perl-generators
Requires: perl(Bit::Vector)
Requires: perl(Encode)
Requires: perl(HTTP::Request)
Requires: perl(IO::Select)
Requires: perl(IO::Socket::INET)
Requires: perl(IO::String)
Requires: perl(LWP::UserAgent)
Requires: perl(POSIX)
Requires: perl(base)
Requires: perl(constant)
Requires: perl(strict)
Requires: perl(utf8)
Requires: perl(warnings)
# thrift improperly packages some components in files with names different
# than the package they contain
Provides: perl(Thrift::Exception)
Provides: perl(Thrift::MessageType)
Provides: perl(Thrift::Type)
BuildArch: noarch
%description -n perl-%{name}
The perl-%{name} package contains Perl bindings for %{name}.
%files -n perl-%{name}
%{perl_vendorlib}/Thrift
%{perl_vendorlib}/Thrift.pm
%doc LICENSE NOTICE
#-----------------------------------------------------
%if 0%{?want_java} > 0
%package -n lib%{name}-javadoc
Summary: API documentation for java-%{name}
Requires: lib%{name}-java = %{version}-%{release}
BuildArch: noarch
%description -n lib%{name}-javadoc
The lib%{name}-javadoc package contains API documentation for the
Java bindings for %{name}.
%files -n lib%{name}-javadoc
%{_javadocdir}/%{name}
%doc LICENSE NOTICE
#-----------------------------------------------------
%package -n lib%{name}-java
Summary: Java support for %{name}
BuildRequires: apache-commons-codec
BuildRequires: apache-commons-lang
BuildRequires: apache-commons-logging
BuildRequires: httpcomponents-client
BuildRequires: httpcomponents-core
BuildRequires: java-devel
BuildRequires: javapackages-tools
BuildRequires: javapackages-local
BuildRequires: junit
BuildRequires: log4j
BuildRequires: slf4j
# javax.servlet-api 3.1.0 is provided by glassfish-servlet-api
BuildRequires: mvn(javax.servlet:javax.servlet-api) = 3.1.0
Requires: java-headless >= 1:1.6.0
Requires: javapackages-tools
Requires: mvn(org.slf4j:slf4j-api)
Requires: mvn(commons-lang:commons-lang)
Requires: mvn(org.apache.httpcomponents:httpclient)
Requires: mvn(org.apache.httpcomponents:httpcore)
BuildArch: noarch
# Java stack is not supported on x86_32
ExcludeArch: %{ix86}
%description -n lib%{name}-java
The lib%{name}-java package contains Java bindings for %{name}.
%files -n lib%{name}-java -f .mfiles
%doc LICENSE NOTICE
%endif
#-----------------------------------------------------
%prep
%autosetup -p1
# avoid spurious executable permissions in debuginfo package
find . -name \*.cpp -or -name \*.cc -or -name \*.h | xargs -r chmod 644
# work around linking issues
echo 'libthrift_c_glib_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) -L../cpp/.libs ' >> lib/c_glib/Makefile.am
echo 'libthriftqt5_la_LIBADD = $(QT_LIBS) -lthrift -L.libs' >> lib/cpp/Makefile.am
echo 'libthriftz_la_LIBADD = $(ZLIB_LIBS) -lthrift -L.libs' >> lib/cpp/Makefile.am
echo 'EXTRA_libthriftqt5_la_DEPENDENCIES = libthrift.la' >> lib/cpp/Makefile.am
echo 'EXTRA_libthriftz_la_DEPENDENCIES = libthrift.la' >> lib/cpp/Makefile.am
# fix broken upstream check for ant version; we enforce this with BuildRequires, so no need to check here
sed -i 's|ANT_VALID=.*|ANT_VALID=1|' aclocal/ax_javac_and_java.m4
# explicitly set python3
shopt -s globstar
sed -i -E 's@^(#!.*/env) *python *$@\1 python3@' **/*.py
%build
export PY_PREFIX=%{_prefix}
export PERL_PREFIX=%{_prefix}
export JAVA_PREFIX=%{_javadir}
export GLIB_LIBS=$(pkg-config --libs glib-2.0)
export GLIB_CFLAGS=$(pkg-config --cflags glib-2.0)
export GOBJECT_LIBS=$(pkg-config --libs gobject-2.0)
export GOBJECT_CFLAGS=$(pkg-config --cflags gobject-2.0)
find %{_builddir} -name rebar -exec rm -f '{}' \;
find . -name Makefile\* -exec sed -i -e 's/[.][/]rebar/rebar/g' {} \;
# install javadocs in proper places
sed -i 's|-Dinstall.javadoc.path=$(DESTDIR)$(docdir)/java|-Dinstall.javadoc.path=$(DESTDIR)%{_javadocdir}/%{name}|' lib/java/Makefile.*
# build a jar without a version number
#sed -i 's|${thrift.artifactid}-${version}|${thrift.artifactid}|' lib/java/build.xml
# use unversioned doc dirs where appropriate (via _pkgdocdir macro)
export PYTHON=%{_bindir}/python3
#export CC=/opt/llvm16/bin/clang
#export CXX=/opt/llvm16/bin/clang++
%cmake \
-DBUILD_NODEJS=OFF \
-DBUILD_JAVASCRIPT=OFF \
-DBUILD_JAVA=OFF \
-DBUILD_PYTHON=OFF
# build python support
pushd ../lib/py
%py3_build
popd
# build perl support
pushd ../lib/perl
perl Makefile.PL INSTALLDIRS=vendor
%make
popd
%make
%install
%make_install -C build
# install python support
pushd ./lib/py
%py3_install
popd
# install perl support
pushd ./lib/perl
%makeinstall_std
popd
# Remove javadocs jar
%if 0%{?want_java} > 0
find %{buildroot}/%{_javadir} -name lib%{name}-javadoc.jar -exec rm -f '{}' \;
# Add POM file and depmap
mkdir -p %{buildroot}%{_mavenpomdir}
install -pm 644 %{SOURCE1} %{buildroot}%{_mavenpomdir}/JPP-libthrift.pom
%add_maven_depmap JPP-libthrift.pom libthrift.jar
%endif
# Remove bundled jar files
find %{buildroot} -name \*.jar -a \! -name \*thrift\* -exec rm -f '{}' \;
# Remove inneeded perl files
find %{buildroot} -name \*.pod -exec rm -f '{}' \;
find %{buildroot} -name .packlist -exec rm -f '{}' \;
#rm -r %{buildroot}%{_libdir}/perl5
# Ensure all python scripts are executable
find %{buildroot} -name \*.py -exec grep -q /usr/bin/env {} \; -print | xargs -r chmod 755