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 $roothomedir=(getpwuid(0))[7]; # ~root is traditionally just /
11 $roothomedir='/root' unless defined $roothomedir;
13 my $has_kohaautobuild_conf = 0;
15 if (-e "$roothomedir/.kohaautobuild.conf") {
16 open C, "<$roothomedir/.kohaautobuild.conf";
22 if (/kohahtmldir=(.*)/) {
26 $has_kohaautobuild_conf = 1;
32 ***************************************
33 * Welcome to the Koha Release Builder *
34 ***************************************
36 This script will automatically build a release tarball.
38 The script assumes that you already have the koha and koha-html modules checked
39 out for the release that you want to build, although it will update the modules
43 print "\nWhere is the 'koha' cvs module located [$kohadir]: ";
44 chomp($input = <STDIN>);
47 unless ($has_kohaautobuild_conf) {
48 $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir);
53 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
54 chomp($input = <STDIN>);
59 open (C, ">$roothomedir/.kohaautobuild.conf");
62 kohahtmldir=$kohahtmldir
65 #----------------------------------------------------------
66 # which VERSION are we building ?
67 #----------------------------------------------------------
68 print "\n\nGuessing at next release version. You may need to enter your SourceForge password...\n";
69 open (CVSLOG, "cvs log $kohadir/misc/buildrelease|");
70 my $symbolicnamessection=0;
78 if (/^symbolic names:/) {
79 $symbolicnamessection=1;
81 if ($symbolicnamessection && (/^\s+([^:]*):/)) {
88 if ($id =~/(.*)RC(.*)/) {
91 $version=~m#(\d+\.\d+)\.#;
92 if (versioncompare($version, $majorversion->{$1})) {
93 $majorversion->{$1}=$version;
94 $majorversionrc->{$1}=$rc;
96 if (versioncompare($version, $highestversion)) {
97 $highestversion=$version;
103 $version=~m#(\d+\.\d+)\.#;
104 if (versioncompare($version, $majorversion->{$1})) {
105 $majorversion->{$1}=$version;
106 $majorversionrc->{$1}=0;
108 if (versioncompare($version, $highestversion)) {
109 $highestversion=$version;
114 $symbolicnames->{$version}->{$rc}=1;
120 my $releaseversion='';
121 my $currentversion='';
123 my $branchdata=`grep buildrelease CVS/Entries`;
125 my $branch=(split(m#/#, $branchdata))[5];
127 if ($branch eq 'Trel-1-2') {
128 $highestversion=$majorversion->{'1.2'};
129 $highestrc=$majorversionrc->{'1.2'};
130 ($highestrc) ? ($released=0) : ($released=1);
134 my @components=split(/\./, $highestversion);
135 $components[$#components]++;
136 $nexthighestversion=join '.', @components;
137 my $minornumber=(split(/\./, $highestversion))[1];
138 if ($minornumber/2 == int($minornumber/2)) {
139 $releaseversion=$nexthighestversion."RC1";
141 $releaseversion=$nexthighestversion;
143 $currentversion=$highestversion;
145 $releaseversion=$highestversion."RC".($highestrc+1);
146 $currentversion=$highestversion."RC$highestrc";
150 print "Current release tag is $currentversion.\n";
151 print "\nWould you like to bump that up to $releaseversion (or manually enter version)? [Y]/N: ";
152 chomp($input = <STDIN>);
153 my $tagging_needs_confirmation = 0;
154 if ($input =~ /^n/i) {
155 print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: ";
156 chomp($input = <STDIN>);
157 print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
158 if ($input =~ /^y/i) {
159 $releaseversion=$currentversion;
160 $tagging_needs_confirmation = 1;
162 print "What should the new version be? [$releaseversion]: ";
163 chomp ($input=<STDIN>);
165 $releaseversion=$input;
169 print "What should the new version be? [$releaseversion]: ";
170 chomp ($input=<STDIN>);
172 $releaseversion=$input;
177 print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: ";
178 chomp ($input=<STDIN>);
180 # FIXME: This means anything other than n will tag; too dangerous?
186 if ($cvstag && $tagging_needs_confirmation) {
188 print "Do not do this if you have released the tarball to anybody, as it will\n";
189 print "overwrite the tag marking the files that were in the tarball:\n\n";
190 print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
191 chomp($input = <STDIN>);
192 if ($input =~ /^n/i || $input !~ /\S/) {
193 print "\nStopping. Please re-run buildrelease now.\n";
200 if ($cvsroot=$ENV{'CVSROOT'}) {
201 $cvsroot=~m#(.*)\@cvs#;
204 $ENV{'CVS_RSH'}='ssh';
205 print "\nWhat is your userid at SourceForge: ";
206 chomp($input = <STDIN>);
210 $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
212 my $tagname=$releaseversion;
216 Updating your checked-out copy of the 'koha' CVS files.
217 You may need to enter your SourceForge password.
220 chdir($kohadir) || die "$kohadir: $!\n";
221 system("cvs update");
224 Tagging koha with tag R_$tagname
226 system("cvs tag -F R_$tagname");
229 Updating your checked-out copy of the 'koha-html' CVS files.
230 You may need to enter your SourceForge password.
233 chdir($kohahtmldir) || die "$kohahtmldir: $!\n";
234 system("cvs update");
238 Tagging koha-html with tag R_$tagname
240 system("cvs tag -F R_$tagname");
243 #----------------------------------------------------------
244 # MOVE files to /tmp and build tar.gz
245 #----------------------------------------------------------
250 my $rootdir="/tmp/koha-".$releaseversion;
251 system("rm -rf $rootdir");
252 mkdir ($rootdir, 0700);
253 chdir($rootdir) || die "$rootdir: $!\n";
255 mkdir("intranet-cgi", 0755);
256 mkdir("intranet-html", 0755);
257 mkdir("opac-cgi", 0755);
258 mkdir("opac-html", 0755);
259 mkdir("scripts", 0755);
260 mkdir("scripts/z3950daemon", 0755);
261 mkdir("modules", 0755);
264 # Create koha.version file
265 open (KV, ">$rootdir/koha.version");
266 print KV "$releaseversion\n";
269 # Copy all CVS files to intranet-cgi
270 # FIXME: "cp -a" is GNU-ism. It is not portable.
271 system("cp -a $kohadir/* $rootdir/intranet-cgi");
273 # Move C4 to modules directory
274 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
276 # Move files from intranet-cgi to root of tarball
277 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
278 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
279 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
280 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
281 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
282 chmod 0770, "$rootdir/installer.pl";
283 chmod 0770, "$rootdir/koha.upgrade";
284 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
285 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
286 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
287 system("gzip -9 $rootdir/sampledata-1.2");
289 # Copy files from intranet-cgi to opac-cgi
290 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
291 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
292 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
293 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
294 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
295 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
296 system("rmdir $rootdir/intranet-cgi/opac");
299 # Move files from intranet-cgi to /scripts/ directory
300 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
301 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
302 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
303 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
304 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
305 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
306 system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/");
307 system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/");
310 # Remove extraneous files from intranet-cgi
311 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
312 system("rm -f $rootdir/intranet-cgi/SendMessages");
313 system("rm -f $rootdir/intranet-cgi/buildrelease");
314 #system("rm -f $rootdir/intranet-cgi/database.mysql");
315 #system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
316 # FIXME: The following two lines look suspicious
317 #system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
318 #system("rm -f $rootdir/intranet-cgi/rel-1-2");
319 #system("rm -f $rootdir/intranet-cgi/testKoha.pl");
320 #system("rm -rf $rootdir/intranet-cgi/html-template");
321 system("rm -rf $rootdir/intranet-cgi/t");
323 # Set all .pl scripts executable
324 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
325 # Copy all CVS files to intranet-html and opac-html
326 # FIXME: "cp -a" is GNU-ism. It is not portable.
327 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
328 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
330 # Copy koha-tmpl files
331 # FIXME: "cp -a" is GNU-ism. It is not portable.
332 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/opac-tmpl", "$rootdir/opac-html");
333 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/intranet-tmpl", "$rootdir/intranet-html");
334 system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl");
336 # Remove extraneous files from opac-html
337 system("rm -f $rootdir/opac-html/koha.mo");
338 system("rm -f $rootdir/opac-html/koha.pot");
339 system("rm -f $rootdir/opac-html/test");
341 # Remove extraneous files from intranet-html
342 system("rm -f $rootdir/intranet-html/koha.pot");
343 system("rm -f $rootdir/intranet-html/results.html");
344 system("rm -f $rootdir/intranet-html/test");
346 # Remove junk from directory
347 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
348 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
349 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
352 # FIXME: Why do we copy from $roothomedir? What is supposed to be there?
353 if (-e "$roothomedir/docs") {
354 print "Copying docs folder from $roothomedir/docs...";
355 system("cp -r $roothomedir/docs/* $rootdir/docs/");
357 print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n";
358 print "Press <ENTER> to continue...\n";
363 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
364 system("rm -rf $rootdir");
371 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
379 my @v1=split(/\./, $v1);
380 my @v2=split(/\./, $v2);
382 ($#v2>$count) && ($count=$#v2);
383 for (my $index=0; $index<$count; $index++) {
384 if ($v1[$index]>$v2[$index]) {
391 sub guess_kohahtmldir ($;$) {
392 my($kohadir, $default) = @_;
394 # It probably makes sense to assume that the 'koha' and 'koha-html'
395 # modules are checked out within the same parent directory
396 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
397 $kohahtmldir = "$1/koha-html"
399 $kohahtmldir = $default;