aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-01-31 03:38:16 +0900
committerOphestra <cat@gensokyo.uk>2026-01-31 05:01:22 +0900
commit5f81aac0e23e0197b449373912aa995dd7bb004a (patch)
treeec537ec178b0d3820d22754b18fe222a710d6212
parent47490823be4d81643ed3895263feec1da64f751e (diff)
internal/rosa: make helper
This change only migrates artifacts that remain unchanged under the helper, so this change should not cause any rebuilds. Signed-off-by: Ophestra <cat@gensokyo.uk>
-rw-r--r--internal/rosa/acl.go32
-rw-r--r--internal/rosa/gnu.go289
-rw-r--r--internal/rosa/libffi.go27
-rw-r--r--internal/rosa/libgd.go35
-rw-r--r--internal/rosa/make.go109
-rw-r--r--internal/rosa/pkg-config.go24
-rw-r--r--internal/rosa/xcb.go25
-rw-r--r--internal/rosa/xz.go21
8 files changed, 278 insertions, 284 deletions
diff --git a/internal/rosa/acl.go b/internal/rosa/acl.go
index ca9b8771..7369896a 100644
--- a/internal/rosa/acl.go
+++ b/internal/rosa/acl.go
@@ -24,8 +24,7 @@ make "-j$(nproc)" check
make DESTDIR=/work install
`, pkg.Path(AbsUsrSrc.Append("attr"), true, t.NewPatchedSource(
"attr", version, pkg.NewHTTPGetTar(
- nil,
- "https://download.savannah.nongnu.org/releases/attr/"+
+ nil, "https://download.savannah.nongnu.org/releases/attr/"+
"attr-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
@@ -77,26 +76,23 @@ func (t Toolchain) newACL() pkg.Artifact {
version = "2.3.2"
checksum = "-fY5nwH4K8ZHBCRXrzLdguPkqjKI6WIiGu4dBtrZ1o0t6AIU73w8wwJz_UyjIS0P"
)
- return t.New("acl-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
-
- t.Load(Attr),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/acl/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --enable-static
-make "-j$(nproc)"
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("acl"), true, pkg.NewHTTPGetTar(
+ return t.NewViaMake("acl", version, pkg.NewHTTPGetTar(
nil,
"https://download.savannah.nongnu.org/releases/acl/"+
"acl-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+
+ Configure: [][2]string{
+ {"enable-static"},
+ },
+
+ // makes assumptions about uid_map/gid_map
+ SkipCheck: true,
+ },
+ t.Load(Attr),
+ )
}
func init() { artifactsF[ACL] = Toolchain.newACL }
diff --git a/internal/rosa/gnu.go b/internal/rosa/gnu.go
index 81229ae1..6bb7004d 100644
--- a/internal/rosa/gnu.go
+++ b/internal/rosa/gnu.go
@@ -7,27 +7,19 @@ func (t Toolchain) newM4() pkg.Artifact {
version = "1.4.20"
checksum = "RT0_L3m4Co86bVBY3lCFAEs040yI1WdeNmRylFpah8IZovTm6O4wI7qiHJN3qsW9"
)
- return t.New("m4-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- }, nil, nil, `
-cd /usr/src/m4
-chmod +w tests/test-c32ispunct.sh && echo '#!/bin/sh' > tests/test-c32ispunct.sh
-
-cd "$(mktemp -d)"
-/usr/src/m4/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("m4"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/m4/m4-"+version+".tar.bz2",
+ return t.NewViaMake("m4", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/m4/m4-"+version+".tar.bz2",
mustDecode(checksum),
pkg.TarBzip2,
- )))
+ ), &MakeAttr{
+ Writable: true,
+ ScriptEarly: `
+cd /usr/src/m4
+chmod +w tests/test-c32ispunct.sh && echo '#!/bin/sh' > tests/test-c32ispunct.sh
+`,
+ },
+ t.Load(Diffutils),
+ )
}
func init() { artifactsF[M4] = Toolchain.newM4 }
@@ -36,24 +28,13 @@ func (t Toolchain) newSed() pkg.Artifact {
version = "4.9"
checksum = "pe7HWH4PHNYrazOTlUoE1fXmhn2GOPFN_xE62i0llOr3kYGrH1g2_orDz0UtZ9Nt"
)
- return t.New("sed-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/sed/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("sed"), false, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/sed/sed-"+version+".tar.gz",
+ return t.NewViaMake("sed", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/sed/sed-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), nil,
+ t.Load(Diffutils),
+ )
}
func init() { artifactsF[Sed] = Toolchain.newSed }
@@ -94,23 +75,14 @@ func (t Toolchain) newGzip() pkg.Artifact {
version = "1.14"
checksum = "NWhjUavnNfTDFkZJyAUonL9aCOak8GVajWX2OMlzpFnuI0ErpBFyj88mz2xSjz0q"
)
- return t.New("gzip-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/gzip/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)"
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("gzip"), false, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/gzip/gzip-"+version+".tar.gz",
+ return t.NewViaMake("gzip", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/gzip/gzip-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ // dependency loop
+ SkipCheck: true,
+ })
}
func init() { artifactsF[Gzip] = Toolchain.newGzip }
@@ -119,14 +91,13 @@ func (t Toolchain) newGettext() pkg.Artifact {
version = "0.26"
checksum = "IMu7yDZX7xL5UO1ZxXc-iBMbY9LLEUlOroyuSlHMZwg9MKtxG7HIm8F2LheDua0y"
)
- return t.New("gettext-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- t.Load(Gzip),
- t.Load(Sed),
- }, nil, nil, `
+ return t.NewViaMake("gettext", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/pub/gnu/gettext/gettext-"+version+".tar.gz",
+ mustDecode(checksum),
+ pkg.TarGzip,
+ ), &MakeAttr{
+ Writable: true,
+ ScriptEarly: `
cd /usr/src/gettext
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
@@ -141,19 +112,12 @@ test_disable '#!/bin/sh' gettext-tools/gnulib-tests/test-c32ispunct.sh
test_disable 'int main(){return 0;}' gettext-tools/gnulib-tests/test-stdcountof-h.c
touch gettext-tools/misc/archive.dir.tar
-
-cd "$(mktemp -d)"
-/usr/src/gettext/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("gettext"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/pub/gnu/gettext/gettext-"+version+".tar.gz",
- mustDecode(checksum),
- pkg.TarGzip,
- )))
+`,
+ },
+ t.Load(Diffutils),
+ t.Load(Gzip),
+ t.Load(Sed),
+ )
}
func init() { artifactsF[Gettext] = Toolchain.newGettext }
@@ -162,28 +126,22 @@ func (t Toolchain) newDiffutils() pkg.Artifact {
version = "3.12"
checksum = "9J5VAq5oA7eqwzS1Yvw-l3G5o-TccUrNQR3PvyB_lgdryOFAfxtvQfKfhdpquE44"
)
- return t.New("diffutils-"+version, TEarly, []pkg.Artifact{
- t.Load(Make),
- }, nil, nil, `
+ return t.NewViaMake("diffutils", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/diffutils/diffutils-"+version+".tar.gz",
+ mustDecode(checksum),
+ pkg.TarGzip,
+ ), &MakeAttr{
+ Writable: true,
+ ScriptEarly: `
cd /usr/src/diffutils
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
test_disable '#!/bin/sh' gnulib-tests/test-c32ispunct.sh
test_disable 'int main(){return 0;}' gnulib-tests/test-c32ispunct.c
test_disable '#!/bin/sh' tests/cmp
-
-cd "$(mktemp -d)"
-/usr/src/diffutils/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("diffutils"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/diffutils/diffutils-"+version+".tar.gz",
- mustDecode(checksum),
- pkg.TarGzip,
- )))
+`,
+ Flag: TEarly,
+ })
}
func init() { artifactsF[Diffutils] = Toolchain.newDiffutils }
@@ -192,27 +150,21 @@ func (t Toolchain) newPatch() pkg.Artifact {
version = "2.8"
checksum = "MA0BQc662i8QYBD-DdGgyyfTwaeALZ1K0yusV9rAmNiIsQdX-69YC4t9JEGXZkeR"
)
- return t.New("patch-"+version, TEarly, []pkg.Artifact{
- t.Load(Make),
- }, nil, nil, `
+ return t.NewViaMake("patch", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/patch/patch-"+version+".tar.gz",
+ mustDecode(checksum),
+ pkg.TarGzip,
+ ), &MakeAttr{
+ Writable: true,
+ ScriptEarly: `
cd /usr/src/patch
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
test_disable '#!/bin/sh' tests/ed-style
test_disable '#!/bin/sh' tests/need-filename
-
-cd "$(mktemp -d)"
-/usr/src/patch/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("patch"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/patch/patch-"+version+".tar.gz",
- mustDecode(checksum),
- pkg.TarGzip,
- )))
+`,
+ Flag: TEarly,
+ })
}
func init() { artifactsF[Patch] = Toolchain.newPatch }
@@ -221,23 +173,19 @@ func (t Toolchain) newBash() pkg.Artifact {
version = "5.3"
checksum = "4LQ_GRoB_ko-Ih8QPf_xRKA02xAm_TOxQgcJLmFDT6udUPxTAWrsj-ZNeuTusyDq"
)
- return t.New("bash-"+version, TEarly, []pkg.Artifact{
- t.Load(Make),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/bash/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --without-bash-malloc
-make "-j$(nproc)" check
-make DESTDIR=/work install
-ln -s bash /work/system/bin/sh
-`, pkg.Path(AbsUsrSrc.Append("bash"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/bash/bash-"+version+".tar.gz",
+ return t.NewViaMake("bash", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/bash/bash-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+
+ Script: "ln -s bash /work/system/bin/sh\n",
+ Configure: [][2]string{
+ {"without-bash-malloc"},
+ },
+ Flag: TEarly,
+ })
}
func init() { artifactsF[Bash] = Toolchain.newBash }
@@ -246,32 +194,27 @@ func (t Toolchain) newCoreutils() pkg.Artifact {
version = "9.9"
checksum = "B1_TaXj1j5aiVIcazLWu8Ix03wDV54uo2_iBry4qHG6Y-9bjDpUPlkNLmU_3Nvw6"
)
- return t.New("coreutils-"+version, TEarly, []pkg.Artifact{
- t.Load(Make),
- t.Load(Perl),
- t.Load(Bash),
-
- t.Load(KernelHeaders),
- }, nil, nil, `
+ return t.NewViaMake("coreutils", version, pkg.NewHTTPGetTar(
+ nil, "https://ftp.gnu.org/gnu/coreutils/coreutils-"+version+".tar.gz",
+ mustDecode(checksum),
+ pkg.TarGzip,
+ ), &MakeAttr{
+ Writable: true,
+ ScriptEarly: `
cd /usr/src/coreutils
test_disable() { chmod +w "$2" && echo "$1" > "$2"; }
test_disable '#!/bin/sh' gnulib-tests/test-c32ispunct.sh
test_disable '#!/bin/sh' tests/split/line-bytes.sh
test_disable '#!/bin/sh' tests/dd/no-allocate.sh
+`,
+ Flag: TEarly,
+ },
+ t.Load(Perl),
+ t.Load(Bash),
-cd "$(mktemp -d)"
-/usr/src/coreutils/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("coreutils"), true, pkg.NewHTTPGetTar(
- nil,
- "https://ftp.gnu.org/gnu/coreutils/coreutils-"+version+".tar.gz",
- mustDecode(checksum),
- pkg.TarGzip,
- )))
+ t.Load(KernelHeaders),
+ )
}
func init() { artifactsF[Coreutils] = Toolchain.newCoreutils }
@@ -280,23 +223,15 @@ func (t Toolchain) newGperf() pkg.Artifact {
version = "3.3"
checksum = "RtIy9pPb_Bb8-31J2Nw-rRGso2JlS-lDlVhuNYhqR7Nt4xM_nObznxAlBMnarJv7"
)
- return t.New("gperf-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/gperf/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("gperf"), true, pkg.NewHTTPGetTar(
+ return t.NewViaMake("gperf", version, pkg.NewHTTPGetTar(
nil, "https://ftp.gnu.org/pub/gnu/gperf/gperf-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+ },
+ t.Load(Diffutils),
+ )
}
func init() { artifactsF[Gperf] = Toolchain.newGperf }
@@ -305,20 +240,16 @@ func (t Toolchain) newGawk() pkg.Artifact {
version = "5.3.2"
checksum = "uIs0d14h_d2DgMGYwrPtegGNyt_bxzG3D6Fe-MmExx_pVoVkQaHzrtmiXVr6NHKk"
)
- return t.New("gawk-"+version, TEarly, []pkg.Artifact{
- t.Load(Make),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/gawk/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)"
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("gawk"), false, pkg.NewHTTPGetTar(
+ return t.NewViaMake("gawk", version, pkg.NewHTTPGetTar(
nil, "https://ftp.gnu.org/gnu/gawk/gawk-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Flag: TEarly,
+
+ // dependency loop
+ SkipCheck: true,
+ })
}
func init() { artifactsF[Gawk] = Toolchain.newGawk }
@@ -327,32 +258,24 @@ func (t Toolchain) newFindutils() pkg.Artifact {
version = "4.10.0"
checksum = "ZXABdNBQXL7QjTygynRRTdXYWxQKZ0Wn5eMd3NUnxR0xaS0u0VfcKoTlbo50zxv6"
)
- return t.New("findutils-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- t.Load(XZ),
- t.Load(Sed),
- }, nil, nil, `
+ return t.NewViaMake("findutils", version, pkg.NewHTTPGet(
+ nil, "https://ftp.gnu.org/gnu/findutils/findutils-"+version+".tar.xz",
+ mustDecode(checksum),
+ ), &MakeAttr{
+ SourceSuffix: ".tar.xz",
+ ScriptEarly: `
cd /usr/src/
tar xf findutils.tar.xz
-mv findutils-`+version+` findutils
+mv findutils-` + version + ` findutils
cd findutils
echo '#!/bin/sh' > gnulib-tests/test-c32ispunct.sh
echo 'int main(){return 0;}' > tests/xargs/test-sigusr.c
-
-cd "$(mktemp -d)"
-/usr/src/findutils/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("findutils.tar.xz"), false, pkg.NewHTTPGet(
- nil,
- "https://ftp.gnu.org/gnu/findutils/findutils-"+version+".tar.xz",
- mustDecode(checksum),
- )))
+`,
+ },
+ t.Load(Diffutils),
+ t.Load(XZ),
+ t.Load(Sed),
+ )
}
func init() { artifactsF[Findutils] = Toolchain.newFindutils }
diff --git a/internal/rosa/libffi.go b/internal/rosa/libffi.go
index b04ce863..01dcf834 100644
--- a/internal/rosa/libffi.go
+++ b/internal/rosa/libffi.go
@@ -7,26 +7,17 @@ func (t Toolchain) newLibffi() pkg.Artifact {
version = "3.4.5"
checksum = "apIJzypF4rDudeRoI_n3K7N-zCeBLTbQlHRn9NSAZqdLAWA80mR0gXPTpHsL7oMl"
)
- return t.New("libffi-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
-
- t.Load(KernelHeaders),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/libffi/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --enable-static
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("libffi"), false, pkg.NewHTTPGetTar(
- nil,
- "https://github.com/libffi/libffi/releases/download/"+
+ return t.NewViaMake("libffi", version, pkg.NewHTTPGetTar(
+ nil, "https://github.com/libffi/libffi/releases/download/"+
"v"+version+"/libffi-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Configure: [][2]string{
+ {"enable-static"},
+ },
+ },
+ t.Load(KernelHeaders),
+ )
}
func init() { artifactsF[Libffi] = Toolchain.newLibffi }
diff --git a/internal/rosa/libgd.go b/internal/rosa/libgd.go
index d4e83d1c..f61e99b0 100644
--- a/internal/rosa/libgd.go
+++ b/internal/rosa/libgd.go
@@ -7,27 +7,26 @@ func (t Toolchain) newLibgd() pkg.Artifact {
version = "2.3.3"
checksum = "8T-sh1_FJT9K9aajgxzh8ot6vWIF-xxjcKAHvTak9MgGUcsFfzP8cAvvv44u2r36"
)
- return t.New("libgd-"+version, 0, []pkg.Artifact{
- t.Load(Make),
-
- t.Load(Zlib),
- }, nil, []string{
- "TMPDIR=/dev/shm/gd",
- }, `
-mkdir /dev/shm/gd
-
-cd "$(mktemp -d)"
-/usr/src/libgd/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --enable-static
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("libgd"), true, pkg.NewHTTPGetTar(
+ return t.NewViaMake("libgd", version, pkg.NewHTTPGetTar(
nil, "https://github.com/libgd/libgd/releases/download/"+
"gd-"+version+"/libgd-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+
+ OmitDefaults: true,
+ Env: []string{
+ "TMPDIR=/dev/shm/gd",
+ },
+ ScriptEarly: `
+mkdir /dev/shm/gd
+`,
+ Configure: [][2]string{
+ {"enable-static"},
+ },
+ },
+ t.Load(Zlib),
+ )
}
func init() { artifactsF[Libgd] = Toolchain.newLibgd }
diff --git a/internal/rosa/make.go b/internal/rosa/make.go
index 61763be3..7d7418f7 100644
--- a/internal/rosa/make.go
+++ b/internal/rosa/make.go
@@ -1,6 +1,11 @@
package rosa
-import "hakurei.app/internal/pkg"
+import (
+ "slices"
+ "strings"
+
+ "hakurei.app/internal/pkg"
+)
func (t Toolchain) newMake() pkg.Artifact {
const (
@@ -23,3 +28,105 @@ cd "$(mktemp -d)"
)))
}
func init() { artifactsF[Make] = Toolchain.newMake }
+
+// MakeAttr holds the project-specific attributes that will be applied to a new
+// [pkg.Artifact] compiled via [Make].
+type MakeAttr struct {
+ // Mount the source tree writable.
+ Writable bool
+
+ // Do not include default extras.
+ OmitDefaults bool
+
+ // Additional environment variables.
+ Env []string
+ // Runs before cmake.
+ ScriptEarly string
+ // Runs after cmake.
+ Script string
+
+ // Flags passed to the configure script.
+ Configure [][2]string
+ // Target triple, zero value is equivalent to the Rosa OS triple.
+ Build string
+ // Whether to skip the check target.
+ SkipCheck bool
+
+ // Suffix appended to the source pathname.
+ SourceSuffix string
+
+ // Passed through to [Toolchain.New].
+ Flag int
+}
+
+// NewViaMake returns a [pkg.Artifact] for compiling and installing via [Make].
+func (t Toolchain) NewViaMake(
+ name, version string,
+ source pkg.Artifact,
+ attr *MakeAttr,
+ extra ...pkg.Artifact,
+) pkg.Artifact {
+ if name == "" || version == "" {
+ panic("names must be non-empty")
+ }
+ if attr == nil {
+ attr = new(MakeAttr)
+ }
+ build := `"${ROSA_TRIPLE}"`
+ if attr.Build != "" {
+ build = attr.Build
+ }
+
+ var configureFlags string
+ if len(attr.Configure) > 0 {
+ const sep = " \\\n\t"
+ configureFlags += sep + strings.Join(
+ slices.Collect(func(yield func(string) bool) {
+ for _, v := range attr.Configure {
+ s := v[0]
+ if v[1] == "" || (v[0] != "" &&
+ v[0][0] >= 'a' &&
+ v[0][0] <= 'z') {
+ s = "--" + s
+ }
+ if v[1] != "" {
+ s += "=" + v[1]
+ }
+ if !yield(s) {
+ return
+ }
+ }
+ }),
+ sep,
+ )
+ }
+
+ defaults := []pkg.Artifact{
+ t.Load(Make),
+ }
+ if attr.OmitDefaults || attr.Flag&TEarly == 0 {
+ defaults = append(defaults,
+ t.Load(Gawk),
+ t.Load(Coreutils),
+ )
+ }
+
+ var makeSuffix string
+ if !attr.SkipCheck {
+ makeSuffix += " check"
+ }
+
+ return t.New(name+"-"+version, attr.Flag, stage3Concat(t,
+ defaults,
+ extra...,
+ ), nil, attr.Env, attr.ScriptEarly+`
+cd "$(mktemp -d)"
+/usr/src/`+name+`/configure \
+ --prefix=/system \
+ --build=`+build+configureFlags+`
+make "-j$(nproc)"`+makeSuffix+`
+make DESTDIR=/work install
+`+attr.Script, pkg.Path(AbsUsrSrc.Append(
+ name+attr.SourceSuffix,
+ ), attr.Writable, source))
+}
diff --git a/internal/rosa/pkg-config.go b/internal/rosa/pkg-config.go
index 1e3ff217..28a42dc0 100644
--- a/internal/rosa/pkg-config.go
+++ b/internal/rosa/pkg-config.go
@@ -7,25 +7,19 @@ func (t Toolchain) newPkgConfig() pkg.Artifact {
version = "0.29.2"
checksum = "gi7yAvkwo20Inys1tHbeYZ3Wjdm5VPkrnO0Q6_QZPCAwa1zrA8F4a63cdZDd-717"
)
- return t.New("pkg-config-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/pkg-config/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- CFLAGS='-Wno-int-conversion' \
- --with-internal-glib
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("pkg-config"), true, pkg.NewHTTPGetTar(
+ return t.NewViaMake("pkg-config", version, pkg.NewHTTPGetTar(
nil,
"https://pkgconfig.freedesktop.org/releases/"+
"pkg-config-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+
+ Configure: [][2]string{
+ {"CFLAGS", "'-Wno-int-conversion'"},
+ {"with-internal-glib"},
+ },
+ })
}
func init() { artifactsF[PkgConfig] = Toolchain.newPkgConfig }
diff --git a/internal/rosa/xcb.go b/internal/rosa/xcb.go
index 134f5d2f..3f0e3671 100644
--- a/internal/rosa/xcb.go
+++ b/internal/rosa/xcb.go
@@ -7,24 +7,19 @@ func (t Toolchain) newXCBProto() pkg.Artifact {
version = "1.17.0"
checksum = "_NtbKaJ_iyT7XiJz25mXQ7y-niTzE8sHPvLXZPcqtNoV_-vTzqkezJ8Hp2U1enCv"
)
- return t.New("xcb-proto-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Python),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/xcb-proto/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}" \
- --enable-static
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("xcb-proto"), true, pkg.NewHTTPGetTar(
+ return t.NewViaMake("xcb-proto", version, pkg.NewHTTPGetTar(
nil, "https://xcb.freedesktop.org/dist/xcb-proto-"+version+".tar.gz",
mustDecode(checksum),
pkg.TarGzip,
- )))
+ ), &MakeAttr{
+ Writable: true,
+
+ Configure: [][2]string{
+ {"enable-static"},
+ },
+ },
+ t.Load(Python),
+ )
}
func init() { artifactsF[XCBProto] = Toolchain.newXCBProto }
diff --git a/internal/rosa/xz.go b/internal/rosa/xz.go
index 9e5e0cbf..0b9578b8 100644
--- a/internal/rosa/xz.go
+++ b/internal/rosa/xz.go
@@ -7,24 +7,13 @@ func (t Toolchain) newXZ() pkg.Artifact {
version = "5.8.2"
checksum = "rXT-XCp9R2q6cXqJ5qenp0cmGPfiENQiU3BWtUVeVgArfRmSsISeUJgvCR3zI0a0"
)
- return t.New("xz-"+version, 0, []pkg.Artifact{
- t.Load(Make),
- t.Load(Gawk),
- t.Load(Coreutils),
- t.Load(Diffutils),
- }, nil, nil, `
-cd "$(mktemp -d)"
-/usr/src/xz/configure \
- --prefix=/system \
- --build="${ROSA_TRIPLE}"
-make "-j$(nproc)" check
-make DESTDIR=/work install
-`, pkg.Path(AbsUsrSrc.Append("xz"), false, pkg.NewHTTPGetTar(
- nil,
- "https://github.com/tukaani-project/xz/releases/download/"+
+ return t.NewViaMake("xz", version, pkg.NewHTTPGetTar(
+ nil, "https://github.com/tukaani-project/xz/releases/download/"+
"v"+version+"/xz-"+version+".tar.bz2",
mustDecode(checksum),
pkg.TarBzip2,
- )))
+ ), nil,
+ t.Load(Diffutils),
+ )
}
func init() { artifactsF[XZ] = Toolchain.newXZ }