summaryrefslogtreecommitdiff
path: root/acme2certifier/PKGBUILD
blob: 2abeb27115db1333c78e6f2f7d3bba6e011eba29 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Maintainer: Erich Eckner <arch at eckner dot net>

pkgname=acme2certifier
pkgver=0.13.1.r15.g89dc6bd
_commit="${pkgver##*.g}"
pkgrel=1
pkgdesc='experimental acme server written in python'
arch=('any')
url='https://github.com/grindsa/acme2certifier'
license=('GPL3')
depends=(
  'python-jwcrypto'
  'python-pyopenssl'
  'python-dnspython'
  'python-pytz'
  'python-dateutil'
  'python-requests'
)
makedepends=(
  'git'
#  'python-setuptools'
)
source=(
  "${pkgname}::git+https://github.com/grindsa/${pkgname}.git#commit=${_commit}"
  'systemd.patch'
  'ssl.conf'
)
sha512sums=('SKIP'
            '6700736f127297293067930e92b711c579d800c684b587ca2c5cbc2430dee241500932b57398d87a4dbf4111483bf0942814a06587bbe2a77958c9da18a18e63'
            '3ed87346bf0776f50e452b1928c8f24db5498a5af1010042e9680ca136242f49e78d30ebca5e4328f485d1c051ab51f859a1ae2f936e0c6eb5b1cde700b3b201')
install="${pkgname}.install"

pkgver() {
  for _trial in 'origin/devel' 'devel'; do
    _commit=$(
      git -C "${pkgname}" rev-parse "${_trial}" 2>/dev/null
    ) && break
  done

  _line_revision="${_commit}"
  while true; do
    _version_line=$(
      git -C "${pkgname}" archive "${_line_revision}" -- acme/version.py \
      | tar -Ox \
      | grep -n '^__version__\s*='
    )
    _line="${_version_line%%:*}"
    _line_revision=$(
      git -C "${pkgname}" blame -L"${_line},${_line}" "${_line_revision}" -- acme/version.py \
      | awk '{print $1}'
    )
    if ! git -C "${pkgname}" archive "${_line_revision}^" -- acme/version.py \
    | tar -Ox \
    | grep -qxF "${_version_line#*:}"; then
      break
    fi
    _line_revision="${_line_revision}^"
  done
  _version="${_version_line%\'*}"
  _version="${_version##*\'}"
  _version="${_version%-*}"
  printf '%s.r%s.g%s' \
    "${_version}" \
    "$(
      git -C "${pkgname}" rev-list --count "${_commit}" ^"${_line_revision}"
    )" \
    "$(
      git -C "${pkgname}" rev-parse --short "${_commit}"
    )"
}

#build() {
#  cd "${srcdir}/${pkgname}"
#  python setup.py build
#}

prepare() {
  cd "${srcdir}/${pkgname}"
  patch -p1 -i "${srcdir}/systemd.patch"
}

package() {
  cd "${srcdir}/${pkgname}"
#  python setup.py install --root="${pkgdir}"
  install -Dm644 \
    examples/nginx/uwsgi.service \
    "${pkgdir}/usr/lib/systemd/system/acme2certifier.service"
  backup+=('etc/uwsgi/acme2certifier.ini')
  install -Dm644 \
    examples/nginx/acme2certifier.ini \
    "${pkgdir}/etc/uwsgi/acme2certifier.ini"
  install -dm755 -o http -g http "${pkgdir}/var/lib/${pkgname}"
  mv acme examples tools "${pkgdir}/var/lib/${pkgname}/"
  install -dm755 -o http -g http "${pkgdir}/var/lib/${pkgname}/acme/ca"
  install -Dm644 -t "${pkgdir}/var/lib/${pkgname}/examples/" "${srcdir}/ssl.conf"
  chown -R http:http "${pkgdir}/var/lib/${pkgname}"
  install -Dm644 -t "${pkgdir}/usr/share/doc/${pkgname}" docs/*
}