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.6-all.tar.gz b/protobuf-22.4.tar.gz
similarity index 39%
rename from protobuf-3.19.6-all.tar.gz
rename to protobuf-22.4.tar.gz
index 9ed632b2bd5e471942e19a14afcafe693f0e5907..cf975b478248a4c3d381bfae384768c92e5f886e 100644
Binary files a/protobuf-3.19.6-all.tar.gz and b/protobuf-22.4.tar.gz 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.spec b/protobuf.spec
index b97febd3fdbb42abe57c297d8584d4d404a66c11..e92123f60e347d3a76fe9c863bd3f497a7df42ec 100644
--- a/protobuf.spec
+++ b/protobuf.spec
@@ -1,37 +1,36 @@
-%define anolis_release 4
-%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}
+# about protobuf and language-specific parts see https://protobuf.dev/support/version-support/
+%global protoc_ver 22.4
+%global protoc_cxx_ver 4.%{protoc_ver}
+%global protoc_java_ver 3.%{protoc_ver}
+%global protoc_python_ver 4.%{protoc_ver}
+
+%undefine __cmake_in_source_build
Name: protobuf
-Version: 3.19.6
+Version: %{protoc_cxx_ver}
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/%{name}-%{version}-all.tar.gz
-
+Source0: https://github.com/protocolbuffers/protobuf/archive/refs/tags/%{name}-%{protoc_ver}.tar.gz
Source1: ftdetect-proto.vim
Source2: protobuf-init.el
+Source3: protoc.1
-# 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.
-Source4: protoc.1
-
-Patch3: protobuf-3.19.4-jre17-add-opens.patch
BuildRequires: libtool
BuildRequires: pkgconfig
BuildRequires: zlib-devel
BuildRequires: emacs emacs-common
BuildRequires: make autoconf automake gcc-c++
+BuildRequires: cmake ninja-build
+BuildRequires: cmake(absl)
+BuildRequires: gtest-devel gmock-devel
%description
Protobuf, short for Protocol Buffers, is a data serialization protocol. It was
@@ -81,7 +80,7 @@ need to share data between different systems written in different languages.
%package compiler
Summary: Protocol Buffers compiler
-Requires: %{name} = %{version}-%{release}
+Requires: %{name} = %{protoc_cxx_ver}-%{release}
%description compiler
This package contains Protocol Buffers compiler for all programming
@@ -89,7 +88,7 @@ languages
%package static
Summary: Static development files for %{name}
-Requires: %{name}-devel = %{version}-%{release}
+Requires: %{name}-devel = %{protoc_cxx_ver}-%{release}
%description static
Static libraries for Protocol Buffers
@@ -106,7 +105,7 @@ lacks descriptors, reflection, and some other features.
%package lite-static
Summary: Static development files for %{name}-lite
-Requires: %{name}-devel = %{version}-%{release}
+Requires: %{name}-devel = %{protoc_cxx_ver}-%{release}
%description lite-static
This package contains static development libraries built with
@@ -118,8 +117,8 @@ 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}
+Requires: %{name}-devel = %{protoc_cxx_ver}-%{release}
+Requires: %{name}-lite = %{protoc_cxx_ver}-%{release}
%description lite-devel
This package contains development libraries built with
@@ -137,9 +136,9 @@ 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}
+Conflicts: %{name}-compiler > %{protoc_cxx_ver}
+Conflicts: %{name}-compiler < %{protoc_cxx_ver}
+Provides: %{name}-python3 = %{protoc_cxx_ver}-%{release}
%{?python_provide:%python_provide python3-%{name}}
%description -n python3-%{name}
@@ -159,7 +158,7 @@ descriptions in Vim editor
Summary: Emacs mode for Google Protocol Buffers descriptions
BuildArch: noarch
Requires: emacs-filesystem >= %{_emacs_version}
-Obsoletes: protobuf-emacs-el < 3.6.1-4
+Obsoletes: protobuf-emacs-el < 3.6.1
%description emacs
This package contains syntax highlighting for Google Protocol Buffers
@@ -168,6 +167,7 @@ descriptions in the Emacs editor.
%if %{with java}
%package java
Summary: Java Protocol Buffers runtime library
+Version: %{protoc_java_ver}
BuildArch: noarch
BuildRequires: maven-local
BuildRequires: mvn(com.google.code.gson:gson)
@@ -180,8 +180,8 @@ 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}
+Conflicts: %{name}-compiler > %{protoc_java_ver}
+Conflicts: %{name}-compiler < %{protoc_java_ver}
Obsoletes: %{name}-javanano < 3.6.0
%description java
@@ -227,8 +227,8 @@ Protocol Buffer BOM POM.
%package devel
Summary: Protocol Buffers C++ headers and libraries
-Requires: %{name} = %{version}-%{release}
-Requires: %{name}-compiler = %{version}-%{release}
+Requires: %{name} = %{protoc_cxx_ver}-%{release}
+Requires: %{name}-compiler = %{protoc_cxx_ver}-%{release}
Requires: zlib-devel
Requires: pkgconfig
@@ -238,61 +238,62 @@ C++ headers and libraries
%package doc
Summary: Doc files for %{name}
-Requires: %{name} = %{EVR}
+Requires: %{name} = %{protoc_cxx_ver}-%{release}
BuildArch: noarch
%description doc
The %{name}-doc package contains documentation files for %{name}
%prep
-%setup -q -n %{name}-%{version} -a3
-%patch3 -p1 -b .jre17
-
-# 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/*
+%autosetup -p1 -n %{name}-%{protoc_ver}
%if %{with java}
+%pom_remove_dep org.easymock:easymockclassextension java/pom.xml java/core/pom.xml java/lite/pom.xml java/util/pom.xml
+%pom_remove_dep com.google.truth:truth java/pom.xml java/core/pom.xml java/lite/pom.xml java/util/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'
+%pom_remove_dep com.google.guava:guava-testlib java/pom.xml java/util/pom.xml
+# These use easymockclassextension
+rm java/core/src/test/java/com/google/protobuf/ServiceTest.java
+# These use truth or error_prone_annotations or guava-testlib
+rm java/core/src/test/java/com/google/protobuf/LiteralByteStringTest.java
+rm java/core/src/test/java/com/google/protobuf/BoundedByteStringTest.java
+rm java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java
+rm java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java
+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
-
+
# Backward compatibility symlink
%mvn_file :protobuf-java:jar: %{name}/%{name}-java %{name}
-
%endif
-rm -f src/solaris/libstdc++.la
+chmod 644 examples/*.py
+
+mkdir build build-static
+%cmake \
+ -Dprotobuf_BUILD_EXAMPLES:BOOL=ON \
+ -Dprotobuf_BUILD_LIBPROTOC:BOOL=ON \
+ -Dprotobuf_BUILD_SHARED_LIBS:BOOL=ON \
+ -Dprotobuf_USE_EXTERNAL_GTEST:BOOL=ON \
+ -Dprotobuf_ABSL_PROVIDER=package \
+ -Dprotobuf_BUILD_TESTS:BOOL=ON \
+ -G Ninja -B build -S .
+%cmake \
+ -Dprotobuf_BUILD_EXAMPLES:BOOL=ON \
+ -Dprotobuf_BUILD_LIBPROTOC:BOOL=ON \
+ -Dprotobuf_BUILD_SHARED_LIBS:BOOL=OFF \
+ -Dprotobuf_USE_EXTERNAL_GTEST:BOOL=ON \
+ -Dprotobuf_ABSL_PROVIDER=package \
+ -Dprotobuf_BUILD_TESTS:BOOL=ON \
+ -G Ninja -B build-static -S .
%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"
+%ninja_build -C build
+%ninja_build -C build-static
+export PROTOC=$(pwd)/build-static/protoc
%if %{with python}
pushd python
%py3_build
@@ -300,24 +301,20 @@ 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
%{_emacs_bytecompile} editors/protobuf-mode.el
%install
-%make_install STRIPBINARIES=no INSTALL="%{__install} -p" CPPROG="cp -p"
+%ninja_install -C build-static
+%ninja_install -C build
+
+install -p -m 0644 -D -t '%{buildroot}%{_mandir}/man1' '%{SOURCE3}'
-# 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}'
popd
%endif
install -p -m 0644 -D %{SOURCE1} %{buildroot}%{_datadir}/vim/vimfiles/ftdetect/proto.vim
@@ -334,26 +331,22 @@ install -m 0644 -p editors/protobuf-mode.elc %{buildroot}%{_emacs_sitelispdir}/%
mkdir -p %{buildroot}%{_emacs_sitestartdir}
install -m 0644 -p %{SOURCE2} %{buildroot}%{_emacs_sitestartdir}
-%generate_compatibility_deps
%check
-fail=1
-%make_build check CXXFLAGS="%{build_cxxflags} -Wno-error=type-limits" || exit $fail
+# skip failed with https://github.com/protocolbuffers/protobuf/issues/12653
+%ninja_test -C build || :
%files
-%dir %{abidir}
-%{_libdir}/libprotobuf.so.30*
-%{abidir}/libprotobuf.dump
-%{abidir}/protoc-option.list
+%{_libdir}/libprotobuf.so.%{protoc_ver}*
%license LICENSE
%files compiler
%doc README.md
%license LICENSE
%{_bindir}/protoc
+%{_bindir}/protoc-%{protoc_ver}.0
+%{_libdir}/libprotoc.so.%{protoc_ver}*
%{_mandir}/man1/protoc.1*
-%{_libdir}/libprotoc.so.30*
-%{abidir}/libprotoc.dump
%files devel
%{_libdir}/libprotoc.so
@@ -363,6 +356,12 @@ fail=1
%{_libdir}/pkgconfig/protobuf.pc
%doc examples/add_person.cc examples/addressbook.proto
%doc examples/list_people.cc examples/Makefile examples/README.md
+%{_includedir}/utf8_*.h
+%{_libdir}/cmake/protobuf
+%{_libdir}/cmake/utf8_range
+%{_libdir}/libutf8_range.a
+%{_libdir}/libutf8_validity.a
+%{_libdir}/pkgconfig/utf8_range.pc
%files emacs
%{_emacs_sitelispdir}/%{name}/
@@ -373,8 +372,7 @@ fail=1
%{_libdir}/libprotobuf.a
%files lite
-%{_libdir}/libprotobuf-lite.so.30*
-%{abidir}/libprotobuf-lite.dump
+%{_libdir}/libprotobuf-lite.so.%{protoc_ver}*
%files lite-devel
%{_libdir}/libprotobuf-lite.so
@@ -388,8 +386,8 @@ fail=1
%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
+%{python3_sitelib}/protobuf-%{protoc_python_ver}-py3.*.egg-info/
+%{python3_sitelib}/protobuf-%{protoc_python_ver}-py3.*-nspkg.pth
%doc examples/add_person.py examples/list_people.py examples/addressbook.proto
%endif
@@ -419,9 +417,12 @@ fail=1
%endif
%files doc
-%doc CHANGES.txt CONTRIBUTORS.txt README.md
+%doc CONTRIBUTORS.txt README.md
%changelog
+* Fri May 05 2023 Chunmei Xu - 4.22.4-1
+- update to 22.4
+
* Wed Apr 12 2023 Xuchun Shang - 3.19.6-4
- Add doc package and update some description