From a88d8cf61d5019db2f39eda68a3099a0f4922000 Mon Sep 17 00:00:00 2001 From: moeller Date: Tue, 8 Feb 2011 11:08:27 +0000 Subject: [PATCH] Circumvented bug in hwriter that cannot write empty tables. Using getopt package to read arguments. The cran2deb shell script needed to be adapted for it and the DESCRIPTION now mentions also getopt. (little)r and getopt together as so strong, that in the (a bit) longer run I also see it substitute what today is implemented in the plan 9 shell, if you do not mind. git-svn-id: svn://svn.r-forge.r-project.org/svnroot/cran2deb@322 edb9625f-4e0d-4859-8d74-9fd3b1da38cb --- trunk/DESCRIPTION | 2 +- trunk/exec/cran2deb | 15 ++++++++++-- trunk/exec/web | 57 +++++++++++++++++++++++++++++++++++++-------- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/trunk/DESCRIPTION b/trunk/DESCRIPTION index b5129db..c12c082 100644 --- a/trunk/DESCRIPTION +++ b/trunk/DESCRIPTION @@ -4,7 +4,7 @@ Date: 2008-07-14 Title: Convert CRAN packages into Debian packages Author: Charles Blundell , with assistance from Dirk Eddelbuettel <> Maintainer: Charles Blundell -Depends: ctv, utils, RSQLite, DBI, digest, hwriter +Depends: ctv, utils, RSQLite, DBI, digest, hwriter, getopt SystemRequirements: littler, rc, pbuilder, debian toolchain, web server, mini-dinstall, curl Description: Convert CRAN packages into Debian packages, mostly unassisted, easily subverting the R package system. diff --git a/trunk/exec/cran2deb b/trunk/exec/cran2deb index 3b2794a..e47543d 100755 --- a/trunk/exec/cran2deb +++ b/trunk/exec/cran2deb @@ -2,15 +2,26 @@ umask 002 root=$(r -e 'suppressMessages(library(cran2deb));cat(system.file(package="cran2deb"),file=stdout())') cmd=$1 -shift + +if [ "x" = "x$cmd" ]; then + cmd="help" +fi + if [ ! -x "$root/exec/$cmd" ]; then echo unknown command $cmd exit 1 fi +shift + precmd="" if [ "$(id -un)" != c2d ]; then precmd="sudo -u c2d -E" fi -$precmd "$root/exec/$cmd" "$root" $* +if [ "web" = "$cmd" ]; then + # web uses getopt and would be irritated by the "$root" argument + $precmd "$root/exec/$cmd" $* +else + $precmd "$root/exec/$cmd" "$root" $* +fi diff --git a/trunk/exec/web b/trunk/exec/web index 10dbcb4..3a52292 100755 --- a/trunk/exec/web +++ b/trunk/exec/web @@ -5,19 +5,51 @@ suppressPackageStartupMessages(library(cran2deb)) library(hwriter) +library(getopt) -banned_builds_path='/var/www/banned_packages.html' -todays_builds_path='/var/www/todays_packages.html' -latest_builds_path='/var/www/latest_packages.html' -failed_builds_path='/var/www/failed_packages.html' +opt<-getopt(matrix(c( + 'verbose','v', 0, "logical", + 'debug', 'd', 0, "logical", + 'help', 'h', 0, "logical", + 'root', 'r', 2, "character" +),byrow=TRUE,ncol=4)) + +.Last <- function() { if (!is.null(opt$verbose)) {cat("Printing the traceback, just to be sure:\n"); print(traceback())} } + +web.cran2deb.root<-"/var/www/cran2deb" +if (!is.null(opt$root)) { + web.cran2deb.root <- opt$root +} + +if (!is.null(opt$debug)) { + cat("Settings:\n") + cat(" * root: ",web.cran2deb.root,"\n",sep="") + cat("\n") + print(opt) + q() +} + + +if (!is.null(opt$verbose)) cat("building banned_packages.html\n") +banned_builds_path=paste(web.cran2deb.root,"banned_packages.html",sep="/") + +if (!is.null(opt$verbose)) cat("building todays_packages.html\n") +todays_builds_path=paste(web.cran2deb.root,"todays_packages.html",sep="/") + +if (!is.null(opt$verbose)) cat("building latest_packages.html\n") +latest_builds_path=paste(web.cran2deb.root,"latest_packages.html",sep="/") + +if (!is.null(opt$verbose)) cat("building failed_packages.html\n") +failed_builds_path=paste(web.cran2deb.root,"failed_packages.html",sep="/") links <- function(p) { hwrite(c( - hwrite('Packages built today',link='/todays_packages.html') - ,hwrite('Successful packages',link='/latest_packages.html') - ,hwrite('Failed packages',link='/failed_packages.html') - ,hwrite('Banned packages',link='/banned_packages.html') + hwrite('Packages built today',link='todays_packages.html') + ,hwrite('Successful packages',link='latest_packages.html') + ,hwrite('Failed packages',link='failed_packages.html') + ,hwrite('Banned packages',link='banned_packages.html') ),p,center=TRUE,border=0,style='padding: 6px 6px 6px 12px') + if (!is.null(opt$verbose)) cat("Wrote links for ",p,".\n",sep="") } page <- function(content,path,title) { @@ -26,9 +58,14 @@ page <- function(content,path,title) { hwrite(title,p,heading=1) hwrite('Install instructions',p,center=TRUE,link='/') links(p) - hwrite(content,p,center=TRUE,border=1,table.style='border-collapse: collapse; padding: 0; margin: 0' + if (nrow(content)>0) { + hwrite(content,p,center=TRUE,border=1 + ,table.style='border-collapse: collapse; padding: 0; margin: 0' ,row.names=FALSE,row.bgcolor='#ffaaaa') - links(p) + links(p) + } else { + hwrite("None",p,center=TRUE) + } closePage(p) } -- 2.39.2