chiark / gitweb /
setversion script for test builds
authorRichard Kettlewell <rjk@greenend.org.uk>
Sat, 6 Dec 2008 22:44:43 +0000 (22:44 +0000)
committerRichard Kettlewell <rjk@greenend.org.uk>
Sat, 6 Dec 2008 22:44:43 +0000 (22:44 +0000)
scripts/setversion [new file with mode: 0755]

diff --git a/scripts/setversion b/scripts/setversion
new file mode 100755 (executable)
index 0000000..142f7da
--- /dev/null
@@ -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 = <C>;
+    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);