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";
70 open (CVSLOG, "cvs log misc/buildrelease|");
71 my $symbolicnamessection=0;
79 if (/^symbolic names:/) {
80 $symbolicnamessection=1;
82 if ($symbolicnamessection && (/^\s+([^:]*):/)) {
89 if ($id =~/(.*)RC(.*)/) {
92 $version=~m#(\d+\.\d+)\.#;
93 if (versioncompare($version, $majorversion->{$1})) {
94 $majorversion->{$1}=$version;
95 $majorversionrc->{$1}=$rc;
97 if (versioncompare($version, $highestversion)) {
98 $highestversion=$version;
104 $version=~m#(\d+\.\d+)\.#;
105 if (versioncompare($version, $majorversion->{$1})) {
106 $majorversion->{$1}=$version;
107 $majorversionrc->{$1}=0;
109 if (versioncompare($version, $highestversion)) {
110 $highestversion=$version;
115 $symbolicnames->{$version}->{$rc}=1;
121 my $releaseversion='';
122 my $currentversion='';
124 my $branchdata=`grep buildrelease CVS/Entries`;
126 my $branch=(split(m#/#, $branchdata))[5];
128 if ($branch eq 'Trel-1-2') {
129 $highestversion=$majorversion->{'1.2'};
130 $highestrc=$majorversionrc->{'1.2'};
131 ($highestrc) ? ($released=0) : ($released=1);
135 my @components=split(/\./, $highestversion);
136 $components[$#components]++;
137 $nexthighestversion=join '.', @components;
138 my $minornumber=(split(/\./, $highestversion))[1];
139 if ($minornumber/2 == int($minornumber/2)) {
140 $releaseversion=$nexthighestversion."RC1";
142 $releaseversion=$nexthighestversion;
144 $currentversion=$highestversion;
146 $releaseversion=$highestversion."RC".($highestrc+1);
147 $currentversion=$highestversion."RC$highestrc";
151 print "Current release tag is $currentversion.\n";
152 print "\nWould you like to bump that up to $releaseversion (or manually enter version)? [Y]/N: ";
153 chomp($input = <STDIN>);
154 my $tagging_needs_confirmation = 0;
155 if ($input =~ /^n/i) {
156 print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: ";
157 chomp($input = <STDIN>);
158 print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
159 if ($input =~ /^y/i) {
160 $releaseversion=$currentversion;
161 $tagging_needs_confirmation = 1;
163 print "What should the new version be? [$releaseversion]: ";
164 chomp ($input=<STDIN>);
166 $releaseversion=$input;
170 print "What should the new version be? [$releaseversion]: ";
171 chomp ($input=<STDIN>);
173 $releaseversion=$input;
178 print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: ";
179 chomp ($input=<STDIN>);
181 # FIXME: This means anything other than n will tag; too dangerous?
187 if ($cvstag && $tagging_needs_confirmation) {
189 print "Do not do this if you have released the tarball to anybody, as it will\n";
190 print "overwrite the tag marking the files that were in the tarball:\n\n";
191 print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
192 chomp($input = <STDIN>);
193 if ($input =~ /^n/i || $input !~ /\S/) {
194 print "\nStopping. Please re-run buildrelease now.\n";
201 if ($cvsroot=$ENV{'CVSROOT'}) {
202 $cvsroot=~m#(.*)\@cvs#;
205 $ENV{'CVS_RSH'}='ssh';
206 print "\nWhat is your userid at SourceForge: ";
207 chomp($input = <STDIN>);
211 $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
213 my $tagname=$releaseversion;
217 Updating your checked-out copy of the 'koha' CVS files.
218 You may need to enter your SourceForge password.
221 chdir($kohadir) || die "$kohadir: $!\n";
222 system("cvs update");
225 Tagging koha with tag R_$tagname
227 system("cvs tag -F R_$tagname");
230 Updating your checked-out copy of the 'koha-html' CVS files.
231 You may need to enter your SourceForge password.
234 chdir($kohahtmldir) || die "$kohahtmldir: $!\n";
235 system("cvs update");
239 Tagging koha-html with tag R_$tagname
241 system("cvs tag -F R_$tagname");
244 #----------------------------------------------------------
245 # MOVE files to /tmp and build tar.gz
246 #----------------------------------------------------------
251 my $rootdir="/tmp/koha-".$releaseversion;
252 system("rm -rf $rootdir");
253 mkdir ($rootdir, 0700);
254 chdir($rootdir) || die "$rootdir: $!\n";
256 mkdir("intranet-cgi", 0755);
257 mkdir("intranet-html", 0755);
258 mkdir("opac-cgi", 0755);
259 mkdir("opac-html", 0755);
260 mkdir("scripts", 0755);
261 mkdir("scripts/z3950daemon", 0755);
262 mkdir("modules", 0755);
265 # Create koha.version file
266 open (KV, ">$rootdir/koha.version");
267 print KV "$releaseversion\n";
270 # Copy all CVS files to intranet-cgi
271 # FIXME: "cp -a" is GNU-ism. It is not portable.
272 system("cp -a $kohadir/* $rootdir/intranet-cgi");
274 # Move C4 to modules directory
275 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
277 # Move files from intranet-cgi to root of tarball
278 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
279 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
280 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
281 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
282 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
283 chmod 0770, "$rootdir/installer.pl";
284 chmod 0770, "$rootdir/koha.upgrade";
285 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
286 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
287 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
288 system("gzip -9 $rootdir/sampledata-1.2");
290 # Copy files from intranet-cgi to opac-cgi
291 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
292 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
293 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
294 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
295 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
296 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
297 system("rmdir $rootdir/intranet-cgi/opac");
300 # Move files from intranet-cgi to /scripts/ directory
301 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
302 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
303 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
304 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
305 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
306 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
307 system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/");
308 system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/");
311 # Remove extraneous files from intranet-cgi
312 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
313 system("rm -f $rootdir/intranet-cgi/SendMessages");
314 system("rm -f $rootdir/intranet-cgi/buildrelease");
315 #system("rm -f $rootdir/intranet-cgi/database.mysql");
316 #system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
317 # FIXME: The following two lines look suspicious
318 #system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
319 #system("rm -f $rootdir/intranet-cgi/rel-1-2");
320 #system("rm -f $rootdir/intranet-cgi/testKoha.pl");
321 #system("rm -rf $rootdir/intranet-cgi/html-template");
322 system("rm -rf $rootdir/intranet-cgi/t");
324 # Set all .pl scripts executable
325 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
326 # Copy all CVS files to intranet-html and opac-html
327 # FIXME: "cp -a" is GNU-ism. It is not portable.
328 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
329 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
331 # Copy koha-tmpl files
332 # FIXME: "cp -a" is GNU-ism. It is not portable.
333 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/opac-tmpl", "$rootdir/opac-html");
334 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/intranet-tmpl", "$rootdir/intranet-html");
335 system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl");
337 # Remove extraneous files from opac-html
338 system("rm -f $rootdir/opac-html/koha.mo");
339 system("rm -f $rootdir/opac-html/koha.pot");
340 system("rm -f $rootdir/opac-html/test");
342 # Remove extraneous files from intranet-html
343 system("rm -f $rootdir/intranet-html/koha.pot");
344 system("rm -f $rootdir/intranet-html/results.html");
345 system("rm -f $rootdir/intranet-html/test");
347 # Remove junk from directory
348 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
349 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
350 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
353 # FIXME: Why do we copy from $roothomedir? What is supposed to be there?
354 if (-e "$roothomedir/docs") {
355 print "Copying docs folder from $roothomedir/docs...";
356 system("cp -r $roothomedir/docs/* $rootdir/docs/");
358 print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n";
359 print "Press <ENTER> to continue...\n";
364 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
365 system("rm -rf $rootdir");
372 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
380 my @v1=split(/\./, $v1);
381 my @v2=split(/\./, $v2);
383 ($#v2>$count) && ($count=$#v2);
384 for (my $index=0; $index<$count; $index++) {
385 if ($v1[$index]>$v2[$index]) {
392 sub guess_kohahtmldir ($;$) {
393 my($kohadir, $default) = @_;
395 # It probably makes sense to assume that the 'koha' and 'koha-html'
396 # modules are checked out within the same parent directory
397 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
398 $kohahtmldir = "$1/koha-html"
400 $kohahtmldir = $default;