[Rd] pointers on including SVN revision number in package info?

Dirk Eddelbuettel edd at debian.org
Fri Jan 6 23:59:17 CET 2012

On 6 January 2012 at 16:45, Duncan Murdoch wrote:
| I'd like one that produced an R version number directly, but I think 
| Dirk's script is the only way to do it, and I forget how to use such 
| scripts five minutes after I write them.

And I of course forgot to include the little script once written for
littler; now below.

For Rcpp and RInside, I wrote little ad-hoc release helper scripts to also
run doxygen, copy vignettes and tarballs to webfolders etc pp. If you do
that, you have a hook -- but then you'd have to run this once pre-commit /

| R-forge sometimes gets out of sync in what it displays as the revision, 
| the Version, and what it actually offers as the "Package source" (let 
| alone binaries), so I find putting the revision into the version number 
| very helpful.  But I often forget to do it...

Scripts can help. Somewhat.


PS The ad-hoc script 'bootstrap' from littler is below.  

#!/bin/bash -e

call_svnversion() {
    svnrevision=`LC_ALL=C svn info | awk '/^Revision:/ {print $2}'`
    svndate=`LC_ALL=C svn info | awk '/^Last Changed Date:/ {print $4,$5}'`


    if [ "$svnrevision" != "" ]; then
	if [ "$svndate" != "" ]; then
	    cat <<EOF > svnversion.h

// Do not edit!  This file was autogenerated 
//      by $0 
//      on $now
// svnrevision and svndate are as reported by svn at that point in time,
// compiledate and compiletime are being filled gcc at compilation

#include <stdlib.h>
static const char* svnrevision = "$svnrevision";
static const char* svndate = "$svndate";
static const char* compiletime = __TIME__;
static const char* compiledate = __DATE__;


if [ "$#" -ge 0 ]; then
    if [ "$1" = "--svnversion" ]; then
        # added hoops: make sure we only call this when we have a 
	# svn binary in the path ... so that this does not get called
	# on machines that do not have svn
	set +e
	svnprog=`type -p svn`
	set -e
	if [ "${svnprog}" != "" ]; then

test -f svnversion.h || call_svnversion

"Outside of a dog, a book is a man's best friend. Inside of a dog, it is too
dark to read." -- Groucho Marx

More information about the R-devel mailing list