fix: runtime install deadlock, manifest raw_bytes, CLI flag order
- extractTarZst uses Windows' System32 tar.exe (reads .tar.zst and D:\ paths); a bare "tar" could resolve to GNU tar, whose failure left the zstd | tar pipe deadlocked. The fallback now decompresses to a temp file. - pack-runtime.ps1 casts raw_bytes to an integer (PowerShell 7 summed to a double, "962466926.0", which the Go reader rejected); the reader now also accepts whole-number floats. - `runtime fetch latest --candidate` honours flags after the positional arg. - Docs: release layout, source package contents and the open MSYS2 source question (portable-runtime-spec.md §4, §7); roadmap M1.2 and M2.1 progress. Verified: a fresh `reims-go runtime fetch latest --candidate` downloads the published runtime-3731afd from GitHub, checks SHA256SUMS.txt, unpacks and activates it (75 s for 169 MB); reims-ctl and QEMU run from the result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c7fe3d27f0
commit
36c937d718
6 files changed
+316
-244
No files matched your search
+114
-99
@@ -1,99 +1,114 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/config"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
"github.com/Nwflower/reims-go/internal/installer"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
)
|
||||
|
||||
// runtime available [--candidate]: published runtimes on GitHub Releases.
|
||||
func cmdRuntimeAvailable(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
fs := flag.NewFlagSet("runtime available", flag.ContinueOnError)
|
||||
candidate := fs.Bool("candidate", cfg.RuntimeChannel == rt.ChannelCandidate, "Include candidate runtimes")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := rt.DefaultSource().ListRemote(context.Background(), *candidate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(list) == 0 {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.empty"))
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("%-9s %-10s %-11s %9s %s\n", "COMMIT", "CHANNEL", "PUBLISHED", "SIZE", "INSTALLED")
|
||||
for _, r := range list {
|
||||
mark := ""
|
||||
if rt.IsInstalled(cfg, r.Commit) {
|
||||
mark = "*"
|
||||
}
|
||||
date := r.PublishedAt
|
||||
if len(date) >= 10 {
|
||||
date = date[:10]
|
||||
}
|
||||
fmt.Printf("%-9s %-10s %-11s %9s %s\n", r.Commit, r.Channel, date, humanBytes(r.ArchiveSize), mark)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// runtime fetch [commit|latest] [--candidate]: download, verify, install, activate.
|
||||
func cmdRuntimeFetch(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
fs := flag.NewFlagSet("runtime fetch", flag.ContinueOnError)
|
||||
candidate := fs.Bool("candidate", cfg.RuntimeChannel == rt.ChannelCandidate, "Allow candidate runtimes for \"latest\"")
|
||||
if err := fs.Parse(args); err != nil {
|
||||
return err
|
||||
}
|
||||
want := fs.Arg(0)
|
||||
explicit := want != "" && want != "latest"
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
defer stop()
|
||||
src := rt.DefaultSource()
|
||||
list, err := src.ListRemote(ctx, *candidate || explicit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := rt.Pick(list, want)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !rt.IsInstalled(cfg, r.Commit) {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.downloading", r.Commit, r.Channel, humanBytes(r.ArchiveSize)))
|
||||
bar := newProgressLine()
|
||||
path, err := src.Download(ctx, *r, rt.DownloadsDir(cfg), func(done, total int64) {
|
||||
p := -1.0
|
||||
if total > 0 {
|
||||
p = float64(done) * 100 / float64(total)
|
||||
}
|
||||
bar.update(installer.Update{Kind: installer.KindProgress, Done: done, Total: total, Percent: p})
|
||||
})
|
||||
bar.finish()
|
||||
if errors.Is(err, context.Canceled) {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.paused"))
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inst, err := rt.InstallFromArchive(cfg, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove(path)
|
||||
r.Commit = inst.Commit
|
||||
}
|
||||
cfg.ActiveRuntime = r.Commit
|
||||
if err := config.Save("", cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "runtime.activated", r.Commit))
|
||||
return nil
|
||||
}
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/signal"
|
||||
|
||||
"github.com/Nwflower/reims-go/internal/config"
|
||||
"github.com/Nwflower/reims-go/internal/i18n"
|
||||
"github.com/Nwflower/reims-go/internal/installer"
|
||||
rt "github.com/Nwflower/reims-go/internal/runtime"
|
||||
)
|
||||
|
||||
// runtime available [--candidate]: published runtimes on GitHub Releases.
|
||||
func cmdRuntimeAvailable(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
fs := flag.NewFlagSet("runtime available", flag.ContinueOnError)
|
||||
candidate := fs.Bool("candidate", cfg.RuntimeChannel == rt.ChannelCandidate, "Include candidate runtimes")
|
||||
if err := fs.Parse(flagsFirst(args)); err != nil {
|
||||
return err
|
||||
}
|
||||
list, err := rt.DefaultSource().ListRemote(context.Background(), *candidate)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if len(list) == 0 {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.empty"))
|
||||
return nil
|
||||
}
|
||||
fmt.Printf("%-9s %-10s %-11s %9s %s\n", "COMMIT", "CHANNEL", "PUBLISHED", "SIZE", "INSTALLED")
|
||||
for _, r := range list {
|
||||
mark := ""
|
||||
if rt.IsInstalled(cfg, r.Commit) {
|
||||
mark = "*"
|
||||
}
|
||||
date := r.PublishedAt
|
||||
if len(date) >= 10 {
|
||||
date = date[:10]
|
||||
}
|
||||
fmt.Printf("%-9s %-10s %-11s %9s %s\n", r.Commit, r.Channel, date, humanBytes(r.ArchiveSize), mark)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// runtime fetch [commit|latest] [--candidate]: download, verify, install, activate.
|
||||
func cmdRuntimeFetch(cfg *config.Config, loc i18n.Locale, args []string) error {
|
||||
fs := flag.NewFlagSet("runtime fetch", flag.ContinueOnError)
|
||||
candidate := fs.Bool("candidate", cfg.RuntimeChannel == rt.ChannelCandidate, "Allow candidate runtimes for \"latest\"")
|
||||
if err := fs.Parse(flagsFirst(args)); err != nil {
|
||||
return err
|
||||
}
|
||||
want := fs.Arg(0)
|
||||
explicit := want != "" && want != "latest"
|
||||
|
||||
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt)
|
||||
defer stop()
|
||||
src := rt.DefaultSource()
|
||||
list, err := src.ListRemote(ctx, *candidate || explicit)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
r, err := rt.Pick(list, want)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !rt.IsInstalled(cfg, r.Commit) {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.downloading", r.Commit, r.Channel, humanBytes(r.ArchiveSize)))
|
||||
bar := newProgressLine()
|
||||
path, err := src.Download(ctx, *r, rt.DownloadsDir(cfg), func(done, total int64) {
|
||||
p := -1.0
|
||||
if total > 0 {
|
||||
p = float64(done) * 100 / float64(total)
|
||||
}
|
||||
bar.update(installer.Update{Kind: installer.KindProgress, Done: done, Total: total, Percent: p})
|
||||
})
|
||||
bar.finish()
|
||||
if errors.Is(err, context.Canceled) {
|
||||
fmt.Println(i18n.T(loc, "runtime.remote.paused"))
|
||||
return nil
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
inst, err := rt.InstallFromArchive(cfg, path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = os.Remove(path)
|
||||
r.Commit = inst.Commit
|
||||
}
|
||||
cfg.ActiveRuntime = r.Commit
|
||||
if err := config.Save("", cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(i18n.T(loc, "runtime.activated", r.Commit))
|
||||
return nil
|
||||
}␍
|
||||
␍
|
||||
// flagsFirst moves "-x" arguments before positional ones, so
|
||||
// "fetch latest --candidate" works like "fetch --candidate latest" (the flag
|
||||
// package stops at the first positional argument).
|
||||
func flagsFirst(args []string) []string {
|
||||
var flags, rest []string
|
||||
for _, a := range args {
|
||||
if len(a) > 1 && a[0] == '-' {
|
||||
flags = append(flags, a)
|
||||
} else {
|
||||
rest = append(rest, a)
|
||||
}
|
||||
}
|
||||
return append(flags, rest...)
|
||||
}
|
||||
Reference in new issue
Block a user