mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-04-06 10:26:49 +00:00
fix(legacy): keep solaris/illumos as-is, drop sunos translation
LIVE_cache confirms: go.json uses 'illumos' and 'solaris' as distinct values. No package in the live cache uses 'sunos'. The build-classifier (triplet.js) also keeps all three distinct (illumos, solaris, sunos). The previous sunos translation matched the old normalize.js path, not the build-classifier path that the Go rewrite targets.
This commit is contained in:
@@ -71,17 +71,13 @@ func (a Asset) toLegacy() LegacyAsset {
|
||||
// values the legacy Node.js resolver expects. This is called at export time
|
||||
// only — the canonical values are preserved in Go-native storage (pgstore).
|
||||
//
|
||||
// Global rules (all packages):
|
||||
// - solaris/illumos → sunos (Node.js only knows "sunos")
|
||||
//
|
||||
// Package-specific rules replicate per-package overrides in production's releases.js:
|
||||
// - ffmpeg: Windows .gz → .exe (prod releases.js: rel.ext = 'exe')
|
||||
//
|
||||
// Note: solaris/illumos are kept as-is. The live cache uses them as distinct
|
||||
// values (go.json has "illumos" and "solaris" entries). The build-classifier
|
||||
// (triplet.js) also keeps all three distinct: illumos, solaris, sunos.
|
||||
func legacyFieldBackport(pkg string, a Asset) Asset {
|
||||
// Global OS normalization: Node.js uses "sunos" for both Solaris and Illumos.
|
||||
if a.OS == "solaris" || a.OS == "illumos" {
|
||||
a.OS = "sunos"
|
||||
}
|
||||
|
||||
switch pkg {
|
||||
case "ffmpeg":
|
||||
if a.OS == "windows" {
|
||||
|
||||
@@ -69,11 +69,11 @@ func TestExportLegacyDrops(t *testing.T) {
|
||||
}
|
||||
|
||||
// TestExportLegacyTranslations verifies that legacyFieldBackport applies the
|
||||
// correct field translations for Node.js compatibility. Translations are lossy
|
||||
// in canonical terms but necessary for the legacy resolver.
|
||||
// correct field translations for Node.js compatibility.
|
||||
func TestExportLegacyTranslations(t *testing.T) {
|
||||
t.Run("solaris_translated_to_sunos", func(t *testing.T) {
|
||||
// Node.js only knows "sunos" for Sun/Oracle platforms.
|
||||
t.Run("solaris_kept_as_is", func(t *testing.T) {
|
||||
// The live cache uses "solaris" and "illumos" as distinct values (go.json).
|
||||
// The build-classifier (triplet.js) keeps all three distinct: illumos, solaris, sunos.
|
||||
pd := storage.PackageData{
|
||||
Assets: []storage.Asset{
|
||||
{Filename: "go1.20.1.solaris-amd64.tar.gz", OS: "solaris", Arch: "x86_64", Format: ".tar.gz"},
|
||||
@@ -83,23 +83,23 @@ func TestExportLegacyTranslations(t *testing.T) {
|
||||
if len(lc.Releases) != 1 {
|
||||
t.Fatalf("releases = %d, want 1", len(lc.Releases))
|
||||
}
|
||||
if lc.Releases[0].OS != "sunos" {
|
||||
t.Errorf("OS = %q, want %q", lc.Releases[0].OS, "sunos")
|
||||
if lc.Releases[0].OS != "solaris" {
|
||||
t.Errorf("OS = %q, want %q", lc.Releases[0].OS, "solaris")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("illumos_translated_to_sunos", func(t *testing.T) {
|
||||
t.Run("illumos_kept_as_is", func(t *testing.T) {
|
||||
pd := storage.PackageData{
|
||||
Assets: []storage.Asset{
|
||||
{Filename: "caddy_2.9.0_illumos_amd64.tar.gz", OS: "illumos", Arch: "x86_64", Format: ".tar.gz"},
|
||||
{Filename: "go1.20.1.illumos-amd64.tar.gz", OS: "illumos", Arch: "x86_64", Format: ".tar.gz"},
|
||||
},
|
||||
}
|
||||
lc, _ := storage.ExportLegacy("caddy", pd)
|
||||
lc, _ := storage.ExportLegacy("go", pd)
|
||||
if len(lc.Releases) != 1 {
|
||||
t.Fatalf("releases = %d, want 1", len(lc.Releases))
|
||||
}
|
||||
if lc.Releases[0].OS != "sunos" {
|
||||
t.Errorf("OS = %q, want %q", lc.Releases[0].OS, "sunos")
|
||||
if lc.Releases[0].OS != "illumos" {
|
||||
t.Errorf("OS = %q, want %q", lc.Releases[0].OS, "illumos")
|
||||
}
|
||||
})
|
||||
|
||||
@@ -191,18 +191,18 @@ func TestExportLegacyMixed(t *testing.T) {
|
||||
t.Errorf("releases = %d, want 2 (linux + sunos)", len(lc.Releases))
|
||||
}
|
||||
|
||||
// Verify the illumos → sunos translation was applied.
|
||||
var foundSunos bool
|
||||
// Verify illumos is kept as-is (not translated to sunos).
|
||||
var foundIllumos bool
|
||||
for _, r := range lc.Releases {
|
||||
if r.OS == "sunos" {
|
||||
foundSunos = true
|
||||
}
|
||||
if r.OS == "illumos" {
|
||||
t.Error("illumos should have been translated to sunos")
|
||||
foundIllumos = true
|
||||
}
|
||||
if r.OS == "sunos" {
|
||||
t.Error("illumos should NOT be translated to sunos")
|
||||
}
|
||||
}
|
||||
if !foundSunos {
|
||||
t.Error("expected a sunos release (translated from illumos)")
|
||||
if !foundIllumos {
|
||||
t.Error("expected an illumos release (kept as-is)")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user