Skip to content

Commit

Permalink
Make autoversioning/spec gen work better.
Browse files Browse the repository at this point in the history
issue memcached#98 is about how our specfiles for rc's aren't upgradeable.
Now they should be.
  • Loading branch information
dormando authored and dustin committed Nov 2, 2009
1 parent f966dba commit 2906fae
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# #


# Get the initial version. # Get the initial version.
sh version.sh perl version.pl


echo "aclocal..." echo "aclocal..."
ACLOCAL=`which aclocal-1.10 || which aclocal-1.9 || which aclocal19 || which aclocal-1.7 || which aclocal17 || which aclocal-1.5 || which aclocal15 || which aclocal || exit 1` ACLOCAL=`which aclocal-1.10 || which aclocal-1.9 || which aclocal19 || which aclocal-1.7 || which aclocal17 || which aclocal-1.5 || which aclocal15 || which aclocal || exit 1`
Expand Down
11 changes: 7 additions & 4 deletions memcached.spec.in
Original file line number Original file line Diff line number Diff line change
@@ -1,12 +1,12 @@
Name: memcached Name: memcached
Version: @VERSION@ Version: @VERSION@
Release: 1%{?dist} Release: @RELEASE@%{?dist}
Summary: High Performance, Distributed Memory Object Cache Summary: High Performance, Distributed Memory Object Cache


Group: System Environment/Daemons Group: System Environment/Daemons
License: BSD License: BSD
URL: http://www.danga.com/memcached/ URL: http://www.danga.com/memcached/
Source0: http://www.danga.com/memcached/dist/%{name}-%{version}.tar.gz Source0: http://memcached.googlecode.com/files/%{name}-@FULLVERSION@.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)


BuildRequires: libevent-devel BuildRequires: libevent-devel
Expand All @@ -23,11 +23,11 @@ system, generic in nature, but intended for use in speeding up dynamic
web applications by alleviating database load. web applications by alleviating database load.


%prep %prep
%setup -q %setup -q -n %{name}-@FULLVERSION@




%build %build
%configure --enable-threads %configure


make %{?_smp_mflags} make %{?_smp_mflags}


Expand Down Expand Up @@ -94,6 +94,9 @@ exit 0
%{_includedir}/memcached %{_includedir}/memcached


%changelog %changelog
* Mon Nov 2 2009 Dormando <dormando@rydia.net> - 1.4.3-1
- Fix autogen more.

* Sat Aug 29 2009 Dustin Sallings <dustin@spy.net> - 1.4.1-1 * Sat Aug 29 2009 Dustin Sallings <dustin@spy.net> - 1.4.1-1
- Autogenerate the version number from tags. - Autogenerate the version number from tags.


Expand Down
59 changes: 59 additions & 0 deletions version.pl
Original file line number Original file line Diff line number Diff line change
@@ -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;
}

0 comments on commit 2906fae

Please sign in to comment.