]> git.koha-community.org Git - koha.git/blob - buildrelease
Fixed hard coded directories in z3950 shell scripts, and moved z3950 scripts to
[koha.git] / buildrelease
1 #!/usr/bin/perl
2
3 my $kohadir=`pwd`;
4 chomp $kohadir;
5 my $kohahtmldir="/koha/koha/koha-html/";
6
7 if (-e "/root/.kohaautobuild.conf") {
8     open C, "/root/.kohaautobuild.conf";
9     while (<C>) {
10         chomp;
11         if (/kohadir=(.*)/) {
12             $kohadir=$1;
13         }
14         if (/kohahtmldir=(.*)/) {
15             $kohahtmldir=$1;
16         }
17     }
18 }
19
20 my $input;
21
22 print qq |
23 ***************************************
24 * Welcome to the Koha Release Builder *
25 ***************************************
26
27 This script will automatically build a release tarball.
28
29 The script assumes that you already have the koha and koha-html modules checked
30 out for the release that you want to build, although it will update the modules
31 before building.
32
33 |;
34 print "\nWhere is the 'koha' cvs module located [$kohadir]: ";
35 chomp($input = <STDIN>);
36 if ($input) {
37     $kohadir=$input;
38 }
39
40
41 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
42 chomp($input = <STDIN>);
43 if ($input) {
44     $kohahtmldir=$input;
45 }
46
47 open (C, ">/root/.kohaautobuild.conf");
48 print C qq|
49 kohadir=$kohadir
50 kohahtmldir=$kohahtmldir
51 |;
52
53 print "\n\nGuessing at next release version.  You may need to enter your SourceForge password...\n";
54 chdir $kohadir;
55 open (CVSLOG, "cvs log buildrelease|");
56 my $symbolicnamessection=0;
57 my $symbolicnames;
58 my $highestversion;
59 my $highestrc;
60 my $released;
61 while (<CVSLOG>) {
62     if (/^symbolic names:/) {
63         $symbolicnamessection=1;
64     }
65     if ($symbolicnamessection && (/^\s+([^:]*):/)) {
66         my $tag=$1;
67         if ($tag=~/R_(.*)/) {
68             my $version='';
69             my $rc=0;
70             my $id=$1;
71             $id=~s/-/\./g;
72             if ($id =~/(.*)RC(.*)/) {
73                 $version=$1;
74                 $rc=$2;
75                 if (versioncompare($version, $highestversion)) {
76                     $highestversion=$version;
77                     $released=0;
78                     $highestrc=$rc;
79                 }
80             } else {
81                 $version=$id;
82                 if (versioncompare($version, $highestversion)) {
83                     $highestversion=$version;
84                     $released=1;
85                     $highestrc=0;
86                 }
87             }
88             $symbolicnames->{$version}->{$rc}=1;
89         }
90     }
91 }
92
93
94 my $releaseversion='';
95 my $currentversion='';
96
97 if ($released) {
98     $releaseversion=($highestversion+1)."RC1";
99     $currentversion=$highestversion;
100 } else {
101     $releaseversion="$highestversion\RC".($highestrc+1);
102     $currentversion="$highestversion\RC$highestrc";
103 }
104
105 print "Current release tag is $currentversion.\n";
106 print "\nWould you like to bump that up to $releaseversion?  [Y]/N: ";
107 chomp($input = <STDIN>);
108 if ($input =~ /^n/i) {
109     print "\nWould you like to rebuild the $currentversion tarball?  Y/[N]: ";
110     chomp($input = <STDIN>);
111     if ($input =~ /^y/i) {
112         $releaseversion=$currentversion;
113         print "\n\n";
114         print "Do not do this if you have released the tarball to anybody, as it will\n";
115         print "overwrite the tag marking the files that were in the tarball.\n\n";
116         print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
117         chomp($input = <STDIN>);
118         if ($input =~ /^n/i || $input eq '') {
119             print "\nStopping.  Please re-run buildrelease now.\n";
120             exit;
121         }
122     } else {
123         print "What should the new version be? [$releaseversion]: ";
124         chomp ($input=<STDIN>);
125         if ($input) {
126             $releaseversion=$input;
127         }
128     }
129 }
130
131
132 my $sfuserid='';
133 if ($cvsroot=$ENV{'CVSROOT'}) {
134     $cvsroot=~m#(.*)\@cvs#;
135     $sfuserid=$1;
136 } else {
137     $ENV{'CVS_RSH'}='ssh';
138     print "\nWhat is your userid at SourceForge: ";
139     chomp($input = <STDIN>);
140     if ($input) {
141         $sfuserid=$input;
142     }
143     $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
144 }
145 my $tagname=$releaseversion;
146 $tagname=~s/\./-/g;
147
148 print qq|
149 Updating the 'koha' CVS files.  You may need to enter your SourceForge password.
150 Using $kohadir.
151 |;
152 chdir($kohadir);
153 system("cvs update");
154 print qq|
155 Tagging koha with tag R_$tagname
156 |;
157 system("cvs tag -F R_$tagname");
158 print qq|
159 Updating the 'koha-html' CVS files.  You may need to enter your SourceForge password.
160 Using $kohahtmldir.
161 |;
162 chdir($kohahtmldir);
163 system("cvs update");
164 print qq|
165 Tagging koha-html with tag R_$tagname
166 |;
167 system("cvs tag -F R_$tagname");
168
169
170
171
172 my $rootdir="/tmp/koha-".$releaseversion;
173 system("rm -rf $rootdir");
174 mkdir ($rootdir, 0700);
175 chdir($rootdir);
176
177 mkdir("intranet-cgi", 0755);
178 mkdir("intranet-html", 0755);
179 mkdir("opac-cgi", 0755);
180 mkdir("opac-html", 0755);
181 mkdir("scripts", 0755);
182 mkdir("modules", 0755);
183 mkdir("docs", 0755);
184
185 # Copy all CVS files to intranet-cgi
186 system("cp -a $kohadir/* $rootdir/intranet-cgi");
187
188 # Move C4 to modules directory
189 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
190
191 # Move files from intranet-cgi to root of tarball
192 system("mv $rootdir/intranet-cgi/INSTALL $rootdir");
193 system("mv $rootdir/intranet-cgi/ChangeLog $rootdir");
194 system("mv $rootdir/intranet-cgi/Hints $rootdir");
195 system("mv $rootdir/intranet-cgi/LICENSE $rootdir");
196 system("mv $rootdir/intranet-cgi/News $rootdir");
197 system("mv $rootdir/intranet-cgi/README $rootdir");
198 system("mv $rootdir/intranet-cgi/TODO $rootdir");
199 system("mv $rootdir/intranet-cgi/databaseinstall.sh $rootdir");
200 system("mv $rootdir/intranet-cgi/installer.pl $rootdir"); 
201 system("mv $rootdir/intranet-cgi/koha.conf $rootdir");
202 system("mv $rootdir/intranet-cgi/koha.mysql $rootdir");
203 system("mv $rootdir/intranet-cgi/sampledata-1.2 $rootdir");
204 system("gzip -9 $rootdir/sampledata-1.2");
205
206 # Copy files from intranet-cgi to opac-cgi
207 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
208 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
209 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
210
211
212 # Move files from intranet-cgi to /scripts/ directory
213 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
214 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
215 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
216 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
217 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
218 system("mv $rootdir/intranet-cgi/acqui.simple/processz3950queue $rootdir/scripts");
219 system("mv $rootdir/intranet-cgi/acqui.simple/z3950-daemon-launch.sh $rootdir/scripts");
220 system("mv $rootdir/intranet-cgi/acqui.simple/z3950-daemon-shell.sh $rootdir/scripts");
221
222
223 # Remove extraneous files from intranet-cgi
224 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
225 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
226 system("rm -f $rootdir/intranet-cgi/SendMessages");
227 system("rm -f $rootdir/intranet-cgi/buildrelease");
228 system("rm -f $rootdir/intranet-cgi/database.mysql");
229 system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
230 system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
231 system("rm -f $rootdir/intranet-cgi/rel-1-2");
232 system("rm -f $rootdir/intranet-cgi/testKoha.pl");
233 system("rm -rf $rootdir/intranet-cgi/html-template");
234 system("rm -rf $rootdir/intranet-cgi/t");
235
236 # Copy all CVS files to intranet-html and opac-html
237 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
238 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
239
240 # Remove extraneous files from opac-html
241 system("rm -f $rootdir/opac-html/koha.mo");
242 system("rm -f $rootdir/opac-html/koha.pot");
243 system("rm -f $rootdir/opac-html/test");
244
245 # Remove extraneous files from intranet-html
246 system("rm -f $rootdir/intranet-html/koha.pot");
247 system("rm -f $rootdir/intranet-html/results.html");
248 system("rm -f $rootdir/intranet-html/test");
249
250 # Remove junk from directory
251 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
252 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
253 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
254
255
256 chdir("/tmp");
257 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
258 system("rm -rf $rootdir");
259
260 print qq|
261 ============
262 = ALL DONE =
263 ============
264
265 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
266
267 |;
268
269
270 sub versioncompare {
271     my $v1=shift;
272     my $v2=shift;
273     my @v1=split(/\./, $v1);
274     my @v2=split(/\./, $v2);
275     my $count=$#v1;
276     ($#v2>$count) && ($count=$#v2);
277     for (my $index=0; $index<$count; $index++) {
278         if ($v1[$index]>$v2[$index]) {
279             return 1;
280         }
281     }
282     return 0;
283 }