forked from rosa/hakurei
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user