From 91e80527fc63140dc0c0a7afebe74f37494abd68 Mon Sep 17 00:00:00 2001
From: jvoisin <julien.voisin@dustri.org>
Date: Sat, 1 Sep 2018 15:07:01 +0200
Subject: [PATCH] Add archlinux to the CI

---
 .gitlab-ci.yml      |  7 +++++++
 libmat2/__init__.py | 21 ++++++++++++++++-----
 libmat2/images.py   |  4 ++--
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0d8d0ee..cd64b42 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -53,3 +53,10 @@ tests:fedora:
   - dnf install -y python3 python3-mutagen python3-gobject gdk-pixbuf2 poppler-glib gdk-pixbuf2 gdk-pixbuf2-modules cairo-gobject cairo python3-cairo perl-Image-ExifTool mailcap
   - gdk-pixbuf-query-loaders-64 > /usr/lib64/gdk-pixbuf-2.0/2.10.0/loaders.cache
   - python3 setup.py test
+
+tests:archlinux:
+  image: archlinux/base
+  stage: test
+  script:
+  - pacman -Sy --noconfirm python-mutagen python-gobject gdk-pixbuf2 poppler-glib gdk-pixbuf2 python-cairo perl-image-exiftool python-setuptools mailcap
+  - python3 setup.py test
diff --git a/libmat2/__init__.py b/libmat2/__init__.py
index 6072b42..6067861 100644
--- a/libmat2/__init__.py
+++ b/libmat2/__init__.py
@@ -3,7 +3,7 @@
 import os
 import collections
 import importlib
-from typing import Dict
+from typing import Dict, Optional
 
 # make pyflakes happy
 assert Dict
@@ -35,13 +35,24 @@ DEPENDENCIES = {
     'mutagen': 'Mutagen',
     }
 
+def _get_exiftool_path() -> Optional[str]:
+    exiftool_path = '/usr/bin/exiftool'
+    if os.path.isfile(exiftool_path):
+        if os.access(exiftool_path, os.X_OK):  # pragma: no cover
+            return exiftool_path
+
+    # ArchLinux
+    exiftool_path = '/usr/bin/vendor_perl/exiftool'
+    if os.path.isfile(exiftool_path):
+        if os.access(exiftool_path, os.X_OK):  # pragma: no cover
+            return exiftool_path
+
+    return None
+
 def check_dependencies() -> dict:
     ret = collections.defaultdict(bool)  # type: Dict[str, bool]
 
-    exiftool = '/usr/bin/exiftool'
-    ret['Exiftool'] = False
-    if os.path.isfile(exiftool) and os.access(exiftool, os.X_OK):  # pragma: no cover
-        ret['Exiftool'] = True
+    ret['Exiftool'] = True if _get_exiftool_path() else False
 
     for key, value in DEPENDENCIES.items():
         ret[value] = True
diff --git a/libmat2/images.py b/libmat2/images.py
index faa93a4..837f015 100644
--- a/libmat2/images.py
+++ b/libmat2/images.py
@@ -13,7 +13,7 @@ import gi
 gi.require_version('GdkPixbuf', '2.0')
 from gi.repository import GdkPixbuf
 
-from . import abstract
+from . import abstract, _get_exiftool_path
 
 # Make pyflakes happy
 assert Set
@@ -40,7 +40,7 @@ class _ImageParser(abstract.AbstractParser):
         self.filename to prevent parameter injections, so we need to take care
         of this.
         """
-        fun = lambda f: subprocess.check_output(['/usr/bin/exiftool', '-json', f])
+        fun = lambda f: subprocess.check_output([_get_exiftool_path(), '-json', f])
         if re.search('^[a-z0-9/]', self.filename) is None:
             out = self.__handle_problematic_filename(self.filename, fun)
         else:
-- 
GitLab