3 sub guess_kohahtmldir ($;$);
4 #----------------------------------------------------------
5 # DIRECTORIES where source code is located
6 #----------------------------------------------------------
9 my $kohahtmldir=guess_kohahtmldir($kohadir, "/koha/koha/koha-html/");
10 my $kohatmpldir=guess_kohatmpldir($kohadir, "/koha/koha/koha-tmpl/");
11 my $roothomedir=(getpwuid(0))[7]; # ~root is traditionally just /
12 $roothomedir='/root' unless defined $roothomedir;
14 my $has_kohaautobuild_conf = 0;
16 if (-e "$roothomedir/.kohaautobuild.conf") {
17 open C, "<$roothomedir/.kohaautobuild.conf";
23 if (/kohahtmldir=(.*)/) {
26 if (/kohatmpldir=(.*)/) {
30 $has_kohaautobuild_conf = 1;
36 ***************************************
37 * Welcome to the Koha Release Builder *
38 ***************************************
40 This script will automatically build a release tarball.
42 The script assumes that you already have the koha and koha-html modules checked
43 out for the release that you want to build, although it will update the modules
47 print "\nWhere is the 'koha' cvs module located [$kohadir]: ";
48 chomp($input = <STDIN>);
51 unless ($has_kohaautobuild_conf) {
52 $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir);
53 $kohatmpldir=guess_kohatmpldir($kohadir, $kohatmpldir);
58 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
59 chomp($input = <STDIN>);
64 print "\nWhere is the 'koha-tmpl' cvs module located [$kohatmpldir]: ";
65 chomp($input = <STDIN>);
70 open (C, ">$roothomedir/.kohaautobuild.conf");
73 kohahtmldir=$kohahtmldir
74 kohatmpldir=$kohatmpldir
77 #----------------------------------------------------------
78 # which VERSION are we building ?
79 #----------------------------------------------------------
80 print "\n\nGuessing at next release version. You may need to enter your SourceForge password...\n";
81 open (CVSLOG, "cvs log misc/buildrelease|");
82 my $symbolicnamessection=0;
90 if (/^symbolic names:/) {
91 $symbolicnamessection=1;
93 if ($symbolicnamessection && (/^\s+([^:]*):/)) {
100 if ($id =~/(.*)RC(.*)/) {
103 $version=~m#(\d+\.\d+)\.#;
104 if (versioncompare($version, $majorversion->{$1})) {
105 $majorversion->{$1}=$version;
106 $majorversionrc->{$1}=$rc;
108 if (versioncompare($version, $highestversion)) {
109 $highestversion=$version;
115 $version=~m#(\d+\.\d+)\.#;
116 if (versioncompare($version, $majorversion->{$1})) {
117 $majorversion->{$1}=$version;
118 $majorversionrc->{$1}=0;
120 if (versioncompare($version, $highestversion)) {
121 $highestversion=$version;
126 $symbolicnames->{$version}->{$rc}=1;
132 my $releaseversion='';
133 my $currentversion='';
135 my $branchdata=`grep buildrelease CVS/Entries`;
137 my $branch=(split(m#/#, $branchdata))[5];
139 if ($branch eq 'Trel-1-2') {
140 $highestversion=$majorversion->{'1.2'};
141 $highestrc=$majorversionrc->{'1.2'};
142 ($highestrc) ? ($released=0) : ($released=1);
146 my @components=split(/\./, $highestversion);
147 $components[$#components]++;
148 $nexthighestversion=join '.', @components;
149 my $minornumber=(split(/\./, $highestversion))[1];
150 if ($minornumber/2 == int($minornumber/2)) {
151 $releaseversion=$nexthighestversion."RC1";
153 $releaseversion=$nexthighestversion;
155 $currentversion=$highestversion;
157 $releaseversion=$highestversion."RC".($highestrc+1);
158 $currentversion=$highestversion."RC$highestrc";
162 print "Current release tag is $currentversion.\n";
163 print "\nWould you like to bump that up to $releaseversion (or manually enter version)? [Y]/N: ";
164 chomp($input = <STDIN>);
165 my $tagging_needs_confirmation = 0;
166 if ($input =~ /^n/i) {
167 print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: ";
168 chomp($input = <STDIN>);
169 print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
170 if ($input =~ /^y/i) {
171 $releaseversion=$currentversion;
172 $tagging_needs_confirmation = 1;
174 print "What should the new version be? [$releaseversion]: ";
175 chomp ($input=<STDIN>);
177 $releaseversion=$input;
181 print "What should the new version be? [$releaseversion]: ";
182 chomp ($input=<STDIN>);
184 $releaseversion=$input;
189 print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: ";
190 chomp ($input=<STDIN>);
192 # FIXME: This means anything other than n will tag; too dangerous?
198 if ($cvstag && $tagging_needs_confirmation) {
200 print "Do not do this if you have released the tarball to anybody, as it will\n";
201 print "overwrite the tag marking the files that were in the tarball:\n\n";
202 print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
203 chomp($input = <STDIN>);
204 if ($input =~ /^n/i || $input !~ /\S/) {
205 print "\nStopping. Please re-run buildrelease now.\n";
212 if ($cvsroot=$ENV{'CVSROOT'}) {
213 $cvsroot=~m#(.*)\@cvs#;
216 $ENV{'CVS_RSH'}='ssh';
217 print "\nWhat is your userid at SourceForge: ";
218 chomp($input = <STDIN>);
222 $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
224 my $tagname=$releaseversion;
228 Updating your checked-out copy of the 'koha' CVS files.
229 You may need to enter your SourceForge password.
232 chdir($kohadir) || die "$kohadir: $!\n";
233 system("cvs update");
236 Tagging koha with tag R_$tagname
238 system("cvs tag -F R_$tagname");
241 Updating your checked-out copy of the 'koha-html' CVS files.
242 You may need to enter your SourceForge password.
245 chdir($kohahtmldir) || die "$kohahtmldir: $!\n";
246 system("cvs update");
250 Tagging koha-html with tag R_$tagname
252 system("cvs tag -F R_$tagname");
255 #----------------------------------------------------------
256 # MOVE files to /tmp and build tar.gz
257 #----------------------------------------------------------
260 Updating your checked-out copy of the 'koha-tmpl' CVS files.
261 You may need to enter your SourceForge password.
264 chdir($kohatmpldir) || die "$kohatmpldir: $!\n";
265 system("cvs update");
269 Tagging koha-tmpl with tag R_$tagname
271 system("cvs tag -F R_$tagname");
277 my $rootdir="/tmp/koha-".$releaseversion;
278 system("rm -rf $rootdir");
279 mkdir ($rootdir, 0700);
280 chdir($rootdir) || die "$rootdir: $!\n";
282 mkdir("intranet-cgi", 0755);
283 mkdir("intranet-html", 0755);
284 mkdir("opac-cgi", 0755);
285 mkdir("opac-html", 0755);
286 mkdir("scripts", 0755);
287 mkdir("scripts/z3950daemon", 0755);
288 mkdir("modules", 0755);
291 # Create koha.version file
292 open (KV, ">$rootdir/koha.version");
293 print KV "$releaseversion\n";
296 # Copy all CVS files to intranet-cgi
297 # FIXME: "cp -a" is GNU-ism. It is not portable.
298 system("cp -a $kohadir/* $rootdir/intranet-cgi");
300 # Move C4 to modules directory
301 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
303 # Move files from intranet-cgi to root of tarball
304 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
305 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
306 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
307 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
308 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
309 chmod 0770, "$rootdir/installer.pl";
310 chmod 0770, "$rootdir/koha.upgrade";
311 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
312 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
313 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
314 system("gzip -9 $rootdir/sampledata-1.2");
316 # Copy files from intranet-cgi to opac-cgi
317 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
318 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
319 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
320 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
321 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
322 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
323 system("rmdir $rootdir/intranet-cgi/opac");
326 # Move files from intranet-cgi to /scripts/ directory
327 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
328 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
329 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
330 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
331 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
332 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
333 system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/");
334 system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/");
337 # Remove extraneous files from intranet-cgi
338 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
339 system("rm -f $rootdir/intranet-cgi/SendMessages");
340 system("rm -f $rootdir/intranet-cgi/buildrelease");
341 #system("rm -f $rootdir/intranet-cgi/database.mysql");
342 #system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
343 # FIXME: The following two lines look suspicious
344 #system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
345 #system("rm -f $rootdir/intranet-cgi/rel-1-2");
346 #system("rm -f $rootdir/intranet-cgi/testKoha.pl");
347 #system("rm -rf $rootdir/intranet-cgi/html-template");
348 system("rm -rf $rootdir/intranet-cgi/t");
350 # Set all .pl scripts executable
351 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
352 # Copy all CVS files to intranet-html and opac-html
353 # FIXME: "cp -a" is GNU-ism. It is not portable.
354 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
355 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
357 # Copy koha-tmpl files
358 # FIXME: "cp -a" is GNU-ism. It is not portable.
359 system('cp', '-a', "$kohatmpldir/opac-tmpl", "$rootdir/opac-html");
360 system('cp', '-a', "$kohatmpldir/intranet-tmpl", "$rootdir/intranet-html");
361 system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl");
363 # Remove extraneous files from opac-html
364 system("rm -f $rootdir/opac-html/koha.mo");
365 system("rm -f $rootdir/opac-html/koha.pot");
366 system("rm -f $rootdir/opac-html/test");
368 # Remove extraneous files from intranet-html
369 system("rm -f $rootdir/intranet-html/koha.pot");
370 system("rm -f $rootdir/intranet-html/results.html");
371 system("rm -f $rootdir/intranet-html/test");
373 # Remove junk from directory
374 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
375 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
376 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
379 # FIXME: Why do we copy from $roothomedir? What is supposed to be there?
380 if (-e "$roothomedir/docs") {
381 print "Copying docs folder from $roothomedir/docs...";
382 system("cp -r $roothomedir/docs/* $rootdir/docs/");
384 print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n";
385 print "Press <ENTER> to continue...\n";
390 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
391 system("rm -rf $rootdir");
398 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
406 my @v1=split(/\./, $v1);
407 my @v2=split(/\./, $v2);
409 ($#v2>$count) && ($count=$#v2);
410 for (my $index=0; $index<$count; $index++) {
411 if ($v1[$index]>$v2[$index]) {
418 sub guess_kohahtmldir ($;$) {
419 my($kohadir, $default) = @_;
421 # It probably makes sense to assume that the 'koha' and 'koha-html'
422 # modules are checked out within the same parent directory
423 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
424 $kohahtmldir = "$1/koha-html"
426 $kohahtmldir = $default;
431 sub guess_kohatmpldir ($;$) {
432 my($kohadir, $default) = @_;
434 # "koha-tmpl" is now just a subdirectory within the "koha" module.
435 # Otherwise, it probably makes sense to assume that the "koha" and
436 # "koha-tmpl" modules are checked out within the same parent directory
437 if (-d $kohadir && -d "$kohadir/koha-tmpl") {
438 $kohatmpldir = "$kohadir/koha-tmpl";
439 } elsif (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
440 $kohatmpldir = "$1/koha-tmpl"
442 $kohatmpldir = $default;