diff --git a/cmd/tailscale/depaware-minlinux.txt b/cmd/tailscale/depaware-minlinux.txt index 77993b7f0..b30948028 100644 --- a/cmd/tailscale/depaware-minlinux.txt +++ b/cmd/tailscale/depaware-minlinux.txt @@ -80,7 +80,7 @@ tailscale.com/cmd/tailscale dependencies: (generated by github.com/tailscale/dep tailscale.com/types/empty from tailscale.com/ipn tailscale.com/types/ipproto from tailscale.com/ipn+ tailscale.com/types/key from tailscale.com/client/tailscale+ - tailscale.com/types/lazy from tailscale.com/version+ + tailscale.com/types/lazy from tailscale.com/version tailscale.com/types/logger from tailscale.com/client/web+ tailscale.com/types/netmap from tailscale.com/cmd/tailscale/cli+ tailscale.com/types/nettype from tailscale.com/net/netcheck+ diff --git a/cmd/tailscaled/depaware-minlinux.txt b/cmd/tailscaled/depaware-minlinux.txt index 820d27f20..912355aa0 100644 --- a/cmd/tailscaled/depaware-minlinux.txt +++ b/cmd/tailscaled/depaware-minlinux.txt @@ -77,7 +77,7 @@ tailscale.com/cmd/tailscaled dependencies: (generated by github.com/tailscale/de tailscale.com/types/flagtype from tailscale.com/cmd/tailscaled tailscale.com/types/ipproto from tailscale.com/ipn+ tailscale.com/types/key from tailscale.com/control/controlbase+ - tailscale.com/types/lazy from tailscale.com/version+ + tailscale.com/types/lazy from tailscale.com/version tailscale.com/types/logger from tailscale.com/cmd/tailscaled+ tailscale.com/types/logid from tailscale.com/ipn/ipnlocal+ tailscale.com/types/netmap from tailscale.com/control/controlclient+ diff --git a/version/distro/distro.go b/version/distro/distro.go index f7997e1d9..1299ed16d 100644 --- a/version/distro/distro.go +++ b/version/distro/distro.go @@ -4,16 +4,6 @@ // Package distro reports which distro we're running on. package distro -import ( - "bytes" - "os" - "runtime" - "strconv" - - "tailscale.com/types/lazy" - "tailscale.com/util/lineiter" -) - type Distro string const ( @@ -33,124 +23,19 @@ const ( UBNT = Distro("ubnt") // Ubiquiti Networks ) -var distro lazy.SyncValue[Distro] -var isWSL lazy.SyncValue[bool] - // Get returns the current distro, or the empty string if unknown. func Get() Distro { - return distro.Get(func() Distro { - switch runtime.GOOS { - case "linux": - return linuxDistro() - case "freebsd": - return freebsdDistro() - default: - return Distro("") - } - }) + return "" } // IsWSL reports whether we're running in the Windows Subsystem for Linux. func IsWSL() bool { - return runtime.GOOS == "linux" && isWSL.Get(func() bool { - // We could look for $WSL_INTEROP instead, however that may be missing if - // the user has started to use systemd in WSL2. - return have("/proc/sys/fs/binfmt_misc/WSLInterop") || have("/mnt/wsl") - }) + return false } -func have(file string) bool { - _, err := os.Stat(file) - return err == nil -} - -func haveDir(file string) bool { - fi, err := os.Stat(file) - return err == nil && fi.IsDir() -} - -func linuxDistro() Distro { - switch { - case haveDir("/usr/syno"): - return Synology - case have("/usr/local/bin/freenas-debug"): - // TrueNAS Scale runs on debian - return TrueNAS - case have("/usr/bin/ubnt-device-info"): - // UBNT runs on Debian-based systems. This MUST be checked before Debian. - // - // Currently supported product families: - // - UDM (UniFi Dream Machine, UDM-Pro) - return UBNT - case have("/etc/debian_version"): - return Debian - case have("/etc/arch-release"): - return Arch - case have("/etc/openwrt_version"): - return OpenWrt - case have("/run/current-system/sw/bin/nixos-version"): - return NixOS - case have("/etc/config/uLinux.conf"): - return QNAP - case haveDir("/gokrazy"): - return Gokrazy - case have("/usr/local/wdmcserver/bin/wdmc.xml"): // Western Digital MyCloud OS3 - return WDMyCloud - case have("/usr/sbin/wd_crontab.sh"): // Western Digital MyCloud OS5 - return WDMyCloud - case have("/etc/unraid-version"): - return Unraid - case have("/etc/alpine-release"): - return Alpine - } - return "" -} - -func freebsdDistro() Distro { - switch { - case have("/etc/pfSense-rc"): - return Pfsense - case have("/usr/local/sbin/opnsense-shell"): - return OPNsense - case have("/usr/local/bin/freenas-debug"): - // TrueNAS Core runs on FreeBSD - return TrueNAS - } - return "" -} - -var dsmVersion lazy.SyncValue[int] - // DSMVersion reports the Synology DSM major version. // // If not Synology, it reports 0. func DSMVersion() int { - if runtime.GOOS != "linux" { - return 0 - } - return dsmVersion.Get(func() int { - if Get() != Synology { - return 0 - } - // This is set when running as a package: - v, _ := strconv.Atoi(os.Getenv("SYNOPKG_DSM_VERSION_MAJOR")) - if v != 0 { - return v - } - // But when run from the command line, we have to read it from the file: - for lr := range lineiter.File("/etc/VERSION") { - line, err := lr.Value() - if err != nil { - break // but otherwise ignore - } - line = bytes.TrimSpace(line) - if string(line) == `majorversion="7"` { - return 7 - } - if string(line) == `majorversion="6"` { - return 6 - } - } - return 0 - }) + return 0 }