summaryrefslogtreecommitdiffstats
path: root/meta-networking/recipes-connectivity/tailscale/tailscale_1.98.3.bb
blob: a352c5cf5885ab83b95a64e9b470fdc2cc4fcbae (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
89
90
SUMMARY = "Tailscale client and daemon"
DESCRIPTION = "The easiest, most secure way to use WireGuard and 2FA."
HOMEPAGE = "https://github.com/tailscale/tailscale"
SECTION = "networking"

LICENSE = "BSD-3-Clause"
LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=cadeae10a8856ddfdb129866b75b33e3"
require ${BPN}-licenses.inc

MAJOR_MINOR = "${@oe.utils.trim_version('${PV}', 2)}"
SRC_URI = "git://github.com/tailscale/tailscale.git;protocol=https;branch=release-branch/${MAJOR_MINOR};destsuffix=${GO_SRCURI_DESTSUFFIX} \
           file://default \
           file://tailscaled.init \
           "
SRCREV = "8f2c8d6a14419e95fb9d02d6bf6113893daef5c3"
SRCREV_SHORT = "${@d.getVar('SRCREV')[:8]}"
require ${BPN}-go-mods.inc

GO_IMPORT = "tailscale.com"
GO_INSTALL = "${GO_IMPORT}/cmd/tailscaled"
GO_LINKSHARED = ""
GOBUILDFLAGS:prepend = "-tags=${@','.join(d.getVar('PACKAGECONFIG_CONFARGS').split())} "
GO_EXTRA_LDFLAGS = "-X tailscale.com/version.longStamp=${PV}-${SRCREV_SHORT} -X tailscale.com/version.shortStamp=${PV}"

# Pass build tags so go list in update-modules discovers all conditional deps
export GOFLAGS = "-tags=${@','.join(d.getVar('PACKAGECONFIG_CONFARGS').split())}"

inherit go-mod go-mod-update-modules \
    ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'update-rc.d', '', d)} \
    ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd', '', d)}

PACKAGECONFIG ??= "aws bird capture cli kube ssh tap wakeonlan"
PACKAGECONFIG[aws] = "ts_aws,ts_omit_aws"
PACKAGECONFIG[bird] = "ts_bird,ts_omit_bird"
PACKAGECONFIG[capture] = "ts_capture,ts_omit_capture"
PACKAGECONFIG[cli] = "ts_include_cli,ts_omit_include_cli"
PACKAGECONFIG[completion] = "ts_completion,ts_omit_completion"
PACKAGECONFIG[kube] = "ts_kube,ts_omit_kube"
PACKAGECONFIG[ssh] = "ts_ssh,ts_omit_ssh"
PACKAGECONFIG[tap] = "ts_tap,ts_omit_tap"
PACKAGECONFIG[wakeonlan] = "ts_wakeonlan,ts_omit_wakeonlan"

INITSCRIPT_PACKAGES = "${PN}d"
INITSCRIPT_NAME:${PN}d = "tailscaled"
INITSCRIPT_PARAMS:${PN}d = "defaults 91 9"

SYSTEMD_PACKAGES = "${BPN}d"
SYSTEMD_SERVICE:${BPN}d = "${BPN}d.service"

# override do_install, since it installs in bin instead of sbin
do_install() {
    install -d ${D}/${sbindir}
    install -m 0755 ${B}/${GO_BUILD_BINDIR}/tailscaled ${D}/${sbindir}/tailscaled

    if [ "${@bb.utils.contains('PACKAGECONFIG', 'cli', 'true', 'false', d)}" = 'true' ]; then
        install -d ${D}/${bindir}
        ln -sr ${D}${sbindir}/tailscaled ${D}${bindir}/tailscale
    fi

    if ${@bb.utils.contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
        install -d ${D}${sysconfdir}/init.d
        install -m 0755 ${UNPACKDIR}/tailscaled.init ${D}${sysconfdir}/init.d/tailscaled
        install -d ${D}${sysconfdir}/default
        install -m 644 ${UNPACKDIR}/default ${D}${sysconfdir}/default/${BPN}d
    fi

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        install -d ${D}${systemd_system_unitdir}
        install -m 644 ${B}/src/tailscale.com/cmd/tailscaled/tailscaled.service ${D}${systemd_system_unitdir}/${BPN}d.service
        install -d ${D}${sysconfdir}/default
        install -m 644 ${B}/src/tailscale.com/cmd/tailscaled/tailscaled.defaults ${D}${sysconfdir}/default/${BPN}d
    fi

}

PACKAGES =+ "${PN}d"

# mark these as src, since there are bash script etc in there and QA will complain otherwise
FILES:${PN}-src += "${libdir}/go/src"
FILES:${PN}d = "${sysconfdir} ${systemd_system_unitdir}"

RDEPENDS:${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'completion', 'bash-completion', '', d)}"
RDEPENDS:${PN}d = "iptables"

RRECOMMENDS:${PN}d = "\
    kernel-module-wireguard \
    kernel-module-tun \
    kernel-module-xt-mark \
    kernel-module-xt-tcpudp \
    kernel-module-xt-masquerade"