@@ -29,6 +29,56 @@ check:
29
29
R CMD check --as-cran --no-manual --no-vignettes \
30
30
--no-build-vignettes $(PKG_TAR)
31
31
32
+ # Check reverse dependencies
33
+ #
34
+ # 1) Install packages (in ./revdep/lib) to check reverse dependencies.
35
+ # 2) Check reverse dependencies using 'R CMD check'.
36
+ # 3) Collect results from '00check.log' files.
37
+ revdep : revdep_install revdep_check revdep_results
38
+
39
+ # Install packages to check reverse dependencies
40
+ revdep_install : clean
41
+ mkdir -p revdep/lib
42
+ cd .. && R CMD INSTALL --library=$(PKG_NAME ) /revdep/lib $(PKG_NAME )
43
+ Rscript --vanilla \
44
+ -e "options(repos = c(CRAN='https ://cran.r-project.org'))" \
45
+ -e "lib <- 'revdep/lib'" \
46
+ -e "pkg <- tools ::package_dependencies('$(PKG_NAME ) ', which = 'all', reverse = TRUE)" \
47
+ -e "pkg <- as.character(unlist(pkg))" \
48
+ -e "dep <- sapply(pkg, tools ::package_dependencies, which = 'all')" \
49
+ -e "dep <- as.character(unlist(dep))" \
50
+ -e "if ('BiocInstaller' %in% dep) {" \
51
+ -e " source('https ://bioconductor.org/biocLite.R')" \
52
+ -e " biocLite('BiocInstaller', lib = lib)" \
53
+ -e "}" \
54
+ -e "install.packages(pkg, lib = lib, dependencies = TRUE)" \
55
+ -e "download.packages(pkg, destdir = 'revdep')"
56
+
57
+ # Check reverse dependencies with 'R CMD check'
58
+ revdep_check :
59
+ $(foreach var,$(wildcard revdep/* .tar.gz) ,R_LIBS=revdep/lib \
60
+ _R_CHECK_CRAN_INCOMING_ =FALSE R --vanilla CMD check --as-cran \
61
+ --no-stop-on-test-error --output=revdep $(var ) \
62
+ | tee --append revdep/00revdep.log;)
63
+
64
+ # Collect results from checking reverse dependencies
65
+ revdep_results :
66
+ Rscript --vanilla \
67
+ -e "options(repos = c(CRAN='https ://cran.r-project.org'))" \
68
+ -e "pkg <- tools ::package_dependencies('$(PKG_NAME ) ', which = 'all', reverse = TRUE)" \
69
+ -e "pkg <- as.character(unlist(pkg))" \
70
+ -e "results <- do.call('rbind', lapply(pkg, function(x) {" \
71
+ -e " filename <- paste0('revdep/', x, '.Rcheck/00check.log')" \
72
+ -e " lines <- readLines(filename)" \
73
+ -e " status <- sub('^Status : ', '', lines[grep('^Status: ', lines)])" \
74
+ -e " data.frame(Package = x, Status = status)" \
75
+ -e "}))" \
76
+ -e "results <- results[order(results[, 'Status']), ]" \
77
+ -e "rownames(results) <- NULL" \
78
+ -e "cat('\n\n*** Results ***\n\n')" \
79
+ -e "results" \
80
+ -e "cat('\n\n')"
81
+
32
82
# Build and check package with gctorture
33
83
check_gctorture :
34
84
cd .. && R CMD build --no-build-vignettes $(PKG_NAME )
@@ -115,5 +165,8 @@ configure: configure.ac
115
165
116
166
clean :
117
167
./cleanup
168
+ -rm -rf revdep
118
169
119
- .PHONY : all readme install roxygen sync_libgit2 Makevars check check_gctorture check_valgrind valgrind clean
170
+ .PHONY : all readme install roxygen sync_libgit2 Makevars check check_gctorture \
171
+ check_valgrind revdep revdep_install revdep_check revdep_results valgrind \
172
+ clean
0 commit comments