From de510da3910c7ba3c4f10780bb671f3eb52d8569 Mon Sep 17 00:00:00 2001 From: Iñaki Úcar Date: Aug 03 2022 13:03:12 +0000 Subject: further improved version, using only specs --- diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e994f65 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.Rproj.user +.Rhistory +.RData +.Ruserdata +*.Rproj +*.txt +tmp diff --git a/pkg-build-list.R b/pkg-build-list.R old mode 100644 new mode 100755 index ab47597..522450c --- a/pkg-build-list.R +++ b/pkg-build-list.R @@ -1,29 +1,41 @@ +#!/usr/bin/Rscript # Generates dependency-wise batches of builds, one per line # Author: Iñaki Úcar -# Usage: Rscript pkg-build-list.R > pkg-build-list.txt +# Usage: ./pkg-build-list.R > blist.txt -options(repos = BiocManager:::repositories()) +DIR <- getwd() +TMP <- file.path(DIR, "tmp") +dir.create(TMP, showWarnings=FALSE) +setwd(TMP) +on.exit(setwd(DIR)) -get_build_list <- function(pkgs, cran=available.packages()) { - base <- rownames(installed.packages(priority="high")) - pkgs <- lapply(tools::package_dependencies(pkgs, db=cran), setdiff, base) - pkgs <- lapply(Filter(Negate(is.null), pkgs), intersect, names(pkgs)) +# clone all R packages and disable checks +system(file.path(DIR, "pkg-clone-bootstrap.sh")) - build <- list() - while (length(pkgs)) { - x <- names(Filter(function(i) all(i %in% unlist(build)), pkgs)) - build[[length(build)+1]] <- x - pkgs <- pkgs[!names(pkgs) %in% x] - } +# parse every spec to get BuildRequires +specs <- list.files(pattern="\\.spec", recursive=TRUE) - build -} +pkgs <- lapply(setNames(specs, dirname(specs)), function(spec) { + br <- system(paste0("rpmspec -P ", spec, " | grep '^BuildRequires'"), intern=TRUE) + deps <- unlist(strsplit(br, " ")) # explode + deps <- gsub(",|-devel|-core", "", deps) # remove commas, -devel, -core + deps <- grep("^R-", deps, value=TRUE) # only R packages + unique(deps) +}) -cran <- available.packages() +# filter out base packages and ensure we didn't miss anything +base <- paste0("R-", rownames(installed.packages(priority="high"))) +pkgs <- lapply(pkgs, setdiff, base) +filt <- lapply(Filter(Negate(is.null), pkgs), intersect, names(pkgs)) +stopifnot(all.equal(pkgs, filt)) -pkgs <- system("dnf repoquery --repo=fedora-source --qf %{name} R-*", intern=TRUE) -pkgs <- gsub("-", ".", sub("^R-", "", pkgs)) -pkgs <- pkgs[pkgs %in% cran[,"Package"]] +# get the build list +build <- list() +while (length(pkgs)) { + x <- names(Filter(function(i) all(i %in% unlist(build)), pkgs)) + build[[length(build)+1]] <- x + pkgs <- pkgs[!names(pkgs) %in% x] +} -bl <- get_build_list(pkgs, cran) -cat(paste(sapply(bl, paste, collapse=" "), collapse="\n")) +# one batch per line +cat(paste(sapply(build, paste, collapse=" "), collapse="\n")) diff --git a/pkg-clone-bootstrap.sh b/pkg-clone-bootstrap.sh new file mode 100755 index 0000000..1ff5f17 --- /dev/null +++ b/pkg-clone-bootstrap.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +do_clone () { + if [ ! -d "$1" ]; then + fedpkg clone $1 + else + return 0 + fi +} +export -f do_clone + +PKGS=$(dnf repoquery -q --repo=fedora-source --qf %{name} R-* | grep -v rpm-macros) +parallel --retry-failed do_clone ::: $PKGS + +# enable bootstrap, disable check +find . -name *.spec -exec sed -i 's/%bcond_with bootstrap/%bcond_without bootstrap/' {} \; +find . -name *.spec -exec sed -i 's/%bcond_without check/%bcond_with check/' {} \;