commit:     33f8ad8962c4f754a7c0de47b919cf271171dbc2
Author:     Denis Pronin <dannftk <AT> yandex <DOT> ru>
AuthorDate: Thu Nov 28 10:48:51 2024 +0000
Commit:     Joonas Niilola <juippis <AT> gentoo <DOT> org>
CommitDate: Mon Dec  2 11:13:17 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=33f8ad89

dev-util/librnp: apply upstream patch to build with libc++

Closes: https://bugs.gentoo.org/945231
Signed-off-by: Denis Pronin <dannftk <AT> yandex.ru>
Closes: https://github.com/gentoo/gentoo/pull/39500
Signed-off-by: Joonas Niilola <juippis <AT> gentoo.org>

 .../librnp/files/librnp-0.17.1-libcxx-fix.patch    | 94 ++++++++++++++++++++++
 dev-util/librnp/librnp-0.17.1-r2.ebuild            | 87 ++++++++++++++++++++
 2 files changed, 181 insertions(+)

diff --git a/dev-util/librnp/files/librnp-0.17.1-libcxx-fix.patch 
b/dev-util/librnp/files/librnp-0.17.1-libcxx-fix.patch
new file mode 100644
index 000000000000..f10e1c5e7046
--- /dev/null
+++ b/dev-util/librnp/files/librnp-0.17.1-libcxx-fix.patch
@@ -0,0 +1,94 @@
+# This patch is fetched from upstream https://github.com/rnpgp/rnp
+# The patch is added to the tree by <Denis Pronin> [email protected]
+
+From 20419f739f632fb30666650544f0055e8d4f1afa Mon Sep 17 00:00:00 2001
+From: Maxim Samsonov <[email protected]>
+Date: Wed, 19 Jun 2024 16:52:08 +0300
+Subject: [PATCH] Removed lookup against basic_string<uint8_t>
+
+---
+ src/lib/types.h                |  5 +----
+ src/lib/utils.cpp              | 17 +----------------
+ src/librekey/key_store_g10.cpp |  8 ++++----
+ src/libsexpp                   |  2 +-
+ 4 files changed, 7 insertions(+), 25 deletions(-)
+
+diff --git a/src/lib/types.h b/src/lib/types.h
+index f0c25d3d..a7eac3a1 100644
+--- a/src/lib/types.h
++++ b/src/lib/types.h
+@@ -71,9 +71,6 @@ class id_str_pair {
+     static int         lookup(const id_str_pair           pair[],
+                               const std::vector<uint8_t> &bytes,
+                               int                         notfound = 0);
+-    static int         lookup(const id_str_pair                 pair[],
+-                              const std::basic_string<uint8_t> &bytes,
+-                              int                               notfound = 0);
+ };
+ 
+ /** pgp_fingerprint_t */
+diff --git a/src/lib/utils.cpp b/src/lib/utils.cpp
+index 3c6216c6..fd526379 100644
+--- a/src/lib/utils.cpp
++++ b/src/lib/utils.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2021, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2021, 2024 [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -63,18 +63,3 @@ id_str_pair::lookup(const id_str_pair pair[], const 
std::vector<uint8_t> &bytes,
+     }
+     return notfound;
+ }
+-
+-int
+-id_str_pair::lookup(const id_str_pair                 pair[],
+-                    const std::basic_string<uint8_t> &bytes,
+-                    int                               notfound)
+-{
+-    while (pair && pair->str) {
+-        if ((strlen(pair->str) == bytes.size()) &&
+-            !memcmp(pair->str, bytes.data(), bytes.size())) {
+-            return pair->id;
+-        }
+-        pair++;
+-    }
+-    return notfound;
+-}
+diff --git a/src/librekey/key_store_g10.cpp b/src/librekey/key_store_g10.cpp
+index e646f02f..21136866 100644
+--- a/src/librekey/key_store_g10.cpp
++++ b/src/librekey/key_store_g10.cpp
+@@ -1,5 +1,5 @@
+ /*
+- * Copyright (c) 2017-2022, [Ribose Inc](https://www.ribose.com).
++ * Copyright (c) 2017-2024, [Ribose Inc](https://www.ribose.com).
+  * All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+@@ -311,12 +311,12 @@ read_curve(const sexp_list_t *list, const std::string 
&name, pgp_ec_key_t &key)
+ 
+     const auto &bytes = data->get_string();
+     pgp_curve_t curve = static_cast<pgp_curve_t>(
+-      id_str_pair::lookup(g10_curve_aliases, data->get_string(), 
PGP_CURVE_UNKNOWN));
++      id_str_pair::lookup(g10_curve_aliases, (const char *) bytes.data(), 
PGP_CURVE_UNKNOWN));
+     if (curve != PGP_CURVE_UNKNOWN) {
+         key.curve = curve;
+         return true;
+     }
+-    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (char *) bytes.data());
++    RNP_LOG("Unknown curve: %.*s", (int) bytes.size(), (const char *) 
bytes.data());
+     return false;
+ }
+ 
+@@ -807,7 +807,7 @@ g23_parse_seckey(pgp_key_pkt_t &seckey,
+ 
+     auto &           alg_bt = alg_s_exp->sexp_string_at(0)->get_string();
+     pgp_pubkey_alg_t alg = static_cast<pgp_pubkey_alg_t>(
+-      id_str_pair::lookup(g10_alg_aliases, alg_bt.c_str(), PGP_PKA_NOTHING));
++      id_str_pair::lookup(g10_alg_aliases, (const char *) alg_bt.data(), 
PGP_PKA_NOTHING));
+     if (alg == PGP_PKA_NOTHING) {
+         RNP_LOG(
+           "Unsupported algorithm: '%.*s'", (int) alg_bt.size(), (const char 
*) alg_bt.data());

diff --git a/dev-util/librnp/librnp-0.17.1-r2.ebuild 
b/dev-util/librnp/librnp-0.17.1-r2.ebuild
new file mode 100644
index 000000000000..622351d9190f
--- /dev/null
+++ b/dev-util/librnp/librnp-0.17.1-r2.ebuild
@@ -0,0 +1,87 @@
+# Copyright 2022-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake multiprocessing
+
+DESCRIPTION="High performance C++ OpenPGP library"
+HOMEPAGE="https://www.rnpgp.org/ https://github.com/rnpgp/rnp";
+SRC_URI="https://github.com/rnpgp/rnp/archive/refs/tags/v${PV}.tar.gz -> 
${P}.tar.gz"
+S="${WORKDIR}/${P/*lib/}"
+
+LICENSE="Apache-2.0 BSD BSD-2"
+SLOT="0/0.16.1"
+KEYWORDS="~amd64 ~arm64 ~loong ~ppc64 ~x86"
+
+IUSE="+botan man test"
+RESTRICT="!test? ( test )"
+
+RDEPEND="app-arch/bzip2
+       dev-libs/json-c:=
+       >=dev-libs/sexpp-0.8.7
+       sys-libs/zlib
+       botan? ( dev-libs/botan:3= )
+       !botan? ( >=dev-libs/openssl-1.1.1:= )"
+DEPEND="${RDEPEND}
+       test? ( dev-cpp/gtest )"
+BDEPEND="man? ( dev-ruby/asciidoctor )"
+
+PATCHES=( "${FILESDIR}"/${P}-libcxx-fix.patch )
+
+src_configure() {
+       local mycmakeargs=(
+               -DBUILD_TESTING=$(usex test on off)
+
+               -DCRYPTO_BACKEND=$(usex botan botan3 openssl)
+
+               -DDOWNLOAD_GTEST=off
+
+               -DENABLE_COVERAGE=off
+               -DENABLE_DOC=$(usex man on off)
+               -DENABLE_FUZZERS=off
+               -DENABLE_SANITIZERS=off
+
+               -DSYSTEM_LIBSEXPP=on
+       )
+
+       if use botan; then
+               local mycmakeargs+=(
+                       -DENABLE_AEAD=on
+                       -DENABLE_BLOWFISH=on
+                       -DENABLE_BRAINPOOL=on
+                       -DENABLE_CAST5=on
+                       -DENABLE_IDEA=on
+                       -DENABLE_RIPEMD160=on
+                       -DENABLE_SM2=on
+                       -DENABLE_TWOFISH=on
+               )
+
+       # OpenSSL support is still not as complete as botan.
+       # https://github.com/rnpgp/rnp/issues/1877 SM2,
+       # https://github.com/openssl/openssl/issues/2046 TWOFISH (won't be 
implemented).
+       else
+               local mycmakeargs+=(
+                       -DENABLE_AEAD=on
+                       -DENABLE_BLOWFISH=on
+                       -DENABLE_BRAINPOOL=on
+                       -DENABLE_CAST5=on
+                       -DENABLE_IDEA=on
+                       -DENABLE_RIPEMD160=on
+                       -DENABLE_SM2=off
+                       -DENABLE_TWOFISH=off
+               )
+       fi
+
+       cmake_src_configure
+}
+
+src_test() {
+       cd "${BUILD_DIR}"/src/tests || die
+       ctest -j$(makeopts_jobs) -R .* --output-on-failure || die
+}
+
+src_install() {
+       cmake_src_install
+       find "${D}" -name '*.a' -delete || die
+}

Reply via email to