summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: c36d769d004dcb776cbbc97043a3d1118609f368 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Original maintainer: Corentin Cadiou <contact@cphyc.me>
# Current maintainer: Corentin Cadiou <contact@cphyc.me>
pkgname=zotero-extension-ocr
_pkgname=zotero-ocr
pkgver=0.8.1
pkgrel=1
pkgdesc="Zotero Plugin for OCR."
arch=(any)
url="https://github.com/UB-Mannheim/zotero-ocr"
license=('AGPL3')
depends=(
    'poppler'
    'tesseract'
)
makedepends=(
    'zip'
)
optdepends=()
groups=("zotero-addons")
source=(
    "${_pkgname}-${pkgver}.xpi::https://github.com/UB-Mannheim/${_pkgname}/releases/download/${pkgver}/${_pkgname}-${pkgver}.xpi"
)
sha256sums=('345556bc3753a0e4c653ecb501e00a320dafba498629c4d9dc20e1bd8104a293')

prepare() {
  # Make sure zotero is not running
  if [[ $(pgrep -c zotero) -gt 0 ]]; then
    echo "Zotero is running, please close it before installing this package."
    exit 1
  fi

  # Edit the defaults to point to the right location
  LOCAL_TESSERACT=$(which tesseract)
  LOCAL_PDFTOPPM=$(which pdftoppm)

  printf 'pref("extensions.zotero.zoteroocr.ocrPath", "%s");\n' $LOCAL_TESSERACT >> defaults/preferences/defaults.js
  printf 'pref("extensions.zotero.zoteroocr.pdftoppmPath", "%s");\n' $LOCAL_PDFTOPPM >> defaults/preferences/defaults.js

  # Update the preferences in the xpi to reflect this
  zip -u ${_pkgname}-${pkgver}.xpi defaults/preferences/defaults.js
}

package() {
    folder=${pkgdir}/usr/lib/zotero/extensions
    mkdir "$folder" -p
    install -Dm644 ${_pkgname}-${pkgver}.xpi "$folder/${_pkgname}@bib.uni-mannheim.de.xpi"
}

# vim:set ts=2 sw=2 et: