From edd at debian.org  Fri Jan  6 23:59:17 2012
From: edd at debian.org (Dirk Eddelbuettel)
Date: Fri, 6 Jan 2012 16:59:17 -0600
Subject: [Rd] pointers on including SVN revision number in package info?
In-Reply-To: <4F076B86.2010008@gmail.com>
References: <4F075895.3030509@gmail.com>
	<4F076B86.2010008@gmail.com>
Message-ID: <20231.31941.488263.523839@max.nulle.part>


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 /
build.

| 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.

Dirk

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}'`

    now=`date`

    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__;

EOF
	fi
    fi
}

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
	    call_svnversion 
	fi
	exit
    fi
fi

test -f svnversion.h || call_svnversion
aclocal 
autoheader 
automake 
autoconf 
./configure 
make


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



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