[Rd] R CMD INSTALL --clean

Romain Francois romain.francois at dbmail.com
Mon Sep 7 11:05:42 CEST 2009


Hello,

I am using "R CMD INSTALL --clean" so that when my package is finished 
installed, a cleanup script is executed to post-process the generated 
html index file and add some more information. The cleanup (or 
cleanup.win script eventually calls the R code below)

This works well, but it depends on the --clean switch. Is there another 
way, or can I force --clean (for example from the configure script) ?

Romain


h2 <- function( txt ){
	sprintf( "<h2>%s</h2>\n", txt )
}
link <- function( txt, href ){
	sprintf( '<a href="%s">%s</a>', href, txt )
}
line <- function( link, txt ){
	sprintf( '<tr><td width="25%%">%s</td>\n<td>%s</td></tr>\n', link, txt )
}

ooindex.file <- file.path( Sys.getenv( "R_PACKAGE_DIR" ) , "html", 
"00Index.html" )
if( file.exists( ooindex.file ) ){
	# read the 00Index.html file
	ooindex <- readLines( ooindex.file )
	bottom <- grep( "^</table>", ooindex)
	bottom <- bottom[ length(bottom) ]
	
	# add java specific things
	txt <- paste(
		'</table>\n',
		h2( "Java" ),
		'<table width="100%">\n',
		line( link( "javadoc" , "../javadoc/index.html" ), "API documentation" ),
		"</table>\n"
	 )
	ooindex[ bottom ] <- txt
	
	# write back
	cat( ooindex, file = ooindex.file, sep = "\n" )
}

-- 
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://tr.im/xMdt : update on the ant package
|- http://tr.im/xHLs : R capable version of ant
`- http://tr.im/xHiZ : Tip: get java home from R with rJava



More information about the R-devel mailing list