# Maintainer: AndyRTR <andyrtr@archlinux.org>
# Maintainer: Caleb Maclennan <caleb@alerque.com>
# Contributor: Eric BĂ©langer <eric@archlinux.org>
# Contributor: Lukas Jirkovsky <l.jirkovsky@gmail.com>

pkgname=geeqie
pkgver=2.5
pkgrel=1
pkgdesc='Lightweight image viewer'
arch=('x86_64')
url="http://www.geeqie.org/"
license=('GPL-2.0-or-later')
# https://github.com/BestImageViewer/geeqie#optional-libraries
depends=('exiv2' 'gtk3' 'ffmpegthumbnailer' 'djvulibre' 'libheif' 'libchamplain'
         'poppler-glib' 'libarchive' 'libraw' 'lua' 'libjxl' 'gspell'
         'glib2' 'glibc' 'gcc-libs' 'lcms2' 'openjpeg2' 'clutter-gtk' 'clutter'
         'gdk-pixbuf2' 'libtiff' 'cairo' 'pango' 'libjpeg-turbo' 'libunwind'
         'sh' 'hicolor-icon-theme')
makedepends=('evince'
             'fbida'
             'gawk'
             'glib2-devel'
             'imagemagick'
             'intltool'
             'librsvg'
             'libwebp'
             'libwmf'
             'meson'
             'perl-image-exiftool'
             'python'
             'vim'
             # for the docs
             'doxygen' 'yelp-tools' 'graphviz'
             'pandoc-cli'
             #'fop' - for pdf format but 'pdfoutline' is missing
)
checkdepends=('xorg-server-xvfb' 'shellcheck')
optdepends=('librsvg: SVG rendering'
            'fbida: for jpeg rotation'
            'gawk: to use the geo-decode function'
            'perl-image-exiftool: for the jpeg extraction plugin'
            'gphoto2: command-line tools for various (plugin) operations'
            'imagemagick: command-line tools for various (plugin) operations'
            'evince: for print preview'
            'libwebp: for WebP image format')
source=(#"http://www.geeqie.org/${pkgname}-${pkgver}.tar.xz"{,.asc}
        https://github.com/BestImageViewer/geeqie/releases/download/v${pkgver}/${pkgname}-${pkgver}.tar.xz{,.asc}
        Skip-failing-tests.patch)
sha256sums=('cc991c9d4c78c58668105a15f7ece953bfc21b6b78cedc26ccbaaee6a12b8952'
            'SKIP'
            'cfb1ddc810006c26a28a2bc1e35116819e8f191644265c5027b5dfce532aaa2e')
validpgpkeys=('91EC400226201276E2ADCEC7D0DA6F44C936D1DA') # "Colin Clark <colin.clark@cclark.uk>"

# main repo: http://www.geeqie.org/cgi-bin/gitweb.cgi?p=geeqie.git
# bug tracker: https://github.com/BestImageViewer/geeqie/issues

prepare() {
  cd $pkgname-$pkgver
  # disable "Ancillary files" test
  # https://github.com/BestImageViewer/geeqie/issues/1274
  patch -Np1 -i $srcdir/Skip-failing-tests.patch
}

build() {
  arch-meson $pkgname-$pkgver build
  meson compile -C build
}

check() {
  meson test -C build
}

package(){
  DESTDIR="$pkgdir" meson install -C build

  # add Changelog listed in help menu
  install -m644 $pkgname-$pkgver/ChangeLog.gqview "${pkgdir}/usr/share/doc/${pkgname}/ChangeLog"

  # add missing html doc
  cp -arv build/doc/html "${pkgdir}/usr/share/doc/${pkgname}/"
}