From a3685b840bda6ad133b4a7e8edfd53de98f37dcd Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Wed, 11 Mar 2026 12:31:17 -0600 Subject: [PATCH] =?UTF-8?q?fix:=20Windows=20gnu=E2=86=92none,=20install.sh?= =?UTF-8?q?=208-space=20padding?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Windows gnu (MinGW) builds are self-contained: classify as libc='none' - Pad install.sh content to 8 spaces to match production template indent - Use replaceMarkerLine for both bash and PS1 installer injection --- internal/classifypkg/classifypkg.go | 4 ++++ internal/render/render.go | 32 +++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/internal/classifypkg/classifypkg.go b/internal/classifypkg/classifypkg.go index ccb711b..4069394 100644 --- a/internal/classifypkg/classifypkg.go +++ b/internal/classifypkg/classifypkg.go @@ -371,6 +371,10 @@ func classifyGitHub(pkg string, conf *installerconf.Conf, d *rawcache.Dir) ([]st if libc == buildmeta.LibcMusl && reRustMuslStatic.MatchString(a.Name) { libc = buildmeta.LibcNone } + // Windows gnu (MinGW) is self-contained — no runtime deps. + if r.OS == buildmeta.OSWindows && libc == buildmeta.LibcGNU { + libc = buildmeta.LibcNone + } assets = append(assets, storage.Asset{ Filename: name, diff --git a/internal/render/render.go b/internal/render/render.go index e0dadf2..ba9da75 100644 --- a/internal/render/render.go +++ b/internal/render/render.go @@ -127,8 +127,11 @@ func Bash(tplPath, installersDir, pkgName string, p Params) (string, error) { } // Inject the installer script at the {{ installer }} marker. - text = strings.Replace(text, "# {{ installer }}", string(installSh), 1) - text = strings.Replace(text, "{{ installer }}", string(installSh), 1) + // The marker sits inside __init_installer() at 8-space indent. + // Production pads every line of install.sh to match, and replaces + // the entire line (including leading whitespace). + padded := padScript(string(installSh), " ") + text = replaceMarkerLine(text, "{{ installer }}", padded) return text, nil } @@ -167,8 +170,8 @@ func PowerShell(tplPath, installersDir, pkgName string, p Params) (string, error text = InjectPSVar(text, v.name, v.value) } - text = strings.Replace(text, "# {{ installer }}", string(installPs1), 1) - text = strings.Replace(text, "{{ installer }}", string(installPs1), 1) + // PS1 marker is at column 0, no padding needed. + text = replaceMarkerLine(text, "{{ installer }}", string(installPs1)) return text, nil } @@ -238,3 +241,24 @@ func InjectVar(text, name, value string) string { func sanitizeShellValue(s string) string { return strings.ReplaceAll(s, "'", `'\''`) } + +// padScript prepends each line of a script with the given indent string. +// This matches production behavior where install.sh content is indented +// to align with the surrounding template code. +func padScript(script, indent string) string { + lines := strings.Split(script, "\n") + for i, line := range lines { + if line != "" { + lines[i] = indent + line + } + } + return strings.Join(lines, "\n") +} + +// replaceMarkerLine replaces an entire line containing the marker +// (including any leading whitespace) with the replacement text. +// This matches production's regex: /\s*#?\s*{{ installer }}/ +func replaceMarkerLine(text, marker, replacement string) string { + re := regexp.MustCompile(`(?m)^[ \t]*#?[ \t]*` + regexp.QuoteMeta(marker) + `[^\n]*`) + return re.ReplaceAllString(text, replacement) +}