summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: ea73cea307bde7270481b8d56f1d79dbd731569e (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Maintainer: dreieck

_pkgname='wiki2pdf'
pkgname="${_pkgname}-git"
epoch=2
pkgver=1.0.5.r6.20171207.19e936a
pkgrel=1
pkgdesc='Github Wiki to pdf Converter allows you to generate HTML & PDF documentation from your Github wiki or any other markdown-based wiki.'
arch=('any')
url='https://github.com/madajaju/wiki2pdf'
license=('custom: MIT')
depends=(
  'nodejs'
  'phantomjs'
  'wkhtmltopdf'
)
makedepends=(
  'git'
  'jshon' # To get package version
  'npm'
)
provides=(
  "${_pkgname}=${pkgver}"
)
conflicts=(
  "${_pkgname}"
)

source=(
  "${_pkgname}::git+https://github.com/madajaju/wiki2pdf.git"
)
sha256sums=(
  'SKIP'
)

prepare() {
  cd "${srcdir}/${_pkgname}"
  msg2 "Installing npm modules ..."
  npm install --cache "${srcdir}/npm-cache"
}

pkgver () {
  cd "${srcdir}/${_pkgname}"
  _ver="$(jshon -e version < package.json | tr -d '"')"
  _rev="$(git rev-list --count HEAD)"
  _date="$(git log -1 --date=format:"%Y%m%d" --format="%ad")"
  _hash="$(git rev-parse --short HEAD)"

  if [ -z "${_ver}" ]; then
    error "Version could not be determined."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

build() {
  cd "${srcdir}/${_pkgname}"
  npm run build
}

package() {
  cd "${srcdir}/${_pkgname}"

  npm install -g --cache "${srcdir}/npm-cache" --prefix="${pkgdir}/usr" "$(npm pack . | tail -n1)"
  chown -R root:root "${pkgdir}"/*

  install -D -v -m644 README.md "${pkgdir}/usr/share/doc/${_pkgname}/README.md"
  install -D -v -m644 LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.MIT.txt"
}