%define ver_maj 6 %define ver_rel 33.0 %define _disable_source_fetch 0 %bcond_without python %bcond_with java Name: protobuf%{ver_maj} Version: %{ver_maj}.%{ver_rel} Release: 1%{?dist} License: BSD Summary: Protocol Buffers - Google's data interchange format URL: https://github.com/protocolbuffers/protobuf Source0: https://github.com/protocolbuffers/protobuf/archive/v%{ver_rel}%{?rcver}/protobuf-%{ver_rel}%{?rcver}-all.tar.gz Source1: ftdetect-proto.vim Source10: https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java/4.%{ver_rel}/protobuf-java-4.%{ver_rel}.pom Source11: https://repo1.maven.org/maven2/com/google/protobuf/protobuf-javalite/4.%{ver_rel}/protobuf-javalite-4.%{ver_rel}.pom Source12: https://repo1.maven.org/maven2/com/google/protobuf/protobuf-java-util/4.%{ver_rel}/protobuf-java-util-4.%{ver_rel}.pom Patch100: protobuf-SOVERSION.patch BuildRequires: make BuildRequires: cmake BuildRequires: gcc-c++ BuildRequires: ninja-build BuildRequires: cmake(absl) BuildRequires: pkgconfig(zlib) BuildRequires: pkgconfig(gtest) %global _lto_cflags %nil %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. Protocol buffers are a flexible, efficient, automated mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format. %package compiler Summary: Protocol Buffers compiler Requires: %{name} = %{version}-%{release} %description compiler This package contains Protocol Buffers compiler for all programming languages %package devel Summary: Protocol Buffers C++ headers and libraries Requires: %{name} = %{version}-%{release} Requires: %{name}-compiler = %{version}-%{release} Requires: zlib-devel Requires: pkgconfig %description devel This package contains Protocol Buffers compiler for all languages and C++ headers and libraries %package static Summary: Static development files for %{name} Requires: %{name}-devel = %{version}-%{release} %description static Static libraries for Protocol Buffers %package lite Summary: Protocol Buffers LITE_RUNTIME libraries %description lite Protocol Buffers built with optimize_for = LITE_RUNTIME. The "optimize_for = LITE_RUNTIME" option causes the compiler to generate code which only depends libprotobuf-lite, which is much smaller than libprotobuf but lacks descriptors, reflection, and some other features. %package lite-devel Summary: Protocol Buffers LITE_RUNTIME development libraries Requires: %{name}-devel = %{version}-%{release} Requires: %{name}-lite = %{version}-%{release} %description lite-devel This package contains development libraries built with optimize_for = LITE_RUNTIME. The "optimize_for = LITE_RUNTIME" option causes the compiler to generate code which only depends libprotobuf-lite, which is much smaller than libprotobuf but lacks descriptors, reflection, and some other features. %if %{with python} %package -n python%{python3_pkgversion}-%{name} Summary: Python 3 bindings for Google Protocol Buffers BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-setuptools BuildRequires: python%{python3_pkgversion}-wheel Requires: python%{python3_pkgversion}-six >= 1.9 Conflicts: %{name}-compiler > %{version} Conflicts: %{name}-compiler < %{version} Provides: %{name}-python3 = %{version}-%{release} Provides: protobuf-python3 = %{version}-%{release} Obsoletes: protobuf-python3 < %{version} Conflicts: protobuf-python3 < %{version} Obsoletes: python%{python3_pkgversion}-protobuf < %{version}-%{release} Enhances: protobuf-python3 %{?python_provide:%python_provide python%{python3_pkgversion}-%{name}} %description -n python%{python3_pkgversion}-%{name} This package contains Python 3 libraries for Google Protocol Buffers %endif %package vim Summary: Vim syntax highlighting for Google Protocol Buffers descriptions BuildArch: noarch Requires: vim-enhanced %description vim This package contains syntax highlighting for Google Protocol Buffers descriptions in Vim editor %if %{with java} %package java Summary: Java Protocol Buffers runtime library BuildArch: noarch BuildRequires: maven-local BuildRequires: mvn(com.google.code.gson:gson) BuildRequires: mvn(com.google.guava:guava) BuildRequires: mvn(junit:junit) BuildRequires: mvn(org.apache.felix:maven-bundle-plugin) BuildRequires: mvn(org.apache.maven.plugins:maven-antrun-plugin) BuildRequires: mvn(org.apache.maven.plugins:maven-source-plugin) BuildRequires: mvn(org.codehaus.mojo:build-helper-maven-plugin) BuildRequires: mvn(org.easymock:easymock) Conflicts: %{name}-compiler > %{version} Conflicts: %{name}-compiler < %{version} Obsoletes: %{name}-javanano < 3.6.0 %description java This package contains Java Protocol Buffers runtime library. %package javalite Summary: Java Protocol Buffers lite runtime library BuildArch: noarch %description javalite This package contains Java Protocol Buffers lite runtime library. %package java-util Summary: Utilities for Protocol Buffers BuildArch: noarch %description java-util Utilities to work with protos. It contains JSON support as well as utilities to work with proto3 well-known types. %package javadoc Summary: Javadoc for %{name}-java BuildArch: noarch %description javadoc This package contains the API documentation for %{name}-java. %package parent Summary: Protocol Buffer Parent POM BuildArch: noarch %description parent Protocol Buffer Parent POM. %package bom Summary: Protocol Buffer BOM POM BuildArch: noarch %description bom Protocol Buffer BOM POM. %endif %prep %autosetup -p1 -n protobuf-%{ver_rel} find -name \*.cc -o -name \*.h | xargs chmod -x # https://github.com/protocolbuffers/protobuf/issues/8459 sed -e "/^TEST(ArenaTest, BlockSizeSmallerThanAllocation) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" \ -e "/^TEST(ArenaTest, SpaceAllocated_and_Used) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" \ -i src/google/protobuf/arena_unittest.cc # https://github.com/protocolbuffers/protobuf/issues/8460 sed -e "/^TEST(AnyTest, TestPackFromSerializationExceedsSizeLimit) {$/a\\ if (sizeof(void*) == 4) {\n GTEST_SKIP();\n }" -i src/google/protobuf/any_test.cc %if %{with java} cp %{SOURCE10} java/core/pom.xml cp %{SOURCE11} java/lite/pom.xml cp %{SOURCE12} java/util/pom.xml # Remove unnecessary animal sniffer %pom_remove_plugin org.codehaus.mojo:animal-sniffer-maven-plugin java/pom.xml %pom_remove_dep com.google.errorprone:error_prone_annotations java/util/pom.xml %pom_remove_dep com.google.j2objc:j2objc-annotations java/util/pom.xml # Remove annotation libraries we don't have annotations=$( find -name '*.java' | xargs grep -h -e '^import com\.google\.errorprone\.annotation' \ -e '^import com\.google\.j2objc\.annotations' | sort -u | sed 's/.*\.\([^.]*\);/\1/' | paste -sd\| ) find -name '*.java' | xargs sed -ri \ "s/^import .*\.($annotations);//;s/@($annotations)"'\>\s*(\((("[^"]*")|([^)]*))\))?//g' # These use truth or error_prone_annotations or guava-testlib rm -r java/util/src/test/java/com/google/protobuf/util rm -r java/util/src/main/java/com/google/protobuf/util # Make OSGi dependency on sun.misc package optional %pom_xpath_inject "pom:configuration/pom:instructions" "sun.misc;resolution:=optional,*" java/core/pom_template.xml # Backward compatibility symlink %mvn_file :protobuf-java:jar: %{name}/%{name}-java %{name} # This test is incredibly slow on arm # https://github.com/google/protobuf/issues/2389 %ifarch %{arm32} s390x mv java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java \ java/core/src/test/java/com/google/protobuf/IsValidUtf8Test.java.slow mv java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java \ java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java.slow mv java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java \ java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java.slow mv java/core/src/test/java/com/google/protobuf/Proto3SchemaTest.java \ java/core/src/test/java/com/google/protobuf/Proto3SchemaTest.java.slow mv java/core/src/test/java/com/google/protobuf/Proto3LiteSchemaTest.java \ java/core/src/test/java/com/google/protobuf/Proto3LiteSchemaTest.java.slow %endif %endif rm -f src/solaris/libstdc++.la iconv -f iso8859-1 -t utf-8 CONTRIBUTORS.txt > CONTRIBUTORS.txt.utf8 mv CONTRIBUTORS.txt.utf8 CONTRIBUTORS.txt # editions/internal_defaults_escape.cc echo 'add_executable(internal_defaults_escape editions/internal_defaults_escape.cc)' >> CMakeLists.txt echo 'target_link_libraries(internal_defaults_escape ${protobuf_ABSL_USED_TARGETS} ${protobuf_LIB_PROTOBUF} absl_flags_parse)' >> CMakeLists.txt %build export CXXFLAGS="%{build_cxxflags} -Wno-error=type-limits" %cmake -GNinja \ -Dprotobuf_VERBOSE:BOOL=ON \ -Dprotobuf_BUILD_TESTS:BOOL=OFF \ -Dprotobuf_BUILD_LIBPROTOC:BOOL=ON \ -Dprotobuf_LOCAL_DEPENDENCIES_ONLY:BOOL=ON %cmake_build %if %{with python} pushd python %{python3} protobuf_distutils/protobuf_distutils/generate_py_protobufs.py %{python3} protobuf_distutils/setup.py build %{python3} dist/setup.py build popd %endif %if %{with java} pushd java protoc \ --java_out=core/src/main/java \ -I../src \ ../src/google/protobuf/descriptor.proto \ --proto_path=core/src/main/resources/google/protobuf \ core/src/main/resources/google/protobuf/java_features.proto popd %ifarch %ix86 s390x %{arm32} export MAVEN_OPTS=-Xmx1024m %endif %pom_disable_module kotlin java/pom.xml %pom_disable_module kotlin-lite java/pom.xml %mvn_build -s %{!?with_java_tests:--skip-tests} -- -f java/pom.xml %endif %if %{with check} %check export CXXFLAGS="%{build_cxxflags} -Wno-error=type-limits" %ctest %endif %install %cmake_install %if %{with python} pushd python %{python3} dist/setup.py install -O1 --skip-build --root %{buildroot} --prefix /usr --install-lib %{python3_sitearch} %{python3} protobuf_distutils/setup.py install -O1 --skip-build --root %{buildroot} --prefix /usr --install-lib %{python3_sitearch} popd # python_edition_defaults.binpb mkdir -p %{__cmake_builddir}/python %{_builddir}/protobuf-%{ver_rel}/%{__cmake_builddir}/protoc \ --edition_defaults_out %{__cmake_builddir}/python/python_edition_defaults.binpb \ --edition_defaults_minimum PROTO2 \ --edition_defaults_maximum 2024 \ --proto_path %{_builddir}/protobuf-%{ver_rel}/src/ \ google/protobuf/descriptor.proto # python_edition_defaults.py %{_builddir}/protobuf-%{ver_rel}/%{__cmake_builddir}/internal_defaults_escape \ '--encoding=octal' \ '--defaults_path=%{__cmake_builddir}/python/python_edition_defaults.binpb' \ '--template_path=python/google/protobuf/internal/python_edition_defaults.py.template' \ '--output_path=%{buildroot}/%{python3_sitearch}/google/protobuf/internal/python_edition_defaults.py' \ '--placeholder=DEFAULTS_VALUE' # compile python protobufs for f in $(find src/google/protobuf/ -maxdepth 1 -name *.proto | grep -v test | grep -v sample | grep -v late); do echo "Compile Python Protobuf [$f]" %{_builddir}/protobuf-%{ver_rel}/%{__cmake_builddir}/protoc \ --descriptor_set_out=$f.bin \ -I./src -I./src/google/protobuf/ $f \ --retain_options \ --option_dependencies $f %{_builddir}/protobuf-%{ver_rel}/%{__cmake_builddir}/protoc \ --python_out=%{buildroot}/%{python3_sitearch} \ --descriptor_set_in=$f.bin \ --proto_path ./src/ $f done %endif install -p -m 644 -D %{SOURCE1} %{buildroot}%{_datadir}/vim/vimfiles/ftdetect/proto.vim install -p -m 644 -D editors/proto.vim %{buildroot}%{_datadir}/vim/vimfiles/syntax/proto.vim %if %{with java} %mvn_install %endif %files %doc CONTRIBUTORS.txt README.md %license LICENSE %{_libdir}/libprotobuf.so.* %files compiler %doc README.md %license LICENSE %{_bindir}/protoc* %{_libdir}/libprotoc.so.* %{_libdir}/libutf8_range.so.* %{_libdir}/libutf8_validity.so.* %files devel %dir %{_includedir}/google %{_includedir}/google/protobuf/ %{_libdir}/libprotobuf.so %{_libdir}/libprotoc.so %{_libdir}/pkgconfig/* %doc examples/add_person.cc examples/addressbook.proto examples/list_people.cc examples/Makefile examples/README.md %{_libdir}/cmake/* %dir %{_includedir}/upb %{_includedir}/upb/* %{_includedir}/utf8_range.h %{_includedir}/utf8_validity.h %{_libdir}/libutf8_range.so %{_libdir}/libutf8_validity.so %files static %{_libdir}/libupb.a %files lite %{_libdir}/libprotobuf-lite.so.* %files lite-devel %{_libdir}/libprotobuf-lite.so %{_libdir}/pkgconfig/protobuf-lite.pc %if %{with python} %files -n python%{python3_pkgversion}-%{name} %doc python/README.md %doc examples/add_person.py examples/list_people.py examples/addressbook.proto %{python3_sitearch}/* %endif %files vim %{_datadir}/vim/vimfiles/ftdetect/proto.vim %{_datadir}/vim/vimfiles/syntax/proto.vim %if %{with java} %files java -f .mfiles-protobuf-java %doc examples/AddPerson.java examples/ListPeople.java %doc java/README.md %license LICENSE %files java-util -f .mfiles-protobuf-java-util %files javadoc -f .mfiles-javadoc %license LICENSE %files parent -f .mfiles-protobuf-parent %license LICENSE %files bom -f .mfiles-protobuf-bom %license LICENSE %files javalite -f .mfiles-protobuf-javalite %license LICENSE %endif %changelog * Fri Oct 17 2025 Balint Cristian - update release