summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 19b7f0e72b7e62b9435462a6b542b6e62220cf4c (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.7.2
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=('adda8566d9c2612bc80c622c48b066c7bc00d7e33a7a7b1ee7507b246625608e')

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: