From c3e48742612f653599af0c5fa66686acdd7f4b3a Mon Sep 17 00:00:00 2001
From: Lilac <lilac@noreply.bgme.me>
Date: Mon, 3 Jul 2023 19:01:10 +0000
Subject: [PATCH] mcomix: auto updated to 2.1.1-2

---
 repo/mcomix/01-pillow_version.patch | 15 +++++++++++++++
 repo/mcomix/PKGBUILD                | 18 +++++++++++++-----
 2 files changed, 28 insertions(+), 5 deletions(-)
 create mode 100644 repo/mcomix/01-pillow_version.patch

diff --git a/repo/mcomix/01-pillow_version.patch b/repo/mcomix/01-pillow_version.patch
new file mode 100644
index 0000000..ce0bef0
--- /dev/null
+++ b/repo/mcomix/01-pillow_version.patch
@@ -0,0 +1,15 @@
+--- mcomix/run.py.orig	2023-07-03 21:39:35.146479272 +0300
++++ mcomix/run.py	2023-07-03 21:40:16.742507561 +0300
+@@ -122,7 +122,11 @@
+     try:
+         import PIL.Image
+ 
+-        if PIL.__version__ < '6.0.0':
++        try:
++            pil_major_version = int(PIL.__version__[0:PIL.__version__.index('.')])
++        except (ValueError, IndexError):
++            pil_major_version = 0
++        if pil_major_version < 6:
+             log.error( _("You don't have the required version of the Python Imaging Library Fork (Pillow) installed."))
+             log.error( _('Installed Pillow version is: %s') % PIL.__version__ )
+             log.error( _('Required Pillow version is: 6.0.0 or higher') )
diff --git a/repo/mcomix/PKGBUILD b/repo/mcomix/PKGBUILD
index 7241f19..71a2483 100644
--- a/repo/mcomix/PKGBUILD
+++ b/repo/mcomix/PKGBUILD
@@ -4,7 +4,7 @@
 pkgname=mcomix
 # Might want to move to date-based versions.
 pkgver=2.1.1
-pkgrel=1
+pkgrel=2
 pkgdesc="A user-friendly, customizable image viewer specifically designed to handle comic books"
 arch=('any')
 url="https://sourceforge.net/p/mcomix/wiki/Home/"
@@ -19,16 +19,24 @@ optdepends=(
   'unrar: for rar compressed comics'
   'unzip: for zip compressed comics'
 )
-source=("https://downloads.sourceforge.net/project/${pkgname}/MComix-${pkgver}/${pkgname}-${pkgver}.tar.gz")
-sha256sums=('3faa22ca77392c9496e686706193219c8d2435c213ed52ae69212e0def7060d5')
+source=(
+  "https://downloads.sourceforge.net/project/${pkgname}/MComix-${pkgver}/${pkgname}-${pkgver}.tar.gz"
+  "01-pillow_version.patch"
+)
+sha256sums=('3faa22ca77392c9496e686706193219c8d2435c213ed52ae69212e0def7060d5'
+            '11964ff2ba788bcff91c7b1188c7d64f45ca139968b9ff7578eeda15430d9464')
 
-build(){
+prepare() {
+  cd "${pkgname}-${pkgver}"
+  patch -p0 < "$srcdir/01-pillow_version.patch"
+}
+
+build() {
   cd "${pkgname}-${pkgver}"
   python -m build --wheel --no-isolation
 }
 
 package() {
   cd "${pkgname}-${pkgver}"
-
   python -m installer --destdir="$pkgdir" dist/*.whl
 }