(import (htmlprag)
(sxml xpath)
(gnu packages)
(guix packages)
(guix import cran)
(guix import utils)
(srfi srfi-1)
(ice-9 pretty-print)
(web client))
(define recent
(call-with-values
(lambda ()
(http-get "https://cran.r-project.org/web/packages/available_packages_by_date.html"))
(lambda (response body)
((sxpath '(// table * td a *text*))
(html->sxml body)))))
(define all recent)
(define existing
(fold-packages
(lambda (pkg res)
(if (eq? (package-build-system pkg)
(@ (guix build-system r) r-build-system))
(cons (or (and=> (package-properties pkg)
(lambda (prop)
(assoc-ref prop 'upstream-name)))
(string-drop (package-name pkg) 2))
res)
res))
(list)))
(define missing
(lset-difference string= all existing))
(pk 'missing (length missing))
(define (import-from-cran names)
(append-map
(lambda (name)
(map package->definition
(filter identity (cran-recursive-import name))))
names))
(pretty-print (import-from-cran (take (reverse missing) 5)))