From 608fae373c92dd73cb8f5c13d1ed9cd211e11cfc Mon Sep 17 00:00:00 2001 Message-Id: <608fae373c92dd73cb8f5c13d1ed9cd211e11cfc.1717564140.git.mdw@distorted.org.uk> From: Mark Wooding Date: Sat, 6 Dec 2008 22:44:43 +0000 Subject: [PATCH] setversion script for test builds Organization: Straylight/Edgeware From: Richard Kettlewell --- scripts/setversion | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 scripts/setversion diff --git a/scripts/setversion b/scripts/setversion new file mode 100755 index 0000000..142f7da --- /dev/null +++ b/scripts/setversion @@ -0,0 +1,57 @@ +#! /usr/bin/perl -w +# +# scripts/setversion VERSION +# +# Sets a new version number, including a debian/changelog entry (albeit +# a rather terse and informal one). + +use strict; +use POSIX qw(strftime uname); + +my $version = shift; + +my $hostname = (uname)[1]; +$hostname = (gethostbyname($hostname))[0]; +my $logname = (getpwuid($<))[0]; +my $name = (getpwuid($<))[6]; +$name =~ s/,.*//; +my $email = "$logname\@$hostname"; +my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime); + +sub input { + my $path = shift; + open(C, "<$path") or die "$path: $!\n"; + my @f = ; + close C; + return @f; +} + +sub output { + my $path = shift; + my $contents = shift; + my $new = "$path.new"; + (open(O, ">$new") + and (print O @$contents) + and (close O)) + or die "$new: $!\n"; + (rename $new, $path) + or die "$new -> $path: $!\n"; +} + +my @c = input("configure.ac"); +foreach(@c) { + if(/^AC_INIT|AM_INIT/) { + s/\[[0-9\.\+]+\]/[$version]/g; + } +} +output("configure.ac", \@c); + +@c = input("debian/changelog"); +unshift(@c, + "disorder ($version) unstable; urgency=low\n", + "\n", + " * Disorder $version\n", + "\n", + " -- $name <$email> $date\n", + "\n"); +output("debian/changelog", \@c); -- [mdw]