aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-06-20 01:18:12 +0900
committerOphestra <cat@gensokyo.uk>2026-06-20 01:18:12 +0900
commit7ab54b8c94df425e541b0ee00b871a9c7d0dc64e (patch)
tree279b5587c8e157a55f2a44c1fc085d3bd34b7433
parenta4fab678114b61c1c3473661577797ecf029514d (diff)
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 <cat@gensokyo.uk>
-rw-r--r--internal/rosa/state.go13
1 files changed, 12 insertions, 1 deletions
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))
}),