@ -29,7 +29,6 @@ import (
"github.com/google/uuid"
"tailscale.com/clientupdate/distsign"
"tailscale.com/hostinfo"
"tailscale.com/types/logger"
"tailscale.com/util/cmpver"
"tailscale.com/util/winutil"
@ -163,10 +162,9 @@ func NewUpdater(args Arguments) (*Updater, error) {
type updateFunction func ( ) error
func ( up * Updater ) getUpdateFunction ( ) ( fn updateFunction , canAutoUpdate bool ) {
canAutoUpdate = ! hostinfo . New ( ) . Container . EqualBool ( true ) // EqualBool(false) would return false if the value is not set.
switch runtime . GOOS {
case "windows" :
return up . updateWindows , canAutoUpdat e
return up . updateWindows , tru e
case "linux" :
switch distro . Get ( ) {
case distro . NixOS :
@ -180,20 +178,20 @@ func (up *Updater) getUpdateFunction() (fn updateFunction, canAutoUpdate bool) {
// auto-update mechanism.
return up . updateSynology , false
case distro . Debian : // includes Ubuntu
return up . updateDebLike , canAutoUpdat e
return up . updateDebLike , tru e
case distro . Arch :
if up . archPackageInstalled ( ) {
// Arch update func just prints a message about how to update,
// it doesn't support auto-updates.
return up . updateArchLike , false
}
return up . updateLinuxBinary , canAutoUpdat e
return up . updateLinuxBinary , tru e
case distro . Alpine :
return up . updateAlpineLike , canAutoUpdat e
return up . updateAlpineLike , tru e
case distro . Unraid :
return up . updateUnraid , canAutoUpdat e
return up . updateUnraid , tru e
case distro . QNAP :
return up . updateQNAP , canAutoUpdat e
return up . updateQNAP , tru e
}
switch {
case haveExecutable ( "pacman" ) :
@ -202,21 +200,21 @@ func (up *Updater) getUpdateFunction() (fn updateFunction, canAutoUpdate bool) {
// it doesn't support auto-updates.
return up . updateArchLike , false
}
return up . updateLinuxBinary , canAutoUpdat e
return up . updateLinuxBinary , tru e
case haveExecutable ( "apt-get" ) : // TODO(awly): add support for "apt"
// The distro.Debian switch case above should catch most apt-based
// systems, but add this fallback just in case.
return up . updateDebLike , canAutoUpdat e
return up . updateDebLike , tru e
case haveExecutable ( "dnf" ) :
return up . updateFedoraLike ( "dnf" ) , canAutoUpdat e
return up . updateFedoraLike ( "dnf" ) , tru e
case haveExecutable ( "yum" ) :
return up . updateFedoraLike ( "yum" ) , canAutoUpdat e
return up . updateFedoraLike ( "yum" ) , tru e
case haveExecutable ( "apk" ) :
return up . updateAlpineLike , canAutoUpdat e
return up . updateAlpineLike , tru e
}
// If nothing matched, fall back to tarball updates.
if up . Update == nil {
return up . updateLinuxBinary , canAutoUpdat e
return up . updateLinuxBinary , tru e
}
case "darwin" :
switch {
@ -232,7 +230,7 @@ func (up *Updater) getUpdateFunction() (fn updateFunction, canAutoUpdate bool) {
return nil , false
}
case "freebsd" :
return up . updateFreeBSD , canAutoUpdat e
return up . updateFreeBSD , tru e
}
return nil , false
}