fix: Windows gnu→none, install.sh 8-space padding

- 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
This commit is contained in:
AJ ONeal
2026-03-11 12:31:17 -06:00
parent 2e1d824b27
commit a3685b840b
2 changed files with 32 additions and 4 deletions

View File

@@ -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,

View File

@@ -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)
}