From 8b4576bc5f6eaaf703886629f2dfa12ba38b574c Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 31 Jan 2026 05:09:17 +0900 Subject: internal/rosa: migrate to make helper This migrates artifacts that the helper cannot produce an identical instance of. Signed-off-by: Ophestra --- internal/rosa/make.go | 56 ++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'internal/rosa/make.go') diff --git a/internal/rosa/make.go b/internal/rosa/make.go index 7d7418f7..f47be4eb 100644 --- a/internal/rosa/make.go +++ b/internal/rosa/make.go @@ -21,8 +21,7 @@ cd "$(mktemp -d)" ./build.sh ./make DESTDIR=/work install check `, pkg.Path(AbsUsrSrc.Append("make"), false, pkg.NewHTTPGetTar( - nil, - "https://ftp.gnu.org/gnu/make/make-"+version+".tar.gz", + nil, "https://ftp.gnu.org/gnu/make/make-"+version+".tar.gz", mustDecode(checksum), pkg.TarGzip, ))) @@ -37,6 +36,8 @@ type MakeAttr struct { // Do not include default extras. OmitDefaults bool + // Dependencies not provided by stage3. + NonStage3 []pkg.Artifact // Additional environment variables. Env []string @@ -45,12 +46,19 @@ type MakeAttr struct { // Runs after cmake. Script string + // Remain in working directory set up during ScriptEarly. + InPlace bool + // Flags passed to the configure script. Configure [][2]string + // Extra make targets. + Make []string // Target triple, zero value is equivalent to the Rosa OS triple. Build string // Whether to skip the check target. SkipCheck bool + // Name of the check target, zero value is equivalent to "check". + CheckName string // Suffix appended to the source pathname. SourceSuffix string @@ -101,30 +109,50 @@ func (t Toolchain) NewViaMake( ) } - defaults := []pkg.Artifact{ + var buildFlag string + if attr.Build != `""` { + buildFlag = ` \ + --build=` + build + } + + makeTargets := make([]string, 1, 2+len(attr.Make)) + if !attr.SkipCheck { + if attr.CheckName == "" { + makeTargets = append(makeTargets, "check") + } else { + makeTargets = append(makeTargets, attr.CheckName) + } + } + makeTargets = append(makeTargets, attr.Make...) + if len(makeTargets) == 1 { + makeTargets = nil + } + + finalExtra := []pkg.Artifact{ t.Load(Make), } if attr.OmitDefaults || attr.Flag&TEarly == 0 { - defaults = append(defaults, + finalExtra = append(finalExtra, t.Load(Gawk), t.Load(Coreutils), ) } + finalExtra = append(finalExtra, extra...) - var makeSuffix string - if !attr.SkipCheck { - makeSuffix += " check" + scriptEarly := attr.ScriptEarly + if !attr.InPlace { + scriptEarly += "\ncd \"$(mktemp -d)\"" + } else if scriptEarly == "" { + panic("cannot remain in root") } return t.New(name+"-"+version, attr.Flag, stage3Concat(t, - defaults, - extra..., - ), nil, attr.Env, attr.ScriptEarly+` -cd "$(mktemp -d)" + attr.NonStage3, + finalExtra..., + ), nil, attr.Env, scriptEarly+` /usr/src/`+name+`/configure \ - --prefix=/system \ - --build=`+build+configureFlags+` -make "-j$(nproc)"`+makeSuffix+` + --prefix=/system`+buildFlag+configureFlags+` +make "-j$(nproc)"`+strings.Join(makeTargets, " ")+` make DESTDIR=/work install `+attr.Script, pkg.Path(AbsUsrSrc.Append( name+attr.SourceSuffix, -- cgit v1.3.1