|
| 1 | +# Copyright 2020-2023 Gentoo Authors |
| 2 | +# Distributed under the terms of the GNU General Public License v2 |
| 3 | + |
| 4 | +EAPI=8 |
| 5 | +inherit go systemd tmpfiles |
| 6 | + |
| 7 | +DESCRIPTION="Tailscale VPN client and CLI tools" |
| 8 | +HOMEPAGE="https://tailscale.com https://github.com/tailscale/tailscale" |
| 9 | + |
| 10 | +SRC_URI="https://github.com/tailscale/tailscale/archive/v${PV}.tar.gz -> ${P}.tar.gz |
| 11 | + https://github.com/bekcpear/gopkg-vendors/archive/refs/tags/vendor-${P}.tar.gz -> ${P}-vendor.tar.gz" |
| 12 | + |
| 13 | +LICENSE="Apache-2.0 BSD-2 BSD MIT" |
| 14 | +SLOT="0" |
| 15 | +KEYWORDS="~amd64 ~arm ~arm64 ~riscv ~x86" |
| 16 | +IUSE="derp tools" |
| 17 | + |
| 18 | +BDEPEND=">=dev-lang/go-1.22:=" |
| 19 | + |
| 20 | +# 'iptables' is no longer mandatory, |
| 21 | +# refer to https://github.com/tailscale/tailscale/issues/391 , |
| 22 | +# and https://github.com/tailscale/tailscale/commit/243ce6ccc1a3e032e3d4a014e7dd09a9379c3c42 |
| 23 | +RDEPEND=" |
| 24 | + derp? ( |
| 25 | + acct-user/derper |
| 26 | + acct-group/derper |
| 27 | + ) |
| 28 | +" |
| 29 | + |
| 30 | +GO_SBIN="tailscaled" |
| 31 | +GO_TARGET_PKGS=" |
| 32 | + ./cmd/tailscale |
| 33 | + ./cmd/tailscaled |
| 34 | +" |
| 35 | + |
| 36 | +src_configure() { |
| 37 | + use derp && GO_TARGET_PKGS+=" ./cmd/derper" |
| 38 | + use tools && GO_TARGET_PKGS+=" ./cmd/derpprobe" |
| 39 | + |
| 40 | + . "$WORKDIR"/gopkg-vendors-vendor-$P/version.txt || die |
| 41 | + GO_LDFLAGS=" |
| 42 | + -X 'tailscale.com/version.longStamp=${VERSION_LONG}' |
| 43 | + -X 'tailscale.com/version.shortStamp=${VERSION_SHORT}' |
| 44 | + -X 'tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}'" |
| 45 | +} |
| 46 | + |
| 47 | +src_install() { |
| 48 | + go_src_install |
| 49 | + |
| 50 | + exeinto /usr/libexec |
| 51 | + doexe "$ED"/usr/bin/tailscale |
| 52 | + rm "$ED"/usr/bin/tailscale || die |
| 53 | + newbin "$FILESDIR"/tailscale.sh tailscale |
| 54 | + |
| 55 | + keepdir /var/lib/${PN} |
| 56 | + fperms 0750 /var/lib/${PN} |
| 57 | + |
| 58 | + insinto /etc/default |
| 59 | + newins "${FILESDIR}"/tailscaled.defaults tailscaled |
| 60 | + |
| 61 | + newtmpfiles "${FILESDIR}"/${PN}.tmpfiles ${PN}.conf |
| 62 | + |
| 63 | + systemd_dounit cmd/tailscaled/tailscaled.service |
| 64 | + systemd_newunit "${FILESDIR}"/tailscaled-at.service tailscaled@.service |
| 65 | + |
| 66 | + # conf for fix, should be removed later |
| 67 | + exeinto /opt/bin |
| 68 | + newexe "${FILESDIR}"/fix-mis-configured-path.sh tailscaled.misconfiged.fix.sh |
| 69 | + sed -i '/ExecStartPre=/iExecStartPre=/opt/bin/tailscaled.misconfiged.fix.sh' \ |
| 70 | + "${D}$(systemd_get_systemunitdir)"/tailscaled.service \ |
| 71 | + "${D}$(systemd_get_systemunitdir)"/tailscaled@.service |
| 72 | + |
| 73 | + newinitd "${FILESDIR}"/${PN}d.initd ${PN}d |
| 74 | + |
| 75 | + if use derp; then |
| 76 | + insinto /etc/default |
| 77 | + newins "${FILESDIR}"/derper.defaults derper |
| 78 | + |
| 79 | + exeinto /usr/libexec |
| 80 | + doexe "${FILESDIR}"/derper-pre.sh |
| 81 | + |
| 82 | + systemd_dounit "${FILESDIR}"/derper.service |
| 83 | + systemd_install_serviced "${FILESDIR}"/derper.service.conf derper |
| 84 | + |
| 85 | + newinitd "${FILESDIR}"/derper.initd derper |
| 86 | + fi |
| 87 | +} |
| 88 | + |
| 89 | +pkg_preinst() { |
| 90 | + sed -i "s#@EPREFIX@#$EPREFIX#" "$ED"/usr/bin/tailscale || die |
| 91 | + sed -i "s#@EPREFIX@#$EPREFIX#" "$ED"/opt/bin/tailscaled.misconfiged.fix.sh || die |
| 92 | +} |
| 93 | + |
| 94 | +pkg_postinst() { |
| 95 | + tmpfiles_process ${PN}.conf |
| 96 | + |
| 97 | + ewarn "multiple instances support still exists problems, such as iptables/nftables rules." |
| 98 | +} |
0 commit comments