From 7ab54b8c94df425e541b0ee00b871a9c7d0dc64e Mon Sep 17 00:00:00 2001 From: Ophestra Date: Sat, 20 Jun 2026 01:18:12 +0900 Subject: [PATCH] internal/rosa: read overridden version string from source This is more correct than the hardcoded string and is generally more robust against relative paths. Signed-off-by: Ophestra --- internal/rosa/state.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/internal/rosa/state.go b/internal/rosa/state.go index 864b70fa..48f3e897 100644 --- a/internal/rosa/state.go +++ b/internal/rosa/state.go @@ -7,6 +7,7 @@ import ( "context" "encoding/json" "errors" + "fmt" "io" "io/fs" "iter" @@ -1255,6 +1256,16 @@ func (s *S) RegisterFS(fsys fs.FS) error { // 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 version string + if p, err := fs.ReadFile(fsys, "cmd/dist/VERSION"); err != nil { + return err + } else if len(p) < 2 { + return fmt.Errorf("invalid version string %q", string(p)) + } else { + version = unsafe.String(unsafe.SliceData(p), len(p)) + } + version = version[1:len(version)-1] + "-CURRENT" + var buf bytes.Buffer w, err := gzip.NewWriterLevel(&buf, gzip.BestSpeed) if err != nil { @@ -1326,7 +1337,7 @@ func (s *S) SetSource(fsys fs.FS) error { return &Metadata{ Name: name, Description: "hakurei source tree (current)", - Version: "1.0.0-CURRENT", + Version: version, Exclude: true, }, pkg.NewTar(pkg.NewDecompress(a, pkg.Gzip)) }),