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:
NwflowerandClaude Opus 5.5 committed 2026-11-28 04:28:30 -07:00
1 parent c7fe3d27f0
commit 36c937d718
6 files changed
+316 -244

No files matched your search

+55 -30
View File
@@ -30,7 +30,7 @@ type Manifest struct {
BuiltAt string `json:"built_at"`
FileCount int `json:"file_count"`
DLLCount int `json:"dll_count"`
RawBytes int64 `json:"raw_bytes"`
RawBytes ByteCount `json:"raw_bytes"`
SHA256 map[string]string `json:"sha256"`
// Schema 2 (docs/portable-runtime-spec.md §3.1, §5, §7): what the package
@@ -43,6 +43,19 @@ type Manifest struct {
SourcePackage string `json:"source_package,omitempty"` // file name of the matching source archive
}
// ByteCount is an integer that also accepts a whole-number float ("962466926.0"),
// which PowerShell 7 wrote into manifests before pack-runtime.ps1 cast it.
type ByteCount int64
func (b *ByteCount) UnmarshalJSON(data []byte) error {
var f float64
if err := json.Unmarshal(data, &f); err != nil {
return err
}
*b = ByteCount(f)
return nil
}
// Patch is one local patch applied on top of upstream.
type Patch struct {
Name string `json:"name"`
@@ -317,37 +330,49 @@ func fileSHA256(path string) (string, error) {
return hex.EncodeToString(h.Sum(nil)), nil
}
func extractTarZst(archivePath, destDir string) error {
// Windows 10/11 built-in bsdtar supports .tar.zst natively on modern builds;
// fall back to zstd -dc | tar -xf if needed.
cmd := exec.Command("tar", "-xf", archivePath, "-C", destDir)
configureCmd(cmd)
if out, err := cmd.CombinedOutput(); err == nil {
return nil
} else {
zstdBin := findZstd()
if zstdBin == "" {
return fmt.Errorf("tar -xf failed (%v: %s) and zstd was not found", err, strings.TrimSpace(string(out)))
// tarCommand is Windows' own bsdtar (System32/tar.exe, Windows 10 1803+),
// which reads .tar.zst directly and takes "D:\..." paths. A bare "tar" can
// resolve to GNU tar from Git or MSYS2, which does neither.
func tarCommand() string {
if runtime.GOOS == "windows" {
if root := os.Getenv("SystemRoot"); root != "" {
p := filepath.Join(root, "System32", "tar.exe")
if _, err := os.Stat(p); err == nil {
return p
}
}
z := exec.Command(zstdBin, "-dc", archivePath)
t := exec.Command("tar", "-xf", "-", "-C", destDir)
configureCmd(z)
configureCmd(t)
pipe, err := z.StdoutPipe()
if err != nil {
return err
}
t.Stdin = pipe
if err := z.Start(); err != nil {
return err
}
tOut, tErr := t.CombinedOutput()
zErr := z.Wait()
if tErr != nil {
return fmt.Errorf("tar extract failed: %v (%s)", tErr, strings.TrimSpace(string(tOut)))
}
return zErr
}
return "tar"
}
func extractTarZst(archivePath, destDir string) error {
tarBin := tarCommand()
cmd := exec.Command(tarBin, "-xf", archivePath, "-C", destDir)
configureCmd(cmd)
out, err := cmd.CombinedOutput()
if err == nil {
return nil
}
// Fallback for a tar without zstd: decompress to a temporary .tar first.
// (Piping zstd into tar deadlocked when tar exited early: zstd blocked on a
// full pipe nobody read.)
zstdBin := findZstd()
if zstdBin == "" {
return fmt.Errorf("tar -xf failed (%v: %s) and zstd was not found", err, strings.TrimSpace(string(out)))
}
tmpTar := filepath.Join(destDir, ".extract.tar")
defer os.Remove(tmpTar)
z := exec.Command(zstdBin, "-d", "-q", "-f", archivePath, "-o", tmpTar)
configureCmd(z)
if zOut, zErr := z.CombinedOutput(); zErr != nil {
return fmt.Errorf("zstd -d failed: %v (%s)", zErr, strings.TrimSpace(string(zOut)))
}
t := exec.Command(tarBin, "-xf", tmpTar, "-C", destDir)
configureCmd(t)
if tOut, tErr := t.CombinedOutput(); tErr != nil {
return fmt.Errorf("tar extract failed: %v (%s)", tErr, strings.TrimSpace(string(tOut)))
}
return nil
}
func findZstd() string {