fix(patches): validator portability, clearer docs, broader hook trigger

This commit is contained in:
Patrick Schratz 2026-06-30 09:17:24 +02:00
commit f3f3bfa20d
Signed by: pat-s
GPG key ID: 3C6318841EF78925
2 changed files with 2428 additions and 8 deletions

View file

@ -34,10 +34,10 @@ To add a new patch entry:
## Validation
The registry is validated and applied by bincraft during the build process.
For manual validation, use:
For manual validation, run the validator from the repo root:
```r
x <- jsonlite::fromJSON("local/patches/registry.json", simplifyVector = FALSE)
```bash
Rscript local/validate-patches.R
```
This loads the registry; inspect the structure to verify correctness.
This validates the schema, referenced patch-file existence, and checks for duplicate entries across platforms and versions.

View file

@ -9,6 +9,8 @@ if (!file.exists(registry_file)) {
quit(status = 0L)
}
or_q <- function(x) if (is.null(x)) "?" else x
reg <- jsonlite::fromJSON(registry_file, simplifyVector = FALSE)
required <- c("package", "versions", "platforms", "reason")
errs <- character(0L)
@ -36,9 +38,9 @@ for (i in seq_along(reg)) {
keys <- vapply(reg, function(e) {
sprintf(
"%s|%s|%s",
e$package %||% "?",
or_q(e$package),
paste(sort(as.character(unlist(e$platforms))), collapse = ","),
e$versions %||% "?"
or_q(e$versions)
)
}, character(1L))
dups <- keys[duplicated(keys)]
@ -51,4 +53,4 @@ if (length(errs) > 0L) {
cat(paste0(" - ", errs, "\n"))
quit(status = 1L)
}
cat(sprintf("Patch registry OK (%d entrie(s)).\n", length(reg)))
cat(sprintf("Patch registry OK (%d %s).\n", length(reg), if (length(reg) == 1L) "entry" else "entries"))