add adopt to completions
[disorder] / scripts / setversion
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
8 use strict;
9 use POSIX qw(strftime uname);
10
11 my $version = shift;
12
13 my $hostname = (uname)[1];
14 $hostname = (gethostbyname($hostname))[0];
15 my $logname = (getpwuid($<))[0];
16 my $name = (getpwuid($<))[6];
17 $name =~ s/,.*//;
18 my $email = "$logname\@$hostname";
19 my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime);
20
21 sub 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
29 sub 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
41 my @c = input("configure.ac");
42 foreach(@c) {
43 if(/^AC_INIT|AM_INIT/) {
44 s/\[[0-9\.\+]+\]/[$version]/g;
45 }
46 }
47 output("configure.ac", \@c);
48
49 @c = input("debian/changelog");
50 unshift(@c,
51 "disorder ($version) unstable; urgency=low\n",
52 "\n",
53 " * Disorder $version\n",
54 "\n",
55 " -- $name <$email> $date\n",
56 "\n");
57 output("debian/changelog", \@c);