yggdrasil-go-0.4.7.ebuild 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. # Copyright 2021-2023 Gentoo Authors
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=8
  4. inherit go-module linux-info systemd fcaps
  5. DESCRIPTION="An experiment in scalable routing as an encrypted IPv6 overlay network"
  6. HOMEPAGE="
  7. https://yggdrasil-network.github.io/
  8. https://github.com/yggdrasil-network/yggdrasil-go
  9. "
  10. SRC_URI="
  11. https://github.com/${PN%%-*}-network/${PN}/archive/v${PV/_rc/rc}.tar.gz -> ${P}.tar.gz
  12. https://github.com/dm9pZCAq/gentoo-go-deps/releases/download/${P}/${P}-deps.tar.xz
  13. https://github.com/dm9pZCAq/gentoo-go-deps/releases/download/${P}/${P}-vendor.tar.xz
  14. "
  15. LICENSE="LGPL-3 MIT Apache-2.0 BSD ZLIB"
  16. SLOT="0"
  17. KEYWORDS="amd64 arm arm64 ppc64 ~riscv ~s390 x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
  18. RDEPEND="
  19. acct-user/${PN%-*}
  20. acct-group/${PN%-*}
  21. "
  22. BDEPEND=">=dev-lang/go-1.17"
  23. FILECAPS=(
  24. cap_net_admin,cap_net_raw+eip "usr/bin/${PN%-*}"
  25. )
  26. S="${WORKDIR}/${P/_rc/rc}"
  27. pkg_setup() {
  28. linux-info_pkg_setup
  29. if ! linux_config_exists; then
  30. eerror "Unable to check your kernel for TUN support"
  31. else
  32. CONFIG_CHECK="~TUN"
  33. ERROR_TUN="Your kernel lacks TUN support."
  34. fi
  35. }
  36. src_compile() {
  37. local src_version="github.com/yggdrasil-network/yggdrasil-go/src/version"
  38. local cmd=''
  39. for cmd in "${PN%-*}"{,ctl}; do
  40. CGO_ENABLED=0 ego build -ldflags="
  41. -X ${src_version}.buildName=${P}
  42. -X ${src_version}.buildVersion=v${PV}
  43. -extldflags '-static'
  44. " -o "${cmd}" "./cmd/${cmd}"
  45. done
  46. }
  47. src_install() {
  48. dobin yggdrasil{,ctl}
  49. systemd_dounit "contrib/systemd/${PN%-*}.service"
  50. doinitd "contrib/openrc/${PN%-*}"
  51. einstalldocs
  52. }
  53. pkg_postinst() {
  54. local issue=''
  55. fcaps_pkg_postinst
  56. einfo "runit service: https://notabug.org/dm9pZCAq/etcfiles/src/master/sv/${PN%-*}"
  57. einfo "which can run ${PN%-*} as non-root user"
  58. einfo "you can see how it's done there to do so for yours init system"
  59. einfo 'contributing patches here to do so for systemd and openrc are appreciated'
  60. einfo
  61. einfo 'also, related upstream issues:'
  62. for issue in 8{0{2..3},16}; do
  63. einfo " > https://github.com/yggdrasil-network/yggdrasil-go/issues/${issue}"
  64. done
  65. }