Commit e621d27c authored by unknown's avatar unknown

- Cleanup: removed obsolete build tools (build toolchain is now maintained sepearately)


BitKeeper/deleted/.del-Bootstrap~bfc426bd800ccc3a:
  Delete: Build-tools/Bootstrap
BitKeeper/deleted/.del-Do-pkg~5079e47cde0baad8:
  Delete: Build-tools/Do-pkg
BitKeeper/deleted/.del-logger.pm~9234101b5b668373:
  Delete: Build-tools/logger.pm
BitKeeper/deleted/.del-Do-rpm~c0ef3ebafbf53117:
  Delete: Build-tools/Do-rpm
BitKeeper/deleted/.del-cvs-sanity-check~a3c58acf37f27cee:
  Delete: Build-tools/cvs-sanity-check
BitKeeper/deleted/.del-Do-all-build-steps~bb7d38f34728ac06:
  Delete: Build-tools/Do-all-build-steps
BitKeeper/deleted/.del-Do-local-patch-file~b86e1bfa3b7c13d3:
  Delete: Build-tools/Do-local-patch-file
BitKeeper/deleted/.del-Do-linux-build~b3b941454648a285:
  Delete: Build-tools/Do-linux-build
BitKeeper/deleted/.del-Do-patch-file~a2e87df5f75fd496:
  Delete: Build-tools/Do-patch-file
BitKeeper/deleted/.del-newest~2dd91db13f2ea308:
  Delete: Build-tools/newest
BitKeeper/deleted/.del-Do-create-perl-rpms~1f946e7d8560b3d0:
  Delete: Build-tools/Do-create-perl-rpms
BitKeeper/deleted/.del-Do-win-build~cb5c5e1df8b3de6:
  Delete: Build-tools/Do-win-build
BitKeeper/deleted/.del-my_md5sum~4680250631e4fd9:
  Delete: Build-tools/my_md5sum
BitKeeper/deleted/.del-Do-compile~d1a6d7e535befea3:
  Delete: Build-tools/Do-compile
BitKeeper/deleted/.del-mysql-copyright~56fc330ae63cfe03:
  Delete: Build-tools/mysql-copyright
BitKeeper/deleted/.del-mysql-copyright-2~e73ec01547206fec:
  Delete: Build-tools/mysql-copyright-2
parent 7a2a7de2
This diff is collapsed.
#!/bin/sh
WD=`pwd`
# Don't write a wrong path for BD !!!!!
if [ -w /my/tmp ]
then
BD=/my/tmp/BUILD
elif [ -n "$TMPDIR" ]
then
BD=$TMPDIR/BUILD
else
BD=/tmp/BUILD
fi
TMP_SCRIPT=$WD/Logs/00-temp-for-do-all-build-steps.$$
# We build on work
to_host=`hostname`
cc=gcc
ccc=gcc
EXTRA_CONFIG="--without-perl"
#AM_MAKEFLAGS="-j 2"
echo "Building on $to_host"
rm -rf $BD/*
rm -f $WD/binary/*
mkdir -p $WD/binary
mkdir -p $WD/Logs
mkdir -p $BD/Logs
cat > $TMP_SCRIPT <<END
# Show executed commands
set -x
# Move to the right place
cd "$WD"
# Create a build directory tree
bk export $BD
cd "$BD"
chmod -R u+rw,g+rw .
# Make it easy to remove an old build
umask 002
CC=$cc CXX=$ccc
export CC CXX
gmake -j 2 -k distclean
rm -f NEW-RPMS/*
# Stop on error
set -e
/bin/rm -f */.deps/*.P
/bin/rm -f config.cache
aclocal; autoheader; aclocal; automake; autoconf
(cd bdb/dist && sh s_all)
(cd innobase && aclocal && autoheader && aclocal && automake && autoconf)
# A normal user starts here. We must use mit-threads, bdb and innodb.
# Otherwise they do not end up in the distribution.
./configure \
--with-unix-socket-path=/var/tmp/mysql.sock \
--with-low-memory \
--with-mit-threads=yes $EXTRA_CONFIG \
--enable-thread-safe-client \
--enable-local-infile \
--with-berkeley-db \
--with-innodb \
--with-vio \
--without-pstack \
--with-extra-tools \
--with-embedded-server
gmake -j 2
time gmake -j 2 distcheck \
EXTRA_CONF_ARGS="--with-unix-socket-path=/var/tmp/mysql.sock --with-low-memory $EXTRA_CONFIG"
sh $BD/Build-tools/Do-rpm $*
rm -f $TMP_SCRIPT
END
set -e
log=$WD/Logs/Log-distcheck-`date +%y%m%d-%H%M`
echo "Logging script $TMP_SCRIPT into $log"
if test $to_host = "mysql-work"
then
# Try to get the right user for MySQL builds on work so that all
# files is owned by the same user (mysql)
ssh -n $to_host -l my "time sh $TMP_SCRIPT" > $log 2>&1
else
time sh $TMP_SCRIPT > $log 2>&1
fi
# Create a commercial MySQL distribution (mysqlcom-VER.tar.gz) from
# the newly made source distribution
cd "$BD"
DIST=`ls -t mysql-*.tar.gz | head -1`
$BD/Build-tools/mysql-copyright --target=. $DIST
# move the binaries to the 'binary' directory
mv $BD/mysql*tar.gz $WD/binary
mv $BD/NEW-RPMS/* $WD/binary
This diff is collapsed.
#!/bin/bash
PM_FILES='Data-Dumper Data-ShowTable DBI Msql-Mysql-modules'
FILE_EXT='tar.gz'
ARCH=`uname -m | perl -p -e 's/^i[0-9]86$/i386/'`
# directories
[ -d /usr/src/redhat ] && RPM_SRC=/usr/src/redhat
[ -d /usr/src/packages ] && RPM_SRC=/usr/src/packages
SRC_DIR=/home/matt/work/pm_rpm/tarballs # pristine tarballs
DEST_DIR=${RPM_SRC}/SOURCES # RPM SOURCES (building area)
RPM_DEPOSIT=/var/tmp/ftp/RPMS # RPM production deposit
SRPM_DEPOSIT=/var/tmp/ftp/SRPMS # SRPM production deposit
# keyword replacement for SPEC templates
REPLACE_KEY='REPLACE_VERSION'
# paths to beloved programs
NEWEST=/home/matt/work/build_pm_rpms/newest
REPLACE=/usr/local/bin/replace
#++
# Copy the source tarballs up to staging area for RPM building.
#--
cd $SRC_DIR
for i in $PM_FILES
do
echo Copying $i...
cp ${SRC_DIR}/`$NEWEST -s $SRC_DIR -b $i -t $FILE_EXT` $DEST_DIR
done
#++
# Do keyword replacements on the SPEC templates, and build RPMS
#--
cd ${RPM_SRC}/SPECS
for i in $PM_FILES
do
cat ${i}.spec.template | $REPLACE $REPLACE_KEY `$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v` > ${i}.spec
rpm -ba ${i}.spec
rm ${i}.spec
done
#++
# Copy new RPMS and SRPMS to production deposit
#--
cd $RPM_SRC
# kludge code
PM_FILES=`echo $PM_FILES | $REPLACE Msql-Mysql-modules DBD-Mysql`
tmpv=`$NEWEST -s $DEST_DIR -b Msql-Mysql-modules -t $FILE_EXT -v`
mv SOURCES/Msql-Mysql-modules-${tmpv}.${FILE_EXT} SOURCES/DBD-Mysql-${tmpv}.${FILE_EXT}
for i in $PM_FILES
do
cp RPMS/${ARCH}/${i}-`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v`-1.${ARCH}.rpm $RPM_DEPOSIT
cp SRPMS/${i}-`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT -v`-1.src.rpm $SRPM_DEPOSIT
rm SOURCES/`$NEWEST -s $DEST_DIR -b $i -t $FILE_EXT`
done
#! /bin/sh
set -e -x
# Only use the "--with-other-libc" parameter, if another libc actually
# exists, since this will also force static linking, which does not work
# together with OpenSSL
OTHER_LIBC_DIR=/usr/local/mysql-glibc
OTHER_LIBC=""
if [ -d OTHER_LIBC_DIR ] ; then
OTHER_LIBC="--with-other-libc=$OTHER_LIBC_DIR"
fi
BUILD/compile-pentium-max $OTHER_LIBC \
--with-comment="Official MySQL Binary" \
--prefix=/usr/local/mysql --with-extra-charset=complex \
--enable-thread-safe-client --enable-local-infile \
--with-server-suffix=-max
nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz
scripts/make_binary_distribution
make dist
Build-tools/Do-rpm --local
BUILD/compile-pentium --with-other-libc=$OTHER_LIBC_DIR \
--with-comment="Official MySQL Binary" \
--prefix=/usr/local/mysql --with-extra-charset=complex \
--enable-thread-safe-client --enable-local-infile
nm -n sql/mysqld | gzip -9 -v 2>&1 > sql/mysqld.sym.gz
scripts/make_binary_distribution
#!/bin/sh
# make a patch file of a mysql distribution
# takes as argument the previous version
case $# in
0) echo Usage: $0 previous_version; exit 1;;
esac
PVER=$1;
VER=`grep SERVER_VERSION include/mysql_version.h | cut -d'"' -f2`
NEW="mysql-$VER.tar.gz"
OLD="mysql-$PVER.tar.gz"
RESULT="mysql-$PVER-$VER.patch.gz"
PATCH_DIR=/my/data/tcxwww/html/Downloads/Patches
RESULT_DIR=/my/data/tcxwww/html/Downloads/MySQL-3.22
if test ! -f $NEW
then
echo "$NEW doesn't exist";
exit 1;
fi
if test ! -f $RESULT_DIR/$OLD
then
echo "$RESULT_DIR/$OLD doesn't exist";
exit 1;
fi
mkdir patch
cd patch
gtar xfz ../$NEW
gtar xfz $RESULT_DIR/$OLD
cd mysql-$PVER
diff --context --new-file --recursive . ../mysql-$VER | gzip -9 > ../../$RESULT
cd ../..
/bin/rm -rf patch
#!/bin/sh
# make a patch file of a mysql distribution
# takes as argument the previous version
case $# in
0) echo Usage: $0 previous_version; exit 1;;
esac
PVER=$1;
VER=`grep SERVER_VERSION /my/tmp/BUILD/include/mysql_version.h | cut -d'"' -f2`
NEWDIR="binary"
NEW="mysql-$VER.tar.gz"
OLD="mysql-$PVER.tar.gz"
RESULT="mysql-$PVER-$VER.patch.gz"
PATCH_DIR=/my/web/Downloads-live/Patches
RESULT_DIR=/my/web/Downloads-live/MySQL-4.0
RESULT_DIR_MAX=/my/web/Downloads-live/MySQL-Max-4.0
if test ! -f $NEWDIR/$NEW
then
echo "$NEWDIR/$NEW doesn't exist";
exit 1;
fi
if test ! -f $RESULT_DIR/$OLD
then
echo "$RESULT_DIR/$OLD doesn't exist";
exit 1;
fi
mkdir patch
cd patch
gtar xfz ../$NEWDIR/$NEW
gtar xfz $RESULT_DIR/$OLD
cd mysql-$PVER
diff --unified --new-file --recursive . ../mysql-$VER | gzip -9 > ../../$RESULT
cd ../..
/bin/rm -rf patch
chmod a+r,o-w $RESULT binary/*
mv $RESULT $PATCH_DIR
cp binary/mysqlcom-* binary/mysql*win* /net/web/home/production/data/nweb/customer/Downloads
rm binary/mysqlcom-*
mv binary/*Max* binary/*-max* $RESULT_DIR_MAX
cp binary/* $RESULT_DIR
#!/usr/bin/perl -w
#
# Do-pkg - convert a binary distribution into a Mac OS X PKG and put it
# inside a Disk Image (.dmg). Additionally, add a separate package,
# including the required Startup Item to automatically start MySQL on
# bootup.
#
# The script currently assumes the following environment (which should exist
# like that, if the Do-compile script was used to build the binary
# distribution)
#
# - there must be a binary distribution (*.tar.gz) in the directory
# `hostname` of the current directory
# - the extracted and compiled source tree should be located in the
# `hostname` directory, too
#
# Use the "--help" option for more info!
#
# written by Lenz Grimmer <lenz@mysql.com>
#
use Cwd;
use File::Basename;
use File::Copy;
use Getopt::Long;
Getopt::Long::Configure ("bundling");
use Sys::Hostname;
$opt_dry_run= undef;
$opt_help= undef;
$opt_log= undef;
$opt_mail= "";
$opt_skip_dmg= undef;
$opt_skip_si= undef;
$opt_suffix= undef;
$opt_verbose= undef;
$opt_version= undef;
GetOptions(
"dry-run",
"help|h",
"log|l:s",
"mail|m=s",
"skip-dmg|skip-disk-image|s",
"skip-si|skip-startup-item",
"suffix=s",
"verbose|v",
"version=s",
) || &print_help;
# Include helper functions
$PWD= cwd();
$LOGGER= "$PWD/logger.pm";
if (-f "$LOGGER")
{
do "$LOGGER";
}
else
{
die "ERROR: $LOGGER cannot be found!\n";
}
$PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker";
# Try another location on 10.3.3
unless (-e "$PM")
{
$PM= "/Developer/Applications/Utilities/PackageMaker.app/Contents/MacOS/PackageMaker";
}
$TMP= $ENV{TMPDIR};
$TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$";
$PKGROOT= "$TMP/PMROOT";
$PKGDEST= "$TMP/PKG";
$RESOURCE_DIR= "$TMP/Resources";
$SUFFIX= $opt_suffix;
$VERSION= $opt_version;
($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION);
$NAME= "mysql$SUFFIX-$VERSION";
$HOST= hostname();
$ID= getpwuid($>);
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/$HOST-$MAJOR.$MINOR$SUFFIX.log";
$BUILDDIR= "$PWD/$HOST";
$SRCBASEDIR= <$BUILDDIR/mysql*-$VERSION>;
$SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>;
$TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc*.tar.gz>;
$TAR =~ /.*\/$NAME(.*)\.tar\.gz$/;
$ARCH= $1;
$NAME= $NAME . $ARCH;
$INFO= <$SUPFILEDIR/Info.plist>;
$DESC= <$SUPFILEDIR/Description.plist>;
$SI_INFO= <$SUPFILEDIR/StartupItem.Info.plist>;
$SI_DESC= <$SUPFILEDIR/StartupItem.Description.plist>;
$SI_PARAMS= <$SUPFILEDIR/StartupParameters.plist>;
$SI_POST= <$SUPFILEDIR/StartupItem.postinstall>;
$SI_NAME= "MySQLStartupItem";
$SI_SCRIPT= <$SUPFILEDIR/MySQL>;
@RESOURCES= qw/ ReadMe.txt postinstall preinstall /;
@LICENSES= ("$SRCBASEDIR/COPYING","$SRCBASEDIR/MySQLEULA.txt");
&print_help("") if ($opt_help || !$opt_suffix || !$opt_version);
#
# Override predefined Log file name
#
if (defined $opt_log)
{
if ($opt_log ne "")
{
if ($opt_log =~ /^\/.*/)
{
$LOGFILE= $opt_log;
}
else
{
$LOGFILE= $PWD . "/" . $opt_log;
}
}
}
# Creating the UFS disk image requires root privileges
die("You must be root to run this script!") if ($ID ne "root" && !$opt_dry_run);
@files= ($TAR, $INFO, $DESC);
@files= (@files, $SI_INFO, $SI_DESC, $SI_POST, $SI_SCRIPT) unless $opt_skip_si;
foreach $file (@files)
{
&abort("Unable to find $file!") unless (-f "$file");
}
# Remove old temporary build directories first
&logger("Cleaning up temporary build directories");
&run_command("rm -rf $TMP", "Could not clean up $TMP!");
&logger("Creating temp directories");
foreach $dir ($TMP, $PKGROOT, $PKGDEST, $RESOURCE_DIR)
{
if (!-d $dir)
{
&logger("Creating directory $dir!");
unless($opt_dry_run)
{
mkdir($dir) or &abort("Could not make directory $dir!");
}
}
}
foreach $resfile (@RESOURCES)
{
&logger("Copying $SUPFILEDIR/$resfile to $RESOURCE_DIR");
unless($opt_dry_run)
{
copy("$SUPFILEDIR/$resfile", "$RESOURCE_DIR") or
&abort("Error while copying $SUPFILEDIR/$resfile to $RESOURCE_DIR");
}
}
# Search for license file
foreach $license (@LICENSES)
{
if (-f "$license")
{
&logger("Copy $license to $RESOURCE_DIR/License.txt");
unless($opt_dry_run)
{
copy("$license", "$RESOURCE_DIR/License.txt") or
&abort("Error while copying $license to $RESOURCE_DIR");
}
}
}
&abort("Could not find a license file!")
unless (-f "$RESOURCE_DIR/License.txt");
# Extract the binary tarball and create the "mysql" symlink
&logger("Extracting $TAR to $PKGROOT");
&run_command("gnutar zxf $TAR -C $PKGROOT", "Unable to extract $TAR!");
&run_command("cd $PKGROOT ; ln -s mysql* ./mysql", "Unable to create symlink!");
&run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!");
# Now build the PGK using PackageMaker
# The "|| true" is a nasty hack to work around a problem with Package Maker
# returning a non-zero value, even though the package was created correctly
&logger("Running PackageMaker");
$command= "$PM -build -p $PKGDEST/$NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $INFO -d $DESC || true";
&run_command($command, "Error while building package $NAME.pkg!");
#
# Build the Startup Item PKG
#
unless ($opt_skip_si)
{
&logger("Cleaning up $PKGROOT");
&run_command("rm -rf $PKGROOT/*", "Unable to clean up $PKGROOT!");
&logger("Cleaning up $RESOURCE_DIR");
&run_command("rm -rf $RESOURCE_DIR/*", "Unable to clean up $RESOURCE_DIR!");
&logger("Installing MySQL StartupItem files into $PKGROOT/MySQL");
unless($opt_dry_run)
{
mkdir("$PKGROOT/MySQL") or &abort("Error creating $PKGROOT/MySQL");
copy("$SI_SCRIPT", "$PKGROOT/MySQL/")
or &abort("Error copying $SI_SCRIPT!");
chmod(0755, "$PKGROOT/MySQL/" . basename("$SI_SCRIPT"));
copy("$SI_PARAMS", "$PKGROOT/MySQL/")
or &abort("Error copying $SI_PARAMS!");
chmod(0644, "$PKGROOT/MySQL/" . basename("$SI_PARAMS"));
&run_command("chown -R root:wheel $PKGROOT/*", "Cannot chown $PKGROOT!");
copy("$SI_POST", "$RESOURCE_DIR/postinstall")
or &abort("Error copying $SI_POST!");
chmod(0644, "$RESOURCE_DIR/postinstall");
}
&logger("Building $SI_NAME.pkg using PackageMaker");
$command= "$PM -build -p $PKGDEST/$SI_NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $SI_INFO -d $SI_DESC || true";
&run_command($command, "Error while building package $SI_NAME.pkg!");
}
if ($opt_skip_dmg)
{
&logger("SUCCESS: Package $PKGDEST/$NAME.pkg created");
exit 0;
}
# Determine the size of the Disk image to be created and add a 5% safety
# margin for filesystem overhead
&logger("Determining required disk image size for $PKGDEST");
unless($opt_dry_run)
{
chomp($_= `du -sk $PKGDEST`);
@size= split();
$size= int($size[0]+($size[0]*0.05));
&logger("Disk image size: $size KB");
}
unless($opt_dry_run)
{
&abort("Zero bytes? Something is wrong here!") if ($size == 0);
}
# Now create and mount the disk image
$TMPNAME= $NAME . ".tmp";
&logger("Creating temporary Disk image $TMPNAME.dmg");
$command= "hdiutil create $TMPNAME -size ${size}k -ov -fs UFS -volname $NAME";
&run_command($command, "Unable to create disk image $TMPNAME.dmg!");
&logger("Attaching Disk image $TMPNAME.dmg");
&run_command("hdid $TMPNAME.dmg", "Unable to attach $TMPNAME.dmg!");
# Install the PKG into the .dmg
chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f3 -d" "`) if (!$opt_dry_run);
&logger("Copying $PKGDEST/$NAME.pkg to Disk image /Volumes/$NAME");
&run_command("ditto $PKGDEST /Volumes/$NAME", "Could not copy $PKGDEST to /Volumes/$NAME!");
&run_command("ditto $SUPFILEDIR/ReadMe.txt /Volumes/$NAME", "Could not copy $SPFILEDIR/ReadMe.txt to /Volumes/$NAME!");
chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f1 -d" "`) if (!$opt_dry_run);
&abort("/Volumes/$NAME not attached!") if (!$mountpoint && !$opt_dry_run);
&logger("Unmounting $mountpoint");
&run_command("hdiutil detach $mountpoint", "Unable to detach $mountpoint");
&run_command("rm -f $NAME.dmg", "Unable to remove $NAME.dmg!") if (-f "$NAME.dmg");
&logger("Compressing disk image");
$command= "hdiutil convert $TMPNAME.dmg -format UDZO -imagekey zlib-level=9 -o $NAME.dmg";
&run_command($command, "Unable to compress disk image!");
# Final cleanups
&logger("Removing $TMPNAME.dmg");
&run_command("rm -f $TMPNAME.dmg", "Unable to remove $TMPNAME.dmg!");
&logger("Removing $TMP");
&run_command("rm -rf $TMP", "Unable to remove $TMP!");
&logger("SUCCESS: $NAME.dmg created.") if (!$opt_dry_run);
exit 0;
sub print_help
{
my $message= $_[0];
if ($message ne "")
{
print "\n";
print "ERROR: $message\n";
}
print <<EOF;
Usage: Do-pkg <options> --suffix=<suffix> --version=<version>
Creates a Mac OS X installation package (PKG) and stores it inside
a Disk Image (.dmg) file. You need to create a binary distribution
tarball with scripts/make_binary_distribution first!
NOTE: You need to run this script with root privileges (required
to create the disk image)
Options:
--dry-run Dry run without executing
-h, --help Print this help
-l, --log[=<filename>] Write a log file [to <filename>]
(default is "$LOGFILE")
-m, --mail=<address> Mail a failure report to the given
address (and include a log file snippet,
if logging is enabled)
Note that the \@-Sign needs to be quoted!
Example: --mail=user\\\@domain.com
-s, --skip-disk-image, --skip-dmg Just build the PKGs, don't put it into a
disk image afterwards
--skip-startup-item, --skip-si Skip the creation of the StartupItem PKG
--suffix=<suffix> The package suffix
(e.g. "-standard" or "-pro)
--version=<version> The MySQL version number
(e.g. 4.0.11-gamma)
-v, --verbose Verbose execution
EOF
exit 1;
}
#!/usr/bin/perl -w
#
# Do-rpm - compile RPM packages out of a source tarball and move the
# resulting RPM packages into the current directory.
#
# The script currently assumes the following environment:
#
# - there must be a source distribution (mysql-<version>.tar.gz)
# in the current directory
# - You must provide the name of an RPM spec file (mysql-<version>.spec)
# as the argument
#
# Use the "--help" option for more info!
#
# written by Lenz Grimmer <lenz@mysql.com>
#
use Cwd;
use File::Basename;
use File::Copy;
use Getopt::Long;
Getopt::Long::Configure ("bundling");
use Sys::Hostname;
$opt_cc= undef;
$opt_cflags= undef;
$opt_clean= undef;
$opt_cxx= undef;
$opt_cxxflags= undef;
$opt_dry_run= undef;
$opt_help= undef;
$opt_log= undef;
$opt_mail= "";
$opt_verbose= undef;
$opt_susebuild= undef;
$opt_susebuildroot= undef;
$opt_suserpms= undef;
# Set a dummy version until we know the correct one
$VERSION= "x.y.z";
$MAJOR= $MINOR= $RELEASE= 0;
$SUFFIX= "";
GetOptions(
"cc=s",
"cflags=s",
"clean|c",
"cxx=s",
"cxxflags=s",
"dry-run|t",
"help|h",
"log|l:s",
"mail|m=s",
"susebuild|s",
"susebuildroot|r=s",
"suserpms=s",
"verbose|v",
) || &print_help;
&print_help("") if ($opt_help);
defined($SPECFILE=$ARGV[0]) || print_help("Please provide the spec file name!");
&print_help("Please define the location of the RPM repository!") if $opt_susebuild && !($opt_suserpms || $ENV{BUILD_RPMS});
unless ($opt_susebuildroot)
{
if ($ENV{BUILD_ROOT})
{
$opt_susebuildroot= $ENV{BUILD_ROOT};
}
else
{
$opt_susebuildroot="/var/tmp/build-root";
}
}
# Include helper functions
$PWD= cwd();
$LOGGER= "$PWD/logger.pm";
if (-f "$LOGGER")
{
do "$LOGGER";
}
else
{
die "ERROR: $LOGGER cannot be found!\n";
}
$subject= "RPM build for $SPECFILE failed" if $opt_mail;
# Open the spec file and extract the version number
open(SPEC, $SPECFILE) or die "Unable to open \"$ARGV[0]\": $!";
@spec= <SPEC>;
close SPEC;
foreach (@spec)
{
if (m/^%define\s*mysql_version\s*(.*)/)
{
$VERSION= $1;
$VERSION_SRPM=$VERSION;
($MAJOR, $MINOR, $RELEASE)= split(/\./,$VERSION);
$VERSION_SRPM= $MAJOR . '.' . $MINOR . '.' . $RELEASE;
$VERSION_SRPM =~ s/\-\w+$//;
($RELEASE, $SUFFIX)= split(/\-/,$RELEASE);
$SUFFIX= "-" . $SUFFIX if ($SUFFIX);
}
}
$HOST= hostname();
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log";
&logger("Logging to $LOGFILE");
#
# Override predefined Log file name
#
if (defined $opt_log)
{
if ($opt_log ne "")
{
if ($opt_log =~ /^\/.*/)
{
$LOGFILE= $opt_log;
}
else
{
$LOGFILE= $PWD . "/" . $opt_log;
}
}
}
&logger("Using spec file for version: $VERSION");
if ($opt_susebuild)
{
&susebuild;
}
else
{
&rpmbuild;
}
&logger("SUCCESS: RPM files successfully created.") unless ($opt_dry_run);
exit 0;
#
# Build using SUSE's "build" script
#
sub susebuild
{
$BUILD= "/usr/bin/build";
( -x $BUILD) ? &logger("$BUILD found, proceeding.") : &abort("$BUILD could not be found!");
$command= "sudo $BUILD --clean";
$command.= " --root=$opt_susebuildroot";
$command.= " --rpms=$opt_suserpms" if $opt_suserpms;
$command.= " $SPECFILE";
&logger("Building RPMs using SUSE build.");
&run_command($command, "Error while running the SUSE RPM build!");
#
# Move the resulting RPMs into the pwd - we can use broad globs here
# as the build root has been cleaned up before so there should not be
# any residuals from previous build runs
#
$command= "cp";
$command.= " -v " if ($opt_verbose);
$command.= " $opt_susebuildroot/usr/src/packages/SRPMS/MySQL*.src.rpm $PWD";
&logger("Copying source RPM to current dir.");
&run_command($command, "Error moving source RPM!");
$command= "cp";
$command.= " -v " if ($opt_verbose);
$command.= " $opt_susebuildroot/usr/src/packages/RPMS/*/MySQL*.rpm $PWD";
&logger("Copying binary RPMs to current dir.");
&run_command($command, "Error moving binary RPMs!");
}
#
# Build using "plain" RPM
#
sub rpmbuild
{
#
# Newer RPM versions ship with a separate tool "rpmbuild" to build RPMs
#
if (-x "/usr/bin/rpmbuild")
{
$RPM= "/usr/bin/rpmbuild";
$RMSOURCE= "--rmsource --rmspec";
}
else
{
$RPM= "/bin/rpm";
$RMSOURCE= "--rmspec";
}
if ($RPM)
{
&logger("Found rpm binary: $RPM");
}
else
{
&abort("Unable to find RPM binary!");
}
#
# determine some RPM settings for this host
#
chomp($RPMARCH= `$RPM --eval "%{_arch}" 2> /dev/null`);
chomp($RPMDIR= `$RPM --eval "%{_rpmdir}" 2> /dev/null`);
chomp($SOURCEDIR= `$RPM --eval "%{_sourcedir}" 2> /dev/null`);
chomp($SPECDIR= `$RPM --eval "%{_specdir}" 2> /dev/null`);
chomp($SRCRPMDIR= `$RPM --eval "%{_srcrpmdir}" 2> /dev/null`);
$SOURCEFILE= glob "mysql*-$VERSION.tar.gz";
&logger("Starting RPM build of MySQL-$VERSION on $HOST");
foreach $file ($SOURCEFILE, $SPECFILE)
{
&abort("Unable to find $file!") unless (-f "$file");
}
#
# Install source and spec file
#
&logger("Copying SOURCE and SPEC file to build directories.");
unless ($opt_dry_run)
{
copy($SOURCEFILE, $SOURCEDIR)
or &abort("Unable to copy $SOURCEFILE to $SOURCEDIR!");
copy($SPECFILE, $SPECDIR)
or &abort("Unable to copy $SPECFILE to $SPECDIR!");
}
#
# Set environment variables - these are being used in the
# official MySQL RPM spec file
#
&logger("Setting special build environment variables")
if ($opt_cc) or ($opt_cflags) or ($opt_cxxflags) or ($opt_cxx);
$ENV{MYSQL_BUILD_CC}=$opt_cc if ($opt_cc);
$ENV{MYSQL_BUILD_CFLAGS}=$opt_cflags if ($opt_cflags);
$ENV{MYSQL_BUILD_CXXFLAGS}=$opt_cxxflags if ($opt_cxxflags);
$ENV{MYSQL_BUILD_CXX}=$opt_cxx if ($opt_cxx);
#
# Build the RPMs
#
$command= "$RPM";
$command.= " -v" if ($opt_verbose);
$command.= " -ba";
$command.= " --clean $RMSOURCE" if $opt_clean;
$command.= " $SPECDIR/";
$command.= basename($SPECFILE);
&logger("Building RPM.");
&run_command($command, "Error while building the RPMs!");
#
# Move the resulting RPMs into the pwd
#
$command= "mv";
$command.= " -v " if ($opt_verbose);
$command.= " $SRCRPMDIR/MySQL*$VERSION_SRPM*.src.rpm $PWD";
&logger("Moving source RPM to current dir.");
&run_command($command, "Error moving source RPM!");
$command= "mv";
$command.= " -v " if ($opt_verbose);
$command.= " $RPMDIR/$RPMARCH/MySQL*$VERSION_SRPM*.$RPMARCH.rpm $PWD";
&logger("Moving binary RPMs to current dir.");
&run_command($command, "Error moving binary RPMs!");
}
sub print_help
{
my $message= $_[0];
if ($message ne "")
{
print "\n";
print "ERROR: $message\n\n";
}
print <<EOF;
Usage: Do-rpm [options] <specfile>
Creates a binary RPM package out of a MySQL source distribution and moves
the resulting RPMs into the current directory. <specfile> is the MySQL RPM
spec file to use (e.g. mysql-4.0.17.spec).
This script expects to find the required MySQL source distribution
(mysql-<version>.tar.gz) in the current directory.
Options:
--cc=<compiler> Use <compiler> to compile C code
--ccflags=<flags> Use special C compiler flags
--cxx=<compiler> Use <compiler> to compile C++ code
--cxxflags=<flags> Use special C++ compiler flags
-c, --clean Clean up after the build
-t, --dry-run Dry run without executing
-h, --help Print this help
-l, --log[=<filename>] Write a log file [to <filename>]
-m, --mail=<address> Mail a failure report to the given address
(and include a log file snippet, if logging
is enabled)
Note that the \@-Sign needs to be quoted!
Example: --mail=user\\\@domain.com
-s, --susebuild Use the SUSE "build" script instead of RPM
directly (requires sudo privileges to run the
/usr/bin/build command)
-r, --susebuildroot=<root> Use <root> as the build root directory for the
SUSE "build" (default is /var/tmp/build-root
or defined by the BUILD_ROOT environment
variable)
--suserpms=<path> Path to the SUSE RPM repository to build up
the build root (mandatory option when using
--susebuild and the BUILD_RPMS environment
variable is not set.)
-v, --verbose Verbose execution
Example:
Do-rpm -cv mysql-4.0.17.spec
EOF
exit 1;
}
#!/usr/bin/perl -w
use Getopt::Long;
$opt_help=0;
$opt_tarball=$opt_builddir=$opt_suffix="";
GetOptions(
"help",
"tarball=s",
"builddir=s",
"suffix=s"
) || print_help();
print_help() if ($opt_help);
chomp($MSDEV=`which msdev`);
if (!$opt_builddir) {
$opt_builddir = "/cygdrive/c/mysql-win-build";
}
$opt_tarball =~ /(mysql[^\/]*)-win-src\.tar/;
$mysqlver=$1;
$basedir = "$opt_builddir/$mysqlver";
$scriptdir = `pwd`;
# Make sure build dir exists
mkdir($opt_builddir);
# Clean out any previous build
system("rm -rf $basedir");
# Unpack in the script directory
system("tar -zxvf $opt_tarball");
# Move to the build directory
system("mv $mysqlver $opt_builddir");
if (!chdir($basedir))
{
print "Do-win-build error: Could not change to $basedir";
exit 1;
}
# Check whether this is a classic edition build
if ($opt_suffix =~ /-classic/)
{
# Blank out ha_innodb.cpp
chmod 0644, 'sql/ha_innodb.cpp';
open(OUT, '>', 'sql/ha_innodb.cpp');
close(OUT);
# Remove HAVE_INNOBASE_DB from the requisite project files
for $dspfile ('libmysqld/libmysqld.dsp', 'mysqldemb/mysqldemb.dsp', 'mysqlserver/mysqlserver.dsp', 'sql/mysqld.dsp', 'sql/mysqldmax.dsp')
{
open(IN, '<', $dspfile);
open(OUT, '>', "$dspfile.tmp");
while (readline IN)
{
s/\D \"HAVE_INNOBASE_DB\" //g;
print OUT $_;
}
close(IN);
close(OUT);
unlink $dspfile;
rename "$dspfile.tmp", $dspfile;
}
}
# Perform compilation
system("\"$MSDEV\" mysql.dsw /MAKE \"ALL\" /OUT $mysqlver-build.log");
# Package binary
system("./scripts/make_win_binary_distribution --suffix=$opt_suffix");
# Copy log back to script directory
system("cp $mysqlver$suffix-build.log $scriptdir");
# Move binary package to script directory
system("mv *.zip $scriptdir");
#
# Print a help text message
#
sub print_help
{
print <<EOF;
Usage: Do-compile-win [options] source-tarball
Unpacks a Windows source distribution on the local machine and
compiles it using VC++ 6.0.
This script is intended for Cygwin Perl. You must have a working
MSDEV.EXE in your path for compilation, as well as the following:
sed
tar (GNU tar)
which
Options:
--help
Print this text.
--builddir=<dir>
Set the Cygwin path to build under; the tarball will actually
be moved to <builddir>/mysql-<version>/tarball and extracted under
<builddir>/mysql-<version>/build.
Default: /cygdrive/c/mysql-win-build
--suffix=<suffix>
If specified, the resulting binary will have the specified suffix
in its name. If the suffix is "-classic", the project files will
be stripped of all occurrences of HAVE_INNOBASE_DB and
ha_innodb.cpp will be blanked out, to create classic edition
server binaries.
--tarball=<file>
Windows source tarball to use for this build. Must be of the form
mysql[com]-x.x.x-win-src.tar.gz (REQUIRED)
EOF
exit 1;
}
#! /bin/sh
CVSROOT=my@work.mysql.com:/home/cvs
CVS_RSH=ssh
TMPDIR=/tmp
cd $TMPDIR
[ -d mysql ] && rm -rf mysql
CVSROOT=$CVSROOT CVS_RSH=$CVS_RSH cvs -z 9 co mysql && cd mysql && \
chmod u+w -R * && BUILD/compile-pentium
if test $? = 0
then
cd $TMPDIR && rm -rf mysql
fi
# Helper functions
#
# Create a log entry
#
sub logger
{
my $message= $_[0];
my $cmnd= $_[1];
print $message . "\n" if !$opt_quiet && !$opt_verbose && !$cmnd;
print timestamp() . " " . $message . "\n" if $opt_verbose;
if (defined $opt_log && !$opt_dry_run)
{
open LOG, ">>$LOGFILE" or die "Can't open logfile $LOGFILE!";
print LOG timestamp() . " " . $message . "\n";
close LOG;
}
}
#
# run_command(<command>,<error message>)
# Execute the given command or die with the respective error message
# Just print out the command when doing a dry run
#
sub run_command
{
my $command= $_[0];
my $errormsg= $_[1];
if ($opt_dry_run)
{
print "$command\n";
}
else
{
&logger($command, 1);
$command.= ';' unless ($command =~ m/^.*;$/);
$command =~ s/;/ >> $LOGFILE 2>&1;/g if defined $opt_log;
$command =~ s/;/ > \/dev\/null;/g if (!$opt_verbose && !$opt_log);
system($command) == 0 or &abort("$errormsg\n");
}
}
#
# abort(<message>)
# Exit with giving out the given error message or by sending
# it via email to the given mail address (including a log file snippet,
# if available)
#
sub abort
{
my $message= $_[0];
my $messagefile;
my $subject= "Bootstrap of $REPO failed" if $opt_mail;
$message= "ERROR: " . $message;
&logger($message);
if ($opt_mail && !$opt_dry_run)
{
$messagefile= "/tmp/message.$$";
open(TMP,">$messagefile");
print TMP "$message\n\n";
close TMP;
if (defined $opt_log)
{
system("tail -n 40 $LOGFILE >> $messagefile");
}
system("mail -s \"$subject\" $opt_mail < $messagefile");
unlink($messagefile);
}
exit 1;
}
# Create a time stamp for logging purposes
sub timestamp
{
return &ymd() . " " . &hms();
}
#
# return the current time as a string (HH:MM:SS)
#
sub hms
{
my @ta= localtime(time());
my $h= $ta[2];
$h= "0" . "$h" if ($h <= 9);
my $m= $ta[1];
$m= "0" . "$m" if ($m <= 9);
my $s= $ta[0];
$s="0" . "$s" if ($s <= 9);
return "$h:$m:$s";
}
#
# return the current date as a string (YYYYMMDD)
#
sub ymd
{
my @ta=localtime(time());
my $d=$ta[3];
$d="0" . "$d" if ($d <= 9);
my $m=$ta[4]+1;
$m="0" . "$m" if ($m <= 9);
my $y=1900+$ta[5];
return "$y$m$d";
}
#!/usr/bin/perl
#
# my_md5sum
#
# Script to clone the 'md5sum' command found on modern systems, since that
# command is not always found on all systems.
#
# Use the "--help" option for more info!
#
# Written by Matt Wagner <matt@mysql.com>
#
use strict;
#
# Use local perl libraries first. 'unshift' adds to the front of @INC
# The local perl library dir hidden is $HOME/.perllibs on each build host
#
BEGIN
{
my $homedir= $ENV{HOME};
unshift (@INC, "$homedir/.perllibs");
}
use Digest::MD5;
use Getopt::Long;
my $VER= "1.3";
my $EXIT= 0;
#
# Strip the leading path info off the program name ($0). We want 'my_md5sum'
# not './my_md5sum'.
#
$0=~ s/^.*\/(.+)$/$1/;
my ($opt_check, $opt_help)= undef;
GetOptions(
"check|c" => \$opt_check,
"help|h" => \$opt_help,
) || usage();
#
# Put all the [file1 file2 file3 ...]'s into an array
#
my @files = @ARGV;
#
# Give the "--help" text if:
# - "--help|-h" was specified
# - The number of files given as arguments is nil
# - The "--check|-c" option is used with more than one [file] argument
#
usage() if $opt_help || $#files == -1 || ($opt_check && $#files > 0);
# If "--check|-c", then go into checking
if ($opt_check)
{
open (CHECKFILE, $files[0]) or die "$files[0]: $!";
while (<CHECKFILE>)
{
#
# Goto the next line in the file if it does not match a typical
# digest line like:
#
# f1007efa2c72daa693981ec764cdeaca Bootstrap
#
next if $_!~ m/^([a-z0-9]{32})\s+(.+)$/;
# Collect the trappings from the above regex
my $checksum= $1;
my $checkfile= $2;
# Generate a fresh MD5 for the file in question
my $digest= &mkmd5($checkfile);
# Check the fresh MD5 against what is recorded in the file
# Print an error message if they don't match, else print OK
print "$checkfile: FAILED\n" if $digest ne $checksum;
print "$checkfile: OK\n" if $digest eq $checksum;
# Set the exit() status to non-zero if FAILED
$EXIT= 1 if $digest ne $checksum;
}
}
# Else generate the MD5 digest to STDOUT
else
{
foreach my $file (@files)
{
my $digest= &mkmd5($file);
print "$digest $file\n";
}
}
exit($EXIT);
#
# This routine generates the MD5 digest of a file
#
sub mkmd5
{
my $file= shift;
open (FILE, $file) or die "$file: $!";
binmode(FILE);
my $digest= Digest::MD5->new->addfile(*FILE)->hexdigest;
close FILE;
return $digest;
}
#
# Print the help text
#
sub usage
{
print <<EOF;
$0 version $VER by Matt Wagner <matt\@mysql.com>
Usage:
$0 [-c [file]] | [file1...]
Generates or checks MD5 message digests.
Options:
-c, --check Check message digests (default is generate)
-h, --help Display this text and exit
The input for -c should be the list of message digests and file names that is
printed on STDOUT by this program when it generates digests.
EOF
exit(0);
}
#!/usr/bin/perl -wi
# Untar a MySQL distribution, change the copyright texts,
# pack it up again to a given directory
$VER="1.5";
use Cwd;
use File::Basename;
use File::Copy;
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", "verbose") || error();
# fix the directory prefix for target dir
$WD= cwd();
my $win_flag = 0;
$opt_target= $WD . '/' . $opt_target;
&main();
####
#### main
####
sub main
{
my $REG_BASENAME = '[a-z0-9A-Z\-\_\+]+';
my $REG_VERSION = '[0-9\.\-]+[a-z]?[0-9\.\-]+?(.alpha|.beta|.gamma|pre\d|[0-9\.\-a-z])?';
my $target;
if ($opt_version)
{
print "$0 version $VER by Jani Tolonen\n";
exit(0);
}
usage() if ($opt_help);
print error() if ($#ARGV == -1);
`mkdir -p $opt_target`;
$pec= $? >> 8;
die "Couldn't make the target directory!\n" if ($pec);
for ($i=0; $ARGV[$i]; $i++)
{
my $distfile= $ARGV[$i];
$win_flag = ($distfile =~ /win-src/) ? 1 : 0;
my $dir;
$dir= "mysql-copyright-";
$dir.= `date +%d%m%y-%H%M%S`;
chop $dir;
if (!(mkdir "$dir", 0700))
{
die "Couldn't make directory $dir!";
}
if (!(chdir "$dir"))
{
abort($dir, "Couldn't cd to $dir!");
}
# 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}([\.\-\+]\w+\-\w+)?[\.\-\+](.*)?$/xo)
{
$distname= $1.$2.$3;
$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);
if ("$destdir" ne "$distname")
{
print "Destination directory (the directory that will be extracted\n";
print "from the original distribution file) differs from the\n";
print "distribution name! Are you sure you want to continue? (Y/N) [N]:";
$ans= my_read(1);
abort($dir, "Aborted!") if ("$ans" ne "Y" && "$ans" ne "y");
}
# everything should be ok, continue with extracting..
`tar xfz ../$distfile`;
$pec= $? >> 8;
abort($dir, "Extracting from tar failed!\n") if ($pec);
# remove the 'PUBLIC' file from distribution and copy MySQLEULA.txt
# on the toplevel of the directory instead. file 'PUBLIC' shouldn't
# exist in the new mysql distributions, but let's be sure..
unlink("$destdir/PUBLIC", "$destdir/README");
unlink("$destdir/COPYING", "$destdir/EXCEPTIONS-CLIENT");
copy("$WD/Docs/MySQLEULA.txt", "$destdir");
# remove subdirectories 'bdb', 'cmd-line-utils/readline'
my @extra_fat= ('bdb', 'cmd-line-utils/readline');
foreach my $fat (@extra_fat)
{
&trim_the_fat($fat);
}
# fix file copyrights
&fix_usage_copyright();
&add_copyright();
# fix LICENSE tag in include/mysql_version.h
&fix_mysql_version();
# apply "autotools" - must be last to ensure proper timestamps
&run_autotools();
# 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 $WD/$newdistname.tar.gz $newdistname`;
$pec= $? >> 8;
abort($dir, "Making new tar archive failed!\n") if ($pec);
# remove temporary directory
chdir($WD) or print "$! Unable to move up one dir\n";
my $cwd = getcwd();
print "current dir is $cwd\n" if $opt_verbose ;
if (-e $dir) {
print "Trying to delete $dir\n" if $opt_verbose;
if ( system("rm -rf $dir")){
print "$! Unable to delete $dir!\n";
}
}
}
exit(0);
}
####
#### This function will s/GPL/Commercial/ in include/mysql_version.h for the
#### LICENSE tag.
####
sub fix_mysql_version
{
my $cwd= getcwd();
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");
}
####
#### This function will remove unwanted parts of a src tree for the mysqlcom
#### distributions.
####
sub trim_the_fat
{
my $the_fat= shift;
my $cwd= getcwd();
chdir("$destdir");
if ( -d "${the_fat}" )
{
system("rm -rf ${the_fat}");
if (!$win_flag)
{
open(CONFIG_IN,"<configure.in") or die "Unable to open configure.in for read: $!\n";
undef $/;
my $config_in= <CONFIG_IN>;
close(CONFIG_IN);
#
# If $the_fat Makefile line closes the parenthesis, then
# replace that line with just the closing parenthesis.
#
if ($config_in=~ m|${the_fat}/Makefile\)\n?|)
{
$config_in=~ s|${the_fat}/Makefile(\)\n?)|$1|;
}
#
# Else just delete the line
#
else
{
$config_in=~ s|${the_fat}/Makefile dnl\n?||;
}
open(CONFIG_IN,">configure.in") or die "Unable to open configure.in for write: $!\n";
print CONFIG_IN $config_in;
close(CONFIG_IN);
}
}
chdir("$cwd");
}
####
#### This function will run the autotools on the reduced source tree.
####
sub run_autotools
{
my $cwd= getcwd();
if (!$win_flag)
{
chdir("$destdir");
unlink ("configure") or die "Can't delete $destdir/configure: $!\n";
# File "configure.in" has already been modified by "trim_the_fat()"
# 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");
if (-d "autom4te.cache") {
print "Trying to delete autom4te.cache dir\n" if $opt_verbose;
system("rm -rf autom4te.cache") or print "Unable to delete 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
{
my $findlist = `find . -type f -name \"*.c*\"`;
my @files = split("\n", $findlist);
my $cwd = getcwd();
foreach my $file (@files)
{
next if ! -f $file;
print "processing file $file in cwd $cwd\n" if $opt_verbose;
`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" -- "$file"` ;
}
}
####
#### change the copyright text in the beginning of the files
####
sub add_copyright
{
my $findlist = `find . -type f -name "*"`;
my @files = split("\n", $findlist);
my $cwd = getcwd();
foreach my $file (@files)
{
next if ! -f $file;
next if -B $file;
print "processing file $file in cwd $cwd\n" if $opt_verbose;
`$WD/Build-tools/mysql-copyright-2 "$file"`;
}
}
####
#### read stdin
####
sub my_read
{
($length)= @_; # Max allowed length for the string.
$input= getc(STDIN);
if($input eq "\n")
{
return "\n";
}
for($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 "..";
print "Removing directory $dir...\n";
`rm -rf $dir`;
exit(0);
}
####
#### usage
####
sub usage
{
print <<EOF;
$0 version $VER by Jani Tolonen
Description: The 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 suffix "com" in
the basename to directory mysql-copyright-target-DATE, where the
command was issued. For example: mysql-3.23.18-beta.tar.gz ->
mysqlcom-3.23.18-beta.tar.gz. DATE is of form DDMMYY-HHMMSS. The
target directory can be changed with option
--target=... 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 Show this help and exit.
--target Target directory for new distribution files.
'.' can be used for the current directory.
(Default: $opt_target)
EOF
exit(0);
}
####
#### error
####
sub error
{
if ($#ARGV == -1)
{
print "Too few arguments to $0!\n";
}
exit(1);
}
#!/usr/bin/perl -i
# Add the header to all given files
# This program asumes that after the copyright there is a empty line
#
$opt_v= 0;
require "getopts.pl";
Getopts("v") || die "Aborted";
@copyright=
(
"Copyright (C) 2000 MySQL AB & MySQL Finland AB",
"",
"This software is distributed with NO WARRANTY OF ANY KIND. No author or",
"distributor accepts any responsibility for the consequences of using it, or",
"for whether it serves any particular purpose or works at all, unless he or",
"she says so in writing. Refer to the MySQLEULA.txt file for details.",
"",
"Every copy of this file must include a copy of the License, normally in a",
"plain ASCII text file named MySQLEULA.txt. The License grants you the right to",
"copy, modify and redistribute this file, but only under certain conditions",
"described in the License. Among other things, the License requires that",
"the copyright notice and this notice be preserved on all copies"
);
while (<>)
{
if (!$first++)
{
add_copyright($_);
}
if ($in_copyright)
{
$in_copyright=check_in_copyright($_);
}
print $_ if (!$in_copyright);
if (eof)
{
$first=0; $in_copyright=1;
}
}
exit 0;
sub add_copyright
{
my ($line)=@_;
my ($row);
$in_copyright= $line =~ /copyright/i;
$found_end_copyright=$skip_this_line=0;
if (!($line =~ /Monty/ || $line =~ /MySQL AB/))
{
$in_copyright=0;
print STDERR "File with unknown copyright ", $ARGV,"\n" if ($opt_v);
return;
}
else
{
print STDERR "To be Changed: ", $ARGV, "\n" if ($opt_v);
}
if ($ARGV =~ /Makefile/ ||
$ARGV =~ /makefile/)
{ # Makefile
$start_copyright="# ";
$line_copyright= "# ";
$end_copyright= "";
}
elsif ($line =~ "^#!")
{ # Shell script
$start_copyright="# ";
$line_copyright= "# ";
$end_copyright= "";
$skip_this_line=1;
print $line;
while ($line=<>) # Copy all until new line or copyright
{
if ($line =~ /copyright/i)
{
last;
}
print $line;
last if ($line =~ /^(\s|\n)*$/);
}
$in_copyright=1;
}
elsif ($ARGV =~ /\.c$/ ||
$ARGV =~ /\.cc$/ ||
$ARGV =~ /\.h$/ ||
$ARGV =~ /\.cpp$/ ||
$ARGV =~ /\.txt$/ ||
$ARGV =~ /\.yy$/)
{
$start_copyright="/* ";
$line_copyright= " ";
$end_copyright= "*/";
}
elsif ($ARGV =~ /-x86\.s$/)
{
$start_copyright="# ";
$line_copyright= "# ";
$end_copyright= "";
}
elsif ($ARGV =~ /\.s$/)
{
$start_copyright="! ";
$line_copyright= "! ";
$end_copyright= "";
}
elsif ($ARGV =~ /\.asm$/)
{
$start_copyright="; ";
$line_copyright= "; ";
$end_copyright= "";
}
else # Unknown file
{
$in_copyright=0;
print STDERR "Unknown file type ", $ARGV,"\n" if ($opt_v);
return;
}
$data=\@copyright;
for ($row=0 ; $row <= $#$data ; $row++)
{
print $row == 0 ? $start_copyright : $line_copyright;
print $data->[$row];
print $row != $#$data ? "\n" : $end_copyright . "\n";
}
print "\n";
$end_copyright =~ /\s*([^\s]+)\s*(([^\s].*)|)$/; # Remove pre and post spaces
}
#
# Return 1 if in copyright
#
sub check_in_copyright
{
my ($line)=@_;
$line =~ /^(.*[^\s])(\s|\n|\r)*$/; # Remove end space and newline
$line=$1;
if (!$line)
{
$found_end_copyright=1 if (!length($end_copyright));
return 1; # Skip empty lines
}
return 0 if ($found_end_copyright);
if ($end_copyright)
{
if (index($line,$end_copyright) != -1)
{
$found_end_copyright=1;
}
return 1;
}
if ($line =~ /copyright/i || index($line . " ",$line_copyright) == 0)
{
return 1;
}
if ($skip_this_line)
{
$skip_this_line=0;
return 1;
}
return 0; # Can't trust the empty copyright line yet
}
#!/usr/bin/perl
package NEWEST;
use Getopt::Long;
use File::Basename;
my $src_dir;
my $basename;
my $type = "tar.gz";
my $versions;
my $help;
my %KEEPER;
GetOptions(
"src_dir=s" => \$src_dir,
"basename=s" => \$basename,
"type=s" => \$type,
"versions!" => \$versions,
"help!" => \$help
);
if (!defined $src_dir || !defined $basename) {
$help = 1;
}
if ($help) {
&help();
exit;
}
&extract_version(\$src_dir, \$basename, \$type, \%KEEPER);
&print_max(\%KEEPER, \$type, \$versions, &find_max(\%KEEPER));
sub extract_version {
my $src_dir = shift;
my $basename = shift;
my $type = shift;
my $KEEPER = shift;
while (glob("$${src_dir}/$${basename}*")) {
my $base = basename("$_",".$${type}");
my @ver = split /-/, $base;
my @nums = split /\./, $ver[$#ver];
my $new;
for (my $i=0; $i<$#nums+1; $i++) {
$new =~ s/^([0-9]*)([a-zA-Z]*)$/$1/;
$new .= 10000+$nums[$i];
$new .= $2;
}
$KEEPER->{"$new"} = [$base,$ver[$#ver]];
}
return;
}
sub find_max {
my $KEEPER = shift;
return reverse sort (keys %$KEEPER);
}
sub print_max {
my $KEEPER = shift;
my $type = shift;
my $versions = shift;
my $max_key = shift;
if ($${versions}) {
print "$KEEPER->{$max_key}->[1]\n";
}
else {
print "$KEEPER->{$max_key}->[0]" . ".$${type}\n";
}
return;
}
sub help {
print qq("newest" finds the tarball in a given directory with the newest version number
and returns it's filename. "newest" is meant to be embedded in UNIX shell
scripts.
Usage:
newest -(src_dir | s) /path/to/dir/with/tarballs
-(basename | b) BaseName (ex. BaseName-2.10.tar.gz)
-(type | t) Type of file (default: tar.gz)
-(versions | v) Print only version information
-(help | h) Prints usage help
Ex: \$ /opt/bin/newest -s /opt/incoming/pm_modules -b Data-Dumper
Data-Dumper-2.101.tar.gz
Both arguments, '-s' and '-b' are required; '-t' and '-v' are optional.
);
return;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment