internal/rosa: IR-curable source override
All checks were successful
Test / Hakurei (push) Successful in 4m16s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 1m54s
Test / ShareFS (push) Successful in 2m36s
Test / Sandbox (race detector) (push) Successful in 2m41s
Test / Flake checks (push) Successful in 1m18s
All checks were successful
Test / Hakurei (push) Successful in 4m16s
Test / Hakurei (race detector) (push) Successful in 6m40s
Test / Create distribution (push) Successful in 1m4s
Test / Sandbox (push) Successful in 1m54s
Test / ShareFS (push) Successful in 2m36s
Test / Sandbox (race detector) (push) Successful in 2m41s
Test / Flake checks (push) Successful in 1m18s
This creates a tarball in-memory for overriding hakurei-source. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -64,11 +64,12 @@ func main() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
e, ok := r.(rosa.LoadError)
|
switch r.(type) {
|
||||||
if !ok {
|
case rosa.LoadError, pkg.IRStringError:
|
||||||
|
log.Fatal(r)
|
||||||
|
default:
|
||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
log.Fatal(e)
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx, stop := signal.NotifyContext(context.Background(),
|
ctx, stop := signal.NotifyContext(context.Background(),
|
||||||
@@ -86,6 +87,7 @@ func main() {
|
|||||||
flagLTO bool
|
flagLTO bool
|
||||||
flagPT bool
|
flagPT bool
|
||||||
|
|
||||||
|
flagSourcePath string
|
||||||
flagCrossOverride int
|
flagCrossOverride int
|
||||||
|
|
||||||
addr net.UnixAddr
|
addr net.UnixAddr
|
||||||
@@ -136,6 +138,12 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if flagSourcePath != "" {
|
||||||
|
if err := rosa.Native().SetSource(os.DirFS(flagSourcePath)); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}).Flag(
|
}).Flag(
|
||||||
&flagQuiet,
|
&flagQuiet,
|
||||||
@@ -196,6 +204,10 @@ func main() {
|
|||||||
&flagPT,
|
&flagPT,
|
||||||
"parse-time", command.BoolFlag(false),
|
"parse-time", command.BoolFlag(false),
|
||||||
"Print duration of the initial azalea parse",
|
"Print duration of the initial azalea parse",
|
||||||
|
).Flag(
|
||||||
|
&flagSourcePath,
|
||||||
|
"source", command.StringFlag(""),
|
||||||
|
"Override hakurei source tree",
|
||||||
)
|
)
|
||||||
|
|
||||||
c.NewCommand(
|
c.NewCommand(
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package rosa
|
package rosa
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"archive/tar"
|
||||||
|
"bytes"
|
||||||
|
"compress/gzip"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
@@ -1173,6 +1176,90 @@ func (s *S) RegisterFS(fsys fs.FS) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetSource overrides the hakurei-source package with a cached tarball of fsys.
|
||||||
|
// The resulting IR is curable on the daemon. Must not be used concurrently with
|
||||||
|
// any other method.
|
||||||
|
func (s *S) SetSource(fsys fs.FS) error {
|
||||||
|
var buf bytes.Buffer
|
||||||
|
w, err := gzip.NewWriterLevel(&buf, gzip.BestSpeed)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
tw := tar.NewWriter(w)
|
||||||
|
|
||||||
|
if err = fs.WalkDir(fsys, ".", func(path string, d fs.DirEntry, err error) error {
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.IsDir() && d.Name() == ".git" {
|
||||||
|
return fs.SkipDir
|
||||||
|
}
|
||||||
|
|
||||||
|
var fi fs.FileInfo
|
||||||
|
if fi, err = d.Info(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var linkname string
|
||||||
|
if fi.Mode()&fs.ModeSymlink != 0 {
|
||||||
|
if linkname, err = fs.ReadLink(fsys, path); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var h *tar.Header
|
||||||
|
if h, err = tar.FileInfoHeader(fi, linkname); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
h.Name = path
|
||||||
|
|
||||||
|
if err = tw.WriteHeader(h); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if fi.Mode().IsRegular() {
|
||||||
|
var f io.ReadCloser
|
||||||
|
if f, err = fsys.Open(path); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = io.Copy(tw, f)
|
||||||
|
if _err := f.Close(); err == nil {
|
||||||
|
err = _err
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = tw.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
} else if err = w.Close(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = "hakurei-source"
|
||||||
|
a := pkg.NewFile("hakurei-src-current.tar.gz", buf.Bytes())
|
||||||
|
s.artifacts.Store(
|
||||||
|
H(name),
|
||||||
|
Artifact(func(t Toolchain) (*Metadata, pkg.Artifact) {
|
||||||
|
return &Metadata{
|
||||||
|
Name: name,
|
||||||
|
Description: "hakurei source tree (current)",
|
||||||
|
Version: "1.0.0-CURRENT",
|
||||||
|
Exclude: true,
|
||||||
|
}, pkg.NewTar(a, pkg.TarGzip)
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
s.DropCaches(s.Arch(), s.Flags())
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// SetGentooStage3 sets the Gentoo stage3 tarball url and checksum. It panics
|
// SetGentooStage3 sets the Gentoo stage3 tarball url and checksum. It panics
|
||||||
// if given zero values or if these values have already been set.
|
// if given zero values or if these values have already been set.
|
||||||
func (s *S) SetGentooStage3(url string, checksum pkg.Checksum) {
|
func (s *S) SetGentooStage3(url string, checksum pkg.Checksum) {
|
||||||
|
|||||||
Reference in New Issue
Block a user