Delete functions that no product code calls, and fold "simple plus WithOptions" pairs into the one signature callers actually use. Rename the live macOS lifecycle functions that were labelled Legacy. The architecture tests now share one source loader and reject functions without a product caller and catalog messages nobody reads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
62 lines
1.7 KiB
Go
62 lines
1.7 KiB
Go
package installer
|
|
|
|
import (
|
|
"encoding/json"
|
|
"unicode"
|
|
"unicode/utf8"
|
|
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
)
|
|
|
|
// Kind is what an Update reports.
|
|
type Kind = host.Kind
|
|
|
|
const (
|
|
KindStep = host.KindStep
|
|
KindProgress = host.KindProgress
|
|
KindNote = host.KindNote
|
|
)
|
|
|
|
// Update is one progress report from reims-util (JSON events) or reims-ctl
|
|
// (text lines that relay reims-util). Total is 0 when the size is unknown;
|
|
// Percent is -1 then.
|
|
type Update = host.Update
|
|
|
|
// event mirrors reims-util's `--json` line format. Upstream reims-vgpu
|
|
// 3731afd, crates/reims-ctl/src/reims_util.rs:423-431: each stdout line is
|
|
// {"event":"step"|"progress"|"note"|"done"|"error", ...}; progress carries
|
|
// done and an optional total; done carries the result.
|
|
type event struct {
|
|
Event string `json:"event"`
|
|
Message string `json:"message"`
|
|
Done int64 `json:"done"`
|
|
Total *int64 `json:"total"`
|
|
Result json.RawMessage `json:"result"`
|
|
}
|
|
|
|
// lowerFirst turns "Downloading OpenCore 1.0.8" into "downloading OpenCore
|
|
// 1.0.8" but leaves "OVMF's code" alone, as reims-ctl shows steps
|
|
// (reims_util.rs:511-521). Keeping the same wording means a step reads the same
|
|
// whether it came from reims-util directly or relayed by reims-ctl.
|
|
func lowerFirst(s string) string {
|
|
a, n := utf8.DecodeRuneInString(s)
|
|
if n == 0 {
|
|
return s
|
|
}
|
|
b, _ := utf8.DecodeRuneInString(s[n:])
|
|
if unicode.IsUpper(a) && unicode.IsLower(b) {
|
|
return string(unicode.ToLower(a)) + s[n:]
|
|
}
|
|
return s
|
|
}
|
|
|
|
func percentOf(done, total int64) float64 {
|
|
if total <= 0 {
|
|
return -1
|
|
}
|
|
if done > total {
|
|
done = total
|
|
}
|
|
return float64(done) * 100 / float64(total)
|
|
}
|