[Koha-cvs] CVS: koha/misc buildrelease,1.23,1.23.2.1

Ambrose C. LI acli at users.sourceforge.net
Sat Jan 15 06:51:37 CET 2005


Update of /cvsroot/koha/koha/misc
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9389

Modified Files:
      Tag: rel_2_2
	buildrelease 
Log Message:
Taught buildrelease what the misc directory and release 2.2 is, and also
that version numbers might only have 1 dot. This should fix bugs 889, 890.

A --verbose or -v option has been added in the process of doing the above.

It now chdir to .. if it discovers that it is being run inside misc, since
running it inside misc screws up various things, and I never remember
whether it should be run inside misc or not.

A confirmation message about whether to tag or not is now displayed after
the user answers the question about tagging. I have never felt safe not
having the release builder confirm with me that I really am not tagging
anything.


Index: buildrelease
===================================================================
RCS file: /cvsroot/koha/koha/misc/buildrelease,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -C2 -r1.23 -r1.23.2.1
*** buildrelease	5 Jan 2005 14:31:06 -0000	1.23
--- buildrelease	15 Jan 2005 05:51:35 -0000	1.23.2.1
***************
*** 1,4 ****
--- 1,60 ----
  #!/usr/bin/perl
+ # This script uses standard 8-space tabs with 4-space indents
+ # vi users can :set sw=4 ai sm
  
+ use Getopt::Long;
+ use vars qw( $verbose_p );
+ 
+ GetOptions(
+     'verbose|v' => \$verbose_p,
+ ) || exit(1);
+ 
+ print <<EOM;
+ ***************************************
+ * Welcome to the Koha Release Builder *
+ ***************************************
+ EOM
+ 
+ #----------------------------------------------------------
+ # To guess the version, we need to first guess where this
+ # script itself is Otherwise we will have different results
+ # depending on whether the script is called as ./buildrelease
+ # or misc/buildrelease. If we run the script from misc, we
+ # will also get errors from "cvs update" later, so this is
+ # rather important information
+ #----------------------------------------------------------
+ print STDERR "Perl reports that buildrelease is $0\n" if $verbose_p;
+ my $self_path;
+ if ($0 =~ /^(\.\/)*buildrelease$/) {
+     $self_path = 'buildrelease';
+ } elsif ($0 =~ /^(?:(\.\/)*\/)?misc\/buildrelease$/) {
+     $self_path = 'misc/buildrelease';
+ } else {
+     print <<EOM;
+ 
+ WARNING: Unable to determine where the buildrelease script is located.
+          The version number guessed by the next step might be wrong.
+ EOM
+     $self_path = (-f 'buildrelease')? 'buildrelease': 'misc/buildrelease';
+ }
+ print STDERR "Assuming buildrelease is $self_path\n" if $verbose_p;
+ 
+ #----------------------------------------------------------
+ # Fixup the current directory
+ #----------------------------------------------------------
+ if ($self_path eq 'buildrelease') {
+     print <<EOM;
+ 
+ WARNING: You should run the buildrelease script from the top of the koha
+          CVS module.  I will try to change to the correct directory, but
+          it is better if you had ran this script there in the first place.
+ EOM
+     chdir ".." || die "..: chdir: $!\n";
+     $self_path = 'misc/buildrelease';
+ }
+ 
+ #----------------------------------------------------------
+ # Start the release builder
+ #----------------------------------------------------------
  #sub guess_kohahtmldir ($;$);
  #----------------------------------------------------------
***************
*** 14,17 ****
--- 70,74 ----
  
  if (-e "$roothomedir/.kohaautobuild.conf") {
+     print STDERR "$roothomedir/.kohaautobuild.conf found\n" if $verbose_p;
      open C, "<$roothomedir/.kohaautobuild.conf";
      while (<C>) {
***************
*** 30,37 ****
  
  print qq |
- ***************************************
- * Welcome to the Koha Release Builder *
- ***************************************
- 
  This script will automatically build a release tarball.
  
--- 87,90 ----
***************
*** 39,45 ****
  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]: ";
  chomp($input = <STDIN>);
  if ($input) {
--- 92,97 ----
  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]: ";
  chomp($input = <STDIN>);
  if ($input) {
***************
*** 62,72 ****
  #kohahtmldir=$kohahtmldir
  |;
  
  #----------------------------------------------------------
  # which VERSION are we building ?
  #----------------------------------------------------------
! print "\n\nGuessing at next release version.  You may need to enter your SourceForge password...\n";
  chdir $kohadir;
! open (CVSLOG, "cvs log misc/buildrelease|");
  my $symbolicnamessection=0;
  my $symbolicnames;
--- 114,128 ----
  #kohahtmldir=$kohahtmldir
  |;
+ print STDERR "$roothomedir/.kohaautobuild.conf written\n" if $verbose_p;
  
  #----------------------------------------------------------
  # which VERSION are we building ?
  #----------------------------------------------------------
! print <<EOM;
! 
! Guessing the next release version. You may need to enter your SourceForge password.
! EOM
  chdir $kohadir;
! open (CVSLOG, "cvs log $self_path|");
  my $symbolicnamessection=0;
  my $symbolicnames;
***************
*** 79,97 ****
      if (/^symbolic names:/) {
  	$symbolicnamessection=1;
      }
      if ($symbolicnamessection && (/^\s+([^:]*):/)) {
  	my $tag=$1;
! 	if ($tag=~/R_(.*)/) {
  	    my $version='';
  	    my $rc=0;
  	    my $id=$1;
! 	    $id=~s/-/\./g;
  	    if ($id =~/(.*)RC(.*)/) {
  		$version=$1;
  		$rc=$2;
! 		$version=~m#(\d+\.\d+)\.#;
  		if (versioncompare($version, $majorversion->{$1})) {
  		    $majorversion->{$1}=$version;
  		    $majorversionrc->{$1}=$rc;
  		}
  		if (versioncompare($version, $highestversion)) {
--- 135,156 ----
      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|rel)_(.*)/) {
  	    my $version='';
  	    my $rc=0;
  	    my $id=$1;
! 	    $id =~ s/[-_]/\./g;
! 	    print STDERR "Found a tag for release $id\n" if $verbose_p;
  	    if ($id =~/(.*)RC(.*)/) {
  		$version=$1;
  		$rc=$2;
! 		$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)) {
***************
*** 99,109 ****
  		    $released=0;
  		    $highestrc=$rc;
  		}
  	    } else {
  		$version=$id;
! 		$version=~m#(\d+\.\d+)\.#;
  		if (versioncompare($version, $majorversion->{$1})) {
  		    $majorversion->{$1}=$version;
  		    $majorversionrc->{$1}=0;
  		}
  		if (versioncompare($version, $highestversion)) {
--- 158,170 ----
  		    $released=0;
  		    $highestrc=$rc;
+ 		    print STDERR "Setting highest version to $highestversion $highestrc\n" if $verbose_p;
  		}
  	    } else {
  		$version=$id;
! 		$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)) {
***************
*** 111,117 ****
--- 172,180 ----
  		    $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;
  	}
      }
***************
*** 121,143 ****
  my $currentversion='';
  
! my $branchdata=`grep buildrelease CVS/Entries`;
  chomp $branchdata;
  my $branch=(split(m#/#, $branchdata))[5];
! 
! if ($branch eq 'Trel-1-2') {
!     $highestversion=$majorversion->{'1.2'};
!     $highestrc=$majorversionrc->{'1.2'};
      ($highestrc) ? ($released=0) : ($released=1);
  }
  
  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";
      } else {
! 	$releaseversion=$nexthighestversion;
      }
      $currentversion=$highestversion;
--- 184,219 ----
  my $currentversion='';
  
! 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];
! $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);
!     if (@components < 3) { # if it's something like just 2.2 or 2.4
! 	$releaseversion = $highestversion.".1RC1";
      } else {
! 	$components[$#components]++;
! 	$nexthighestversion=join '.', @components;
! 	my $minornumber=(split(/\./, $highestversion))[1];
! 	if ($minornumber/2 == int($minornumber/2)) {
! 	    $releaseversion=$nexthighestversion."RC1";
! 	} else {
! 	    $releaseversion=$nexthighestversion;
! 	}
      }
      $currentversion=$highestversion;
***************
*** 155,159 ****
      print "\nWould you like to rebuild the $currentversion tarball?  Y/[N]: ";
      chomp($input = <STDIN>);
-     print STDERR "releaseversion=($releaseversion), currentversion=($currentversion)\n";#XXXZZZ
      if ($input =~ /^y/i) {
  	$releaseversion=$currentversion;
--- 231,234 ----
***************
*** 178,185 ****
  chomp ($input=<STDIN>);
  my $cvstag=0;
- # FIXME: This means anything other than n will tag; too dangerous?
  if ($input=~/^y/i) {
      $cvstag=1;
  }
  
  
--- 253,260 ----
  chomp ($input=<STDIN>);
  my $cvstag=0;
  if ($input=~/^y/i) {
      $cvstag=1;
  }
+ print "The CVS repository ",($cvstag?"WILL BE TAGGED\n":"will not be tagged\n");
  
  
***************
*** 329,332 ****
--- 404,408 ----
  
  
+ # Given two version numbers (v1, v2), returns 0 if v1 <= v2, or 1 if v1 > v2
  sub versioncompare {
      my $v1=shift;





More information about the Koha-cvs mailing list