build-cran-binaries/local/label-removed-cran-packages.R
pat-s 0c59dfb3df
fix: verify the metadata database certificate with sslmode=verify-full
- Switch every `metadata_db_sslmode` passed to bincraft in `.crow/` and `local/` from `require` to `verify-full`.
- Pass `sslrootcert = bincraft::postgres_sslrootcert("verify-full")` alongside `verify-full` in the scripts that call `DBI::dbConnect()` themselves, since libpq does not read the system trust store.
- Note in the README that the endpoint serves a Let's Encrypt certificate and how to verify it.

Part of rpkgs/bincraft#225.
2026-10-17 07:41:23 +00:00

35 lines
919 B
R

### Scope: List decomisisoned CRAN packages and updates them in the metadata DB
library(dplyr)
library(bincraft)
archived <- quickcode::archivedPkg() |>
filter(arch.status == "decom") |>
pull(name)
# Query all distinct pkgs in the DB
con <- DBI::dbConnect(
RPostgres::Postgres(),
dbname = "build_metadata",
host = "r-binaries.devxy.io",
port = 15432,
user = "r_binaries",
password = Sys.getenv("PGPASS"),
sslmode = "verify-full",
sslrootcert = bincraft::postgres_sslrootcert("verify-full")
)
pkgs_db <- query_metadata_table() |>
filter(removed == FALSE) |>
distinct(name) |>
pull(name)
# Check which pkgs in the DB match with the decomissioned ones
to_process <- pkgs_db[pkgs_db %in% archived]
# for all matches, set 'removed = TRUE'
sapply(to_process, function(.x) {
DBI::dbExecute(
con,
"UPDATE single_builds SET removed = 'TRUE' where name = $1",
params = list(.x)
)
})