mirror of
https://github.com/webinstall/webi-installers.git
synced 2026-04-06 18:36:50 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user