@@ -80,25 +80,35 @@ extractManuals <- function(reposRoot, srcContrib, destDir) {
8080 # # helper function to unpack pdf & Rd files from the vig
8181 cleanUnpackDir(tarball , unpackDir , " man" , " .*\\ .(pdf|Rd|rd)$" )
8282 ret <- unpack(tarball , unpackDir , " " )
83- if (ret != 0 )
84- stop(" non-zero exit status " , ret , " extracting " , tarball )
83+ if (ret != 0 ) {
84+ warning(" non-zero exit status " , ret , " extracting " , tarball )
85+ return (FALSE )
86+ }
8587 pkg <- pkgName(tarball )
8688 pkgDir <- file.path(unpackDir , pkg )
8789 pkgManDir <- file.path(pkgDir , " man" )
88- if (dir.exists(pkgManDir ))
89- unlink(pkgManDir , recursive = TRUE )
90- tmp_file <- paste(file.path(pkgDir , pkg ), " pdf" , sep = " ." )
90+ # Remove if exists without an .Rd file
91+ if (dir.exists(pkgManDir ) &&
92+ length(list.files(pkgManDir , pattern = " .*\\ .(Rd|rd)" )) == 0 )
93+ unlink(pkgManDir , recursive = TRUE )
94+ tmp_file <- file.path(pkgDir , paste0(pkg , " .pdf" ))
9195 r_path <- file.path(Sys.getenv(" R_HOME" ), " bin" , " R" )
9296 CmdRd2pdf <- paste0(" CMD Rd2pdf --no-preview --output=" , tmp_file ,
93- " --title=" , pkg , " " , pkgDir )
94- print(paste(r_path , CmdRd2pdf ))
95- system2(r_path , CmdRd2pdf , stdout = FALSE , stderr = FALSE )
96- if (! file.exists(tmp_file ))
97- stop(" non-zero exit status " , ret , " building ref man: " , pkg )
97+ " --force --title=" , pkg , " " , pkgDir )
98+ ret <- system2(r_path , CmdRd2pdf , stdout = FALSE , stderr = FALSE )
99+ if (! file.exists(tmp_file ) || ret != 0 ) {
100+ warning(" non-zero exit status " , ret , " building ref man " , pkg )
101+ return (FALSE )
102+ }
98103 if (! dir.exists(pkgManDir ))
99104 dir.create(pkgManDir )
100- file.rename(tmp_file ,
101- paste(file.path(pkgManDir , pkg ), " pdf" , sep = " ." ))
105+ file.copy(tmp_file , file.path(pkgManDir , paste0(pkg , " .pdf" )),
106+ overwrite = TRUE )
107+ pkgFiles <- list.files(pkgDir )
108+ pkgFiles <- pkgFiles [! grepl(" man" , pkgFiles )]
109+ pkgFiles <- unname(sapply(pkgFiles ,
110+ function (pkgFiles ) file.path(pkgDir , pkgFiles )))
111+ unlink(pkgFiles , recursive = TRUE )
102112 cleanUnpackDir(tarball , unpackDir , " man" , " .*\\ .(Rd|rd)$" )
103113 TRUE
104114 }
0 commit comments