aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/rosa/busybox.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-07-25 14:14:34 +0900
committerOphestra <cat@gensokyo.uk>2026-07-25 14:14:34 +0900
commit0d3efeb456117b87f256e3bfaabd5abbace67ab4 (patch)
tree7405be7a58e634f2d6d1fa00b34b3e054e35666c /internal/rosa/busybox.go
parent35147f6dfb0b81d2fe21f69b3800162b0cd7060f (diff)
internal/rosa: remove xz utils hack
This replaces all xz invocations with the native decompressor. This also significantly cleans up the Gentoo stage3 bootstrap path. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/rosa/busybox.go')
-rw-r--r--internal/rosa/busybox.go124
1 files changed, 0 insertions, 124 deletions
diff --git a/internal/rosa/busybox.go b/internal/rosa/busybox.go
deleted file mode 100644
index ae900a04..00000000
--- a/internal/rosa/busybox.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package rosa
-
-import (
- "fmt"
- "io"
- "net/http"
- "os"
- "time"
-
- "hakurei.app/fhs"
- "hakurei.app/internal/pkg"
-)
-
-// busyboxBin is a busybox binary distribution installed under bin/busybox.
-type busyboxBin struct {
- // Underlying busybox binary.
- bin pkg.FileArtifact
-}
-
-// Kind returns the hardcoded [pkg.Kind] value.
-func (a busyboxBin) Kind() pkg.Kind { return kindBusyboxBin }
-
-// Params is a noop.
-func (a busyboxBin) Params(*pkg.IContext) {}
-
-// IsExclusive returns false: Cure performs a trivial filesystem write.
-func (busyboxBin) IsExclusive() bool { return false }
-
-// Inputs returns the underlying busybox [pkg.FileArtifact].
-func (a busyboxBin) Inputs() []pkg.Artifact {
- return []pkg.Artifact{a.bin}
-}
-
-func init() {
- pkg.Register(kindBusyboxBin, func(r *pkg.IRReader) pkg.Artifact {
- a := busyboxBin{r.Next().(pkg.FileArtifact)}
- if _, ok := r.Finalise(); ok {
- panic(pkg.ErrUnexpectedChecksum)
- }
- return a
- })
-}
-
-// String returns the reporting name of the underlying file prefixed with expand.
-func (a busyboxBin) String() string {
- return "expand-" + a.bin.(fmt.Stringer).String()
-}
-
-// Cure installs the underlying busybox [pkg.File] to bin/busybox.
-func (a busyboxBin) Cure(t *pkg.TContext) (err error) {
- var r io.ReadCloser
- if r, err = t.Open(a.bin); err != nil {
- return
- }
- defer func() {
- closeErr := r.Close()
- if err == nil {
- err = closeErr
- }
- }()
-
- binDir := t.GetWorkDir().Append("bin")
- if err = os.MkdirAll(binDir.String(), 0700); err != nil {
- return
- }
-
- var w *os.File
- if w, err = os.OpenFile(
- binDir.Append("busybox").String(),
- os.O_WRONLY|os.O_CREATE|os.O_EXCL,
- 0500,
- ); err != nil {
- return
- }
- defer func() {
- closeErr := w.Close()
- if err == nil {
- err = closeErr
- }
- }()
-
- _, err = io.Copy(w, r)
- return
-}
-
-// newBusyboxBin returns a [pkg.Artifact] containing a busybox installation from
-// the https://busybox.net/downloads/binaries/ binary release.
-func (s *S) newBusyboxBin() pkg.Artifact {
- var version, url, checksum string
- switch s.arch {
- case "amd64":
- version = "1.35.0"
- url = "https://busybox.net/downloads/binaries/" +
- version + "-" + s.linuxArch() + "-linux-musl/busybox"
- checksum = "L7OBIsPu9enNHn7FqpBT1kOg_mCLNmetSeNMA3i4Y60Z5jTgnlX3qX3zcQtLx5AB"
- case "arm64":
- version = "1.31.0"
- url = "https://busybox.net/downloads/binaries/" +
- version + "-defconfig-multiarch-musl/busybox-armv8l"
- checksum = "npJjBO7iwhjW6Kx2aXeSxf8kXhVgTCDChOZTTsI8ZfFfa3tbsklxRiidZQdrVERg"
-
- default:
- panic("unsupported target " + s.arch)
- }
-
- return pkg.NewExec(
- "busybox-bin-"+version, s.arch, nil, pkg.ExecTimeoutMax, false, false,
- fhs.AbsRoot, []string{
- "PATH=/system/bin",
- },
- AbsSystem.Append("bin", "busybox"),
- []string{"hush", "-c", "" +
- "busybox mkdir -p /work/system/bin/ && " +
- "busybox cp /system/bin/busybox /work/system/bin/ && " +
- "busybox --install -s /work/system/bin/"},
- pkg.Path(AbsSystem, true, busyboxBin{pkg.NewHTTPGet(
- &http.Client{Transport: &http.Transport{
- // busybox website is really slow to respond
- TLSHandshakeTimeout: 2 * time.Minute,
- }}, url,
- mustDecode(checksum),
- )}),
- )
-}