X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=misc%2Fbuildrelease;h=f406a209beda272007f33a89c009703da5d1c0d2;hb=f3fd911dc89d205d0fece785fc2d5d8decb9563b;hp=6c95b9a715214a79d9b03fc5e36a076133c8e315;hpb=075c1259a189440c5a5ee74945345987cc6e8fc0;p=koha.git diff --git a/misc/buildrelease b/misc/buildrelease index 6c95b9a715..f406a209be 100644 --- a/misc/buildrelease +++ b/misc/buildrelease @@ -1,27 +1,84 @@ #!/usr/bin/perl +# This script uses standard 8-space tabs with 4-space indents +# vi users can :set sw=4 ai sm -sub guess_kohahtmldir ($;$); +use Getopt::Long; +use vars qw( $verbose_p ); + +GetOptions( + 'verbose|v' => \$verbose_p, +) || exit(1); + +print <) { chomp; if (/kohadir=(.*)/) { $kohadir=$1; } - if (/kohahtmldir=(.*)/) { - $kohahtmldir=$1; - } +# if (/kohahtmldir=(.*)/) { +# $kohahtmldir=$1; +# } } $has_kohaautobuild_conf = 1; } @@ -29,42 +86,44 @@ if (-e "$roothomedir/.kohaautobuild.conf") { my $input; print qq | -*************************************** -* Welcome to the Koha Release Builder * -*************************************** - This script will automatically build a release tarball. The script assumes that you already have the koha and koha-html modules checked out for the release that you want to build, although it will update the modules before building. - |; -print "\nWhere is the 'koha' cvs module located [$kohadir]: "; +print "\nWhere is the 'koha' cvs module located? [$kohadir]: "; chomp($input = ); if ($input) { $kohadir=$input; - $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir) unless $has_kohaautobuild_conf; +# unless ($has_kohaautobuild_conf) { +# $kohahtmldir=guess_kohahtmldir($kohadir, $kohahtmldir); +# } } -print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: "; -chomp($input = ); -if ($input) { - $kohahtmldir=$input; -} +#print "\nWhere is the 'koha-html' cvs module located [$kohahtmldir]: "; +#chomp($input = ); +#if ($input) { +# $kohahtmldir=$input; +#} open (C, ">$roothomedir/.kohaautobuild.conf"); print C qq| kohadir=$kohadir -kohahtmldir=$kohahtmldir +#kohahtmldir=$kohahtmldir |; +print STDERR "$roothomedir/.kohaautobuild.conf written\n" if $verbose_p; #---------------------------------------------------------- # which VERSION are we building ? #---------------------------------------------------------- -print "\n\nGuessing at next release version. You may need to enter your SourceForge password...\n"; -open (CVSLOG, "cvs log buildrelease|"); +print <) { if (/^symbolic names:/) { $symbolicnamessection=1; + print STDERR "Scanning symbolic names from cvs output\n" if $verbose_p; } if ($symbolicnamessection && (/^\s+([^:]*):/)) { my $tag=$1; - if ($tag=~/R_(.*)/) { + if ($tag=~/(?:R|rel)_(.*)/) { my $version=''; my $rc=0; my $id=$1; - $id=~s/-/\./g; + $id =~ s/[-_]/\./g; + print STDERR "Found a tag for release $id\n" if $verbose_p; if ($id =~/(.*)RC(.*)/) { $version=$1; $rc=$2; - $version=~m#(\d+\.\d+)\.#; + $version =~ /^(\d+\.\d+)(?:\.|[RC]|$)/; if (versioncompare($version, $majorversion->{$1})) { $majorversion->{$1}=$version; $majorversionrc->{$1}=$rc; + print STDERR "Setting major version for $1 to $version $rc\n" if $verbose_p; } if (versioncompare($version, $highestversion)) { $highestversion=$version; $released=0; $highestrc=$rc; + print STDERR "Setting highest version to $highestversion $highestrc\n" if $verbose_p; } } else { $version=$id; - $version=~m#(\d+\.\d+)\.#; + $version =~ /^(\d+\.\d+)(?:\.|[RC]|$)/; if (versioncompare($version, $majorversion->{$1})) { $majorversion->{$1}=$version; $majorversionrc->{$1}=0; + print STDERR "Setting major version for $1 to $version $rc\n" if $verbose_p; } if (versioncompare($version, $highestversion)) { $highestversion=$version; $released=1; $highestrc=0; + print STDERR "Setting highest version to $highestversion $highestrc\n" if $verbose_p; } } $symbolicnames->{$version}->{$rc}=1; + print STDERR "Setting symbolic name mapping for version $version $rc to 1\n" if $verbose_p; } } } - my $releaseversion=''; my $currentversion=''; -my $branchdata=`grep buildrelease CVS/Entries`; +my $cvs_entries_path = $self_path; +$cvs_entries_path =~ s/[^\/]+$/CVS\/Entries/; +print STDERR "Assuming CVS/Entries is $cvs_entries_path\n" if $verbose_p; + +my $branchdata=`grep buildrelease $cvs_entries_path`; chomp $branchdata; my $branch=(split(m#/#, $branchdata))[5]; - -if ($branch eq 'Trel-1-2') { - $highestversion=$majorversion->{'1.2'}; - $highestrc=$majorversionrc->{'1.2'}; +$branch =~ s/^T//; +$branch =~ s/^(?:R|rel)_//; +$branch =~ s/[-_]/./g; +print STDERR "Detected branch $branch\n" if $verbose_p; + +if ($branch =~ /\S/ && defined $majorversion->{$branch}) { + $highestversion=$majorversion->{$branch}; + $highestrc=$majorversionrc->{$branch}; ($highestrc) ? ($released=0) : ($released=1); + print STDERR "Using highest version for branch $branch\n" if $verbose_p; } if ($released) { my @components=split(/\./, $highestversion); - $components[$#components]++; - $nexthighestversion=join '.', @components; - my $minornumber=(split(/\./, $highestversion))[1]; - if ($minornumber/2 == int($minornumber/2)) { - $releaseversion=$nexthighestversion."RC1"; + if (@components < 3) { # if it's something like just 2.2 or 2.4 + $releaseversion = $highestversion.".1RC1"; } else { - $releaseversion=$nexthighestversion; + $components[$#components]++; + $nexthighestversion=join '.', @components; + my $minornumber=(split(/\./, $highestversion))[1]; + if ($minornumber/2 == int($minornumber/2)) { + $releaseversion=$nexthighestversion."RC1"; + } else { + $releaseversion=$nexthighestversion; + } } $currentversion=$highestversion; } else { @@ -152,7 +230,6 @@ my $tagging_needs_confirmation = 0; if ($input =~ /^n/i) { print "\nWould you like to rebuild the $currentversion tarball? Y/[N]: "; chomp($input = ); - print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ if ($input =~ /^y/i) { $releaseversion=$currentversion; $tagging_needs_confirmation = 1; @@ -175,10 +252,10 @@ if ($input =~ /^n/i) { print "\nWould you like to tag the CVS repository?\n(answer yes if releasing tarball) Y/[N]: "; chomp ($input=); my $cvstag=0; -# FIXME: This means anything other than n will tag; too dangerous? if ($input=~/^y/i) { $cvstag=1; } +print "The CVS repository ",($cvstag?"WILL BE TAGGED\n":"will not be tagged\n"); if ($cvstag && $tagging_needs_confirmation) { @@ -215,32 +292,19 @@ Updating your checked-out copy of the 'koha' CVS files. You may need to enter your SourceForge password. Using $kohadir. |; -chdir($kohadir); -system("cvs update"); +chdir($kohadir) || die "$kohadir: $!\n"; +# system("cvs update -P"); if ($cvstag) { print qq| Tagging koha with tag R_$tagname |; system("cvs tag -F R_$tagname"); } -print qq| -Updating your checked-out copy of the 'koha-html' CVS files. -You may need to enter your SourceForge password. -Using $kohahtmldir. -|; -chdir($kohahtmldir) || die "$kohahtmldir: $!\n"; -system("cvs update"); - -if ($cvstag) { - print qq| -Tagging koha-html with tag R_$tagname -|; - system("cvs tag -F R_$tagname"); -} #---------------------------------------------------------- # MOVE files to /tmp and build tar.gz #---------------------------------------------------------- + my $rootdir="/tmp/koha-".$releaseversion; system("rm -rf $rootdir"); mkdir ($rootdir, 0700); @@ -261,6 +325,7 @@ print KV "$releaseversion\n"; close KV; # Copy all CVS files to intranet-cgi +# FIXME: "cp -a" is GNU-ism. It is not portable. system("cp -a $kohadir/* $rootdir/intranet-cgi"); # Move C4 to modules directory @@ -270,7 +335,7 @@ system("mv $rootdir/intranet-cgi/C4 $rootdir/modules"); system("mv $rootdir/intranet-cgi/misc/info/* $rootdir"); system("mv $rootdir/intranet-cgi/misc/installer.pl $rootdir"); system("mv $rootdir/intranet-cgi/misc/koha.upgrade $rootdir"); -#system("mv $rootdir/intranet-cgi/Install.pm $rootdir"); #does not exist ?? +system("mv $rootdir/intranet-cgi/misc/Install.pm $rootdir"); #system("mv $rootdir/intranet-cgi/kohareporter $rootdir"); # does not exist ?? chmod 0770, "$rootdir/installer.pl"; chmod 0770, "$rootdir/koha.upgrade"; @@ -290,68 +355,43 @@ system("rmdir $rootdir/intranet-cgi/opac"); # Move files from intranet-cgi to /scripts/ directory -system("mv $rootdir/intranet-cgi/telnet $rootdir/scripts"); -system("mv $rootdir/intranet-cgi/tkperl $rootdir/scripts"); -system("mv $rootdir/intranet-cgi/translator $rootdir/scripts"); system("mv $rootdir/intranet-cgi/updater $rootdir/scripts"); system("mv $rootdir/intranet-cgi/misc $rootdir/scripts"); -system("mv $rootdir/intranet-cgi/marc $rootdir/scripts"); -system("mv $rootdir/intranet-cgi/misc/bulkmarcimport.pl $rootdir/scripts/z3950daemon/"); -system("mv $rootdir/intranet-cgi/z3950/* $rootdir/scripts/z3950daemon/"); +# move only batch & daemon. pl script stay here +system("mv $rootdir/intranet-cgi/z3950/processz3950queue $rootdir/scripts/z3950daemon/"); +system("mv $rootdir/intranet-cgi/z3950/*.sh $rootdir/scripts/z3950daemon/"); # Remove extraneous files from intranet-cgi system("rm -f $rootdir/intranet-cgi/ChangeLog.bak"); system("rm -f $rootdir/intranet-cgi/SendMessages"); system("rm -f $rootdir/intranet-cgi/buildrelease"); -#system("rm -f $rootdir/intranet-cgi/database.mysql"); -#system("rm -f $rootdir/intranet-cgi/installer-lite.pl"); -# FIXME: The following two lines look suspicious -#system("rm -f $rootdir/intranet-cgi/koha-1.2.0.tar.gz"); -#system("rm -f $rootdir/intranet-cgi/rel-1-2"); -#system("rm -f $rootdir/intranet-cgi/testKoha.pl"); -#system("rm -rf $rootdir/intranet-cgi/html-template"); system("rm -rf $rootdir/intranet-cgi/t"); # Set all .pl scripts executable system("find $rootdir/intranet-cgi -name '*.pl' -exec chmod a+x \\{\\} \\;"); # Copy all CVS files to intranet-html and opac-html -system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html"); -system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html"); - -# Move koha-tmpl files -system("mv $rootdir/intranet-cgi/koha-tmpl/opac-tmpl/* $rootdir/opac-html"); -system("mv $rootdir/intranet-cgi/koha-tmpl/intranet-tmpl/* $rootdir/intranet-html"); -system("rm -rf $rootdir/intranet-cgi/koha-tmpl"); - -# Remove extraneous files from opac-html -system("rm -f $rootdir/opac-html/koha.mo"); -system("rm -f $rootdir/opac-html/koha.pot"); -system("rm -f $rootdir/opac-html/test"); - -# Remove extraneous files from intranet-html -system("rm -f $rootdir/intranet-html/koha.pot"); -system("rm -f $rootdir/intranet-html/results.html"); -system("rm -f $rootdir/intranet-html/test"); +# FIXME: "cp -a" is GNU-ism. It is not portable. +#system("cp -a $kohahtmldir/intranet-html/* $rootdir/intranet-html"); +#system("cp -a $kohahtmldir/opac-html/* $rootdir/opac-html"); + +# Copy koha-tmpl files +# FIXME: "cp -a" is GNU-ism. It is not portable. +system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/opac-tmpl", "$rootdir/opac-html"); +system('cp', '-a', "$rootdir/intranet-cgi/koha-tmpl/intranet-tmpl", "$rootdir/intranet-html"); +#copy index files (they are just redirections to main.pl) +system("cp $rootdir/intranet-cgi/koha-tmpl/opac.html $rootdir/opac-html/index.html"); +system("cp $rootdir/intranet-cgi/koha-tmpl/intranet.html $rootdir/intranet-html/index.html"); +system('rm', '-rf', "$rootdir/intranet-cgi/koha-tmpl"); # Remove junk from directory system("find $rootdir -name CVS -exec rm -rf \\{\\} \\; 2>/dev/null"); system("find $rootdir -name *~ -exec rm -rf \\{\\} \\; 2>/dev/null"); system("find $rootdir -name .#* -exec rm -rf \\{\\} \\; 2>/dev/null"); - -if (-e "$roothomedir/docs") { - print "Copying docs folder from $roothomedir/docs..."; - system("cp -r $roothomedir/docs/* $rootdir/docs/"); -} else { - print "I would have copied the docs from from $roothomedir/docs, but I couldn't find it.\n"; - print "Press to continue...\n"; - ; -} - chdir("/tmp"); system("tar czf /tmp/koha-$releaseversion.tar.gz koha-".$releaseversion); -#system("rm -rf $rootdir"); +system("rm -rf $rootdir"); print qq| ============ @@ -363,6 +403,7 @@ Your new tarball is located in /tmp/koha-$releaseversion.tar.gz |; +# Given two version numbers (v1, v2), returns 0 if v1 <= v2, or 1 if v1 > v2 sub versioncompare { my $v1=shift; my $v2=shift; @@ -378,15 +419,16 @@ sub versioncompare { return 0; } -sub guess_kohahtmldir ($;$) { - my($kohadir, $default) = @_; - my $kohahtmldir; +#sub guess_kohahtmldir ($;$) { +# my($kohadir, $default) = @_; +# my $kohahtmldir; # It probably makes sense to assume that the 'koha' and 'koha-html' # modules are checked out within the same parent directory - if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) { - $kohahtmldir = "$1/koha-html" - } else { - $kohahtmldir = $default; - } - return $kohahtmldir; -} +# if (-d $kohadir && $kohadir =~ /^(.*)\/[^\/]+$/) { +# $kohahtmldir = "$1/koha-html" +# } else { +# $kohahtmldir = $default; +# } +# return $kohahtmldir; +#} +