From 0b32adf9ecb19e990b6c8a2f149fd87a95423200 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Wed, 17 Jul 2024 10:07:33 -0700 Subject: [PATCH] hostinfo: set Hostinfo.PackageType for mkctr container builds Fixes tailscale/corp#21448 Change-Id: Id60fb5cd7d31ef94cdbb176141e034845a480a00 Signed-off-by: Brad Fitzpatrick --- build_docker.sh | 2 +- hostinfo/hostinfo_linux.go | 7 +++++++ hostinfo/packagetype_container.go | 10 ++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 hostinfo/packagetype_container.go diff --git a/build_docker.sh b/build_docker.sh index 43665172a..272f228f8 100755 --- a/build_docker.sh +++ b/build_docker.sh @@ -49,7 +49,7 @@ case "$TARGET" in -X tailscale.com/version.gitCommitStamp=${VERSION_GIT_HASH}" \ --base="${BASE}" \ --tags="${TAGS}" \ - --gotags="ts_kube" \ + --gotags="ts_kube,ts_package_container" \ --repos="${REPOS}" \ --push="${PUSH}" \ --target="${PLATFORM}" \ diff --git a/hostinfo/hostinfo_linux.go b/hostinfo/hostinfo_linux.go index d194fbb0d..53d4187bc 100644 --- a/hostinfo/hostinfo_linux.go +++ b/hostinfo/hostinfo_linux.go @@ -159,7 +159,14 @@ func linuxVersionMeta() (meta versionMeta) { return } +// linuxBuildTagPackageType is set by packagetype_*.go +// build tag guarded files. +var linuxBuildTagPackageType string + func packageTypeLinux() string { + if v := linuxBuildTagPackageType; v != "" { + return v + } // Report whether this is in a snap. // See https://snapcraft.io/docs/environment-variables // We just look at two somewhat arbitrarily. diff --git a/hostinfo/packagetype_container.go b/hostinfo/packagetype_container.go new file mode 100644 index 000000000..9bd14493c --- /dev/null +++ b/hostinfo/packagetype_container.go @@ -0,0 +1,10 @@ +// Copyright (c) Tailscale Inc & AUTHORS +// SPDX-License-Identifier: BSD-3-Clause + +//go:build linux && ts_package_container + +package hostinfo + +func init() { + linuxBuildTagPackageType = "container" +}