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 $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir) unless $has_kohaautobuild_conf;
51 print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: ";
52 chomp($input = <STDIN>);
57 open (C, ">$roothomedir/.kohaautobuild.conf");
60 kohahtmldir=$kohahtmldir
63 #----------------------------------------------------------
64 # which VERSION are we building ?
65 #----------------------------------------------------------
66 print "\n\nGuessing at next release version. You may need to enter your SourceForge password...\n";
67 open (CVSLOG, "cvs log buildrelease|");
68 my $symbolicnamessection=0;
76 if (/^symbolic names:/) {
77 $symbolicnamessection=1;
79 if ($symbolicnamessection && (/^\s+([^:]*):/)) {
86 if ($id =~/(.*)RC(.*)/) {
89 $version=~m#(\d+\.\d+)\.#;
90 if (versioncompare($version, $majorversion->{$1})) {
91 $majorversion->{$1}=$version;
92 $majorversionrc->{$1}=$rc;
94 if (versioncompare($version, $highestversion)) {
95 $highestversion=$version;
101 $version=~m#(\d+\.\d+)\.#;
102 if (versioncompare($version, $majorversion->{$1})) {
103 $majorversion->{$1}=$version;
104 $majorversionrc->{$1}=0;
106 if (versioncompare($version, $highestversion)) {
107 $highestversion=$version;
112 $symbolicnames->{$version}->{$rc}=1;
118 my $releaseversion='';
119 my $currentversion='';
121 my $branchdata=`grep buildrelease CVS/Entries`;
123 my $branch=(split(m#/#, $branchdata))[5];
125 if ($branch eq 'Trel-1-2') {
126 $highestversion=$majorversion->{'1.2'};
127 $highestrc=$majorversionrc->{'1.2'};
128 ($highestrc) ? ($released=0) : ($released=1);
132 my @components=split(/\./, $highestversion);
133 $components[$#components]++;
134 $nexthighestversion=join '.', @components;
135 my $minornumber=(split(/\./, $highestversion))[1];
136 if ($minornumber/2 == int($minornumber/2)) {
137 $releaseversion=$nexthighestversion."RC1";
139 $releaseversion=$nexthighestversion;
141 $currentversion=$highestversion;
143 $releaseversion=$highestversion."RC".($highestrc+1);
144 $currentversion=$highestversion."RC$highestrc";
148 print "Current release tag is $currentversion.\n";
149 print "\nWould you like to bump that up to $releaseversion (or manually enter version)? [Y]/N: ";
150 chomp($input = <STDIN>);
151 my $tagging_needs_confirmation = 0;
152 if ($input =~ /^n/i) {
153 print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: ";
154 chomp($input = <STDIN>);
155 print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
156 if ($input =~ /^y/i) {
157 $releaseversion=$currentversion;
158 $tagging_needs_confirmation = 1;
160 print "What should the new version be? [$releaseversion]: ";
161 chomp ($input=<STDIN>);
163 $releaseversion=$input;
167 print "What should the new version be? [$releaseversion]: ";
168 chomp ($input=<STDIN>);
170 $releaseversion=$input;
175 print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: ";
176 chomp ($input=<STDIN>);
178 # FIXME: This means anything other than n will tag; too dangerous?
184 if ($cvstag && $tagging_needs_confirmation) {
186 print "Do not do this if you have released the tarball to anybody, as it will\n";
187 print "overwrite the tag marking the files that were in the tarball:\n\n";
188 print "Confirm that you want to overwrite the tag for $releaseversion? Y/[N]: ";
189 chomp($input = <STDIN>);
190 if ($input =~ /^n/i || $input !~ /\S/) {
191 print "\nStopping. Please re-run buildrelease now.\n";
198 if ($cvsroot=$ENV{'CVSROOT'}) {
199 $cvsroot=~m#(.*)\@cvs#;
202 $ENV{'CVS_RSH'}='ssh';
203 print "\nWhat is your userid at SourceForge: ";
204 chomp($input = <STDIN>);
208 $ENV{'CVSROOT'}="$sfuserid\@cvs.koha.sourceforge.net:/cvsroot/koha";
210 my $tagname=$releaseversion;
214 Updating your checked-out copy of the 'koha' CVS files.
215 You may need to enter your SourceForge password.
219 system("cvs update");
222 Tagging koha with tag R_$tagname
224 system("cvs tag -F R_$tagname");
227 Updating your checked-out copy of the 'koha-html' CVS files.
228 You may need to enter your SourceForge password.
231 chdir($kohahtmldir) || die "$kohahtmldir: $!\n";
232 system("cvs update");
236 Tagging koha-html with tag R_$tagname
238 system("cvs tag -F R_$tagname");
241 #----------------------------------------------------------
242 # MOVE files to /tmp and build tar.gz
243 #----------------------------------------------------------
244 my $rootdir="/tmp/koha-".$releaseversion;
245 system("rm -rf $rootdir");
246 mkdir ($rootdir, 0700);
247 chdir($rootdir) || die "$rootdir: $!\n";
249 mkdir("intranet-cgi", 0755);
250 mkdir("intranet-html", 0755);
251 mkdir("opac-cgi", 0755);
252 mkdir("opac-html", 0755);
253 mkdir("scripts", 0755);
254 mkdir("scripts/z3950daemon", 0755);
255 mkdir("modules", 0755);
258 # Create koha.version file
259 open (KV, ">$rootdir/koha.version");
260 print KV "$releaseversion\n";
263 # Copy all CVS files to intranet-cgi
264 system("cp -a $kohadir/* $rootdir/intranet-cgi");
266 # Move C4 to modules directory
267 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
269 # Move files from intranet-cgi to root of tarball
270 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
271 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
272 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
273 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
274 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
275 chmod 0770, "$rootdir/installer.pl";
276 chmod 0770, "$rootdir/koha.upgrade";
277 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
278 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
279 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
280 system("gzip -9 $rootdir/sampledata-1.2");
282 # Copy files from intranet-cgi to opac-cgi
283 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
284 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
285 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
286 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
287 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
288 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
289 system("rmdir $rootdir/intranet-cgi/opac");
292 # Move files from intranet-cgi to /scripts/ directory
293 system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts");
294 system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts");
295 system("mv $rootdir/intranet-cgi/translator $rootdir/scripts");
296 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
297 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
298 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
299 system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/");
300 system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/");
303 # Remove extraneous files from intranet-cgi
304 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
305 system("rm -f $rootdir/intranet-cgi/SendMessages");
306 system("rm -f $rootdir/intranet-cgi/buildrelease");
307 #system("rm -f $rootdir/intranet-cgi/database.mysql");
308 #system("rm -f $rootdir/intranet-cgi/installer-lite.pl");
309 # FIXME: The following two lines look suspicious
310 #system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz");
311 #system("rm -f $rootdir/intranet-cgi/rel-1-2");
312 #system("rm -f $rootdir/intranet-cgi/testKoha.pl");
313 #system("rm -rf $rootdir/intranet-cgi/html-template");
314 system("rm -rf $rootdir/intranet-cgi/t");
316 # Set all .pl scripts executable
317 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
318 # Copy all CVS files to intranet-html and opac-html
319 system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
320 system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
322 # Move koha-tmpl files
323 system("mv $rootdir/intranet-cgi/koha-tmpl/opac-tmpl $rootdir/opac-html");
324 system("mv $rootdir/intranet-cgi/koha-tmpl/intranet-tmpl $rootdir/intranet-html");
325 system("rm -rf $rootdir/intranet-cgi/koha-tmpl");
327 # Remove extraneous files from opac-html
328 system("rm -f $rootdir/opac-html/koha.mo");
329 system("rm -f $rootdir/opac-html/koha.pot");
330 system("rm -f $rootdir/opac-html/test");
332 # Remove extraneous files from intranet-html
333 system("rm -f $rootdir/intranet-html/koha.pot");
334 system("rm -f $rootdir/intranet-html/results.html");
335 system("rm -f $rootdir/intranet-html/test");
337 # Remove junk from directory
338 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
339 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
340 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
343 if (-e "$roothomedir/docs") {
344 print "Copying docs folder from $roothomedir/docs...";
345 system("cp -r $roothomedir/docs/* $rootdir/docs/");
347 print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n";
348 print "Press <ENTER> to continue...\n";
353 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
354 #system("rm -rf $rootdir");
361 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
369 my @v1=split(/\./, $v1);
370 my @v2=split(/\./, $v2);
372 ($#v2>$count) && ($count=$#v2);
373 for (my $index=0; $index<$count; $index++) {
374 if ($v1[$index]>$v2[$index]) {
381 sub guess_kohahtmldir ($;$) {
382 my($kohadir, $default) = @_;
384 # It probably makes sense to assume that the 'koha' and 'koha-html'
385 # modules are checked out within the same parent directory
386 if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
387 $kohahtmldir = "$1/koha-html"
389 $kohahtmldir = $default;