moonraker-9999.ebuild 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. # Copyright 2021 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. PYTHON_COMPAT=( python3_{9..11} )
  5. inherit python-single-r1 systemd
  6. DESCRIPTION="API Web Server for Klipper"
  7. HOMEPAGE="https://github.com/Arksine/moonraker"
  8. if [[ ${PV} = *9999 ]]; then
  9. inherit git-r3
  10. EGIT_REPO_URI="https://github.com/Arksine/${PN}"
  11. EGIT_BRANCH="master"
  12. KEYWORDS=""
  13. else
  14. SRC_URI="https://github.com/Arksine/${PN}/archive/v${PV}.tar.gz -> ${P}.tar.gz"
  15. KEYWORDS="~amd64 ~x86 ~arm ~arm64 ~mips"
  16. fi
  17. LICENSE="GPL-3"
  18. SLOT="0"
  19. IUSE="systemd doc"
  20. DEPEND="
  21. acct-group/klipper
  22. acct-user/klipper
  23. "
  24. RDEPEND="${DEPEND}
  25. ${PYTHON_DEPS}
  26. app-misc/klipper
  27. dev-libs/libgpiod
  28. $(python_gen_cond_dep '
  29. dev-python/distro[${PYTHON_USEDEP}]
  30. dev-python/inotify-simple[${PYTHON_USEDEP}]
  31. dev-python/streaming-form-data[${PYTHON_USEDEP}]
  32. dev-python/dbus-next[${PYTHON_USEDEP}]
  33. dev-python/paho-mqtt[${PYTHON_USEDEP}]
  34. dev-python/lmdb[${PYTHON_USEDEP}]
  35. dev-python/libnacl[${PYTHON_USEDEP}]
  36. dev-python/jinja[${PYTHON_USEDEP}]
  37. dev-python/libnacl[${PYTHON_USEDEP}]
  38. >=dev-python/pillow-8.0.1[${PYTHON_USEDEP}]
  39. >=dev-python/pyserial-3.4[${PYTHON_USEDEP}]
  40. >=dev-python/tornado-6.1[${PYTHON_USEDEP}]')"
  41. RESTRICT="mirror"
  42. DOCS=( LICENSE docs/api_changes.md )
  43. src_prepare() {
  44. sed -i -e 's|^DEFAULT_KLIPPY_LOG_PATH.*|DEFAULT_KLIPPY_LOG_PATH = "/var/log/klipper/klipper.log"|g' moonraker/app.py || die
  45. #use systemd || eapply "${FILESDIR}/moonraker-openrc.patch"
  46. default
  47. }
  48. src_compile() {
  49. ${EPYTHON} -m compileall -o 0 -o 1 moonraker
  50. }
  51. src_install() {
  52. if use doc; then
  53. dodoc -r ${DOCS[@]} docs/api_changes.md docs/configuration.md docs/dev_changelog.md docs/plugins.md docs/printer_objects.md docs/user_changes.md docs/web_api.md
  54. fi
  55. diropts -o klipper -g klipper
  56. insopts -o klipper -g klipper
  57. insinto "/opt"
  58. doins -r ${PN}
  59. insinto "/etc/klipper"
  60. doins "${FILESDIR}/${PN}.conf"
  61. insinto "/usr/share/polkit-1/rules.d"
  62. doins "${FILESDIR}/${PN}.rules"
  63. dodir "/opt/${PN}/scripts"
  64. insinto "/opt/${PN}/scripts"
  65. dodir /var/log/${PN}
  66. keepdir /var/log/${PN}
  67. python_fix_shebang "${D}/opt/${PN}/moonraker.py" || die
  68. use systemd && systemd_newunit "${FILESDIR}/${PN}.service" "${PN}.service" || newinitd "${FILESDIR}/${PN}.initd" ${PN}
  69. }
  70. pkg_postinst() {
  71. echo
  72. elog "Moonraker depends on the following configuration items in the printer.cfg of klipper for full functionality:"
  73. elog " [display_status]"
  74. elog " [pause_resume]"
  75. elog " [virtual_sdcard]"
  76. echo
  77. elog "Provide an API Key at /etc/klipper/api_key with owner and group klipper and permissions 0640"
  78. }