Below is the list of changes that have just been committed into a local
5.1 repository of mysqldev. When mysqldev does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-12-21 14:05:15+01:00, tulin@stripped +1 -0
mysql-copyright:
BitKeeper file /data0/mysqldev/users/tomas/mysql-5.1-wl2325-5.0-drop6/mysql-copyright
mysql-copyright@stripped, 2006-12-21 14:04:12+01:00, tulin@stripped +441 -0
BitKeeper file /data0/mysqldev/users/tomas/mysql-5.1-wl2325-5.0-drop6/mysql-copyright
mysql-copyright@stripped, 2006-12-21 14:04:12+01:00, tulin@stripped +0 -0
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: tulin
# Host: production.mysql.com
# Root: /data0/mysqldev/users/tomas/mysql-5.1-wl2325-5.0-drop6
--- New file ---
+++ mysql-copyright 06/12/21 14:04:12
#!/usr/bin/perl -wi
# -*- cperl -*-
# Untar a MySQL distribution, change the copyright texts,
# pack it up again to a given directory
use Cwd;
use File::Basename;
use File::Copy;
use File::Find;
use File::Path;
use FindBin;
use Getopt::Long;
use strict;
use diagnostics;
my $win_flag = 0;
my $destdir= "";
my $cwd= cwd();
my $opt= {
'target'=> $cwd,
};
Getopt::Long::Configure("bundling");
GetOptions(
$opt,
"help|h",
"target=s",
"verbose|v",
) or usage("Invalid flag given");
usage() if $opt->{'help'};
usage("No argument given") unless @ARGV;
my $vflag= $opt->{verbose} ? "-v" : "";
$opt->{'target'}= "$cwd/$opt->{'target'}" unless $opt->{'target'}=~ m,^/,;
print "Target directory is $opt->{'target'}\n" if $opt->{'verbose'};
my $REG_BASENAME = '[a-zA-Z\d\+]+';
my $REG_VERSION = '[\d\.]+[a-z]?(?:.alpha|.beta|.gamma|.rc|pre\d)?(?:-\d+)?';
# '?:' above is needed so that the parenthesis does not count as '$4' far below.
# The last digit string is to support "Bootstrap ... --suffix=YMD".
# We need to find the new "LICENSE.mysql" file in the internal tree
my $lic_path= "/data0/mysqldev/my/internals/build/docs/LICENSE.mysql";
usage("Can't find \"$lic_path\"") unless -f $lic_path;
`mkdir -p $opt->{'target'}` or die "Couldn't make the target directory: $!\n"
unless -d $opt->{'target'};
foreach my $gpl_distfile ( @ARGV )
{
-f $gpl_distfile or usage("Invalid path to TAR: $gpl_distfile");
$win_flag= $gpl_distfile=~ /win-src/;
print "This seems to be a windows source distribution\n"
if $opt->{'verbose'} and $win_flag;
$gpl_distfile= "$cwd/$gpl_distfile" unless $gpl_distfile=~ m,^/,;
print "Converting $gpl_distfile\n" if $opt->{'verbose'};
#
# $gpl_distfile is now the absolute path to the TAR package file, split it up
#
my $gpl_distname= basename($gpl_distfile);
my $gpl_distdir= dirname($gpl_distfile);
#
# Create temporary work directory and enter it
#
my $tmpdir= "$cwd/mysql-copyright-$$-" . time() . ".tmp";
print "Creating and entering $tmpdir\n" if $opt->{'verbose'};
mkdir($tmpdir, 0700) or die "Couldn't make directory $tmpdir: $!\n";
chdir($tmpdir) or abort($tmpdir, "Couldn't cd to $tmpdir: $!\n");
# if the distfile is mysql-3.22.22-alpha.tar.gz, then
# distname is 'mysql-3.22.22-alpha' and fileext '.tar.gz',
# suffix is '-win-src' or empty.
# mysql-4.1.14-br5210.tar.gz
# The new TAR will have exactly the same name but "mysql" => "mysqlcom"
my $com_distname= $gpl_distname;
$com_distname =~ s/^($REG_BASENAME)/${1}com/
or die "Could not change the name to include the \"com\" string";
my $com_distfile= "$opt->{'target'}/$com_distname";
# The unpacked directory will not have a "-win-src" in it
my $gpl_distrdir= $gpl_distname;
my $com_distrdir= $com_distname;
foreach my $name ( $gpl_distrdir, $com_distrdir )
{
$name =~ s/(\.tar\.gz|\.tgz)$//; # Remove ending
$name =~ s/-win-src//; # and win source part if any
}
# find out the extract path (should be same as distname!)
chomp($destdir= `tar -ztf $gpl_distfile | head -1`);
# FIXME error checking!!!
$destdir=~ s,/+$,,; # remove slash from the end
if ($destdir ne $gpl_distrdir)
{
print "Destination directory '$destdir' (the directory that will be extracted\n";
print "from the original distribution file) differs from the\n";
print "distribution name '$gpl_distname'! Are you sure you want to continue? (Y/N) [N]:";
my $ans= my_read(1);
abort($tmpdir, "Aborted!") if $ans ne "Y" and $ans ne "y";
}
# everything should be ok, continue with extracting..
system("tar $vflag -zxf $gpl_distfile") == 0
or abort($tmpdir, "Extracting from $gpl_distfile failed!");
# remove the 'PUBLIC' file from distribution and copy new license file
# on the toplevel of the directory instead. file 'PUBLIC' shouldn't
# exist in the new mysql distributions, but let's be sure..
foreach my $destrpath ( "PUBLIC", "README", "COPYING", "EXCEPTIONS-CLIENT",
"Docs/LICENSE.mysql")
{
unlink("$destdir/$destrpath")
or print "WARNING: Can't remove/find $destrpath, ignored\n";
}
copy($lic_path, $destdir) or die("Can't copy the \"$lic_path\" file!");
# remove subdirectories 'bdb', 'cmd-line-utils/readline'
my @noncommercial_dirs= ('bdb', 'storage/bdb', 'cmd-line-utils/readline');
my @noncommercial_engines= ("berkeley");
remove_non_commercial($destdir,
\@noncommercial_dirs, \@noncommercial_engines);
# fix file copyrights
fix_usage_copyright();
add_copyright();
# fix LICENSE tag in include/mysql_version.h
fix_mysql_version($destdir);
# fix DIST_DIR (kind of temprary solution FIXME)
fix_cmd_line_makefile($destdir);
# apply "autotools" - must be last to ensure proper timestamps
run_autotools($destdir);
# rename the directory with new distribution name
chdir($tmpdir);
print "Renaming $destdir $com_distrdir\n" if $opt->{'verbose'};
rename($destdir, $com_distrdir);
# tar the new distribution
print "Creating new distribution \"$com_distfile\"\n"
if $opt->{'verbose'};
system("tar -czf $com_distfile $com_distrdir") == 0
or abort($tmpdir, "Making new tar archive failed!\n");
# remove temporary directory
chdir($cwd) or die "Unable to move back to $cwd: $!\n";
print "Current dir is $cwd, removing $tmpdir\n" if $opt->{'verbose'} ;
rmtree($tmpdir) or print "WARNING: Unable to delete $tmpdir\n";
}
exit(0);
####
#### This function will s/GPL/Commercial/ in include/mysql_version.h for the
#### LICENSE tag.
####
sub fix_mysql_version
{
my $destdir= shift;
my $cwd= cwd();
chdir($destdir);
my $header_file= (-f 'include/mysql_version.h.in')? 'include/mysql_version.h.in' : 'include/mysql_version.h';
open(MYSQL_VERSION, $header_file) or die "Unable to open $header_file for read: $!\n";
undef $/;
my $mysql_version= <MYSQL_VERSION>;
close(MYSQL_VERSION);
$mysql_version=~ s/\#define LICENSE[\s\t]+GPL/#define LICENSE Commercial/;
open(MYSQL_VERSION,">$header_file") or die "Unable to open $header_file for write: $!\n";
print MYSQL_VERSION $mysql_version;
close(MYSQL_VERSION);
chdir($cwd);
}
####
#### fix DIST_DIR (kind of temprary solution FIXME)
####
sub fix_cmd_line_makefile
{
my $destdir= shift;
my $cwd= cwd();
chdir($destdir);
my $make_file= "cmd-line-utils/Makefile.am";
return unless -f $make_file;
open(MAKEFILE_AM, $make_file) or die "Unable to open $make_file for read: $!\n";
undef $/;
my $text= <MAKEFILE_AM>;
close(MAKEFILE_AM);
$text=~ s/\breadline\b//g;
open(MAKEFILE_AM,">$make_file") or die "Unable to open $make_file for write: $!\n";
print MAKEFILE_AM $text;
close(MAKEFILE_AM);
chdir($cwd);
}
####
#### This function will remove unwanted parts of a src tree for the mysqlcom
#### distributions.
####
sub remove_non_commercial
{
my ($destdir, $dirs, $engines)= @_;
my $config_in;
unless ( $win_flag )
{
print "Updating configure for the removed directories/engines\n";
open(CONFIG_IN,"$destdir/configure.in")
or die "Unable to open configure.in for read: $!\n";
undef $/;
$config_in= <CONFIG_IN>;
close(CONFIG_IN);
}
foreach my $rdir ( @$dirs )
{
my $dir= "$destdir/$rdir";
unless ( -d $dir )
{
print "WARNING: Can't find '$dir' to remove, ignored\n";
next;
}
print "Removing '$dir'\n";
rmtree($dir) or die "Can't remove $dir";
#
# If $dir Makefile line closes the parenthesis, then
# replace that line with just the closing parenthesis.
# Else just delete the line
#
unless ( $win_flag )
{
$config_in =~ s|AC_CONFIG_FILES\s*\(\s*${rdir}/Makefile\s*\)|| or
$config_in =~ s|${rdir}/Makefile(\)\n?)|$1| or
$config_in =~ s|${rdir}/Makefile dnl\n?|| or
print "WARNING: Nothing to change in configure for '$rdir'\n";
}
}
unless ( $win_flag )
{
# In 5.1 engines are handled differently
foreach my $engine ( @$engines )
{
$config_in =~ s/^MYSQL_STORAGE_ENGINE\s*\(\s*$engine\b[^\)]+\)//m
or print "WARNING: No MYSQL_STORAGE_ENGINE($engine....)\n";
}
open(CONFIG_IN,">$destdir/configure.in")
or die "Unable to open configure.in for write: $!\n";
print CONFIG_IN $config_in;
close(CONFIG_IN);
}
}
####
#### This function will run the autotools on the reduced source tree.
####
sub run_autotools
{
my $destdir= shift;
my $cwd= cwd();
if (!$win_flag)
{
print "Running the autotools\n" if $opt->{'verbose'};
chdir($destdir);
unlink ("configure") or die "Can't delete $destdir/configure: $!\n";
# File "configure.in" has already been modified by remove_non_commercial()
# It must be ensured that the timestamps of the relevant files are really
# ascending, for otherwise the Makefile may cause a re-run of these
# autotools. Experience shows that deletion is the only safe way.
unlink ("config.h.in") or die "Can't delete $destdir/config.h.in: $!\n";
unlink ("aclocal.m4") or die "Can't delete $destdir/aclocal.m4: $!\n";
# These sleep commands also ensure the ascending order.
`aclocal && sleep 2 && autoheader && sleep 2 && automake && sleep 2 && autoconf`;
die "'./configure' was not produced!" unless -f "configure";
# FIXME there are "autom4te.cache" directories at other levels as well
if (-d "autom4te.cache")
{
print "Trying to delete autom4te.cache dir\n" if $opt->{'verbose'};
rmtree("autom4te.cache") or die "Can't remove autom4te.cache dir: $!\n";
}
chdir($cwd);
}
}
####
#### mysqld and MySQL client programs have a usage printed with --help.
#### This usage includes a copyright, which needs to be modified
####
sub fix_usage_copyright
{
print "Fixing the usage output\n" if $opt->{'verbose'};
find(sub
{
return unless -f $_ and /\.c.{0,2}$/;
print "\tprocessing file $_ in cwd $File::Find:dir\n" if $opt->{'verbose'};
my $cmd= join(" ",
"replace",
"'This software comes with ABSOLUTELY NO WARRANTY. '",
"''",
"'This software comes with NO WARRANTY: '",
"''",
"'This is free software,'",
"'This is commercial software, and use of this software is governed'",
"'and you are welcome to modify and redistribute it under the GPL license'",
"'by your applicable license agreement with MySQL'",
"--",
"'$_'");
`$cmd`;
}, ".");
}
####
#### change the copyright text in the beginning of the files
####
sub add_copyright
{
print "Adding the copyright headers\n" if $opt->{'verbose'};
find(sub
{
return if ! -f $_ or -B $_;
print "\tprocessing file $_ in cwd $File::Find:dir\n" if $opt->{'verbose'};
`$FindBin::Bin/mysql-copyright-2 "$_"`;
}, ".");
}
####
#### read stdin
####
sub my_read
{
my $length= shift; # Max allowed length for the string.
my $input= getc(STDIN);
if($input eq "\n")
{
return "\n";
}
for(my $new_input= getc(STDIN); $new_input ne "\n" ;)
{
if(length($input) < $length)
{
$input.= $new_input;
}
$new_input= getc(STDIN);
}
return $input;
}
####
#### abort
####
sub abort
{
my ($dir, $errstr)= @_;
# remove newly made directory and it's contents
print "$errstr\n";
chdir ($cwd);
print "Removing directory $dir...\n" if $opt->{'verbose'};
rmtree($dir);
exit(0);
}
####
#### usage
####
sub usage
{
my $msg= shift;
print "\n$msg\n" if $msg;
print <<EOF;
$0 by Jani Tolonen
This program takes one or more MySQL distributions as an argument(s),
extracts them, changes the copyright text in the distribution files
and makes a new distribution with prefix "com" in the target
directory. Some source directories are removed that are not to be
part of a commercial distribution.
The target directory can be changed with option --target=<directory>,
if not set the target directory is the current directory.
mysql-copyright consists of two perl programs, this one and another,
mysql-copyright-2. Make sure the second part of the script is available
to the main script.
Usage: $0 [options] file1 [file2 file3...]
Options:
--help, -h Show this help and exit.
--target Target directory for new distribution files.
(Default is the current directory)
--verbose, -v Verbose execution
EOF
exit(0);
}
| Thread |
|---|
| • bk commit into 5.1 tree (tulin:1.2092) | tomas | 21 Dec |