Imported Robodoc.
[robodoc.git] / bump.pl
1 #!/usr/bin/perl -w
2
3 # $Id: bump.pl,v 1.44 2007/07/10 19:13:51 gumpu Exp $
4 #
5 #
6 use strict;
7 use IO::Dir;
8 use IO::File;
9
10 my $month    = "Jul";
11 my $major    = 4;
12 my $minor    = 99;
13 my $revision = 36;
14 my $release  = 1;
15
16 sub readme {
17     my $file  = shift;
18     my $lines = shift;
19     my $done  = 0;
20     foreach my $line (@{$lines}) {
21         if ($line =~ m/^ROBODoc\sVersion/) {
22             print $line;
23             $line =~ s/\d+\.\d+\.\d+\s\S+\s2/$major.$minor.$revision $month 2/;
24             print $line;
25             print $file $line;
26             ++$done;
27         } else {
28             print $file $line;
29         }
30     }
31     die if ($done != 1);
32 }
33
34 sub robodoc_h {
35     my $file  = shift;
36     my $lines = shift;
37     my $done  = 0;
38     foreach my $line (@{$lines}) {
39         if ($line =~ m/define\sVERSION\s"/) {
40             ++$done;
41             $line = "#define VERSION \"$major.$minor.$revision\"\n";
42             print $line;
43             print $file $line;
44         } else {
45             print $file $line;
46         }
47     }
48     die if ($done != 1);
49 }
50
51 sub configure_in {
52     my $file  = shift;
53     my $lines = shift;
54     my $done  = 0;
55     foreach my $line (@{$lines}) {
56         if ($line =~ m/AM_INIT_AUTOMAKE/) {
57             ++$done;
58             $line = "AM_INIT_AUTOMAKE(robodoc, $major.$minor.$revision)\n";
59             print $line;
60             print $file $line;
61         } elsif ($line =~ m/AC_INIT/) {
62             ++$done;
63             $line = "AC_INIT(robodoc, $major.$minor.$revision)\n";
64             print $line;
65             print $file $line;
66         } else {
67             print $file $line;
68         }
69     }
70     die if ($done != 2);
71 }
72
73
74 sub robodoc_1 {
75     my $file  = shift;
76     my $lines = shift;
77     my $done  = 0;
78     foreach my $line (@{$lines}) {
79         if ($line =~ m/TH\sROBODoc/) {
80             print $line;
81             $line =~ s/ROBODoc\s\d+\.\d+\.\d+/ROBODoc $major.$minor.$revision/;
82             $line =~ s/"\S+\s2/"$month 2/;
83             print $line;
84             print $file $line;
85             ++$done;
86         } else {
87             print $file $line;
88         }
89     }
90     die if ($done != 1);
91 }
92
93
94 sub manual {
95     my $file  = shift;
96     my $lines = shift;
97     my $done  = 0;
98     foreach my $line (@{$lines}) {
99         if ($line =~ m/title>ROBODoc\s\d/) {
100             print $line;
101             $line =~ s/title>ROBODoc\s\d+\.\d+\.\d+/title>ROBODoc $major.$minor.$revision/;
102             print $line;
103             print $file $line;
104             ++$done;
105         } else {
106             print $file $line;
107         }
108     }
109     die if ($done != 1);
110 }
111
112 sub rpm_mk {
113     my $file  = shift;
114     my $lines = shift;
115     my $done  = 0;
116
117     foreach my $line (@{$lines}) {
118         if ($line =~ /^PROJECT\_VERSION/) {
119             print $line;
120             $line =~ s/\d+\.\d+\.\d+/$major.$minor.$revision/;
121             print $line;
122             print $file $line;
123             ++$done;
124         } elsif ($line =~ /^PROJECT\_RELEASE/) {
125             print $line;
126             $line =~ s/\d/$release/;
127             print $line;
128             print $file $line;
129         } else {
130             print $file $line;
131         }
132     }
133     die if ($done != 1);
134 }
135
136 sub makefile_plain {
137     my $file  = shift;
138     my $lines = shift;
139     my $done  = 0;
140
141     foreach my $line (@{$lines}) {
142         if ($line =~ /^VERS/) {
143             print $line;
144             $line =~ s/\d+\.\d+\.\d+/$major.$minor.$revision/;
145             print $line;
146             print $file $line;
147             ++$done;
148         } elsif ($line =~ /^RELEASE/) {
149             print $line;
150             $line =~ s/\d/$release/;
151             print $line;
152             print $file $line;
153         } else {
154             print $file $line;
155         }
156     }
157     die if ($done != 1);
158 }
159
160 my %updaters = ();
161
162 $updaters{"Docs/manual.xml"}   = \&manual;
163 $updaters{"Docs/robodoc.1"}    = \&robodoc_1;
164 $updaters{"Source/robodoc.h"}  = \&robodoc_h;
165 $updaters{"README"}            = \&readme;
166 $updaters{"configure.in"}      = \&configure_in;
167 $updaters{"rpm.mk"}            = \&rpm_mk;
168 $updaters{"Source/makefile.plain"} = \&makefile_plain;
169
170 foreach my $filename ( keys %updaters ) {
171     print $filename, "\n";
172     my $file = IO::File->new("<$filename") or die $filename;
173     my @lines = <$file>;
174     $file->close();
175     $file = IO::File->new(">$filename.bup") or die $filename;
176     $updaters{$filename}( $file, \@lines );
177     $file->close();
178     rename "$filename.bup", $filename;
179 }
180
181 __DATA__
182 Copyright (C) 1994-2007  Frans Slothouber, Jacco van Weert, Petteri Kettunen,
183 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
184 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
185
186 This file is part of ROBODoc
187
188 ROBODoc is free software; you can redistribute it and/or modify
189 it under the terms of the GNU General Public License as published by
190 the Free Software Foundation; either version 3 of the License, or
191 (at your option) any later version.
192
193 This program is distributed in the hope that it will be useful,
194 but WITHOUT ANY WARRANTY; without even the implied warranty of
195 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
196 GNU General Public License for more details.
197
198 You should have received a copy of the GNU General Public License
199 along with this program.  If not, see <http://www.gnu.org/licenses/>.
200