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 $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir) unless $has_kohaautobuild_conf;
55 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
56 chomp($input = <STDIN>);
61 print "\nWhere is the 'koha-tmpl' cvs module located [$kohatmpldir]: ";
62 chomp($input = <STDIN>);
67 open (C, ">$roothomedir/.kohaautobuild.conf");
70 kohahtmldir=$kohahtmldir
71 kohatmpldir=$kohatmpldir
74 #----------------------------------------------------------
75 # which VERSION are we building ?
76 #----------------------------------------------------------
77 print "\n\nGuessing at next release version. You may need to enter your SourceForge password...\n";
78 open (CVSLOG, "cvs log misc/buildrelease|");
79 my $symbolicnamessection=0;
87 if (/^symbolic names:/) {
88 $symbolicnamessection=1;
90 if ($symbolicnamessection && (/^\s+([^:]*):/)) {
97 if ($id =~/(.*)RC(.*)/) {
100 $version=~m#(\d+\.\d+)\.#;
101 if (versioncompare($version, $majorversion->{$1})) {
102 $majorversion->{$1}=$version;
103 $majorversionrc->{$1}=$rc;
105 if (versioncompare($version, $highestversion)) {
106 $highestversion=$version;
112 $version=~m#(\d+\.\d+)\.#;
113 if (versioncompare($version, $majorversion->{$1})) {
114 $majorversion->{$1}=$version;
115 $majorversionrc->{$1}=0;
117 if (versioncompare($version, $highestversion)) {
118 $highestversion=$version;
123 $symbolicnames->{$version}->{$rc}=1;
129 my $releaseversion='';
130 my $currentversion='';
132 my $branchdata=`grep buildrelease CVS/Entries`;
134 my $branch=(split(m#/#, $branchdata))[5];
136 if ($branch eq 'Trel-1-2') {
137 $highestversion=$majorversion->{'1.2'};
138 $highestrc=$majorversionrc->{'1.2'};
139 ($highestrc) ? ($released=0) : ($released=1);
143 my @components=split(/\./, $highestversion);
144 $components[$#components]++;
145 $nexthighestversion=join '.', @components;
146 my $minornumber=(split(/\./, $highestversion))[1];
147 if ($minornumber/2 == int($minornumber/2)) {
148 $releaseversion=$nexthighestversion."RC1";
150 $releaseversion=$nexthighestversion;
152 $currentversion=$highestversion;
154 $releaseversion=$highestversion."RC".($highestrc+1);
155 $currentversion=$highestversion."RC$highestrc";
159 print "Current release tag is $currentversion.\n";
160 print "\nWould you like to bump that up to $releaseversion (or manually enter version)? [Y]/N: ";
161 chomp($input = <STDIN>);
162 my $tagging_needs_confirmation = 0;
163 if ($input =~ /^n/i) {
164 print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: ";
165 chomp($input = <STDIN>);
166 print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
167 if ($input =~ /^y/i) {
168 $releaseversion=$currentversion;
169 $tagging_needs_confirmation = 1;
171 print "What should the new version be? [$releaseversion]: ";
172 chomp ($input=<STDIN>);
174 $releaseversion=$input;
178 print "What should the new version be? [$releaseversion]: ";
179 chomp ($input=<STDIN>);
181 $releaseversion=$input;
186 print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: ";
187 chomp ($input=<STDIN>);
189 # FIXME: This means anything other than n will tag; too dangerous?
195 if ($cvstag && $tagging_needs_confirmation) {
197 print "Do not do this if you have released the tarball to anybody, as it will\n";
198 print "overwrite the tag marking the files that were in the tarball:\n\n";
199 print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
200 chomp($input = <STDIN>);
201 if ($input =~ /^n/i || $input !~ /\S/) {
202 print "\nStopping. Please re-run buildrelease now.\n";
209 if ($cvsroot=$ENV{'CVSROOT'}) {
210 $cvsroot=~m#(.*)\@cvs#;
213 $ENV{'CVS_RSH'}='ssh';
214 print "\nWhat is your userid at SourceForge: ";
215 chomp($input = <STDIN>);
219 $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
221 my $tagname=$releaseversion;
225 Updating your checked-out copy of the 'koha' CVS files.
226 You may need to enter your SourceForge password.
229 chdir($kohadir) || die "$kohadir: $!\n";
230 system("cvs update");
233 Tagging koha with tag R_$tagname
235 system("cvs tag -F R_$tagname");
238 Updating your checked-out copy of the 'koha-html' CVS files.
239 You may need to enter your SourceForge password.
242 chdir($kohahtmldir) || die "$kohahtmldir: $!\n";
243 system("cvs update");
247 Tagging koha-html with tag R_$tagname
249 system("cvs tag -F R_$tagname");
252 #----------------------------------------------------------
253 # MOVE files to /tmp and build tar.gz
254 #----------------------------------------------------------
257 Updating your checked-out copy of the 'koha-tmpl' CVS files.
258 You may need to enter your SourceForge password.
261 chdir($kohatmpldir) || die "$kohatmpldir: $!\n";
262 system("cvs update");
266 Tagging koha-tmpl with tag R_$tagname
268 system("cvs tag -F R_$tagname");
274 my $rootdir="/tmp/koha-".$releaseversion;
275 system("rm -rf $rootdir");
276 mkdir ($rootdir, 0700);
277 chdir($rootdir) || die "$rootdir: $!\n";
279 mkdir("intranet-cgi", 0755);
280 mkdir("intranet-html", 0755);
281 mkdir("opac-cgi", 0755);
282 mkdir("opac-html", 0755);
283 mkdir("scripts", 0755);
284 mkdir("scripts/z3950daemon", 0755);
285 mkdir("modules", 0755);
288 # Create koha.version file
289 open (KV, ">$rootdir/koha.version");
290 print KV "$releaseversion\n";
293 # Copy all CVS files to intranet-cgi
294 system("cp -a $kohadir/* $rootdir/intranet-cgi");
296 # Move C4 to modules directory
297 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
299 # Move files from intranet-cgi to root of tarball
300 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
301 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
302 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
303 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
304 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
305 chmod 0770, "$rootdir/installer.pl";
306 chmod 0770, "$rootdir/koha.upgrade";
307 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
308 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
309 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
310 system("gzip -9 $rootdir/sampledata-1.2");
312 # Copy files from intranet-cgi to opac-cgi
313 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
314 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
315 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
316 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
317 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
318 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
319 system("rmdir $rootdir/intranet-cgi/opac");
322 # Move files from intranet-cgi to /scripts/ directory
323 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
324 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
325 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
326 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
327 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
328 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
329 system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/");
330 system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/");
333 # Remove extraneous files from intranet-cgi
334 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
335 system("rm -f $rootdir/intranet-cgi/SendMessages");
336 system("rm -f $rootdir/intranet-cgi/buildrelease");
337 #system("rm -f $rootdir/intranet-cgi/database.mysql");
338 #system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
339 # FIXME: The following two lines look suspicious
340 #system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
341 #system("rm -f $rootdir/intranet-cgi/rel-1-2");
342 #system("rm -f $rootdir/intranet-cgi/testKoha.pl");
343 #system("rm -rf $rootdir/intranet-cgi/html-template");
344 system("rm -rf $rootdir/intranet-cgi/t");
346 # Set all .pl scripts executable
347 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
348 # Copy all CVS files to intranet-html and opac-html
349 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
350 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
352 # Copy koha-tmpl files
353 system('cp', '-a', "$kohatmpldir/opac-tmpl", "$rootdir/opac-html");
354 system('cp', '-a', "$kohatmpldir/intranet-tmpl", "$rootdir/intranet-html");
355 system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl");
357 # Remove extraneous files from opac-html
358 system("rm -f $rootdir/opac-html/koha.mo");
359 system("rm -f $rootdir/opac-html/koha.pot");
360 system("rm -f $rootdir/opac-html/test");
362 # Remove extraneous files from intranet-html
363 system("rm -f $rootdir/intranet-html/koha.pot");
364 system("rm -f $rootdir/intranet-html/results.html");
365 system("rm -f $rootdir/intranet-html/test");
367 # Remove junk from directory
368 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
369 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
370 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
373 if (-e "$roothomedir/docs") {
374 print "Copying docs folder from $roothomedir/docs...";
375 system("cp -r $roothomedir/docs/* $rootdir/docs/");
377 print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n";
378 print "Press <ENTER> to continue...\n";
383 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
384 system("rm -rf $rootdir");
391 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
399 my @v1=split(/\./, $v1);
400 my @v2=split(/\./, $v2);
402 ($#v2>$count) && ($count=$#v2);
403 for (my $index=0; $index<$count; $index++) {
404 if ($v1[$index]>$v2[$index]) {
411 sub guess_kohahtmldir ($;$) {
412 my($kohadir, $default) = @_;
414 # It probably makes sense to assume that the 'koha' and 'koha-html'
415 # modules are checked out within the same parent directory
416 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
417 $kohahtmldir = "$1/koha-html"
419 $kohahtmldir = $default;
424 sub guess_kohatmpldir ($;$) {
425 my($kohadir, $default) = @_;
427 # It probably makes sense to assume that the 'koha' and 'koha-tmpl'
428 # modules are checked out within the same parent directory
429 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
430 $kohatmpldir = "$1/koha-tmpl"
432 $kohatmpldir = $default;