Skip to content

Commit

Permalink
deskutils/calibre: Update to 6.23.0
Browse files Browse the repository at this point in the history
Upstream code tries to downloads iso-codes during build. To avoid
this add a dependency on misc/iso-codes port extract and patch the
code to copy the required files from there.
  • Loading branch information
madpilot78 committed Jul 14, 2023
1 parent 4415877 commit 14c120d
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 64 deletions.
18 changes: 12 additions & 6 deletions deskutils/calibre/Makefile
@@ -1,6 +1,5 @@
PORTNAME= calibre
PORTVERSION= 6.22.0
PORTREVISION= 1
PORTVERSION= 6.23.0
CATEGORIES= deskutils python
MASTER_SITES= http://download.calibre-ebook.com/${PORTVERSION}/ \
https://curl.haxx.se/ca/:cacert
Expand Down Expand Up @@ -43,7 +42,8 @@ BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVO
${PYTHON_PKGNAMEPREFIX}pyicu>0:devel/py-pyicu@${PY_FLAVOR} \
${LOCALBASE}/bin/cmake:devel/cmake-core \
liberation-fonts-ttf>=2.1.3:x11-fonts/liberation-fonts-ttf \
MathJax3>0:www/mathjax3
MathJax3>0:www/mathjax3 \
${NONEXISTENT}:misc/iso-codes:extract
RUN_DEPENDS= xdg-open:devel/xdg-utils \
${PYTHON_PKGNAMEPREFIX}css-parser>=1.0.4:www/py-css-parser@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}dnspython>=0:dns/py-dnspython@${PY_FLAVOR} \
Expand Down Expand Up @@ -82,8 +82,8 @@ USE_GNOME= glib20
USE_XORG= xrender xext x11

USE_GITHUB= nodefault
GH_TUPLE= kovidgoyal:calibre-translations:d911cab:translations \
LibreOffice:dictionaries:8b6fc85:hypenation
GH_TUPLE= kovidgoyal:calibre-translations:41c9da0:translations \
LibreOffice:dictionaries:d1ddba9:hypenation

SHEBANG_GLOB= *.sh *.py *.recipe
python_OLD_CMD= "/usr/bin/env python" ${LOCALBASE}/bin/python3
Expand All @@ -103,6 +103,10 @@ MAKE_ENV+= FC_INC_DIR="${LOCALBASE}/include/fontconfig" \
SIP_DIR=${PYQT_SIPDIR} \
PYTHONDONTWRITEBYTECODE=true

.include <bsd.port.pre.mk>

ISOCODESWRKSRC!= ${BSDMAKE} -C ${.CURDIR}/../../misc/iso-codes -V WRKSRC

post-extract:
@${MV} ${WRKSRC_translations} ${WRKSRC}/src/translations
@${CP} ${DISTDIR}/${DIST_SUBDIR}/cacert.pem ${WRKSRC}/resources/mozilla-ca-certs.pem
Expand All @@ -114,6 +118,8 @@ post-patch:
${WRKSRC}/setup/install.py \
${WRKSRC}/src/calibre/gui2/dialogs/custom_recipes.py \
${WRKSRC}/src/calibre/gui2/preferences/tweaks.py
@${REINPLACE_CMD} -e "s|%%ISOCODESWRKSRC%%|${ISOCODESWRKSRC}|" \
${WRKSRC}/setup/iso_codes.py

do-configure:
# do nothing
Expand Down Expand Up @@ -151,4 +157,4 @@ update-recent-uas: patch
${PYSETUP} recent_uas)
${CP} ${BUILD_WRKSRC}/resources/user-agent-data.json ${FILESDIR}

.include <bsd.port.mk>
.include <bsd.port.post.mk>
14 changes: 7 additions & 7 deletions deskutils/calibre/distinfo
@@ -1,9 +1,9 @@
TIMESTAMP = 1688111798
SHA256 (calibre/calibre-6.22.0.tar.xz) = 4c15dd11fe8c04feb885e63ab8069526d65cf929e117804d26085c0ae4e8a547
SIZE (calibre/calibre-6.22.0.tar.xz) = 42822576
TIMESTAMP = 1689333206
SHA256 (calibre/calibre-6.23.0.tar.xz) = 5d7e75d6452d2f89694aca7d253b87ac625de0ce82840e8fc18e5e9e7db37fc2
SIZE (calibre/calibre-6.23.0.tar.xz) = 42881840
SHA256 (calibre/cacert.pem) = fb1ecd641d0a02c01bc9036d513cb658bbda62a75e246bedbc01764560a639f0
SIZE (calibre/cacert.pem) = 216583
SHA256 (calibre/kovidgoyal-calibre-translations-d911cab_GH0.tar.gz) = 625b6bed69e376bd05de2b1b76e1c2b21846e31beb6bb2e957cf2aa472c29fb7
SIZE (calibre/kovidgoyal-calibre-translations-d911cab_GH0.tar.gz) = 71813621
SHA256 (calibre/LibreOffice-dictionaries-8b6fc85_GH0.tar.gz) = dcbdeddb3c7c8df2d340ae381bbefd8ee6a64b7a6c79a6ad6e0d095463dcd2a3
SIZE (calibre/LibreOffice-dictionaries-8b6fc85_GH0.tar.gz) = 94696029
SHA256 (calibre/kovidgoyal-calibre-translations-41c9da0_GH0.tar.gz) = 0f16c90262365bae388b4d7f6211b5ce75e5be2c5057640a36d915f9db118a02
SIZE (calibre/kovidgoyal-calibre-translations-41c9da0_GH0.tar.gz) = 71814203
SHA256 (calibre/LibreOffice-dictionaries-d1ddba9_GH0.tar.gz) = 47e10a74859c772592713f1e37b48678453483a1745411bbbac549ecdb0440a1
SIZE (calibre/LibreOffice-dictionaries-d1ddba9_GH0.tar.gz) = 94695596
56 changes: 56 additions & 0 deletions deskutils/calibre/files/patch-setup_iso__codes.py
@@ -0,0 +1,56 @@
--- setup/iso_codes.py.orig 2023-07-14 01:29:18 UTC
+++ setup/iso_codes.py
@@ -1,42 +1,24 @@
#!/usr/bin/env python
# License: GPLv3 Copyright: 2023, Kovid Goyal <kovid at kovidgoyal.net>
-import fnmatch
+import glob
import os
-import shutil, time
-import zipfile
-from io import BytesIO
+import shutil

-from setup import download_securely

-
class ISOData:
- URL = 'https://salsa.debian.org/iso-codes-team/iso-codes/-/archive/main/iso-codes-main.zip'
-
- def __init__(self):
- self._zip_data = None
-
- @property
- def zip_data(self):
- if self._zip_data is None:
- self._zip_data = BytesIO(download_securely(self.URL))
- return self._zip_data
-
def db_data(self, name: str) -> bytes:
- with zipfile.ZipFile(self.zip_data) as zf:
- with zf.open(f'iso-codes-main/data/{name}') as f:
- return f.read()
+ src = f'%%ISOCODESWRKSRC%%/data/{name}'
+ if not os.path.exists(src):
+ raise Exception(src + ' does not exist')
+ with open(src, 'rb') as f:
+ return f.read()

def extract_po_files(self, name: str, output_dir: str) -> None:
name = name.split('.', 1)[0]
- pat = f'iso-codes-main/{name}/*.po'
- with zipfile.ZipFile(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))
+ pat = f'%%ISOCODESWRKSRC%%/{name}/*.po'
+ for name in glob.glob(pat):
+ dest = os.path.join(output_dir, name.split('/')[-1])
+ shutil.copy2(name, dest)

iso_data = ISOData()

0 comments on commit 14c120d

Please sign in to comment.