diff options
author | dormando <dormando@rydia.net> | 2009-11-02 01:30:28 -0800 |
---|---|---|
committer | Dustin Sallings <dustin@spy.net> | 2009-11-02 02:42:55 -0800 |
commit | 2906fae0f13c79d696bc01a2c3de0854798fd9d6 (patch) | |
tree | e945ecc11308c139c44ed8f7e97de551dff5bdfa /version.pl | |
parent | f966dbad8c56d4fcfd6cbb51da5db91c6a22e91f (diff) | |
download | memcached-2906fae0f13c79d696bc01a2c3de0854798fd9d6.tar.gz |
Make autoversioning/spec gen work better.
issue #98 is about how our specfiles for rc's aren't upgradeable.
Now they should be.
Diffstat (limited to 'version.pl')
-rwxr-xr-x | version.pl | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/version.pl b/version.pl new file mode 100755 index 0000000..6f08faf --- /dev/null +++ b/version.pl @@ -0,0 +1,59 @@ +#!/usr/bin/perl +# If you think this is stupid/overkill, blame dormando + +use warnings; +use strict; + +my $version = `git describe`; +chomp $version; +# Test the various versions. +#my $version = 'foob'; +#my $version = '1.4.2-30-gf966dba'; +#my $version = '1.4.3-rc1'; +#my $version = '1.4.3'; +unless ($version =~ m/^\d+\.\d+\.\d+/) { + write_file('version.m4', "m4_define([VERSION_NUMBER], [UNKNOWN])\n"); + exit; +} + +$version =~ s/-/_/g; +write_file('version.m4', "m4_define([VERSION_NUMBER], [$version])\n"); +my ($VERSION, $FULLVERSION, $RELEASE); + +if ($version =~ m/^(\d+\.\d+\.\d+)_rc(\d+)$/) { + $VERSION = $1; + $FULLVERSION = $version; + $RELEASE = '0.1.rc' . $2; +} elsif ($version =~ m/^(\d+\.\d+\.\d+)_(.+)$/) { + $VERSION = $1; + $FULLVERSION = $version; + $RELEASE = '1.' . $2; +} elsif ($version =~ m/^(\d+\.\d+\.\d+)$/) { + $VERSION = $1; + $FULLVERSION = $version; + $RELEASE = '1'; +} + +my $spec = read_file('memcached.spec.in'); +$spec =~ s/\@VERSION\@/$VERSION/gm; +$spec =~ s/\@FULLVERSION\@/$FULLVERSION/gm; +$spec =~ s/\@RELEASE\@/$RELEASE/gm; + +write_file('memcached.spec', $spec); + +sub write_file { + my $file = shift; + my $data = shift; + open(my $fh, "> $file") or die "Can't open $file: $!"; + print $fh $data; + close($fh); +} + +sub read_file { + my $file = shift; + local $/ = undef; + open(my $fh, "< $file") or die "Can't open $file: $!"; + my $data = <$fh>; + close($fh); + return $data; +} |