summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorØystein Sture2024-10-29 10:52:55 +0100
committerØystein Sture2024-10-29 10:52:55 +0100
commit8c7036bb9129857791cba46c4ca10caf665df156 (patch)
treeb97e8253e202232b476543576b8b62be6d6b20de
parent73a9465c0078334c2f6c1aed68a53ee8f54e7576 (diff)
downloadaur-8c7036bb9129857791cba46c4ca10caf665df156.tar.gz
Protobuf 28 patch
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD13
-rw-r--r--protobuf28.patch189
3 files changed, 202 insertions, 4 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 8c96abd9a9c4..ea0d1f186762 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,7 +1,7 @@
pkgbase = gz-transport13
pkgdesc = Transport library for component communication based on publication/subscription and service calls.
pkgver = 13.4.0
- pkgrel = 1
+ pkgrel = 2
url = https://github.com/gazebosim/gz-transport
arch = any
license = Apache
@@ -18,6 +18,8 @@ pkgbase = gz-transport13
depends = zeromq
provides = gz-transport=13
source = https://github.com/gazebosim/gz-transport/archive/gz-transport13_13.4.0.tar.gz
+ source = protobuf28.patch
sha256sums = 7c9d7bc46b2d8abb81487be346cafe56b482873019110e39a7b65adb4cbc8514
+ sha256sums = SKIP
pkgname = gz-transport13
diff --git a/PKGBUILD b/PKGBUILD
index c0859b727418..d69702b7ddc5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@
pkgname=gz-transport13
pkgver=13.4.0
-pkgrel=1
+pkgrel=2
_pkgmaj=${pkgver%%.*}
_pkgbase=${pkgname::-${#_pkgmaj}}
pkgdesc="Transport library for component communication based on publication/subscription and service calls."
@@ -25,11 +25,18 @@ makedepends=(
'util-linux-libs' # uuid
)
provides=("${_pkgbase}=${_pkgmaj}")
-source=("https://github.com/gazebosim/${_pkgbase}/archive/${pkgname}_${pkgver}.tar.gz")
-sha256sums=('7c9d7bc46b2d8abb81487be346cafe56b482873019110e39a7b65adb4cbc8514')
+source=("https://github.com/gazebosim/${_pkgbase}/archive/${pkgname}_${pkgver}.tar.gz"
+ "protobuf28.patch")
+sha256sums=('7c9d7bc46b2d8abb81487be346cafe56b482873019110e39a7b65adb4cbc8514'
+ 'SKIP')
_build_dir="${_pkgbase}-${pkgname}_${pkgver}/build"
+prepare() {
+ cd "${_pkgbase}-${pkgname}_${pkgver}"
+ patch -p1 < "${srcdir}/protobuf28.patch"
+}
+
build() {
mkdir -p "$srcdir/$_build_dir" && cd $_
cmake .. -DCMAKE_BUILD_TYPE='None' \
diff --git a/protobuf28.patch b/protobuf28.patch
new file mode 100644
index 000000000000..6f8f00e168bc
--- /dev/null
+++ b/protobuf28.patch
@@ -0,0 +1,189 @@
+From 8986a688252a72bf55d0032120818a65fb15073a Mon Sep 17 00:00:00 2001
+From: "Ramir \"Ramir0\" Sultanov" <ramir0.sultanov@gmail.com>
+Date: Thu, 19 Sep 2024 13:03:12 +0300
+Subject: [PATCH 1/2] Add compatibility with protobuf 28
+
+Signed-off-by: Ramir Sultanov <ramir0.sultanov@gmail.com>
+---
+ include/gz/transport/RepHandler.hh | 46 ++++++++++++++++++++-
+ include/gz/transport/SubscriptionHandler.hh | 24 ++++++++++-
+ 2 files changed, 68 insertions(+), 2 deletions(-)
+
+diff --git a/include/gz/transport/RepHandler.hh b/include/gz/transport/RepHandler.hh
+index eb2e9d7c1..0ae1e6340 100644
+--- a/include/gz/transport/RepHandler.hh
++++ b/include/gz/transport/RepHandler.hh
+@@ -141,7 +141,51 @@ namespace gz
+ return false;
+ }
+
+-#if GOOGLE_PROTOBUF_VERSION >= 4022000
++#if GOOGLE_PROTOBUF_VERSION >= 5028000
++ const auto msgReq =
++ google::protobuf::DynamicCastMessage<Req>(&_msgReq);
++ auto msgRep =
++ google::protobuf::DynamicCastMessage<Rep>(&_msgRep);
++
++ // Verify the dynamically casted messages are valid
++ if (msgReq == nullptr || msgRep == nullptr)
++ {
++ if (msgReq == nullptr)
++ {
++ if (_msgReq.GetDescriptor() != nullptr)
++ {
++ std::cerr << "RepHandler::RunLocalCallback() error: "
++ << "Failed to cast the request of the type "
++ << _msgReq.GetDescriptor()->full_name()
++ << " to the specified type" << '\n';
++ }
++ else
++ {
++ std::cerr << "RepHandler::RunLocalCallback() error: "
++ << "Failed to cast the request of an unknown type"
++ << " to the specified type" << '\n';
++ }
++ }
++ if (msgRep == nullptr)
++ {
++ if (_msgRep.GetDescriptor() != nullptr)
++ {
++ std::cerr << "RepHandler::RunLocalCallback() error: "
++ << "Failed to cast the response of the type "
++ << _msgRep.GetDescriptor()->full_name()
++ << " to the specified type" << '\n';
++ }
++ else
++ {
++ std::cerr << "RepHandler::RunLocalCallback() error: "
++ << "Failed to cast the response of an unknown type"
++ << " to the specified type" << '\n';
++ }
++ }
++ std::cerr.flush();
++ return false;
++ }
++#elif GOOGLE_PROTOBUF_VERSION >= 4022000
+ auto msgReq =
+ google::protobuf::internal::DownCast<const Req*>(&_msgReq);
+ auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
+diff --git a/include/gz/transport/SubscriptionHandler.hh b/include/gz/transport/SubscriptionHandler.hh
+index 6119e100e..e85eacc16 100644
+--- a/include/gz/transport/SubscriptionHandler.hh
++++ b/include/gz/transport/SubscriptionHandler.hh
+@@ -214,7 +214,29 @@ namespace gz
+ if (!this->UpdateThrottling())
+ return true;
+
+-#if GOOGLE_PROTOBUF_VERSION >= 4022000
++#if GOOGLE_PROTOBUF_VERSION >= 5028000
++ auto msgPtr = google::protobuf::DynamicCastMessage<T>(&_msg);
++
++ // Verify the dynamically casted message is valid
++ if (msgPtr == nullptr)
++ {
++ if (_msg.GetDescriptor() != nullptr)
++ {
++ std::cerr << "SubscriptionHandler::RunLocalCallback() error: "
++ << "Failed to cast the message of the type "
++ << _msg.GetDescriptor()->full_name()
++ << " to the specified type" << '\n';
++ }
++ else
++ {
++ std::cerr << "SubscriptionHandler::RunLocalCallback() error: "
++ << "Failed to cast the message of an unknown type"
++ << " to the specified type" << '\n';
++ }
++ std::cerr.flush();
++ return false;
++ }
++#elif GOOGLE_PROTOBUF_VERSION >= 4022000
+ auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
+ #elif GOOGLE_PROTOBUF_VERSION >= 3000000
+ auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
+
+From ff01a7f5bf40eee4a8d451dc7e8baf9a703186b6 Mon Sep 17 00:00:00 2001
+From: Ramir Sultanov <ramir0.sultanov@gmail.com>
+Date: Sat, 26 Oct 2024 14:08:01 +0300
+Subject: [PATCH 2/2] Add message verification after message down casts
+
+Signed-off-by: Ramir Sultanov <ramir0.sultanov@gmail.com>
+---
+ include/gz/transport/RepHandler.hh | 24 ++++++++++-----------
+ include/gz/transport/SubscriptionHandler.hh | 14 ++++++------
+ 2 files changed, 19 insertions(+), 19 deletions(-)
+
+diff --git a/include/gz/transport/RepHandler.hh b/include/gz/transport/RepHandler.hh
+index 0ae1e6340..ad5329f88 100644
+--- a/include/gz/transport/RepHandler.hh
++++ b/include/gz/transport/RepHandler.hh
+@@ -146,6 +146,18 @@ namespace gz
+ google::protobuf::DynamicCastMessage<Req>(&_msgReq);
+ auto msgRep =
+ google::protobuf::DynamicCastMessage<Rep>(&_msgRep);
++#elif GOOGLE_PROTOBUF_VERSION >= 4022000
++ auto msgReq =
++ google::protobuf::internal::DownCast<const Req*>(&_msgReq);
++ auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
++#elif GOOGLE_PROTOBUF_VERSION > 2999999
++ auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
++ auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
++#else
++ auto msgReq =
++ google::protobuf::internal::down_cast<const Req*>(&_msgReq);
++ auto msgRep = google::protobuf::internal::down_cast<Rep*>(&_msgRep);
++#endif
+
+ // Verify the dynamically casted messages are valid
+ if (msgReq == nullptr || msgRep == nullptr)
+@@ -185,18 +197,6 @@ namespace gz
+ std::cerr.flush();
+ return false;
+ }
+-#elif GOOGLE_PROTOBUF_VERSION >= 4022000
+- auto msgReq =
+- google::protobuf::internal::DownCast<const Req*>(&_msgReq);
+- auto msgRep = google::protobuf::internal::DownCast<Rep*>(&_msgRep);
+-#elif GOOGLE_PROTOBUF_VERSION > 2999999
+- auto msgReq = google::protobuf::down_cast<const Req*>(&_msgReq);
+- auto msgRep = google::protobuf::down_cast<Rep*>(&_msgRep);
+-#else
+- auto msgReq =
+- google::protobuf::internal::down_cast<const Req*>(&_msgReq);
+- auto msgRep = google::protobuf::internal::down_cast<Rep*>(&_msgRep);
+-#endif
+
+ return this->cb(*msgReq, *msgRep);
+ }
+diff --git a/include/gz/transport/SubscriptionHandler.hh b/include/gz/transport/SubscriptionHandler.hh
+index e85eacc16..ed705ad92 100644
+--- a/include/gz/transport/SubscriptionHandler.hh
++++ b/include/gz/transport/SubscriptionHandler.hh
+@@ -216,6 +216,13 @@ namespace gz
+
+ #if GOOGLE_PROTOBUF_VERSION >= 5028000
+ auto msgPtr = google::protobuf::DynamicCastMessage<T>(&_msg);
++#elif GOOGLE_PROTOBUF_VERSION >= 4022000
++ auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
++#elif GOOGLE_PROTOBUF_VERSION >= 3000000
++ auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
++#else
++ auto msgPtr = google::protobuf::internal::down_cast<const T*>(&_msg);
++#endif
+
+ // Verify the dynamically casted message is valid
+ if (msgPtr == nullptr)
+@@ -236,13 +243,6 @@ namespace gz
+ std::cerr.flush();
+ return false;
+ }
+-#elif GOOGLE_PROTOBUF_VERSION >= 4022000
+- auto msgPtr = google::protobuf::internal::DownCast<const T*>(&_msg);
+-#elif GOOGLE_PROTOBUF_VERSION >= 3000000
+- auto msgPtr = google::protobuf::down_cast<const T*>(&_msg);
+-#else
+- auto msgPtr = google::protobuf::internal::down_cast<const T*>(&_msg);
+-#endif
+
+ this->cb(*msgPtr, _info);
+ return true;