yggdrasil-go-0.5.8.ebuild 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. # Copyright 2021-2024 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. S="${WORKDIR}/${P/_rc/rc}"
  16. LICENSE="LGPL-3 MIT Apache-2.0 BSD ZLIB"
  17. SLOT="0"
  18. KEYWORDS="~amd64 ~arm ~arm64 ~ppc64 ~riscv ~s390 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris"
  19. RDEPEND="
  20. acct-user/${PN%-*}
  21. acct-group/${PN%-*}
  22. "
  23. BDEPEND=">=dev-lang/go-1.21"
  24. FILECAPS=(
  25. cap_net_admin,cap_net_raw+eip "usr/bin/${PN%-*}"
  26. )
  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 927; do
  63. einfo " > https://github.com/yggdrasil-network/yggdrasil-go/issues/${issue}"
  64. done
  65. }