The hardware version in `/proc/sys/kernel/syno_hw_version` does not map
exactly to versions in
https://github.com/SynoCommunity/spksrc/wiki/Synology-and-SynoCommunity-Package-Architectures.
It contains some slightly different version formats.
Instead, `/etc/synoinfo.conf` exists and contains a `unique` line with
the CPU architecture encoded. Parse that out and filter through the list
of architectures that we have SPKs for.
Tested on DS218 and DS413j.
Updates #8927
Signed-off-by: Andrew Lytvynov <awly@tailscale.com>
return"",fmt.Errorf("unsupported Synology CPU architecture %q (Go arch %q), please report a bug at https://github.com/tailscale/tailscale/issues/new/choose",cpu,goArch)
}
ifarch==""{
return"",fmt.Errorf("cannot determine CPU architecture for Synology model %q (Go arch %q), please report a bug at https://github.com/tailscale/tailscale/issues/new/choose",hinfo.DeviceModel,hinfo.GoArch)
}
returnarch,nil
}
funcparseSynoinfo(pathstring)(string,error){
f,err:=os.Open(path)
iferr!=nil{
return"",err
}
deferf.Close()
// Look for a line like:
// unique="synology_88f6282_413j"
// Extract the CPU in the middle (88f6282 in the above example).
s:=bufio.NewScanner(f)
fors.Scan(){
l:=s.Text()
if!strings.HasPrefix(l,"unique="){
continue
}
parts:=strings.SplitN(l,"_",3)
iflen(parts)!=3{
return"",fmt.Errorf(`malformed %q: found %q, expected format like 'unique="synology_$cpu_$model'`,path,l)
}
returnparts[1],nil
}
return"",fmt.Errorf(`missing "unique=" field in %q`,path)