From 43f4131d7a79084528e91b4c78adef9864af1971 Mon Sep 17 00:00:00 2001 From: Mario Minardi Date: Tue, 24 Sep 2024 15:00:37 -0600 Subject: [PATCH] {release,version}: add DSM7.2 specific synology builds (#13405) Add separate builds for DSM7.2 for synology so that we can encode separate versioning information in the INFO file to distinguish between the two. Fixes https://github.com/tailscale/corp/issues/22908 Signed-off-by: Mario Minardi --- release/dist/synology/pkgs.go | 31 +++++++++++++++++++++++++++---- release/dist/synology/targets.go | 27 +++++++++++++++++++++------ version/mkversion/mkversion.go | 9 +++++---- 3 files changed, 53 insertions(+), 14 deletions(-) diff --git a/release/dist/synology/pkgs.go b/release/dist/synology/pkgs.go index d6df06d96..7802470e1 100644 --- a/release/dist/synology/pkgs.go +++ b/release/dist/synology/pkgs.go @@ -24,13 +24,14 @@ type target struct { filenameArch string dsmMajorVersion int + dsmMinorVersion int goenv map[string]string packageCenter bool signer dist.Signer } func (t *target) String() string { - return fmt.Sprintf("synology/dsm%d/%s", t.dsmMajorVersion, t.filenameArch) + return fmt.Sprintf("synology/dsm%s/%s", t.dsmVersionString(), t.filenameArch) } func (t *target) Build(b *dist.Build) ([]string, error) { @@ -42,9 +43,31 @@ func (t *target) Build(b *dist.Build) ([]string, error) { return t.buildSPK(b, inner) } +// dsmVersionInt combines major and minor version info into an int +// representation. +// +// Version 7.2 becomes 72 as an example. +func (t *target) dsmVersionInt() int { + return t.dsmMajorVersion*10 + t.dsmMinorVersion +} + +// dsmVersionString returns a string representation of the version +// including minor version information if it exists. +// +// If dsmMinorVersion is 0 this returns dsmMajorVersion as a string, +// otherwise it returns "dsmMajorVersion-dsmMinorVersion". +func (t *target) dsmVersionString() string { + dsmVersionString := fmt.Sprintf("%d", t.dsmMajorVersion) + if t.dsmMinorVersion != 0 { + dsmVersionString = fmt.Sprintf("%s-%d", dsmVersionString, t.dsmMinorVersion) + } + + return dsmVersionString +} + func (t *target) buildSPK(b *dist.Build, inner *innerPkg) ([]string, error) { - synoVersion := b.Version.Synology[t.dsmMajorVersion] - filename := fmt.Sprintf("tailscale-%s-%s-%d-dsm%d.spk", t.filenameArch, b.Version.Short, synoVersion, t.dsmMajorVersion) + synoVersion := b.Version.Synology[t.dsmVersionInt()] + filename := fmt.Sprintf("tailscale-%s-%s-%d-dsm%s.spk", t.filenameArch, b.Version.Short, synoVersion, t.dsmVersionString()) out := filepath.Join(b.Out, filename) if t.packageCenter { log.Printf("Building %s (for package center)", filename) @@ -117,7 +140,7 @@ func (t *target) mkInfo(b *dist.Build, uncompressedSz int64) []byte { fmt.Fprintf(&ret, "%s=%q\n", k, v) } f("package", "Tailscale") - f("version", fmt.Sprintf("%s-%d", b.Version.Short, b.Version.Synology[t.dsmMajorVersion])) + f("version", fmt.Sprintf("%s-%d", b.Version.Short, b.Version.Synology[t.dsmVersionInt()])) f("arch", t.filenameArch) f("description", "Connect all your devices using WireGuard, without the hassle.") f("displayname", "Tailscale") diff --git a/release/dist/synology/targets.go b/release/dist/synology/targets.go index cea372e1a..bc7b20afc 100644 --- a/release/dist/synology/targets.go +++ b/release/dist/synology/targets.go @@ -28,11 +28,22 @@ func Targets(forPackageCenter bool, signer dist.Signer) []dist.Target { var ret []dist.Target - for _, dsmVersion := range []int{6, 7} { + for _, dsmVersion := range []struct { + major int + minor int + }{ + // DSM6 + {major: 6}, + // DSM7 + {major: 7}, + // DSM7.2 + {major: 7, minor: 2}, + } { ret = append(ret, &target{ filenameArch: "x86_64", - dsmMajorVersion: dsmVersion, + dsmMajorVersion: dsmVersion.major, + dsmMinorVersion: dsmVersion.minor, goenv: map[string]string{ "GOOS": "linux", "GOARCH": "amd64", @@ -42,7 +53,8 @@ func Targets(forPackageCenter bool, signer dist.Signer) []dist.Target { }, &target{ filenameArch: "i686", - dsmMajorVersion: dsmVersion, + dsmMajorVersion: dsmVersion.major, + dsmMinorVersion: dsmVersion.minor, goenv: map[string]string{ "GOOS": "linux", "GOARCH": "386", @@ -52,7 +64,8 @@ func Targets(forPackageCenter bool, signer dist.Signer) []dist.Target { }, &target{ filenameArch: "armv8", - dsmMajorVersion: dsmVersion, + dsmMajorVersion: dsmVersion.major, + dsmMinorVersion: dsmVersion.minor, goenv: map[string]string{ "GOOS": "linux", "GOARCH": "arm64", @@ -67,7 +80,8 @@ func Targets(forPackageCenter bool, signer dist.Signer) []dist.Target { for _, v5Arch := range v5Models { ret = append(ret, &target{ filenameArch: v5Arch, - dsmMajorVersion: dsmVersion, + dsmMajorVersion: dsmVersion.major, + dsmMinorVersion: dsmVersion.minor, goenv: map[string]string{ "GOOS": "linux", "GOARCH": "arm", @@ -80,7 +94,8 @@ func Targets(forPackageCenter bool, signer dist.Signer) []dist.Target { for _, v7Arch := range v7Models { ret = append(ret, &target{ filenameArch: v7Arch, - dsmMajorVersion: dsmVersion, + dsmMajorVersion: dsmVersion.major, + dsmMinorVersion: dsmVersion.minor, goenv: map[string]string{ "GOOS": "linux", "GOARCH": "arm", diff --git a/version/mkversion/mkversion.go b/version/mkversion/mkversion.go index 148bca926..2fa84480d 100644 --- a/version/mkversion/mkversion.go +++ b/version/mkversion/mkversion.go @@ -61,7 +61,7 @@ type VersionInfo struct { // Winres is the version string that gets embedded into Windows exe // metadata. It is of the form "x,y,z,0". Winres string - // Synology is a map of Synology DSM major version to the + // Synology is a map of Synology DSM version to the // Tailscale numeric version that gets embedded in Synology spk // files. Synology map[int]int64 @@ -252,12 +252,13 @@ func mkOutput(v verInfo) (VersionInfo, error) { Track: track, Synology: map[int]int64{ // Synology requires that version numbers be in a specific format. - // Builds with version numbers that don't start with "60" or "70" will fail, + // Builds with version numbers that don't start with "60", "70", or "72" will fail, // and the full version number must be within int32 range. // So, we do the following mapping from our Tailscale version to Synology version, // giving major version three decimal places, minor version three, and patch two. - 6: 6*100_000_000 + int64(v.major-1)*1_000_000 + int64(v.minor)*1_000 + int64(v.patch), - 7: 7*100_000_000 + int64(v.major-1)*1_000_000 + int64(v.minor)*1_000 + int64(v.patch), + 60: 60*10_000_000 + int64(v.major-1)*1_000_000 + int64(v.minor)*1_000 + int64(v.patch), + 70: 70*10_000_000 + int64(v.major-1)*1_000_000 + int64(v.minor)*1_000 + int64(v.patch), + 72: 72*10_000_000 + int64(v.major-1)*1_000_000 + int64(v.minor)*1_000 + int64(v.patch), }, }