fix: update-tools should not fail on nuked bird + robust nix prefetch parsing
This commit is contained in:
parent
983210e3b6
commit
8911e699d8
@ -13,10 +13,11 @@ import (
|
||||
)
|
||||
|
||||
type Tool struct {
|
||||
Name string
|
||||
Repo string
|
||||
Assets []AssetSpec
|
||||
NixFile string
|
||||
Name string
|
||||
Repo string
|
||||
Assets []AssetSpec
|
||||
NixFile string
|
||||
Optional bool
|
||||
}
|
||||
|
||||
type AssetSpec struct {
|
||||
@ -248,8 +249,9 @@ func main() {
|
||||
NixFile: filepath.Join(repoRoot, "nix", "pkgs", "sonoscli.nix"),
|
||||
},
|
||||
{
|
||||
Name: "bird",
|
||||
Repo: "steipete/bird",
|
||||
Name: "bird",
|
||||
Repo: "steipete/bird",
|
||||
Optional: true, // repo got nuked; keep packaging pinned, but don't fail the updater
|
||||
Assets: []AssetSpec{
|
||||
{System: "aarch64-darwin", Regex: regexp.MustCompile(`bird-macos-universal-v[0-9.]+\.tar\.gz`)},
|
||||
},
|
||||
@ -295,6 +297,10 @@ func main() {
|
||||
}
|
||||
for _, tool := range tools {
|
||||
if err := updateTool(tool); err != nil {
|
||||
if tool.Optional {
|
||||
log.Printf("[update-tools] skipping optional tool %s: %v", tool.Name, err)
|
||||
continue
|
||||
}
|
||||
log.Fatalf("update %s failed: %v", tool.Name, err)
|
||||
}
|
||||
}
|
||||
|
||||
@ -19,15 +19,16 @@ type PrefetchGitHubResult struct {
|
||||
|
||||
func PrefetchHash(url string) (string, error) {
|
||||
cmd := exec.Command("nix", "store", "prefetch-file", "--json", url)
|
||||
var out bytes.Buffer
|
||||
cmd.Stdout = &out
|
||||
cmd.Stderr = &out
|
||||
var stdout bytes.Buffer
|
||||
var stderr bytes.Buffer
|
||||
cmd.Stdout = &stdout
|
||||
cmd.Stderr = &stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
return "", fmt.Errorf("prefetch failed: %v: %s", err, out.String())
|
||||
return "", fmt.Errorf("prefetch failed: %v\nstdout:\n%s\nstderr:\n%s", err, stdout.String(), stderr.String())
|
||||
}
|
||||
var res PrefetchResult
|
||||
if err := json.Unmarshal(out.Bytes(), &res); err != nil {
|
||||
return "", err
|
||||
if err := json.Unmarshal(stdout.Bytes(), &res); err != nil {
|
||||
return "", fmt.Errorf("prefetch json parse failed: %v\nstdout:\n%s\nstderr:\n%s", err, stdout.String(), stderr.String())
|
||||
}
|
||||
if res.Hash == "" {
|
||||
return "", fmt.Errorf("empty hash for %s", url)
|
||||
@ -87,7 +88,7 @@ func NixBuildSummarizeSystem(system string) (string, error) {
|
||||
}
|
||||
|
||||
func ExtractGotHash(log string) string {
|
||||
re := regexp.MustCompile(`got:\s*(sha256-[A-Za-z0-9+/=]+)`)
|
||||
re := regexp.MustCompile(`got:\s*(sha256-[A-Za-z0-9+/=]+)`)
|
||||
for _, line := range strings.Split(log, "\n") {
|
||||
match := re.FindStringSubmatch(line)
|
||||
if len(match) > 1 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user