chiark / gitweb /
Fix edge cases in dropzone selection code and make it consistent
[disorder] / scripts / setversion
CommitLineData
608fae37
RK
1#! /usr/bin/perl -w
2#
fef972ab 3# scripts/setversion VERSION [DESCRIPTION [DISTRIBUTION]]
608fae37
RK
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;
fef972ab
RK
12my $description;
13my $distribution;
14if(@ARGV > 0) {
15 $description = shift;
16} else {
17 $description = "DisOrder $version";
18}
19if(@ARGV > 0) {
20 $distribution = shift;
21} else {
22 $distribution = "unstable";
23}
608fae37
RK
24
25my $hostname = (uname)[1];
26$hostname = (gethostbyname($hostname))[0];
27my $logname = (getpwuid($<))[0];
28my $name = (getpwuid($<))[6];
29$name =~ s/,.*//;
30my $email = "$logname\@$hostname";
fef972ab
RK
31if(exists $ENV{"EMAIL"}) {
32 $email = $ENV{"EMAIL"};
33}
608fae37
RK
34my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime);
35
36sub input {
37 my $path = shift;
38 open(C, "<$path") or die "$path: $!\n";
39 my @f = <C>;
40 close C;
41 return @f;
42}
43
44sub output {
45 my $path = shift;
46 my $contents = shift;
47 my $new = "$path.new";
48 (open(O, ">$new")
49 and (print O @$contents)
50 and (close O))
51 or die "$new: $!\n";
52 (rename $new, $path)
53 or die "$new -> $path: $!\n";
54}
55
56my @c = input("configure.ac");
57foreach(@c) {
58 if(/^AC_INIT|AM_INIT/) {
59 s/\[[0-9\.\+]+\]/[$version]/g;
60 }
61}
62output("configure.ac", \@c);
63
64@c = input("debian/changelog");
65unshift(@c,
fef972ab 66 "disorder ($version) $distribution; urgency=low\n",
608fae37 67 "\n",
fef972ab 68 " * $description\n",
608fae37
RK
69 "\n",
70 " -- $name <$email> $date\n",
71 "\n");
72output("debian/changelog", \@c);