Commit a86e6f17 authored by unknown's avatar unknown
Browse files

mysql-copyright:

  Fixed various issues to deal with untarring of gpl tar file, clearing configure.in, changed calls to use system vs. backticks


Build-tools/mysql-copyright:
  Fixed various issues to deal with untarring of gpl tar file, clearing configure.in, changed calls to use system vs. backticks
parent fe940003
Loading
Loading
Loading
Loading
+43 −16
Original line number Diff line number Diff line
@@ -12,15 +12,17 @@ use Getopt::Long;

$opt_help    = 0;
$opt_version = 0;
$opt_verbose = 0;
$opt_target  = "mysql-copyright-target-";
$opt_target .= `date +%d%m%y-%H%M%S`;
chop $opt_target;

GetOptions("help","version","target=s") || error();
GetOptions("help","version","target=s", "verbose") || error();

# fix the directory prefix for target dir

$WD= cwd();
my $win_flag = 0;
$opt_target= $WD . '/' . $opt_target;

&main();
@@ -50,6 +52,7 @@ sub main
  for ($i=0; $ARGV[$i]; $i++)
  {
    my $distfile= $ARGV[$i];
    $win_flag = ($distfile =~ /win-src/) ? 1 : 0;
    my $dir;

    $dir= "mysql-copyright-";    
@@ -66,20 +69,19 @@ sub main
    }
    # if the distfile is mysql-3.22.22-alpha.tar.gz, then
    # distname is 'mysql-3.22.22-alpha' and suffix '.tar.gz'
    if ($distfile =~ m/^($REG_BASENAME)([\-\_])
	($REG_VERSION){1}([\.\-\+])
	(.*)?$/xo) 
    if ($distfile =~
      m/^($REG_BASENAME)([\-\_])($REG_VERSION){1}([\.\-\+]\w+\-\w+)?[\.\-\+](.*)?$/xo) 
    {
      $distname= $1.$2.$3;
      $suffix= $5.$6;
      $suffix= $5;
      $fileext = $6;
      $newdistname= $1."com".$2.$3;
      $newdistname .= $suffix if $win_flag;
    }
    # find out the extract path (should be same as distname!)
    chomp($destdir= `tar ztf ../$distfile | head -1`);
    # remove slash from the end
    $destdir= substr($destdir, 0, -1);
		print "destdir: $destdir\n";
		print "distname: $distname\n";
    
    if ("$destdir" ne "$distname")
    {
@@ -103,26 +105,49 @@ sub main
    
    # remove readline subdir and update configure accordingly
    system("rm -rf $destdir/cmd-line-utils/readline");
		unlink ("$destdir/configure") or die "Can't delete $destdir/configure: $!\n";
		`(cd $destdir ; sed -e 's!\ cmd-line-utils\/readline\/Makefile\ dnl!!g' < configure.in > configure.in.new)`;
		rename ("$destdir/configure.in.new","$destdir/configure.in") or die "Can't rename $destdir/configure.in.new: $!\n";;
		`(cd $destdir ; autoconf)`;
    if ($win_flag) {
      chdir("$destdir") or (print "$! Unable to change directory to $desdir!\n" && exit(0));
    } else {
      chdir("$destdir");
      unlink ("configure") or die "Can't delete $destdir/configure: $!\n";
      open(CONFIGURE,"<configure.in") or die "$! Unable to open configure.in to read from!\n";
      undef $/;
      my $configure = <CONFIGURE>;
      close(CONFIGURE);
      $configure =~ s|cmd\-line\-utils/readline/Makefile dnl\n?||g;
      open(CONFIGURE,">configure.in") or die "$! Unable to open configure.in to write to!\n";
      print CONFIGURE $configure;
      close(CONFIGURE);
      `autoconf`;
      if (! -f "configure") {
        print "\"./configure\" was not produced, exiting!\n";
        exit(0);
      }
    }

    # fix file copyrights
    &fix_usage_copyright();
    &add_copyright();
    
    # rename the directory with new distribution name
    chdir("$WD/$dir");
    print "renaming $destdir $newdistname\n" if $opt_verbose; 
    rename($destdir, $newdistname);
    
    # tar the new distribution
    `tar cz -f $opt_target/$newdistname.tar.gz *`;
    `tar cz -f $WD/$newdistname.tar.gz $newdistname`;
    $pec= $? >> 8;
    abort($dir, "Making new tar archive failed!\n") if ($pec);
  
    # remove temporary directory
    chdir "..";
    `rm -rf $dir/`;
    chdir($WD) or print "$! Unable to move up one dir\n";
    my $cwd = getcwd();
    print "current dir is $cwd\n" if $opt_verbose ;
    print "deleting temp dir $dir\n" if $opt_verbose; 
    if (-d $dir) {
      system("rm -rf $dir") or print "$! Unable to delete $dir!\n";
    }

  }
  exit(0);
}  
@@ -138,7 +163,7 @@ sub fix_usage_copyright
  foreach my $Cfile (@Cfiles)
  {
    chop $Cfile;
    `replace "This is free software," "This is commercial software," "and you are welcome to modify and redistribute it under the GPL license" "please see the file MySQLEULA.txt for details" -- $Cfile`;
    `replace "This is free software," "This is commercial software," "and you are welcome to modify and redistribute it under the GPL license" "please see the file MySQLEULA.txt for details" -- "$Cfile"` if -f $Cfile; 
  }
}

@@ -152,7 +177,9 @@ sub add_copyright
  foreach my $file (@files)
  {
    chop $file;
    `$WD/Build-tools/mysql-copyright-2 $file`;
    next if ! -f $file;
    next if -B $file;
    `$WD/Build-tools/mysql-copyright-2 "$file"`;
  }
}