File protobuf.spec of Package protobuf.39291
#
# spec file for package protobuf
#
# Copyright (c) 2024 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
%{!?make_build:%global make_build make %{?_smp_mflags}}
%{?!python_module:%define python_module() python-%{**} python3-%{**}}
%define tarname protobuf
# requires gmock, which is not yet in the distribution
%bcond_with check
%bcond_without java
%bcond_without python3
%{?sle15_python_module_pythons}
%global protoc_arch %{_arch}
%ifarch x86_64 %{?x86_64}
%global protoc_arch x86_64
%endif
%ifarch ppc
%global protoc_arch ppc_32
%endif
%ifarch ppc64
%global protoc_arch ppc_64
%endif
%ifarch ppc64le
%global protoc_arch ppcle_64
%endif
%ifarch %{ix86}
%global protoc_arch x86_32
%endif
%ifarch ia64
%global protoc_arch itanium_64
%endif
%ifarch s390
%global protoc_arch s390_32
%endif
%ifarch s390x
%global protoc_arch s390_64
%endif
%ifarch %{arm}
%global protoc_arch arm_32
%endif
%ifarch aarch64 %{arm64}
%global protoc_arch aarch_64
%endif
# 32 bit sparc, optimized for v9
%ifarch sparcv9
%global protoc_arch sparc_32
%endif
# 64 bit sparc
%ifarch sparc64
%global protoc_arch sparc_64
%endif
%global __requires_exclude_from ^%{_datadir}/maven-metadata/%{name}-protoc.xml$
Name: protobuf
Version: 25.1
%global sover 25_1_0
Release: 0
Summary: Protocol Buffers - Google's data interchange format
License: BSD-3-Clause
Group: Development/Libraries/C and C++
URL: https://github.com/protocolbuffers/protobuf
Source0: https://github.com/protocolbuffers/protobuf/archive/v%{version}.tar.gz#/%{tarname}-%{version}.tar.gz
Source1: baselibs.conf
Source1000: %{name}-rpmlintrc
Patch0: add-missing-stdint-header.patch
# PATCH-FIX-UPSTREAM - Fix StackOverflow vulnerability in Protocol Buffers (CVE-2024-7254)
Patch1: CVE-2024-7254.patch
# PATCH-FIX-UPSTREAM - Fix parsing of untrusted Protocol Buffers data containing an arbitrary
# number of recursive groups or messages can lead to crash due to RecursionError (CVE-2025-4565)
Patch2: CVE-2025-4565.patch
BuildRequires: %{python_module abseil}
BuildRequires: %{python_module devel >= 3.7}
BuildRequires: %{python_module python-dateutil}
BuildRequires: %{python_module setuptools}
BuildRequires: abseil-cpp-devel >= 20230125
BuildRequires: cmake
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: python-rpm-macros
BuildRequires: pkgconfig(zlib)
%if %{with check}
BuildRequires: libgmock-devel >= 1.7.0
%endif
%if %{with java}
BuildRequires: java-devel >= 1.8
BuildRequires: maven-local
BuildRequires: mvn(com.google.code.findbugs:jsr305)
BuildRequires: mvn(com.google.code.gson:gson)
BuildRequires: mvn(com.google.errorprone:error_prone_annotations)
BuildRequires: mvn(com.google.guava:guava)
BuildRequires: mvn(com.google.j2objc:j2objc-annotations)
BuildRequires: mvn(org.apache.felix:maven-bundle-plugin)
BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin)
BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin)
%endif
%if 0%{?suse_version} >= 1500
# generate subpackages for every python3 flavor
%define python_subpackage_only 1
%python_subpackages
%else
# same "defaults" for all distributions, used in files section
%define python_files() -n python3-%{**}
%define python_sitelib %{python3_sitelib}
%endif
%description
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
%package -n libprotobuf%{sover}
Summary: Protocol Buffers - Google's data interchange format
Group: System/Libraries
%description -n libprotobuf%{sover}
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
%package -n libprotoc%{sover}
Summary: Protocol Buffers - Google's data interchange format
Group: System/Libraries
%description -n libprotoc%{sover}
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
%package -n libprotobuf-lite%{sover}
Summary: Protocol Buffers - Google's data interchange format
Group: System/Libraries
%description -n libprotobuf-lite%{sover}
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
%package devel
Summary: Header files, libraries and development documentation for %{name}
Group: Development/Libraries/C and C++
Requires: abseil-cpp-devel >= 20230125
Requires: gcc-c++
Requires: libprotobuf%{sover} = %{VERSION}
Requires: libprotobuf-lite%{sover}
Requires: pkgconfig(zlib)
Conflicts: protobuf2-devel
Conflicts: protobuf21-devel
Provides: libprotobuf-devel = %{VERSION}
%description devel
Protocol Buffers are a way of encoding structured data in an efficient yet
extensible format. Google uses Protocol Buffers for almost all of its internal
RPC protocols and file formats.
%if 0%{?python_subpackage_only}
%package -n python-%{name}
Version: 4.%{VERSION}
Summary: Python Bindings for Google Protocol Buffers
Group: Development/Libraries/Python
%description -n python-%{name}
This package contains the Python bindings for Google Protocol Buffers.
%else
%package -n python3-%{name}
Version: 4.%{VERSION}
Summary: Python3 Bindings for Google Protocol Buffers
Group: Development/Libraries/Python
%description -n python3-%{name}
This package contains the Python bindings for Google Protocol Buffers.
%endif
%package java
Summary: Java Bindings for Google Protocol Buffers
Group: Development/Libraries/Java
Requires: java >= 1.6.0
BuildArch: noarch
%description java
This package contains the Java bindings for Google Protocol Buffers.
%package java-bom
Summary: Java Bindings for Google Protocol Buffers
Group: Development/Libraries/Java
BuildArch: noarch
%description java-bom
This package contains the Java bindings for Google Protocol Buffers.
%package java-parent
Summary: Java Bindings for Google Protocol Buffers
Group: Development/Libraries/Java
BuildArch: noarch
%description java-parent
This package contains the Java bindings for Google Protocol Buffers.
%prep
%autosetup -p1 -n %{tarname}-%{VERSION}
# python module have their own version specified in python/google/protobuf/__init__.py
grep -qF "'4.%{VERSION}'" python/google/protobuf/__init__.py
# The previous blank line is crucial for older system being able
# to use the autosetup macro
mkdir gmock
%if %{with python3}
# only needed for test suite which we don't call anyways.
# googleapis is broken on sle12
sed -i '/apputils/d' python/setup.py
sed -i '/google_test_dir/d' python/setup.py
%endif
# kill shebang that we do not really want
sed -i -e '/env python/d' python/google/protobuf/internal/*.py
%if %{with java}
pushd java
%pom_disable_module kotlin
%pom_disable_module kotlin-lite
%pom_remove_plugin -r :animal-sniffer-maven-plugin
%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:source" "1.8"
%pom_xpath_set "pom:plugin[pom:artifactId[text()='maven-compiler-plugin']]/pom:configuration/pom:target" "1.8"
%{mvn_package} :{*}-parent parent
%{mvn_package} :{*}-bom bom
%{mvn_file} :{*} @1
%{mvn_file} :%{name}-java %{name}
popd
%endif
%build
%global _lto_cflags %{_lto_cflags} -ffat-lto-objects
# tests are not part of offical tar ball
%cmake \
-Dprotobuf_BUILD_TESTS=OFF \
-Dprotobuf_ABSL_PROVIDER=package
%cmake_build
%if %{with java}
pushd ../java
%{mvn_build} -jf -- -Dprotoc=$(pwd)/../build/protoc -Dmaven.compiler.source=8 -Dmaven.compiler.target=8
popd
%endif
pushd ../python
export PROTOC=../build/protoc
%python_build
popd
%if %{with check}
%check
%make_build check
%endif
%install
%cmake_install
install -Dm 0644 editors/proto.vim %{buildroot}%{_datadir}/vim/site/syntax/proto.vim
%if %{with java}
pushd java
%mvn_install
# create maven metadata for the protoc executable
install -dm 0755 %{buildroot}%{_datadir}/maven-metadata
cat <<__PROTOBUF__ >>%{buildroot}%{_datadir}/maven-metadata/%{name}-protoc.xml
<metadata xmlns="http://fedorahosted.org/xmvn/METADATA/2.3.0">
<artifacts>
<artifact>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<extension>exe</extension>
<classifier>linux-%{protoc_arch}</classifier>
<version>3.%{version}</version>
<path>%{_bindir}/protoc</path>
</artifact>
</artifacts>
</metadata>
__PROTOBUF__
popd
%endif
pushd python
export PROTOC=../build/protoc
%python_install
popd
%python_expand %fdupes %{buildroot}%{$python_sitelib}
%fdupes %{buildroot}%{_prefix}
%post -n libprotobuf%{sover} -p /sbin/ldconfig
%postun -n libprotobuf%{sover} -p /sbin/ldconfig
%post -n libprotoc%{sover} -p /sbin/ldconfig
%postun -n libprotoc%{sover} -p /sbin/ldconfig
%post -n libprotobuf-lite%{sover} -p /sbin/ldconfig
%postun -n libprotobuf-lite%{sover} -p /sbin/ldconfig
%files -n libprotobuf%{sover}
%license LICENSE
%{_libdir}/libprotobuf.so.%{VERSION}.0
%files -n libprotoc%{sover}
%{_libdir}/libprotoc.so.%{VERSION}.0
%files -n libprotobuf-lite%{sover}
%{_libdir}/libprotobuf-lite.so.%{VERSION}.0
%files devel
%doc CONTRIBUTORS.txt README.md
%{_bindir}/protoc*
%{_includedir}/google
%dir %{_includedir}/java
%dir %{_includedir}/java/core
%dir %{_includedir}/java/core/src
%dir %{_includedir}/java/core/src/main
%dir %{_includedir}/java/core/src/main/java
%dir %{_includedir}/java/core/src/main/java/com
%dir %{_includedir}/java/core/src/main/java/com/google
%dir %{_includedir}/java/core/src/main/java/com/google/protobuf
%{_includedir}/java/core/src/main/java/com/google/protobuf/java_features.proto
%{_includedir}/*.h
%{_libdir}/cmake/protobuf
%{_libdir}/cmake/utf8_range
%{_libdir}/pkgconfig/*
%{_libdir}/libprotobuf-lite.so
%{_libdir}/libprotobuf.so
%{_libdir}/libprotoc.so
%{_libdir}/libutf8_range.a
%{_libdir}/libutf8_validity.a
%{_datadir}/vim
%if %{with java}
%{_datadir}/maven-metadata/%{name}-protoc.xml
%endif
%if %{with java}
%files java -f java/.mfiles
%files java-bom -f java/.mfiles-bom
%files java-parent -f java/.mfiles-parent
%endif
%if %{with python3}
%files %{python_files %{name}}
%license LICENSE
%dir %{python_sitelib}/google
%{python_sitelib}/google/protobuf
%{python_sitelib}/protobuf*nspkg.pth
%{python_sitelib}/protobuf*info
%endif
%changelog