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>);
56 # $kohahtmldir=$input;
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;
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 -P");
224 Tagging koha with tag R_$tagname
226 system("cvs tag -F R_$tagname");
229 #----------------------------------------------------------
230 # MOVE files to /tmp and build tar.gz
231 #----------------------------------------------------------
233 my $rootdir="/tmp/koha-".$releaseversion;
234 system("rm -rf $rootdir");
235 mkdir ($rootdir, 0700);
236 chdir($rootdir) || die "$rootdir: $!\n";
238 mkdir("intranet-cgi", 0755);
239 mkdir("intranet-html", 0755);
240 mkdir("opac-cgi", 0755);
241 mkdir("opac-html", 0755);
242 mkdir("scripts", 0755);
243 mkdir("scripts/z3950daemon", 0755);
244 mkdir("modules", 0755);
247 # Create koha.version file
248 open (KV, ">$rootdir/koha.version");
249 print KV "$releaseversion\n";
252 # Copy all CVS files to intranet-cgi
253 # FIXME: "cp -a" is GNU-ism. It is not portable.
254 system("cp -a $kohadir/* $rootdir/intranet-cgi");
256 # Move C4 to modules directory
257 system("mv $rootdir/intranet-cgi/C4 $rootdir/modules");
259 # Move files from intranet-cgi to root of tarball
260 system("mv $rootdir/intranet-cgi/misc/info/* $rootdir");
261 system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir");
262 system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir");
263 system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir");
264 #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ??
265 chmod 0770, "$rootdir/installer.pl";
266 chmod 0770, "$rootdir/koha.upgrade";
267 system("mv $rootdir/intranet-cgi/misc/koha.conf $rootdir");
268 system("mv $rootdir/intranet-cgi/misc/koha.mysql $rootdir");
269 system("mv $rootdir/intranet-cgi/misc/sampledata-1.2 $rootdir");
270 system("gzip -9 $rootdir/sampledata-1.2");
272 # Copy files from intranet-cgi to opac-cgi
273 system("cp $rootdir/intranet-cgi/detail.pl $rootdir/opac-cgi");
274 system("cp $rootdir/intranet-cgi/moredetail.pl $rootdir/opac-cgi");
275 system("cp $rootdir/intranet-cgi/search.pl $rootdir/opac-cgi");
276 system("cp $rootdir/intranet-cgi/subjectsearch.pl $rootdir/opac-cgi");
277 system("cp $rootdir/intranet-cgi/logout.pl $rootdir/opac-cgi");
278 system("mv $rootdir/intranet-cgi/opac/* $rootdir/opac-cgi");
279 system("rmdir $rootdir/intranet-cgi/opac");
282 # Move files from intranet-cgi to /scripts/ directory
283 system("mv $rootdir/intranet-cgi/updater $rootdir/scripts");
284 system("mv $rootdir/intranet-cgi/misc $rootdir/scripts");
285 system("mv $rootdir/intranet-cgi/marc $rootdir/scripts");
287 # move only batch & daemon. pl script stay here
288 system("mv $rootdir/intranet-cgi/z3950/processz3950queue $rootdir/scripts/z3950daemon/");
289 system("mv $rootdir/intranet-cgi/z3950/*.sh $rootdir/scripts/z3950daemon/");
291 # Remove extraneous files from intranet-cgi
292 system("rm -f $rootdir/intranet-cgi/ChangeLog.bak");
293 system("rm -f $rootdir/intranet-cgi/SendMessages");
294 system("rm -f $rootdir/intranet-cgi/buildrelease");
295 system("rm -rf $rootdir/intranet-cgi/t");
297 # Set all .pl scripts executable
298 system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;");
299 # Copy all CVS files to intranet-html and opac-html
300 # FIXME: "cp -a" is GNU-ism. It is not portable.
301 #system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html");
302 #system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html");
304 # Copy koha-tmpl files
305 # FIXME: "cp -a" is GNU-ism. It is not portable.
306 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/opac-tmpl", "$rootdir/opac-html");
307 system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/intranet-tmpl", "$rootdir/intranet-html");
308 #copy index files (they are just redirections to main.pl)
309 system("cp $rootdir/intranet-cgi/koha-tmpl/opac.html $rootdir/opac-html/index.html");
310 system("cp $rootdir/intranet-cgi/koha-tmpl/intranet.html $rootdir/intranet-html/index.html");
311 system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl");
313 # Remove junk from directory
314 system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null");
315 system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null");
316 system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null");
319 system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion);
320 system("rm -rf $rootdir");
327 Your new tarball is located in /tmp/koha-$releaseversion.tar.gz
335 my @v1=split(/\./, $v1);
336 my @v2=split(/\./, $v2);
338 ($#v2>$count) && ($count=$#v2);
339 for (my $index=0; $index<$count; $index++) {
340 if ($v1[$index]>$v2[$index]) {
347 #sub guess_kohahtmldir ($;$) {
348 # my($kohadir, $default) = @_;
350 # It probably makes sense to assume that the 'koha' and 'koha-html'
351 # modules are checked out within the same parent directory
352 # if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) {
353 # $kohahtmldir = "$1/koha-html"
355 # $kohahtmldir = $default;
357 # return $kohahtmldir;