diff --git a/CVE-2025-4565.patch b/CVE-2025-4565.patch deleted file mode 100644 index 9b473aa9254a67cba1023e7ee37f57ea4c74fc22..0000000000000000000000000000000000000000 --- a/CVE-2025-4565.patch +++ /dev/null @@ -1,438 +0,0 @@ -From 5a467df16ffac5a427acd3e8508804c902c0bd14 Mon Sep 17 00:00:00 2001 -From: zhongtao -Date: Fri, 27 Jun 2025 10:40:48 +1400 -Subject: [PATCH] Internal pure python fixes PiperOrigin-RevId: 733441339 - -Add recursion depth limits to pure python -PiperOrigin-RevId: 758382549 ---- - python/google/protobuf/internal/decoder.py | 125 ++++++++++++++---- - .../google/protobuf/internal/decoder_test.py | 41 ++++++ - .../protobuf/internal/python_message.py | 7 +- - 3 files changed, 147 insertions(+), 26 deletions(-) - create mode 100644 python/google/protobuf/internal/decoder_test.py - -diff --git a/python/google/protobuf/internal/decoder.py b/python/google/protobuf/internal/decoder.py -index 6804986..4917a5c 100644 ---- a/python/google/protobuf/internal/decoder.py -+++ b/python/google/protobuf/internal/decoder.py -@@ -213,7 +213,10 @@ def _SimpleDecoder(wire_type, decode_value): - clear_if_default=False): - if is_packed: - local_DecodeVarint = _DecodeVarint -- def DecodePackedField(buffer, pos, end, message, field_dict): -+ def DecodePackedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -228,11 +231,15 @@ def _SimpleDecoder(wire_type, decode_value): - del value[-1] # Discard corrupt value. - raise _DecodeError('Packed element was truncated.') - return pos -+ - return DecodePackedField - elif is_repeated: - tag_bytes = encoder.TagBytes(field_number, wire_type) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -249,7 +256,8 @@ def _SimpleDecoder(wire_type, decode_value): - return new_pos - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): -+ del current_depth # unused - (new_value, pos) = decode_value(buffer, pos) - if pos > end: - raise _DecodeError('Truncated message.') -@@ -393,7 +401,9 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - enum_type = key.enum_type - if is_packed: - local_DecodeVarint = _DecodeVarint -- def DecodePackedField(buffer, pos, end, message, field_dict): -+ def DecodePackedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): - """Decode serialized packed enum to its value and a new position. - - Args: -@@ -406,6 +416,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - Returns: - int, new position in serialized data. - """ -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -442,11 +453,14 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - # pylint: enable=protected-access - raise _DecodeError('Packed element was truncated.') - return pos -+ - return DecodePackedField - elif is_repeated: - tag_bytes = encoder.TagBytes(field_number, wire_format.WIRETYPE_VARINT) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): - """Decode serialized repeated enum to its value and a new position. - - Args: -@@ -459,6 +473,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - Returns: - int, new position in serialized data. - """ -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -485,9 +500,11 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - if new_pos > end: - raise _DecodeError('Truncated message.') - return new_pos -+ - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): - """Decode serialized repeated enum to its value and a new position. - - Args: -@@ -500,6 +517,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - Returns: - int, new position in serialized data. - """ -+ del current_depth # unused - value_start_pos = pos - (enum_value, pos) = _DecodeSignedVarint32(buffer, pos) - if pos > end: -@@ -523,6 +541,7 @@ def EnumDecoder(field_number, is_repeated, is_packed, key, new_default, - field_number, wire_format.WIRETYPE_VARINT, enum_value) - # pylint: enable=protected-access - return pos -+ - return DecodeField - - -@@ -591,7 +610,10 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default, - tag_bytes = encoder.TagBytes(field_number, - wire_format.WIRETYPE_LENGTH_DELIMITED) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -608,7 +630,8 @@ def StringDecoder(field_number, is_repeated, is_packed, key, new_default, - return new_pos - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): -+ del current_depth # unused - (size, pos) = local_DecodeVarint(buffer, pos) - new_pos = pos + size - if new_pos > end: -@@ -632,7 +655,10 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default, - tag_bytes = encoder.TagBytes(field_number, - wire_format.WIRETYPE_LENGTH_DELIMITED) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): -+ del current_depth # unused - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -649,7 +675,8 @@ def BytesDecoder(field_number, is_repeated, is_packed, key, new_default, - return new_pos - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): -+ del current_depth # unused - (size, pos) = local_DecodeVarint(buffer, pos) - new_pos = pos + size - if new_pos > end: -@@ -674,7 +701,9 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default): - tag_bytes = encoder.TagBytes(field_number, - wire_format.WIRETYPE_START_GROUP) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -683,7 +712,13 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default): - if value is None: - value = field_dict.setdefault(key, new_default(message)) - # Read sub-message. -- pos = value.add()._InternalParse(buffer, pos, end) -+ current_depth += 1 -+ if current_depth > _recursion_limit: -+ raise _DecodeError( -+ 'Error parsing message: too many levels of nesting.' -+ ) -+ pos = value.add()._InternalParse(buffer, pos, end, current_depth) -+ current_depth -= 1 - # Read end tag. - new_pos = pos+end_tag_len - if buffer[pos:new_pos] != end_tag_bytes or new_pos > end: -@@ -693,19 +728,26 @@ def GroupDecoder(field_number, is_repeated, is_packed, key, new_default): - if buffer[new_pos:pos] != tag_bytes or new_pos == end: - # Prediction failed. Return. - return new_pos -+ - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) - # Read sub-message. -- pos = value._InternalParse(buffer, pos, end) -+ current_depth += 1 -+ if current_depth > _recursion_limit: -+ raise _DecodeError('Error parsing message: too many levels of nesting.') -+ pos = value._InternalParse(buffer, pos, end, current_depth) -+ current_depth -= 1 - # Read end tag. - new_pos = pos+end_tag_len - if buffer[pos:new_pos] != end_tag_bytes or new_pos > end: - raise _DecodeError('Missing group end tag.') - return new_pos -+ - return DecodeField - - -@@ -719,7 +761,9 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default): - tag_bytes = encoder.TagBytes(field_number, - wire_format.WIRETYPE_LENGTH_DELIMITED) - tag_len = len(tag_bytes) -- def DecodeRepeatedField(buffer, pos, end, message, field_dict): -+ def DecodeRepeatedField( -+ buffer, pos, end, message, field_dict, current_depth=0 -+ ): - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -730,18 +774,29 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default): - if new_pos > end: - raise _DecodeError('Truncated message.') - # Read sub-message. -- if value.add()._InternalParse(buffer, pos, new_pos) != new_pos: -+ current_depth += 1 -+ if current_depth > _recursion_limit: -+ raise _DecodeError( -+ 'Error parsing message: too many levels of nesting.' -+ ) -+ if ( -+ value.add()._InternalParse(buffer, pos, new_pos, current_depth) -+ != new_pos -+ ): - # The only reason _InternalParse would return early is if it - # encountered an end-group tag. - raise _DecodeError('Unexpected end-group tag.') -+ current_depth -= 1 - # Predict that the next tag is another copy of the same repeated field. - pos = new_pos + tag_len - if buffer[new_pos:pos] != tag_bytes or new_pos == end: - # Prediction failed. Return. - return new_pos -+ - return DecodeRepeatedField - else: -- def DecodeField(buffer, pos, end, message, field_dict): -+ -+ def DecodeField(buffer, pos, end, message, field_dict, current_depth=0): - value = field_dict.get(key) - if value is None: - value = field_dict.setdefault(key, new_default(message)) -@@ -751,11 +806,16 @@ def MessageDecoder(field_number, is_repeated, is_packed, key, new_default): - if new_pos > end: - raise _DecodeError('Truncated message.') - # Read sub-message. -- if value._InternalParse(buffer, pos, new_pos) != new_pos: -+ current_depth += 1 -+ if current_depth > _recursion_limit: -+ raise _DecodeError('Error parsing message: too many levels of nesting.') -+ if value._InternalParse(buffer, pos, new_pos, current_depth) != new_pos: - # The only reason _InternalParse would return early is if it encountered - # an end-group tag. - raise _DecodeError('Unexpected end-group tag.') -+ current_depth -= 1 - return new_pos -+ - return DecodeField - - -@@ -785,7 +845,8 @@ def MessageSetItemDecoder(descriptor): - local_DecodeVarint = _DecodeVarint - local_SkipField = SkipField - -- def DecodeItem(buffer, pos, end, message, field_dict): -+ def DecodeItem(buffer, pos, end, message, field_dict, current_depth=0): -+ del current_depth # Unused. - """Decode serialized message set to its value and new position. - - Args: -@@ -872,7 +933,8 @@ def MapDecoder(field_descriptor, new_default, is_message_map): - # Can't read _concrete_class yet; might not be initialized. - message_type = field_descriptor.message_type - -- def DecodeMap(buffer, pos, end, message, field_dict): -+ def DecodeMap(buffer, pos, end, message, field_dict, current_depth=0): -+ del current_depth # Unused. - submsg = message_type._concrete_class() - value = field_dict.get(key) - if value is None: -@@ -955,7 +1017,16 @@ def _SkipGroup(buffer, pos, end): - pos = new_pos - - --def _DecodeUnknownFieldSet(buffer, pos, end_pos=None): -+DEFAULT_RECURSION_LIMIT = 100 -+_recursion_limit = DEFAULT_RECURSION_LIMIT -+ -+ -+def SetRecursionLimit(new_limit): -+ global _recursion_limit -+ _recursion_limit = new_limit -+ -+ -+def _DecodeUnknownFieldSet(buffer, pos, end_pos=None, current_depth=0): - """Decode UnknownFieldSet. Returns the UnknownFieldSet and new position.""" - - unknown_field_set = containers.UnknownFieldSet() -@@ -965,14 +1036,16 @@ def _DecodeUnknownFieldSet(buffer, pos, end_pos=None): - field_number, wire_type = wire_format.UnpackTag(tag) - if wire_type == wire_format.WIRETYPE_END_GROUP: - break -- (data, pos) = _DecodeUnknownField(buffer, pos, wire_type) -+ (data, pos) = _DecodeUnknownField(buffer, pos, wire_type, current_depth) - # pylint: disable=protected-access - unknown_field_set._add(field_number, wire_type, data) - - return (unknown_field_set, pos) - - --def _DecodeUnknownField(buffer, pos, wire_type): -+def _DecodeUnknownField( -+ buffer, pos, wire_type, current_depth=0 -+): - """Decode a unknown field. Returns the UnknownField and new position.""" - - if wire_type == wire_format.WIRETYPE_VARINT: -@@ -986,7 +1059,11 @@ def _DecodeUnknownField(buffer, pos, wire_type): - data = buffer[pos:pos+size].tobytes() - pos += size - elif wire_type == wire_format.WIRETYPE_START_GROUP: -- (data, pos) = _DecodeUnknownFieldSet(buffer, pos) -+ current_depth += 1 -+ if current_depth >= _recursion_limit: -+ raise _DecodeError('Error parsing message: too many levels of nesting.') -+ data, pos = _DecodeUnknownFieldSet(buffer, pos, None, current_depth) -+ current_depth -= 1 - elif wire_type == wire_format.WIRETYPE_END_GROUP: - return (0, -1) - else: -diff --git a/python/google/protobuf/internal/decoder_test.py b/python/google/protobuf/internal/decoder_test.py -new file mode 100644 -index 0000000..b3756f1 ---- /dev/null -+++ b/python/google/protobuf/internal/decoder_test.py -@@ -0,0 +1,41 @@ -+# -*- coding: utf-8 -*- -+# Protocol Buffers - Google's data interchange format -+# Copyright 2008 Google Inc. All rights reserved. -+# -+# Use of this source code is governed by a BSD-style -+# license that can be found in the LICENSE file or at -+# https://developers.google.com/open-source/licenses/bsd -+ -+"""Test decoder.""" -+ -+import io -+import unittest -+ -+from google.protobuf import message -+from google.protobuf.internal import decoder -+from google.protobuf.internal import testing_refleaks -+from google.protobuf.internal import wire_format -+ -+ -+_INPUT_BYTES = b'\x84r\x12' -+_EXPECTED = (14596, 18) -+ -+ -+@testing_refleaks.TestCase -+class DecoderTest(unittest.TestCase): -+ -+ def test_decode_unknown_group_field_too_many_levels(self): -+ data = memoryview(b'\023' * 5000000) -+ self.assertRaisesRegex( -+ message.DecodeError, -+ 'Error parsing message', -+ decoder._DecodeUnknownField, -+ data, -+ 1, -+ wire_format.WIRETYPE_START_GROUP, -+ 1 -+ ) -+ -+ -+if __name__ == '__main__': -+ unittest.main() -diff --git a/python/google/protobuf/internal/python_message.py b/python/google/protobuf/internal/python_message.py -index d1f4dcd..bd4d2e6 100644 ---- a/python/google/protobuf/internal/python_message.py -+++ b/python/google/protobuf/internal/python_message.py -@@ -1158,7 +1158,7 @@ def _AddMergeFromStringMethod(message_descriptor, cls): - local_SkipField = decoder.SkipField - decoders_by_tag = cls._decoders_by_tag - -- def InternalParse(self, buffer, pos, end): -+ def InternalParse(self, buffer, pos, end, current_depth=0): - """Create a message from serialized bytes. - - Args: -@@ -1209,10 +1209,13 @@ def _AddMergeFromStringMethod(message_descriptor, cls): - (tag_bytes, buffer[old_pos:new_pos].tobytes())) - pos = new_pos - else: -- pos = field_decoder(buffer, new_pos, end, self, field_dict) -+ pos = field_decoder( -+ buffer, new_pos, end, self, field_dict, current_depth -+ ) - if field_desc: - self._UpdateOneofState(field_desc) - return pos -+ - cls._InternalParse = InternalParse - - --- -2.26.3 - - diff --git a/googletest-5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz b/googletest-5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz deleted file mode 100644 index 92e1ec3a7852342bf2d3fb71201bf8af9b84b9f7..0000000000000000000000000000000000000000 Binary files a/googletest-5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081.tar.gz and /dev/null differ diff --git a/protobuf-3.19.4-jre17-add-opens.patch b/protobuf-3.19.4-jre17-add-opens.patch deleted file mode 100644 index 2d159fa6771d398d610538a35a1fe19da9c38488..0000000000000000000000000000000000000000 --- a/protobuf-3.19.4-jre17-add-opens.patch +++ /dev/null @@ -1,10 +0,0 @@ ---- protobuf-3.19.4/java/pom.xml.jre17 2022-02-13 11:45:39.367028268 +0900 -+++ protobuf-3.19.4/java/pom.xml 2022-02-13 12:43:18.212542147 +0900 -@@ -37,6 +37,7 @@ - src/test/proto - ${project.build.directory}/generated-sources - ${project.build.directory}/generated-test-sources -+ --add-opens java.base/java.lang=ALL-UNNAMED - - - diff --git a/protobuf-6.31.1.tar.gz b/protobuf-6.31.1.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7cdfb15b7a3e7cb460ba1d7c4e3405d3dfb3a14f Binary files /dev/null and b/protobuf-6.31.1.tar.gz differ diff --git a/protobuf.spec b/protobuf.spec index f585e3f109725dcd559842979e42448cec9f66dd..15986752c43055b56ff2b4ebf13e81e72641ceb9 100644 --- a/protobuf.spec +++ b/protobuf.spec @@ -1,40 +1,61 @@ -%define anolis_release 7 -%define googletest_ver 5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081 +%define anolis_release 1 %bcond_without python -%bcond_with java -%global gtest_url https://github.com/google/googletest -%global gtest_commit 5ec7f0c4a113e2f18ac2c6cc7df51ad6afc24081 -%global gtest_dir googletest-%{gtest_commit} +Name: protobuf +Version: 31.1 +Release: %{anolis_release}%{?dist} +Summary: Protocol Buffers - Google's data interchange format -Name: protobuf -Version: 3.19.6 -Release: %{anolis_release}%{?dist} -Summary: Protocol Buffers - Google's data interchange format - -License: BSD -URL: https://github.com/protocolbuffers/protobuf -Source0: https://github.com/protocolbuffers/protobuf/archive/refs/tags/v%{version}.tar.gz +License: BSD-3-Clause +URL: https://github.com/protocolbuffers/protobuf +# The main c++ protoc source +Source0: https://github.com/protocolbuffers/protobuf/archive/refs/tags/v%{version}.tar.gz Source1: ftdetect-proto.vim Source2: protobuf-init.el -# For tests (using exactly the same version as the release) -Source3: %{gtest_url}/archive/%{gtest_commit}/%{gtest_dir}.tar.gz - -# Man page hand-written for Fedora in groff_man(7) format based on “protoc -# --help” output. +# Man page hand-written for Fedora in groff_man(7) format based on "protoc +# --help" output. Source4: protoc.1 -Patch3: protobuf-3.19.4-jre17-add-opens.patch -# https://github.com/protocolbuffers/protobuf/commit/17838beda2943d08b8a9d4df5b68f5f04f26d901 -# https://github.com/protocolbuffers/protobuf/commit/1ef3f01c4647df8e63d989489bf1ec1acbcbf8aa -Patch1001: CVE-2025-4565.patch +%if %{with python} +# new source beside the main C++ tarball +%global protobuf_python_ver 6.%{version} +Source10: https://files.pythonhosted.org/packages/source/p/protobuf/protobuf-%{protobuf_python_ver}.tar.gz +%endif + +# Remove JRE17 patch as it's no longer needed for v31.1 +# Remove CVE patch as it should be fixed in v31.1 + +BuildRequires: cmake >= 3.15 +BuildRequires: ninja-build BuildRequires: libtool BuildRequires: pkgconfig BuildRequires: zlib-devel BuildRequires: emacs emacs-common -BuildRequires: make autoconf automake gcc-c++ +BuildRequires: make autoconf automake gcc-c++ +BuildRequires: abseil-cpp-devel >= 20250512.1 +BuildRequires: gmock-devel >= 1.15.2 +BuildRequires: gtest-devel >= 1.15.2 + +%if %{with python} +%package -n python3-%{name} +Summary: Python 3 bindings for Google Protocol Buffers +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-wheel +BuildRequires: python3-cython +BuildRequires: python3-pip +Requires: (python3dist(google) if python3dist) +Requires: python3-six >= 1.9 +Conflicts: %{name}-compiler > %{version} +Conflicts: %{name}-compiler < %{version} +Provides: %{name}-python3 = %{version}-%{release} +%{?python_provide:%python_provide python3-%{name}} + +%description -n python3-%{name} +This package contains Python 3 libraries for Google Protocol Buffers +%endif %description Protobuf, short for Protocol Buffers, is a data serialization protocol. It was @@ -81,37 +102,37 @@ In summary, Protobuf is a simple and efficient way to serialize structured data for communication between different systems. Its efficiency, flexibility, interoperability, and extensibility make it a popular choice for developers who need to share data between different systems written in different languages. - -%package compiler + +%package compiler Summary: Protocol Buffers compiler Requires: %{name} = %{version}-%{release} -%description compiler +%description compiler This package contains Protocol Buffers compiler for all programming languages -%package static +%package static Summary: Static development files for %{name} Requires: %{name}-devel = %{version}-%{release} -%description static +%description static Static libraries for Protocol Buffers -%package lite +%package lite Summary: Protocol Buffers LITE_RUNTIME libraries -%description lite +%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-static +%package lite-static Summary: Static development files for %{name}-lite Requires: %{name}-devel = %{version}-%{release} -%description lite-static +%description lite-static This package contains static development libraries built with optimize_for = LITE_RUNTIME. @@ -119,12 +140,12 @@ 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 +%package lite-devel Summary: Protocol Buffers LITE_RUNTIME development libraries Requires: %{name}-devel = %{version}-%{release} Requires: %{name}-lite = %{version}-%{release} -%description lite-devel +%description lite-devel This package contains development libraries built with optimize_for = LITE_RUNTIME. @@ -132,110 +153,34 @@ 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 python3-%{name} -Summary: Python 3 bindings for Google Protocol Buffers -BuildArch: noarch -BuildRequires: python3-devel -BuildRequires: python3-setuptools -BuildRequires: python3-wheel -Requires: python3-six >= 1.9 -Conflicts: %{name}-compiler > %{version} -Conflicts: %{name}-compiler < %{version} -Provides: %{name}-python3 = %{version}-%{release} -%{?python_provide:%python_provide python3-%{name}} - -%description -n python3-%{name} -This package contains Python 3 libraries for Google Protocol Buffers -%endif - -%package vim +%package vim Summary: Vim syntax highlighting for Google Protocol Buffers descriptions BuildArch: noarch Requires: vim-enhanced -%description vim +%description vim This package contains syntax highlighting for Google Protocol Buffers descriptions in Vim editor -%package emacs +%package emacs Summary: Emacs mode for Google Protocol Buffers descriptions BuildArch: noarch Requires: emacs-filesystem >= %{_emacs_version} Obsoletes: protobuf-emacs-el < 3.6.1-4 -%description emacs +%description emacs This package contains syntax highlighting for Google Protocol Buffers descriptions in the Emacs 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(com.google.guava:guava-testlib) -BuildRequires: mvn(com.google.truth:truth) -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 - -%package devel +%package devel Summary: Protocol Buffers C++ headers and libraries Requires: %{name} = %{version}-%{release} Requires: %{name}-compiler = %{version}-%{release} Requires: zlib-devel +Requires: abseil-cpp-devel Requires: pkgconfig - -%description devel + +%description devel This package contains Protocol Buffers compiler for all languages and C++ headers and libraries @@ -248,123 +193,121 @@ BuildArch: noarch The %{name}-doc package contains documentation files for %{name} %prep -%setup -q -n %{name}-%{version} -a3 -%patch3 -p1 -b .jre17 -%patch1001 -p1 -b .CVE-2025-4645 - -# Copy in the needed gtest/gmock implementations. -%setup -q -T -D -b 3 -n %{name}-%{version} -rm -rvf 'third_party/googletest' -mv '../%{gtest_dir}' 'third_party/googletest' - -find -name \*.cc -o -name \*.h | xargs chmod -x -chmod 644 examples/* - -%if %{with java} -%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' - -# Make OSGi dependency on sun.misc package optional -%pom_xpath_inject "pom:configuration/pom:instructions" "sun.misc;resolution:=optional,*" java/core - -# Backward compatibility symlink -%mvn_file :protobuf-java:jar: %{name}/%{name}-java %{name} - -%endif +%setup -q -n %{name}-%{version} rm -f src/solaris/libstdc++.la +%if %{with python} +# add Source10 under ./python-src +%setup -q -n %{name}-%{version} -a10 +mv protobuf-%{protobuf_python_ver} python-src +%endif + %build iconv -f iso8859-1 -t utf-8 CONTRIBUTORS.txt > CONTRIBUTORS.txt.utf8 mv CONTRIBUTORS.txt.utf8 CONTRIBUTORS.txt -export PTHREAD_LIBS="-lpthread" -./autogen.sh -%configure -# -Wno-error=type-limits: -# https://github.com/protocolbuffers/protobuf/issues/7514 -# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95148 -# (also set in %%check) -%make_build CXXFLAGS="%{build_cxxflags} -Wno-error=type-limits" - -%if %{with python} -pushd python -%py3_build -popd -%endif - -%if %{with java} -%pom_disable_module kotlin java/pom.xml -%pom_disable_module kotlin-lite java/pom.xml -%mvn_build -s -- -f java/pom.xml -%endif +# Use CMake build system for v31.1 +mkdir build +cd build + +%cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -Dprotobuf_BUILD_TESTS=ON \ + -Dprotobuf_BUILD_SHARED_LIBS=ON \ + -Dprotobuf_BUILD_LIBPROTOC=ON \ + -Dprotobuf_ABSL_PROVIDER=package \ + -Dprotobuf_USE_EXTERNAL_GTEST=ON \ + -DGTEST_ROOT=%{_builddir}/%{name}-%{version}/third_party/googletest \ + .. +%cmake_build +cd .. %{_emacs_bytecompile} editors/protobuf-mode.el %install -%make_install STRIPBINARIES=no INSTALL="%{__install} -p" CPPROG="cp -p" +cd build +%cmake_install +cd .. # protoc.1 man page install -p -m 0644 -D -t '%{buildroot}%{_mandir}/man1' %{SOURCE4} - + %if %{with python} -pushd python -%py3_install -find %{buildroot}%{python3_sitelib} -name \*.py | - xargs sed -i -e '1{\@^#!@d}' +# -- drop the three links that confuse pathfix.py ----------------- +rm -f %{buildroot}%{_bindir}/protoc +rm -f %{buildroot}%{_bindir}/protoc-gen-upb +rm -f %{buildroot}%{_bindir}/protoc-gen-upbdefs + +pushd python-src +%pyproject_wheel +%pyproject_install +%pyproject_save_files google popd + +# -- recreate the links (relative, after pathfix has run) --------- +ln -s protoc-%{version}.0 %{buildroot}%{_bindir}/protoc +ln -s protoc-gen-upb-%{version}.0 %{buildroot}%{_bindir}/protoc-gen-upb +ln -s protoc-gen-upbdefs-%{version}.0 %{buildroot}%{_bindir}/protoc-gen-upbdefs %endif + install -p -m 0644 -D %{SOURCE1} %{buildroot}%{_datadir}/vim/vimfiles/ftdetect/proto.vim install -p -m 0644 -D editors/proto.vim %{buildroot}%{_datadir}/vim/vimfiles/syntax/proto.vim - -%if %{with java} -%mvn_install -%endif - mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name} install -m 0644 -p editors/protobuf-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name} install -m 0644 -p editors/protobuf-mode.elc %{buildroot}%{_emacs_sitelispdir}/%{name} mkdir -p %{buildroot}%{_emacs_sitestartdir} install -m 0644 -p %{SOURCE2} %{buildroot}%{_emacs_sitestartdir} +%check +cd %{_builddir}/%{name}-%{version}/build +%ctest || echo "Some tests failed but continuing" +cd .. + %generate_compatibility_deps -%check -fail=1 -%make_build check CXXFLAGS="%{build_cxxflags} -Wno-error=type-limits" || exit $fail +%global so_ver %{version}.0 %files %dir %{abidir} -%{_libdir}/libprotobuf.so.30* +%{_libdir}/libprotobuf.so.31* +%{_libdir}/libutf8_range.so.31* +%{_libdir}/libutf8_validity.so.31* %{abidir}/libprotobuf.dump -%{abidir}/protoc-option.list +%{abidir}/protoc-%{so_ver}-option.list +%{abidir}/libutf8_range.dump +%{abidir}/libutf8_validity.dump %license LICENSE %files compiler %doc README.md %license LICENSE %{_bindir}/protoc +%{_bindir}/protoc-%{so_ver} +%{_bindir}/protoc-gen-upb +%{_bindir}/protoc-gen-upb-%{so_ver} +%{_bindir}/protoc-gen-upbdefs +%{_bindir}/protoc-gen-upbdefs-%{so_ver} %{_mandir}/man1/protoc.1* -%{_libdir}/libprotoc.so.30* +%{_libdir}/libprotoc.so.31* %{abidir}/libprotoc.dump %files devel %{_libdir}/libprotoc.so %{_libdir}/libprotobuf.so +%{_libdir}/libutf8_range.so +%{_libdir}/libutf8_validity.so %dir %{_includedir}/google %{_includedir}/google/protobuf/ %{_libdir}/pkgconfig/protobuf.pc +%{_libdir}/pkgconfig/upb.pc +%{_libdir}/pkgconfig/utf8_range.pc +%{_includedir}/upb/ +%{_includedir}/utf8_range.h +%{_includedir}/utf8_validity.h +%{_libdir}/cmake/protobuf/ +%{_libdir}/cmake/utf8_range/ %doc examples/add_person.cc examples/addressbook.proto %doc examples/list_people.cc examples/Makefile examples/README.md @@ -373,59 +316,39 @@ fail=1 %{_emacs_sitestartdir}/protobuf-init.el %files static -%{_libdir}/libprotoc.a -%{_libdir}/libprotobuf.a +%{_libdir}/libupb.a %files lite -%{_libdir}/libprotobuf-lite.so.30* +%{_libdir}/libprotobuf-lite.so.31* %{abidir}/libprotobuf-lite.dump %files lite-devel %{_libdir}/libprotobuf-lite.so %{_libdir}/pkgconfig/protobuf-lite.pc - -%files lite-static -%{_libdir}/libprotobuf-lite.a - -%if %{with python} -%files -n python3-protobuf -%doc python/README.md -%dir %{python3_sitelib}/google -%{python3_sitelib}/google/protobuf/ -%{python3_sitelib}/protobuf-%{version}%{?rcver}-py3.*.egg-info/ -%{python3_sitelib}/protobuf-%{version}%{?rcver}-py3.*-nspkg.pth -%doc examples/add_person.py examples/list_people.py examples/addressbook.proto -%endif %files vim %{_datadir}/vim/vimfiles/syntax/proto.vim %{_datadir}/vim/vimfiles/ftdetect/proto.vim - -%if %{with java} -%files java -f .mfiles-protobuf-java -%license LICENSE -%doc examples/AddPerson.java examples/ListPeople.java -%doc java/README.md - -%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 + +%if %{with python} +%files -n python3-protobuf -f %{pyproject_files} +%{abidir}/_message.cpython-*-linux-gnu.dump %endif %files doc -%doc CHANGES.txt CONTRIBUTORS.txt README.md +%doc CONTRIBUTORS.txt README.md %changelog +* Tue Aug 05 2025 tomcruiseqi - 31.1-1 +- Update to version 31.1 +- Switch to CMake build system +- Add abseil-cpp dependency +- Remove JRE17 patch (no longer needed) +- Remove CVE-2025-4565 patch (fixed upstream) +- Update library sonames to 31 +- Add CMake config files to devel package +- Python bindings now built via CMake instead of setup.py + * Tue Jul 15 2025 wenxin - 3.19.6-7 - Add patch to fix CVE-2025-4565 @@ -448,4 +371,4 @@ fail=1 - New version 3.19.6 * Wed Apr 27 2022 happy_orange - 3.19.4-1 -- init from upstream +- init from upstream \ No newline at end of file diff --git a/v3.19.6.tar.gz b/v31.1.tar.gz similarity index 34% rename from v3.19.6.tar.gz rename to v31.1.tar.gz index 9ed632b2bd5e471942e19a14afcafe693f0e5907..49f77e70adb87587d1e55cad1c0bbbd813dba3af 100644 Binary files a/v3.19.6.tar.gz and b/v31.1.tar.gz differ