## Summary
Builds R-minor-sensitive CRAN packages once per installed R minor version (into per-minor S3 slots `…/contrib/<x.y>/`) and everything else once into the generic slot, driven by bincraft 4.2.0's ABI classifier. Both the full and iterative pipelines are covered.
## What's in here
**Detection / precompute**
- `local/r-minor-helpers.R` — pure `classify_from_metadata()` (NeedsCompilation / risky `LinkingTo`) + `parse_build_args()`, with unit tests.
- `local/packages-to-build.R` — adds a per-package `r_minor_sensitive` flag: cheap CRAN-metadata rules first, source download + `bincraft::needs_per_minor_recompile()` only for the ambiguous compiled subset (fail-safe to sensitive). Classified once per package, applied to all versions.
**Full build**
- `local/build-all.R` — passes the per-row `is_r_minor_sensitive` flag; new `--sensitive-only` mode builds just the risky subset.
- `.crow/build-all-versions-{amd64,arm64}.yaml` — install-deps persists the sensitive subset; build step runs a sensitive-only pass under each non-primary `/opt/R/*` minor; new step uploads the generic index plus a per-minor index for each minor.
**Iterative build**
- All 14 `.crow/process-updates-*.yaml` — primary pass uses `r_minor_detection = 'classifier'`; a sensitive-only multi-R pass builds risky updates under each other minor; per-minor index upload added.
**Tooling / housekeeping**
- Pins bincraft `v4.1.1` → `v4.2.0` across all workflows; removes the superseded standalone `build-r-minor-sensitive-packages.yaml`.
- Adds prek/pre-commit hooks (prettier, markdownlint, editorconfig-checker, yamllint, air) and applies them repo-wide; excludes the verbatim GPL `LICENSE.md` and auxiliary shell scripts.
- Design + implementation docs under `docs/superpowers/`.
## Requires before merge
- A `v4.2.0` git tag must be pushed on the bincraft repo (codefloe.com/rpkgs/bincraft) — the workflow install steps pin `@v4.2.0`. The full-build install-deps clones `main`, so it is unaffected.
Reviewed-on: #84
111 lines
2.9 KiB
R
111 lines
2.9 KiB
R
library(httr2, quietly = TRUE)
|
|
|
|
forgejo_base <- "https://git.devxy.io/api/v1"
|
|
repo <- "devxy/build-cran-binaries"
|
|
platform <- Sys.getenv("PLATFORM")
|
|
arch <- Sys.getenv("ARCH")
|
|
token <- Sys.getenv("FORGEJO_TOKEN")
|
|
output_file <- Sys.getenv("REBUILD_PKG_LIST", "/tmp/rebuild_pkgs.txt")
|
|
|
|
if (nchar(platform) == 0) {
|
|
stop("PLATFORM env var is not set")
|
|
}
|
|
if (nchar(arch) == 0) {
|
|
stop("ARCH env var is not set")
|
|
}
|
|
if (nchar(token) == 0) {
|
|
stop("FORGEJO_TOKEN env var is not set")
|
|
}
|
|
|
|
os_family <- if (grepl("^ubuntu", platform)) {
|
|
"Ubuntu"
|
|
} else if (grepl("^alpine", platform)) {
|
|
"Alpine"
|
|
} else if (grepl("^redhat", platform)) {
|
|
"Red Hat"
|
|
} else {
|
|
platform
|
|
}
|
|
|
|
issue_title <- sprintf(
|
|
"Missing package binaries for latest version (%s)",
|
|
os_family
|
|
)
|
|
cat(sprintf("Searching for issue: %s\n", issue_title))
|
|
|
|
search_url <- sprintf(
|
|
"%s/repos/%s/issues?type=issues&state=open&q=%s&limit=50",
|
|
forgejo_base,
|
|
repo,
|
|
utils::URLencode(issue_title, reserved = TRUE)
|
|
)
|
|
search_resp <- request(search_url) |>
|
|
req_headers(Authorization = paste("token", token)) |>
|
|
req_perform()
|
|
|
|
issues <- resp_body_json(search_resp, simplifyVector = FALSE)
|
|
match_idx <- which(
|
|
vapply(issues, function(x) x$title, character(1)) == issue_title
|
|
)
|
|
|
|
if (length(match_idx) == 0) {
|
|
cat("No matching issue found - nothing to rebuild\n")
|
|
writeLines(character(0), output_file)
|
|
q("no")
|
|
}
|
|
|
|
body <- issues[[match_idx[1]]]$body
|
|
if (is.null(body) || nchar(body) == 0) {
|
|
cat("Issue body is empty - nothing to rebuild\n")
|
|
writeLines(character(0), output_file)
|
|
q("no")
|
|
}
|
|
|
|
lines <- strsplit(body, "\n", fixed = TRUE)[[1]]
|
|
|
|
# Find the platform section (## alpine-322)
|
|
plat_header <- sprintf("## %s", platform)
|
|
plat_idx <- which(lines == plat_header)
|
|
if (length(plat_idx) == 0) {
|
|
cat(sprintf(
|
|
"No section found for platform %s - nothing to rebuild\n",
|
|
platform
|
|
))
|
|
writeLines(character(0), output_file)
|
|
q("no")
|
|
}
|
|
|
|
# Find the arch subsection (### arm64 (...))
|
|
arch_pattern <- sprintf("^### %s ", arch)
|
|
arch_idx <- which(grepl(arch_pattern, lines) & seq_along(lines) > plat_idx[1])
|
|
if (length(arch_idx) == 0) {
|
|
cat(sprintf(
|
|
"No section found for arch %s under %s - nothing to rebuild\n",
|
|
arch,
|
|
platform
|
|
))
|
|
writeLines(character(0), output_file)
|
|
q("no")
|
|
}
|
|
|
|
ai <- arch_idx[1]
|
|
|
|
# Find the end of the rebuildable section: stop at ####, ###, ##, ---, or EOF
|
|
end_idx <- which(grepl("^####|^###|^##|^---", lines) & seq_along(lines) > ai)
|
|
end_idx <- if (length(end_idx) > 0) end_idx[1] - 1 else length(lines)
|
|
|
|
section_lines <- lines[seq(ai + 1, end_idx)]
|
|
|
|
# Extract package names from "- PackageName (Version)" lines
|
|
pkg_lines <- section_lines[grepl("^- ", section_lines)]
|
|
pkgs <- sub("^- ([^ ]+) \\(.*\\)$", "\\1", pkg_lines)
|
|
pkgs <- pkgs[nchar(pkgs) > 0 & pkgs != "_None_"]
|
|
|
|
cat(sprintf(
|
|
"Found %d rebuildable packages for %s/%s\n",
|
|
length(pkgs),
|
|
platform,
|
|
arch
|
|
))
|
|
writeLines(pkgs, output_file)
|
|
cat(sprintf("Wrote package list to %s\n", output_file))
|