PKGBUILD Suggestion: Patch MComix 1.2.1 to make it work alongside python2-pillow 6.0.0

#1

Because of breaking changes in python2-pillow (and python-pillow) 6.0.0, MComix 1.2.1 is currently totally broken and unusable in Testing and Unstable. When trying to launch it from the terminal, I get the following output:

[ami@xfcenew Bureau]$ mcomix
Traceback (most recent call last):
  File "/usr/bin/mcomix", line 11, in <module>
    load_entry_point('mcomix==1.2.1', 'console_scripts', 'mcomix')()
  File "/usr/lib/python2.7/site-packages/mcomix/run.py", line 206, in run
    assert PIL.Image.VERSION >= '1.1.5'
AttributeError: 'module' object has no attribute 'VERSION'
[ami@xfcenew Bureau]$

This is a well known issue and reported on Arch Linux bug tracker. See here: https://bugs.archlinux.org/task/62242?project=5&string=mcomix

Upstream fixed the issue on their side with commit 486f02 in master, but have not made a new release yet (they didn't do any new release since February 2016 actually).

I do not use this application myself, but even, I still tried to fix the issue by backporting this commit in the source code for version 1.2.1. It looks like my fix works fine on my side, although I only did the test on a VM.

Here's my PKGBUILD. Consider it as a proof of concept and feel free to adapt it as you want (if you decide to make an overlay of course). https://mega.nz/#!llMxCa6L!FOtkjH9Y4KzTfvR2wxxi6WXYIHJFs4K6yF7obYF11Hw

I don't know how to download a .diff or .patch file from SourceForge, so I had to made the .diff file myself.

The build time should not be much an issue, it should be something really quick to build (it took a few seconds on my machine).

The overlay package will be needed for all branches that has python2-pillow 6.0.0, so currently Unstable and Testing (and Stable soon, when there will be a sync between Stable and Testing).

Thanks in advance.

6 Likes
mcomix broke after latest update on testing branch
[Stable Update] 2019-04-20 - Nvidia, Kernels, Deepin
#2

Just for future reference, an "easy" way to provide a diff for a PKGBUILD is something like:

yay -G mcomix
cd mcomix
git init
git add .
# EDIT PKGBUILD etc. etc.
git diff > my-patch.diff

then you can share just the contents of my-patch.diff and it can be applied to the original source with git apply my-patch.diff.

e.g.

diff --git c/486f02.diff i/486f02.diff
new file mode 100644
index 0000000..0558840
--- /dev/null
+++ i/486f02.diff
@@ -0,0 +1,15 @@
+--- a/mcomix/run.py
++++ b/mcomix/run.py
+@@ -203,7 +203,11 @@
+ 
+     try:
+         import PIL.Image
+-        assert PIL.Image.VERSION >= '1.1.5'
++        try:
++            assert PIL.Image.VERSION >= '1.1.5'
++        except AttributeError:
++            # Field VERSION deprecated in Pillow 5.2.0 and dropped in 6.0.0
++            assert PIL.__version__ >= '5.2.0'
+ 
+     except AssertionError:
+         log.error( _("You don't have the required version of the Python Imaging"), end=' ')
diff --git c/PKGBUILD i/PKGBUILD
index b372bf3..6ce0091 100644
--- c/PKGBUILD
+++ i/PKGBUILD
@@ -1,12 +1,13 @@
+# PROOF OF CONCEPT: PATCH MCOMIX 1.2.1 TO MAKE IT WORK WITH PYTHON2-PILLOW 6.0.0
 # Maintainer: schuay <jakob.gruber@gmail.com>
 # Contributor: Ray Powell <ray_al@xphoniexx.net>
 
 pkgname=mcomix
 pkgver=1.2.1
-pkgrel=4
+pkgrel=4.1
 pkgdesc="A user-friendly, customizable image viewer specifically designed to handle comic books"
 arch=('any')
-url="https://sourceforge.net/projects/mcomix/"
+url="http://sourceforge.net/projects/mcomix/"
 license=('GPL')
 depends=('pygtk' 'python2-pillow' 'xdg-utils' 'python2' \
          'desktop-file-utils' 'hicolor-icon-theme' 'python2-setuptools')
@@ -16,20 +17,32 @@ optdepends=('libunrar: for rar compressed comics'
             'p7zip: for 7zip compressed comics')
 conflicts=('comix')
 replaces=('comix')
-source=("https://downloads.sourceforge.net/project/mcomix/MComix-${pkgver}/mcomix-${pkgver}.tar.bz2")
+source=("http://downloads.sourceforge.net/project/mcomix/MComix-${pkgver}/mcomix-${pkgver}.tar.bz2"
+        "486f02.diff")
+md5sums=('1d05ed7596bd670e5b3a97896e6d4d47'
+         'e033a538925e6119a540bf084f1de878')
+
+prepare() {
+  cd "${srcdir}"/${pkgname}-${pkgver}
+  
+  #Backport commit 486f02eef164df451a72598ce5989a1b37b49c60 to source code so mcomix 1.2.1 works
+  #with python2-pillow 6.0.0 (See https://bugs.archlinux.org/task/62242)
+  #https://sourceforge.net/p/mcomix/git/ci/486f02eef164df451a72598ce5989a1b37b49c60/
+  patch -p1 -i ../486f02.diff
+  #Remove this patch once there is a new version from upstream that works correctly w/ pillow 6.0.0
+}
 
 package() {
-  cd ${srcdir}/${pkgname}-${pkgver}
+  cd "${srcdir}"/${pkgname}-${pkgver}
 
-  export PYTHONPATH=${pkgdir}/usr/lib/python2.7/site-packages/
+  export PYTHONPATH="${pkgdir}"/usr/lib/python2.7/site-packages/
   mkdir -p $PYTHONPATH
 
   python2 setup.py install --prefix=/usr --optimize=1 \
-    --single-version-externally-managed --root=${pkgdir}
+    --single-version-externally-managed --root="${pkgdir}"
 
-  install -Dm755 mime/comicthumb ${pkgdir}/usr/bin/comicthumb
-  install -Dm644 mime/comicthumb.1.gz ${pkgdir}/usr/share/man/man1/comicthumb.1.gz
-  install -Dm644 mime/comicthumb.thumbnailer ${pkgdir}/usr/share/thumbnailers/comicthumb.thumbnailer
+  install -Dm755 mime/comicthumb "${pkgdir}"/usr/bin/comicthumb
+  install -Dm644 mime/comicthumb.1.gz "${pkgdir}"/usr/share/man/man1/comicthumb.1.gz
+  install -Dm644 mime/comicthumb.thumbnailer "${pkgdir}"/usr/share/thumbnailers/comicthumb.thumbnailer
 }
 
-md5sums=('1d05ed7596bd670e5b3a97896e6d4d47')

Building soon, will be in unstable shortly.

mcomix-1.2.1-4.1 is now in unstable .

1 Like