Automagic revision numbers with Perl Modules and SVN

Matthew Seaman m.seaman at infracaninophile.co.uk
Thu Jun 11 06:01:12 UTC 2009


Steve Bertrand wrote:

> Any guidance to fix the version numbering (especially to fix the FreeBSD
> package db) to make it automagic again, is very welcome:
> 
> 
> %svn diff -r56 EagleUser.pm
> Index: EagleUser.pm
> ===================================================================
> --- EagleUser.pm        (revision 56)
> +++ EagleUser.pm        (working copy)
> @@ -13,7 +13,7 @@
>  @EXPORT = qw(
> 
>  );
> -$VERSION = sprintf "%d.%03d", q$Revision: 1.9 $ =~ /: (\d+)\.(\d+)/;

^^^^ This takes a version number like 1.9 (ie. a string of digits containing
one decimal point) and converts it to 1.009

> +$VERSION = (q$Revision: 1.9 $ =~ /: (\d+)\.(\d+)/;

^^^^ whereas this just extracts the number from the revision string and
uses it as is -- ie. 1.9

I believe that svn will update $Revision$ keywords in source files (or it
has some similar function which only differs in the details), but I could be
wrong, and it is entirely possible that the revision numbers will behave
differently -- svn keeping a repository wide version and cvs keeping a version
per file.  Consult the svn documentation on how to embed the version number
into the file -- once that is working, producing a perl one-liner to initialise
$VERSION will be pretty easy.

Assuming this is from a standard module using Module::Build or
ExtUtils::MakeMaker you should check the Makefile.PL at the top
level.  In there if you're using Module::Build it should say something like:

  version_from   lib/EagleUser.pm

(although the path may differ).  This extracts the value of $VERSION 
from the named .pm file and uses it as the overall module version. Assuming
your second line, you'll end up with a package name like bsdpan-EagelUser-1.9
(ExtUtils::MakeMaker works similarly).  If you're desperate, you can
override the setting by patching the Makefile but that doesn't help at all
in your aim of having the version number update dynamically.

The convention about padding version strings with leading zeros seems
to have come and gone in the perl world.  I'm not at all sure what the
current recognised best practice is.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                  Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090611/c12d12a5/signature.pgp


More information about the freebsd-questions mailing list