Re: Yocto recipe for Tailscale #yocto #golang


Randy MacLeod
 

On 2020-09-19 4:58 p.m., Mike Thompson via lists.yoctoproject.org wrote:

I seemed to have resolved all my issues getting a Yocto Bitbake recipe for the Tailscale client and CLI utility.

For future reference and in case it helps others, below is my Bitbake recipe:

Hi Mike,

Could you send your tailscale recipe to meta-openembedded/meta-networking?
    Email: OpenEmbedded Development mailing list <openembedded-devel@...>
    Instructions: https://www.openembedded.org/wiki/How_to_submit_a_patch_to_OpenEmbedded

It looks like all the work is done aside from an email!

../Randy


------------------------------------------------

# tailscale_1.0.5.bb

SUMMARY = "Tailscale client and daemon for Linux"

HOMEPAGE = "github.com/tailscale/tailscale"

SECTION = "net"

 

LICENSE = "CLOSED"

LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=d995c1c44529856a0f35a5ad43e51cc5"

 

SRC_URI = "git://github.com/tailscale/tailscale.git;nobranch=1;tag=v${PV}"

 

inherit go-mod systemd

 

GO_IMPORT = "tailscale.com"

GO_WORKDIR = "${GO_IMPORT}"

GO_INSTALL = "${GO_IMPORT}/cmd/tailscale ${GO_IMPORT}/cmd/tailscaled"

 

FILES_${PN} += "${systemd_unitdir}/*"

 

do_install() {

    install -d ${D}/${bindir}

    install -d ${D}/${sbindir}

    install ${B}/bin/tailscale ${D}/${bindir}/tailscale

    install ${B}/bin/tailscaled ${D}/${sbindir}/tailscaled

 

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then

        install -d ${D}${sysconfdir}/default/

        install -m 0644 ${WORKDIR}/build/src/${GO_IMPORT}/cmd/tailscaled/tailscaled.defaults ${D}${sysconfdir}/default/tailscaled

 

        install -d ${D}${systemd_unitdir}/system

        install -m 0644 ${WORKDIR}/build/src/${GO_IMPORT}/cmd/tailscaled/tailscaled.service ${D}${systemd_unitdir}/system/tailscaled.service

 

        install -d ${D}${sysconfdir}/systemd/system/multi-user.target.wants/

        ln -s ${systemd_unitdir}/system/tailscaled.service ${D}${sysconfdir}/systemd/system/multi-user.target.wants/tailscaled.service

    fi

}

 

SYSTEMD_PACKAGES = "${PN}"

SYSTEMD_SERVICE_${PN} = "tailscaled.service"

SYSTEMD_AUTO_ENABLE = "enable"

------------------------------------------------

 
When installed on my target system, systemd reports the following for the tailscaled daemon:
------------------------------------------------
[[0;1;32m●[[0m tailscaled.service - Tailscale node agent
     Loaded: loaded (/lib/systemd/system/tailscaled.service; enabled; vendor preset: enabled)
     Active: [[0;1;32mactive (running)[[0m since Sat 2020-09-19 20:46:02 UTC; 4min 44s ago
       Docs: https://tailscale.com/kb/
   Main PID: 252 (tailscaled)
      Tasks: 13 (limit: 19081)
     Memory: 56.5M
     CGroup: /system.slice/tailscaled.service
             └─252 /usr/sbin/tailscaled --state=/var/lib/tailscale/tailscaled.state --socket=/run/tailscale/tai
lscaled.sock --port 41641
 
Sep 19 20:48:03 amber tailscaled[252]: 7.2M/39.1M control: cancelMapSafely: synced=false
Sep 19 20:48:03 amber tailscaled[252]: 7.2M/39.1M control: cancelMapSafely: wrote to channel
Sep 19 20:48:03 amber tailscaled[252]: 7.2M/39.1M control: mapRoutine: new map needed while idle.
Sep 19 20:48:03 amber tailscaled[252]: 7.2M/39.1M control: mapRoutine: state:url-visit-required
Sep 19 20:48:03 amber tailscaled[252]: 7.3M/39.1M LinkChange(isExpensive=false); needsRebind=false
Sep 19 20:48:03 amber tailscaled[252]: 7.3M/39.1M magicsock: starting endpoint update (link-change-minor)
Sep 19 20:48:03 amber tailscaled[252]: 7.6M/39.1M LinkChange(isExpensive=false); needsRebind=false
Sep 19 20:48:03 amber tailscaled[252]: 7.6M/39.1M magicsock: starting endpoint update (link-change-minor)
Sep 19 20:48:03 amber tailscaled[252]: 7.5M/39.1M LinkChange(isExpensive=false); needsRebind=false
Sep 19 20:48:03 amber tailscaled[252]: 7.2M/39.1M magicsock: starting endpoint update (link-change-minor)

------------------------------------------------

 
And ifconfig reports the following:
------------------------------------------------

# ifconfig

tailscale0 Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00  

          inet6 addr: fe80::7f12:8835:cc06:b3e7/64 Scope:Link

          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1280  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:14 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:500 

          RX bytes:0 (0.0 B)  TX bytes:825 (825.0 B)

------------------------------------------------

Thank you to Khem for the tip on looking into "inherit go-mod" and patience while I sorted through this.
 
Mike Thompson
 




-- 
# Randy MacLeod
# Wind River Linux

Join yocto@lists.yoctoproject.org to automatically receive all group messages.