chiark / gitweb /
add adopt to completions
[disorder] / scripts / setversion
CommitLineData
608fae37
RK
1#! /usr/bin/perl -w
2#
3# scripts/setversion VERSION
4#
5# Sets a new version number, including a debian/changelog entry (albeit
6# a rather terse and informal one).
7
8use strict;
9use POSIX qw(strftime uname);
10
11my $version = shift;
12
13my $hostname = (uname)[1];
14$hostname = (gethostbyname($hostname))[0];
15my $logname = (getpwuid($<))[0];
16my $name = (getpwuid($<))[6];
17$name =~ s/,.*//;
18my $email = "$logname\@$hostname";
19my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime);
20
21sub input {
22 my $path = shift;
23 open(C, "<$path") or die "$path: $!\n";
24 my @f = <C>;
25 close C;
26 return @f;
27}
28
29sub output {
30 my $path = shift;
31 my $contents = shift;
32 my $new = "$path.new";
33 (open(O, ">$new")
34 and (print O @$contents)
35 and (close O))
36 or die "$new: $!\n";
37 (rename $new, $path)
38 or die "$new -> $path: $!\n";
39}
40
41my @c = input("configure.ac");
42foreach(@c) {
43 if(/^AC_INIT|AM_INIT/) {
44 s/\[[0-9\.\+]+\]/[$version]/g;
45 }
46}
47output("configure.ac", \@c);
48
49@c = input("debian/changelog");
50unshift(@c,
51 "disorder ($version) unstable; urgency=low\n",
52 "\n",
53 " * Disorder $version\n",
54 "\n",
55 " -- $name <$email> $date\n",
56 "\n");
57output("debian/changelog", \@c);