Commit | Line | Data |
---|---|---|
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 | ||
8 | use strict; | |
9 | use POSIX qw(strftime uname); | |
10 | ||
11 | my $version = shift; | |
fef972ab RK |
12 | my $description; |
13 | my $distribution; | |
14 | if(@ARGV > 0) { | |
15 | $description = shift; | |
16 | } else { | |
17 | $description = "DisOrder $version"; | |
18 | } | |
19 | if(@ARGV > 0) { | |
20 | $distribution = shift; | |
21 | } else { | |
22 | $distribution = "unstable"; | |
23 | } | |
608fae37 RK |
24 | |
25 | my $hostname = (uname)[1]; | |
26 | $hostname = (gethostbyname($hostname))[0]; | |
27 | my $logname = (getpwuid($<))[0]; | |
28 | my $name = (getpwuid($<))[6]; | |
29 | $name =~ s/,.*//; | |
30 | my $email = "$logname\@$hostname"; | |
fef972ab RK |
31 | if(exists $ENV{"EMAIL"}) { |
32 | $email = $ENV{"EMAIL"}; | |
33 | } | |
608fae37 RK |
34 | my $date = strftime("%a, %d %b %Y %H:%M:%S %z", localtime); |
35 | ||
36 | sub 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 | ||
44 | sub 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 | ||
56 | my @c = input("configure.ac"); | |
57 | foreach(@c) { | |
58 | if(/^AC_INIT|AM_INIT/) { | |
59 | s/\[[0-9\.\+]+\]/[$version]/g; | |
60 | } | |
61 | } | |
62 | output("configure.ac", \@c); | |
63 | ||
64 | @c = input("debian/changelog"); | |
65 | unshift(@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"); | |
72 | output("debian/changelog", \@c); |