r-windows / rtools-packages

Toolchains and libraries for R-4.0 to R-4.2 (legacy)
https://cran.r-project.org/bin/windows/Rtools/rtools40.html
BSD 3-Clause "New" or "Revised" License
54 stars 36 forks source link

Remaining rwinlib ucrt updates #219

Closed jeroen closed 3 years ago

jeroen commented 3 years ago
cran2git <- read.csv('https://r-universe-org.github.io/cran-to-git/crantogit.csv')
txt <- readLines('https://www.r-project.org/nosvn/winutf8/ucrt3/patches/CRAN/')
pt <- '.*href="(.*).diff".*'
txt <- txt[grepl(pt, txt)]
pkgs <- sub(pt, '\\1', txt)

test_for_rwinlib <- function(pkg){
  has_rwinlib <- url_exists(sprintf('https://raw.githubusercontent.com/cran/%s/master/tools/winlibs.R', pkg))
  has_ucrt <- url_exists(sprintf('https://raw.githubusercontent.com/cran/%s/master/src/Makevars.ucrt', pkg))
  if(!has_ucrt){
    giturl <- cran2git$url[cran2git$package == pkg]
    if(length(giturl)){
      base <- sub("https://github.com/", "", giturl)
      has_ucrt <- url_exists(sprintf('https://raw.githubusercontent.com/%s/master/src/Makevars.ucrt', base))
    }
  }
  return(has_rwinlib && !has_ucrt)
}

url_exists <- function(url){
  req <- curl::curl_fetch_memory(url)
  return(req$status == 200)
}

todo <- Filter(test_for_rwinlib, pkgs)