summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 019ff78437cc95848092f045e65bcb46617a68d7 (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
# Maintainer: dreieck

_pkgname=woice
pkgname="${_pkgname}-git"
epoch=0
pkgver=0.0.4.r10.20230912.6b7799f
pkgrel=3
pkgdesc='Automatic login script for WIFIonICE public WiFi by Deutsche Bahn captive portals.'
url='https://github.com/keans/woice'
arch=(any)
license=(MIT)
depends=(
  'python>=3.7' 'python<4'
  'python-click'
  'python-lxml'
  'python-requests'
)
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
)
optdepends=(
  "bash:           To make use of the NetworkManager integration."
  "networkmanager: To make use of the NetworkManager integration."
  "util-linux:     To make use of the NetworkManager integration (logging)."
  "which:          To make use of the NetworkManager integration."
  "wireless_tools: To make use of the NetworkManager integration."
)
provides=(
  "${_pkgname}"
  "python-${_pkgname}=${pkgver}"
  "python-${_pkgname}-git=${pkgver}"
  "nm-wifionice-login=${pkgver}"
  "nm-wifionice-login-git=${pkgver}"
)
conflicts=(
  "${_pkgname}"
  "python-${_pkgname}"
  "python-${_pkgname}-git"
  "nm-wifionice-login"
  "nm-wifionice-login-git"
)
source=(
  "${_pkgname}::git+${url}.git"
)
sha256sums=(
  'SKIP'
)

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

  git log > git.log
}

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

  _ver="$(grep -E '^[[:space:]]*version[[:space:]]*=[[:space:]]*[^[:space:]]' 'setup.py' | head -n1 | sed -E 's|^[[:space:]]*version[[:space:]]*=||' | sed -E 's|#.*$||' | 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 "Could not determine version."
    return 1
  else
    printf '%s' "${_ver}.r${_rev}.${_date}.${_hash}"
  fi
}

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

  python -m build --wheel --no-isolation
}

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

  python -m installer --destdir="$pkgdir" dist/*.whl

  install -D -v -m755 'examples/wifionice.sh' "${pkgdir}/etc/NetworkManager/dispatcher.d/wifionice.sh"

  for _docfile in README.rst CHANGELOG.rst git.log; do
    install -D -v -m644 "${_docfile}" "${pkgdir}/usr/share/doc/${_pkgname}/${_docfile}"
  done
  install -D -v -m 644 "LICENSE.txt" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
}