diff --git a/deskutils/calibre/files/patch-setup_build.py b/deskutils/calibre/files/patch-setup_build.py index e3e05d0f22ea..d2e31e3be30a 100644 --- a/deskutils/calibre/files/patch-setup_build.py +++ b/deskutils/calibre/files/patch-setup_build.py @@ -1,10 +1,10 @@ ---- setup/build.py.orig 2023-12-15 00:57:56 UTC +--- setup/build.py.orig 2025-04-18 03:14:01 UTC +++ setup/build.py -@@ -703,6 +703,7 @@ sip-file = {os.path.basename(sipf)!r} +@@ -701,6 +701,7 @@ sip-file = {os.path.basename(sipf)!r} include-dirs = {ext.inc_dirs} qmake-QT = {ext.qt_modules} sip-file = {os.path.basename(sipf)!r} +tags = ["WS_X11"] ''') shutil.copy2(sipf, src_dir) diff --git a/deskutils/calibre/files/patch-setup_iso__codes.py b/deskutils/calibre/files/patch-setup_iso__codes.py index 1dece69c176c..e23074d72157 100644 --- a/deskutils/calibre/files/patch-setup_iso__codes.py +++ b/deskutils/calibre/files/patch-setup_iso__codes.py @@ -1,88 +1,88 @@ ---- setup/iso_codes.py.orig 2024-07-31 01:47:58 UTC +--- setup/iso_codes.py.orig 2025-04-18 03:14:01 UTC +++ setup/iso_codes.py @@ -2,6 +2,7 @@ import fnmatch # License: GPLv3 Copyright: 2023, Kovid Goyal import fnmatch +import glob import optparse import os import shutil @@ -24,40 +25,60 @@ class ISOData(Command): description = 'Get ISO codes name localization data' - top_level_filename = 'iso-codes-main' + top_level_filename = 'iso-codes-main' _zip_data = None + extracted = False def add_options(self, parser): with suppress(optparse.OptionConflictError): # ignore if option already added parser.add_option('--path-to-isocodes', help='Path to previously downloaded iso-codes-main.zip') + parser.add_option('--isocodes-extracted', default=False, action='store_true', + help='Isocodes is a directory') def run(self, opts): - if self._zip_data is None and opts.path_to_isocodes: - with open(opts.path_to_isocodes, 'rb') as f: - self._zip_data = f.read() - # get top level directory - top = {item.split('/')[0] for item in zipfile.ZipFile(self.zip_data).namelist()} - assert len(top) == 1 - self.top_level_filename = top.pop() + if opts.isocodes_extracted: + self.top_level = opts.path_to_isocodes + self.extracted = True + else: + if self._zip_data is None and opts.path_to_isocodes: + with open(opts.path_to_isocodes, 'rb') as f: + self._zip_data = f.read() + # get top level directory + top = {item.split('/')[0] for item in zipfile.ZipFile(self.zip_data).namelist()} + assert len(top) == 1 + self.top_level_filename = top.pop() @property def zip_data(self): return self._zip_data or iso_codes_data() def db_data(self, name: str) -> bytes: - with zipfile.ZipFile(BytesIO(self.zip_data)) as zf: - with zf.open(f'{self.top_level_filename}/data/{name}') as f: + if self.extracted: + src = f'{self.top_level}/data/{name}' + if not os.path.exists(src): + raise Exception(src + ' does not exist') + with open(src, 'rb') as f: return f.read() + else: + with zipfile.ZipFile(BytesIO(self.zip_data)) as zf: + with zf.open(f'{self.top_level_filename}/data/{name}') as f: + return f.read() def extract_po_files(self, name: str, output_dir: str) -> None: name = name.split('.', 1)[0] - pat = f'{self.top_level_filename}/{name}/*.po' - with zipfile.ZipFile(BytesIO(self.zip_data)) as zf: - for name in fnmatch.filter(zf.namelist(), pat): + if self.extracted: + pat = f'{self.top_level}/{name}/*.po' + for name in glob.glob(pat): dest = os.path.join(output_dir, name.split('/')[-1]) - zi = zf.getinfo(name) - with zf.open(zi) as src, open(dest, 'wb') as d: - shutil.copyfileobj(src, d) - date_time = time.mktime(zi.date_time + (0, 0, -1)) - os.utime(dest, (date_time, date_time)) + shutil.copy2(name, dest) + else: + pat = f'{self.top_level_filename}/{name}/*.po' + with zipfile.ZipFile(BytesIO(self.zip_data)) as zf: + for name in fnmatch.filter(zf.namelist(), pat): + dest = os.path.join(output_dir, name.split('/')[-1]) + zi = zf.getinfo(name) + with zf.open(zi) as src, open(dest, 'wb') as d: + shutil.copyfileobj(src, d) + date_time = time.mktime(zi.date_time + (0, 0, -1)) + os.utime(dest, (date_time, date_time)) iso_data = ISOData() diff --git a/deskutils/calibre/files/patch-src_calibre_gui2_____init____.py b/deskutils/calibre/files/patch-src_calibre_gui2_____init____.py new file mode 100644 index 000000000000..1558a1a4702c --- /dev/null +++ b/deskutils/calibre/files/patch-src_calibre_gui2_____init____.py @@ -0,0 +1,11 @@ +--- src/calibre/gui2/__init__.py.orig 2025-04-18 03:14:01 UTC ++++ src/calibre/gui2/__init__.py +@@ -1619,6 +1619,8 @@ def ensure_app(headless=True): + has_headless = ismacos or islinux or isbsd + if headless and has_headless: + args += ['-platformpluginpath', plugins_loc, '-platform', os.environ.get('CALIBRE_HEADLESS_PLATFORM', 'headless')] ++ if isbsd: ++ os.environ['QTWEBENGINE_CHROMIUM_FLAGS'] = '--disable-gpu' + if ismacos: + os.environ['QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM'] = '1' + if headless and iswindows: diff --git a/deskutils/calibre/files/patch-src_calibre_linux.py b/deskutils/calibre/files/patch-src_calibre_linux.py index d1a8db112ff4..e75706872eac 100644 --- a/deskutils/calibre/files/patch-src_calibre_linux.py +++ b/deskutils/calibre/files/patch-src_calibre_linux.py @@ -1,29 +1,29 @@ ---- src/calibre/linux.py.orig 2023-12-15 00:57:56 UTC +--- src/calibre/linux.py.orig 2025-04-18 03:14:01 UTC +++ src/calibre/linux.py -@@ -1108,7 +1108,7 @@ TryExec=ebook-viewer +@@ -1111,7 +1111,7 @@ TryExec=ebook-viewer GenericName=Viewer for E-books Comment=Viewer for E-books in all the major formats TryExec=ebook-viewer -Exec=ebook-viewer --detach %f +Exec=ebook-viewer %f Icon=calibre-viewer Categories=Office;Viewer; - ''' -@@ -1121,7 +1121,7 @@ TryExec=ebook-edit + Keywords=epub;ebook;viewer; +@@ -1125,7 +1125,7 @@ TryExec=ebook-edit GenericName=Editor for E-books Comment=Edit E-books in various formats TryExec=ebook-edit -Exec=ebook-edit --detach %f +Exec=ebook-edit %f Icon=calibre-ebook-edit Categories=Office;WordProcessor - ''' -@@ -1134,7 +1134,7 @@ TryExec=calibre + Keywords=epub;ebook;editor; +@@ -1139,7 +1139,7 @@ TryExec=calibre GenericName=E-book library management Comment=E-book library management: Convert, view, share, catalogue all your e-books TryExec=calibre -Exec=calibre --detach %U +Exec=calibre %U Icon=calibre-gui Categories=Office; X-GNOME-UsesNotifications=true