internal/rosa: create /bin symlinks via helper

This centralises the workaround for surprisingly common buggy scripts with nonstandard hardcoded paths.

Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
2026-07-01 14:25:30 +09:00
parent 3ab7116b29
commit 3975dd3e0f
17 changed files with 67 additions and 62 deletions
+24
View File
@@ -414,6 +414,10 @@ type PackageAttr struct {
// Passed to [Toolchain.NewPatchedSource].
Patches []KV
// Programs to make available in /bin/.
Bin []string
// Whether to replace /usr/bin/ with a symlink to /bin/.
PopulateUsrBin bool
// Unregistered extras.
Extra []pkg.Artifact
@@ -544,6 +548,26 @@ cd '/usr/src/` + name + `/'
})
}
bin := attr.Bin
if attr.PopulateUsrBin {
scriptEarly += `
chmod +w /usr/ /usr/bin/
rm -rf /usr/bin/
ln -s ../bin /usr/`
bin = append(bin, "env")
}
if t.stage != stageGentoo && len(bin) > 0 {
scriptEarly += "\nchmod +w /bin/" +
"\n(set -o braceexpand && ln -sf ../system/bin/"
if len(bin) > 1 {
scriptEarly += "{'" + strings.Join(bin, "','") + "'}"
} else {
scriptEarly += "'" + bin[0] + "'"
}
scriptEarly += " /bin/)\n"
}
return t.New(
rn,
attr.Flag,