commit:     bf2e5aad5b63f7b856232f0351cf65905277a734
Author:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 17 11:19:55 2025 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Fri Oct 17 13:09:13 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bf2e5aad

app-text/ebook-tools: Fix CMake <3.10 warning, add another crashfix

Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 app-text/ebook-tools/ebook-tools-0.2.2-r4.ebuild   | 36 ++++++++++++
 .../ebook-tools-0.2.2-cmake-minreqver-3.16.patch   | 31 +++++++++++
 .../files/ebook-tools-0.2.2-crashfix-1.patch       | 65 ++++++++++++++++++++++
 3 files changed, 132 insertions(+)

diff --git a/app-text/ebook-tools/ebook-tools-0.2.2-r4.ebuild 
b/app-text/ebook-tools/ebook-tools-0.2.2-r4.ebuild
new file mode 100644
index 000000000000..c2349fa21b00
--- /dev/null
+++ b/app-text/ebook-tools/ebook-tools-0.2.2-r4.ebuild
@@ -0,0 +1,36 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit cmake
+
+DESCRIPTION="Tools for accessing and converting various ebook file formats"
+HOMEPAGE="https://sourceforge.net/projects/ebook-tools/";
+SRC_URI="https://downloads.sourceforge.net/${PN}/${P}.tar.gz";
+
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~x86"
+IUSE="+lit2epub"
+
+DEPEND="
+       dev-libs/libxml2:=
+       >=dev-libs/libzip-1.7.2:=
+"
+RDEPEND="${DEPEND}
+       lit2epub? ( app-text/convertlit )
+"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-crashfix.patch
+       "${FILESDIR}"/${P}-crashfix-1.patch # KDE-bug 466540
+       "${FILESDIR}"/${P}-fvisibility-hidden.patch
+       "${FILESDIR}"/${P}-libzip-cmake.patch # bug 956821
+       "${FILESDIR}"/${P}-cmake-minreqver-3.16.patch # bug 955639
+)
+
+src_prepare() {
+       cmake_src_prepare
+       use lit2epub || sed -e "\|lit2epub|d" -i src/tools/CMakeLists.txt || die
+}

diff --git 
a/app-text/ebook-tools/files/ebook-tools-0.2.2-cmake-minreqver-3.16.patch 
b/app-text/ebook-tools/files/ebook-tools-0.2.2-cmake-minreqver-3.16.patch
new file mode 100644
index 000000000000..01d432694d23
--- /dev/null
+++ b/app-text/ebook-tools/files/ebook-tools-0.2.2-cmake-minreqver-3.16.patch
@@ -0,0 +1,31 @@
+Source:
+https://build.opensuse.org/projects/openSUSE:Factory/packages/ebook-tools/files/ebook-tools-cmake4.patch?expand=1
+
+From ff65f88d25d8c76ed467b1f3c532c7338ed162d1 Mon Sep 17 00:00:00 2001
+From: Christophe Marin <[email protected]>
+Date: Thu, 20 Mar 2025 23:17:57 +0100
+Subject: [PATCH] Fix build with CMake 4
+
+Required CMake versions older than 3.5 will throw errors.
+
+Bump the minimum version to 3.16
+---
+ CMakeLists.txt | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4bb621c..1dcb5f4 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1,6 +1,6 @@
+-project (EBOOK-TOOLS C)
++cmake_minimum_required(VERSION 3.16)
+ 
+-cmake_minimum_required(VERSION 2.4.0)
++project (EBOOK-TOOLS C)
+ 
+ find_package(PkgConfig)
+ pkg_check_modules(ZIP libzip)
+-- 
+2.49.0
+

diff --git a/app-text/ebook-tools/files/ebook-tools-0.2.2-crashfix-1.patch 
b/app-text/ebook-tools/files/ebook-tools-0.2.2-crashfix-1.patch
new file mode 100644
index 000000000000..704e2581e23e
--- /dev/null
+++ b/app-text/ebook-tools/files/ebook-tools-0.2.2-crashfix-1.patch
@@ -0,0 +1,65 @@
+Source:
+https://build.opensuse.org/projects/openSUSE:Factory/packages/ebook-tools/files/0002-Avoid-crash-on-spine-itemref-without-idref.patch?expand=1
+
+From 37ccdd11e30ea60225276cbfaba4cdd483f9f6fd Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20Br=C3=BCns?= <[email protected]>
+Date: Sun, 23 Apr 2023 05:16:20 +0200
+Subject: [PATCH 2/2] Avoid crash on spine itemref without idref
+
+Although the idref attribute is required, it may be missing in a
+malformed epub file.
+
+Warn during parsing, and skip the node when linearizing.
+
+Return a non-null empty string in case the iterator points to an
+invalid element but not the last one, otherwise the iteration is stopped.
+---
+ src/libepub/epub.c | 9 ++++++++-
+ src/libepub/opf.c  | 4 ++++
+ 2 files changed, 12 insertions(+), 1 deletion(-)
+
+diff --git a/src/libepub/epub.c b/src/libepub/epub.c
+index a259d9d..956c7c5 100644
+--- a/src/libepub/epub.c
++++ b/src/libepub/epub.c
+@@ -255,6 +255,12 @@ char *_get_spine_it_url(struct eiterator *it) {
+         return NULL;
+   
+   data = GetNodeData(it->curr);
++  if (!((struct spine *)data)->idref) {
++        _epub_print_debug(it->epub, DEBUG_INFO,
++                                              "skipping spine itemref without 
idref");
++        return NULL;
++  }
++
+   tmp = _opf_manifest_get_by_id(it->epub->opf, 
+                                 ((struct spine *)data)->idref);
+   if (!tmp) {
+@@ -375,7 +381,8 @@ char *epub_it_get_next(struct eiterator *it) {
+     break;
+   }
+   
+-  return epub_it_get_curr(it);
++  epub_it_get_curr(it);
++  return it->cache ? it->cache : it->curr ? "" : NULL;
+ }
+ 
+ int epub_close(struct epub *epub) {
+diff --git a/src/libepub/opf.c b/src/libepub/opf.c
+index ae41184..3eba55c 100644
+--- a/src/libepub/opf.c
++++ b/src/libepub/opf.c
+@@ -701,6 +701,10 @@ void _opf_parse_spine(struct opf *opf, xmlTextReaderPtr 
reader) {
+       memset(item, 0, sizeof(struct spine));
+ 
+     item->idref = xmlTextReaderGetAttribute(reader, (xmlChar *)"idref");
++    if (!item->idref) {
++      _epub_print_debug(opf->epub, DEBUG_WARNING,
++                        "- missing idref in spine itemref");
++    }
+     linear = xmlTextReaderGetAttribute(reader, (xmlChar *)"linear");
+     if (linear && xmlStrcasecmp(linear, (xmlChar *)"no") == 0) {
+       item->linear = 0;
+-- 
+2.40.0
+

Reply via email to