summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 8780a4247d13ebf67bb740d7ae3b47c0c746e7b6 (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
# Maintainer: Wilhelm Schuster <aur [aT] rot13 dot io>
_pkgname=moonraker
pkgname="${_pkgname}-git"
pkgver=r1952.27a0295
pkgrel=1
pkgdesc="HTTP frontend for Klipper 3D printer firmware"
arch=(any)
url="https://github.com/Arksine/moonraker"
license=('GPL3')
depends=(klipper
         python-tornado
         python-pillow
         python-pyserial-asyncio
         python-lmdb
         python-streaming-form-data
         python-distro
         python-inotify-simple
         python-libnacl
         python-paho-mqtt
         python-jinja
         python-dbus-next
         python-periphery
         curl)
#checkdepends=("python-pytest>=7.0" python-pytest-asyncio python-pytest-timeout)
makedepends=(git python-build python-installer python-wheel python-pdm)
optdepends=("polkit: enable service and machine control through moonraker"
            "python-preprocess-cancellation: enables exclude object processing"
            "python-apprise: enable [notifier] module for sending notifications"
            "python-ldap3: [authorization] using LDAP"
            "python-msgspec: optional speedup"
            "python-uvloop: optional speedup"
            "python-zeroconf: enable zeroconf announcements"
            "wireless_tools: network detection")
provides=("$_pkgname")
conflicts=("$_pkgname")
backup=('etc/klipper/moonraker.conf' 'var/opt/moonraker/systemd/moonraker.env')
install=moonraker.install
source=('git+https://github.com/Arksine/moonraker.git#branch=master' 'moonraker.install' 'moonraker.conf' 'moonraker.service' 'moonraker.env' 'moonraker.rules' 'sysusers.conf' 'tmpfiles.conf' 'moonraker-klipper.cfg')
sha256sums=('SKIP'
            'b118f346ec57228add79b9c37555adc5dbae4cb6de0e39659912376b5ad2e932'
            '16ac5116ff18e67b7334cf9baf4c404734aede0b1d56d5bed8bde90fbd926e8c'
            'c9ab1efe9e225fddaaa20b82ff33d9b00c7e7fffe06d0a27502c17d5484131fc'
            '5611f1a48bb18d0d95a31eaead4f59d84c0ae5e3c407f3488770e2236b97c3bf'
            'cef040e973a9bb697659d1506a37a5f829551d5cc96e3f81ff588d5bd67cf1d0'
            '549309fd129c8c665a5aed2d4229c20e5a9927f4fbdc937e0982db4785b9ee0d'
            '5106762365d6275a514897f5a6b42b2b08cbe941732670ac031d4f842679832b'
            'b6c35114ab2886acbd9168bb4588c86d3baea91ab38eda67b5ef38327cd7b11f')

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

  printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}

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

  # clean wheel before build to prevent subsequent package() runs from erroring
  # due to `dist/*.whl` expanding to multiple files (which `python -m install`
  # doesn't support)
  rm -f dist/*.whl

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

#check() {
#  cd "$srcdir/$_pkgname"
#  pytest
#}

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

  python -m installer --destdir="${pkgdir}" --prefix="/opt/$_pkgname" dist/*.whl

  rm -rf "$pkgdir/opt/$_pkgname/bin" # clean bin/moonraker as it doesn't work with /opt prefix

  install -Dm644 "$srcdir/moonraker.conf" "$pkgdir/etc/klipper/moonraker.conf"
  install -Dm644 "$srcdir/moonraker.service" "$pkgdir/usr/lib/systemd/system/moonraker.service"
  install -Dm644 "$srcdir/moonraker.env" "$pkgdir/var/opt/moonraker/systemd/moonraker.env"
  install -Dm644 "$srcdir/sysusers.conf" "$pkgdir/usr/lib/sysusers.d/moonraker.conf"
  install -Dm644 "$srcdir/tmpfiles.conf" "$pkgdir/usr/lib/tmpfiles.d/moonraker.conf"
  install -Dm644 "$srcdir/moonraker-klipper.cfg" "$pkgdir/usr/share/doc/moonraker/moonraker-klipper.cfg"

  # match directory owner/group and mode from [extra]/polkit
  install -d -o root -g 102 -m 0750 "$pkgdir"/usr/share/polkit-1/rules.d
  install -Dm644 "$srcdir/moonraker.rules" "$pkgdir/usr/share/polkit-1/rules.d/moonraker.rules"
}