summaryrefslogtreecommitdiff
path: root/Build-tools
diff options
context:
space:
mode:
Diffstat (limited to 'Build-tools')
-rwxr-xr-xBuild-tools/Bootstrap38
-rwxr-xr-xBuild-tools/Do-compile7
-rwxr-xr-xBuild-tools/Do-pkg127
-rwxr-xr-xBuild-tools/Do-rpm450
4 files changed, 339 insertions, 283 deletions
diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap
index 33eca958ae0..94446d9880f 100755
--- a/Build-tools/Bootstrap
+++ b/Build-tools/Bootstrap
@@ -10,6 +10,7 @@
# written by Lenz Grimmer <lenz@mysql.com>
#
+use Cwd;
use Getopt::Long;
Getopt::Long::Configure ("bundling");
@@ -26,18 +27,19 @@ else
# Some predefined settings
$build_command= "BUILD/compile-pentium-max";
-chomp ($LOGFILE= `pwd`);
-$LOGFILE.= "/Bootstrap.log";
-chomp ($opt_directory= `pwd`);
-$opt_docdir= $opt_directory . "/mysqldoc";
+$PWD= cwd();
+$LOGFILE= $PWD . "/Bootstrap.log";
+$opt_docdir= $PWD . "/mysqldoc";
$opt_build_command= undef;
$opt_changelog= undef;
$opt_delete= undef;
+$opt_directory= $PWD;
$opt_dry_run= undef;
$opt_export_only= undef;
$opt_help= $opt_verbose= 0;
$opt_log= undef;
$opt_mail= "";
+$opt_pull= undef;
$opt_revision= undef;
$opt_suffix= "";
$opt_test= undef;
@@ -58,6 +60,7 @@ GetOptions(
"help|h",
"log|l:s",
"mail|m=s",
+ "pull|p",
"revision|r=s",
"skip-check|s",
"skip-manual",
@@ -80,8 +83,7 @@ if (defined $opt_log)
}
else
{
- chomp ($LOGFILE= `pwd`);
- $LOGFILE.= "/" . $opt_log;
+ $LOGFILE= $PWD . "/" . $opt_log;
}
}
}
@@ -103,7 +105,7 @@ defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used
system ("bk help > /dev/null") == 0 or &abort("Cannot execute BitKeeper binary!");
system ("bk root $REPO > /dev/null 2>&1") == 0 or &abort("$REPO does not seem to be a valid BK repository!");
-if (($opt_directory ne ".") && (!-d $opt_directory && !$opt_dry_run))
+if (($opt_directory ne $PWD) && (!-d $opt_directory && !$opt_dry_run))
{
&abort("Could not find target directory \"$opt_directory\"!");
}
@@ -111,6 +113,23 @@ if (($opt_directory ne ".") && (!-d $opt_directory && !$opt_dry_run))
&logger("Logging to $LOGFILE") if (defined $opt_log);
#
+# Pull recent changes first
+#
+if ($opt_pull)
+{
+ &logger("Updating BK tree $REPO to latest ChangeSet first");
+ $command= "cd $REPO; bk pull; cd ..";
+ &run_command($command, "Could not update $REPO!");
+
+ unless ($opt_skip_manual)
+ {
+ &logger("Updating manual tree in $opt_docdir");
+ $command= "cd $opt_docdir; bk pull; cd ..";
+ &run_command($command, "Could not update $opt_docdir!");
+ }
+}
+
+#
# Use a temporary name until we know the version number
#
$target_dir= $opt_directory . "/mysql-" . $$ . "-" . time() . ".tmp";
@@ -253,7 +272,7 @@ if (defined $opt_changelog)
#
# Add the latest manual from the mysqldoc tree
#
-if (!$opt_skip_manual)
+unless ($opt_skip_manual)
{
$msg= "Adding manual.texi";
&logger($msg);
@@ -310,7 +329,7 @@ $command= "make dist";
if ($opt_win_dist)
{
&logger ("Creating Windows source package");
- $command= "./scripts/make_win_src_distibution";
+ $command= "./scripts/make_win_src_distribution --tar --zip";
&run_command($command, "make_win_src_distribution failed!");
}
@@ -378,6 +397,7 @@ Options:
include a log file snippet, if logging is enabled)
Note that the \@-Sign needs to be quoted!
Example: --mail=user\\\@domain.com
+-p, --pull Update the source BK trees before building
-r, --revision=<rev> Export the tree as of revision <rev>
(default is up to the latest revision)
-s, --skip-check Skip checking the distribution with "make distcheck"
diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile
index 1e404f9c509..9f5ac657a0b 100755
--- a/Build-tools/Do-compile
+++ b/Build-tools/Do-compile
@@ -8,7 +8,7 @@ use Getopt::Long;
$opt_distribution=$opt_user=$opt_config_env="";
$opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix="";
$opt_tmp=$opt_version_suffix="";
-$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=0;
+$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=0;
$opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=0;
GetOptions(
@@ -51,6 +51,7 @@ GetOptions(
"with-low-memory",
"with-other-libc=s",
"with-small-disk",
+ "without-embedded",
) || usage();
usage() if ($opt_help);
@@ -230,6 +231,7 @@ if ($opt_stage <= 1)
$opt_config_options.= " --with-low-memory" if ($opt_with_low_memory);
$opt_config_options.= " --with-mysqld-ldflags=-all-static" if ($opt_static_server);
$opt_config_options.= " --with-raid" if ($opt_raid);
+ $opt_config_options.= " --with-embedded-server" unless ($opt_without_embedded);
# Only enable InnoDB when requested (required to be able to
# build the "Classic" packages that do not include InnoDB)
@@ -551,6 +553,9 @@ non-standard location overriding default.
--with-small-disk
Clean up the build environment before testing the binary distribution
(to save disk space)
+
+--without-embedded
+Don't compile the embedded server.
EOF
exit 1;
}
diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg
index e95d86c0f6e..4d0f120c6e3 100755
--- a/Build-tools/Do-pkg
+++ b/Build-tools/Do-pkg
@@ -1,7 +1,9 @@
#!/usr/bin/perl -w
#
# Do-pkg - convert a binary distribution into a Mac OS X PKG and put it
-# inside a Disk Image (.dmg)
+# 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
@@ -17,14 +19,19 @@
# 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;
@@ -35,13 +42,14 @@ GetOptions(
"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
-chomp($PWD= `pwd`);
+$PWD= cwd();
$LOGGER= "$PWD/logger.pm";
if (-f "$LOGGER")
{
@@ -54,7 +62,7 @@ else
$PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker";
$TMP= $ENV{TMPDIR};
-$TMP eq "" ? $TMP= $TMP . "/PKGBUILD": $TMP= "/tmp/PKGBUILD";
+$TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$";
$PKGROOT= "$TMP/PMROOT";
$PKGDEST= "$TMP/PKG";
$RESOURCE_DIR= "$TMP/Resources";
@@ -62,8 +70,8 @@ $SUFFIX= $opt_suffix;
$VERSION= $opt_version;
($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION);
$NAME= "mysql$SUFFIX-$VERSION";
-chomp($HOST= `hostname`);
-chomp($ID= `whoami`);
+$HOST= hostname();
+$ID= getpwuid($>);
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/$HOST-$MAJOR.$MINOR$SUFFIX.log";
@@ -73,6 +81,12 @@ $SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>;
$TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc.tar.gz>;
$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");
@@ -99,7 +113,9 @@ if (defined $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);
-foreach $file ($TAR, $INFO, $DESC)
+@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");
}
@@ -112,14 +128,22 @@ foreach $dir ($TMP, $PKGROOT, $PKGDEST, $RESOURCE_DIR)
{
if (!-d $dir)
{
- &run_command("mkdir $dir", "Could not make directory $dir!");
+ &logger("Creating directory $dir!");
+ unless($opt_dry_run)
+ {
+ mkdir($dir) or &abort("Could not make directory $dir!");
+ }
}
}
foreach $resfile (@RESOURCES)
{
- $command= "cp $SUPFILEDIR/$resfile $RESOURCE_DIR";
- &run_command($command, "Error while copying $SUPFILEDIR/$resfile to $RESOURCE_DIR");
+ &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
@@ -127,12 +151,17 @@ foreach $license (@LICENSES)
{
if (-f "$license")
{
- $command= "cp $license $RESOURCE_DIR/License.txt";
- &run_command($command, "Error while copying $license to $RESOURCE_DIR");
+ &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");
+&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");
@@ -145,10 +174,38 @@ foreach $license (@LICENSES)
# 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!");
+&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("Removing $PKGROOT");
-&run_command("rm -rf $PKGROOT", "Unable to remove $PKGROOT!");
+ &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)
{
@@ -159,7 +216,7 @@ if ($opt_skip_dmg)
# 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");
-if (! $opt_dry_run)
+unless($opt_dry_run)
{
chomp($_= `du -sk $PKGDEST`);
@size= split();
@@ -167,7 +224,10 @@ if (! $opt_dry_run)
&logger("Disk image size: $size KB");
}
-&abort("Zero bytes? Something is wrong here!") if ($size == 0);
+unless($opt_dry_run)
+{
+ &abort("Zero bytes? Something is wrong here!") if ($size == 0);
+}
# Now create and mount the disk image
$TMPNAME= $NAME . ".tmp";
@@ -181,7 +241,7 @@ $command= "hdiutil create $TMPNAME -size ${size}k -ov -fs UFS -volname $NAME";
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 $RESOURCE_DIR/ReadMe.txt /Volumes/$NAME", "Could not copy $RESOURCE_DIR/ReadMe.txt 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");
@@ -221,20 +281,23 @@ NOTE: You need to run this script with root privileges (required
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 Just build the PKG, don't put it into a
- disk image afterwards
- --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
+ --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;
diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm
index 6d107bc2413..0f423feb921 100755
--- a/Build-tools/Do-rpm
+++ b/Build-tools/Do-rpm
@@ -1,259 +1,227 @@
-#!/bin/bash
-
-#helper functions
-
-function copy_to_bmachine
+#!/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 (which should exist
+# like that, if the Do-compile script was used to build the binary
+# distribution)
+#
+# - there must be a source distribution (mysql-<version>.tar.gz)
+# in the current directory
+# - there must be a spec file (mysql-<version>.spec) in the directory
+# $HOME/<hostname>/mysql-<version>/support-files/
+#
+# 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;
+
+$MAJOR= $MINOR= $RELEASE= 0;
+
+GetOptions(
+ "cc=s",
+ "cflags=s",
+ "clean|c",
+ "cxx=s",
+ "cxxflags=s",
+ "dry-run|t",
+ "help|h",
+ "log|l:s",
+ "mail|m=s",
+ "verbose|v",
+) || &print_help;
+
+defined($VERSION=$ARGV[0]) || print_help("Please provide the MySQL version!");
+
+# Include helper functions
+$PWD= cwd();
+$LOGGER= "$PWD/logger.pm";
+if (-f "$LOGGER")
{
- if [ x$local_build = x1 ]; then
- rm -f $2
- cp $1 $2
- else
- scp $1 $owner@$bmachine:$2
- fi
+ do "$LOGGER";
}
-
-function copy_from_bmachine
+else
{
- if [ x$local_build = x1 ]; then
- rm -f $2
- cp $1 $2
- else
- scp $owner@$bmachine:$1 $2
- fi
+ die "ERROR: $LOGGER cannot be found!\n";
}
-function run_command
+#
+# Override predefined Log file name
+#
+if (defined $opt_log)
{
- if [ x$local_build = x1 ]; then
- bash $1
- else
- cat $1 | ssh $owner@$bmachine bash
- fi
+ if ($opt_log ne "")
+ {
+ if ($opt_log =~ /^\/.*/)
+ {
+ $LOGFILE= $opt_log;
+ }
+ else
+ {
+ $LOGFILE= $PWD . "/" . $opt_log;
+ }
+ }
}
-#Supply defaults
-
-# We built on one of two machines
-bmachine=work
-smachine=work
-owner=my
-
-# Hard path!!
-bpath=`/bin/pwd`
-
-for d in /usr/src/redhat /usr/src/packages ; do
-if test -d "$d"
-then
- rpmdir=$d
-fi
-done
-
-if test -z "$rpmdir"
-then
- echo "Could not find suitable rpmdir on this system"
- exit 1
-fi
-
-
-logdir="$bpath/Logs"
-
-###### Perl STUFF #####
-
-# Perl version numbers. Should be autodetected from the files in the
-# Perl-mysql-modules/ directory.
-DBI_VERSION="1.14"
-DATA_SHOWTABLE_VERSION="3.3"
-DBD_MYSQL_VERSION="1.2215"
-MAKERPM="$rpmdir/SOURCES/makerpm.pl"
-
-#######################
-AM_MAKEFLAGS="-j 2"
-
-VER=`grep "AM_INIT_AUTOMAKE(mysql, " $bpath/configure.in | \
- sed -e 's;AM_INIT_AUTOMAKE(mysql, ;;' -e 's;);;'`
-VER_NO_DASH=`echo $VER | sed -e "s|-.*$||"`
-tarball=$bpath/mysql-$VER.tar.gz
-
-while test $# -gt 0; do
- case "$1" in
- --rpmdir=*)
- rpmdir=`echo $1 | sed -e "s;--rpmdir=;;"`
- ;;
- --smachine=*)
- smachine=`echo $1 | sed -e "s;--smachine=;;"`
- ;;
- --bmachine=*)
- bmachine=`echo $1 | sed -e "s;--bmachine=;;"`
- ;;
- --owner=*)
- owner=`echo $1 | sed -e "s;--owner=;;"`
- ;;
- --tarball=*)
- tarball=`echo $1 | sed -e "s;--tarball=;;"`
- ;;
- --logdir=*)
- logdir=`echo $1 | sed -e "s;--logdir=;;"`
- ;;
- --local )
- local_build=1
- ;;
- --skip-perl )
- skip_perl=1
- ;;
- * ) break ;;
- esac
- shift
-done
-
-echo "Removing old MySQL packages"
-rm -f $bpath/NEW-RPMS/MySQL-*rpm
-
-if [ ! -d "$logdir" ]; then
- echo "$logdir does not exist, creating"
- mkdir -p $logdir
-fi
-
-if [ ! -f "$tarball" ]; then
- echo "Tarball file $tarball does not exist, please make one first"
- exit 1
-fi
-
-log=$logdir/Log-RPM-`date +%y%m%d-%H%M`
-
-echo "Building RPM for MySQL version $VER on $bmachine"
-echo "Details in $log"
-
-(
-set -x
-# remove old stuff
-rm -rf $rpmdir/BUILD/mysql-*
-rm -f $rpmdir/SOURCES/mysql-*
-rm -f $rpmdir/SRPMS/MySQL-*
-rm -f $rpmdir/SPECS/mysql-*
-rm -rf /var/tmp/mysql
-
-# Copy MySQL source and spec files
-
-#Sasha: I left the scp stuff commented out instead of deleted to make it
-#easy to revert in a hurry, if there is a need. Once everything is tested
-#and works perfectly, the scp stuff should be deleted to avoid confusion
-
-#scp $bpath/mysql-$VER.tar.gz $owner@$bmachine:$rpmdir/SOURCES
-copy_to_bmachine $tarball $rpmdir/SOURCES
-#scp $bpath/Docs/Images/mysql-logo.gif $owner@$bmachine:$rpmdir/SOURCES/mysql.gif
-copy_to_bmachine $bpath/Docs/Images/mysql-logo.gif $rpmdir/SOURCES/mysql.gif
-#scp $bpath/support-files/mysql-$VER.spec $owner@$bmachine:$rpmdir/SPECS
-copy_to_bmachine $bpath/support-files/mysql-$VER.spec $rpmdir/SPECS
-
-# Copy perl things. Has to be uncompressed since Compress.pm is not
-# installed yet. Set CEXT to .gz when we support compression.
-CEXT=
-#scp $bpath/Perl-mysql-modules/To-SOURCES/* $owner@$bmachine:$rpmdir/SOURCES
-
-# This had to be installed on the target machince!
-# http://www.perl.com/CPAN/modules/by-module/Archive/Archive-Tar-0.21.tar.gz
-# cd /usr/lib/perl5/site_perl/5.005; ln -s ../* .; rm -f 5.005
-
-TMP_SCRIPT_MYSQL=00-temp-for-do-rpm.$$
-cat > $logdir/$TMP_SCRIPT_MYSQL <<END
-set -x
-
-# Check environment
-#export MYSQL_BUILD_PATH="/usr/local/bin:/my/gnu/bin:/usr/bin:/bin"
-#export MYSQL_BUILD_CFLAGS="-O6 -fno-omit-frame-pointer -mcpu=pentiumpro"
-#export MYSQL_BUILD_CXXFLAGS="-O6 -fno-omit-frame-pointer \
-# -felide-constructors -fno-exceptions -fno-rtti -mcpu=pentiumpro"
-export MYSQL_BUILD_PATH="/usr/bin:/bin"
-export MYSQL_BUILD_CFLAGS="-O6 -fno-omit-frame-pointer -mpentium"
-export MYSQL_BUILD_CXXFLAGS="-O6 -fno-omit-frame-pointer \
- -felide-constructors -fno-exceptions -fno-rtti -mpentium"
-gcc -v
-
-# Make RPM
-rpm -ba $rpmdir/SPECS/mysql-$VER.spec
-rm -f /tmp/$TMP_SCRIPT_MYSQL
-END
+($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION);
+$HOST= hostname();
+$HOST=~ /^([^.-]*)/;
+$HOST= $1;
+$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log";
-if [ ! x$skip_perl=x1 ]; then
+&print_help("") if ($opt_help);
- TMP_SCRIPT_PERL=00-temp-for-perl-rpm.$$
- cat > $logdir/$TMP_SCRIPT_PERL <<END
- set -x
-
- # First clean up so we do not get old versions when wildcard matching
- rm -f $rpmdir/SOURCES/DBI-*.spec $rpmdir/SOURCES/mysql*
- rm -f $rpmdir/RPMS/i386/Perl-*.rpm
- rm -f $rpmdir/SRPMS/Perl-*.rpm
- rm -f $rpmdir/RPMS/i386/MySQL*-$VER_NO_DASH*.rpm
- rm -f $rpmdir/SRPMS/MySQL*-$VER_NO_DASH*.rpm
-
- chmod a+x ${MAKERPM}
- rm
-
- ${MAKERPM} --verbose --package-name=DBI --package-version ${DBI_VERSION} \
- --specs --source=DBI-${DBI_VERSION}.tar$CEXT
-
- rpm -ba $rpmdir/SPECS/DBI-${DBI_VERSION}.spec
-
- ${MAKERPM} --verbose --package-name=Data-ShowTable \
- --package-version ${DATA_SHOWTABLE_VERSION} \
- --specs --source=Data-ShowTable-${DATA_SHOWTABLE_VERSION}.tar$CEXT
-
- rpm -ba $rpmdir/SPECS/Data-ShowTable-${DATA_SHOWTABLE_VERSION}.spec
-
- for v in ${DBD_MYSQL_VERSION}; do
- ${MAKERPM}
- --specs \
- --source=Msql-Mysql-modules-$v.tar$CEXT \
- --setup-dir=Msql-Mysql-modules-$v \
- --package-name=DBD-mysql \
- --package-version=$v \
- --makemakeropts='--noprompt --mysql-install --mysql-install-nodbd \
- --nomsql-install --nomsql1-install' \
- --require=perl-Data-ShowTable --require=perl-DBI
- rpm -ba $rpmdir/SPECS/DBD-mysql-$v.spec
- done
-
- for srcrpm in $rpmdir/SRPMS/perl-*.src.rpm
- do
- rpm --rebuild $srcrpm
- done
-
- rm -f /tmp/$TMP_SCRIPT_PERL
-END
-fi
-
- # scp $bpath/Logs/$TMP_SCRIPT_MYSQL $owner@$bmachine:/tmp/$TMP_SCRIPT_MYSQL
-
-# ssh $bmachine -l $owner bash $bpath/Logs/$TMP_SCRIPT_MYSQL
-
-cmd=$logdir/$TMP_SCRIPT_MYSQL
-run_command $cmd
+#
+# Newer RPM versions ship with a separate tool "rpmbuild" to build RPMs
+#
+if (-x "/usr/bin/rpmbuild")
+{
+ $RPM= "/usr/bin/rpmbuild";
+}
+else
+{
+ $RPM= "/bin/rpm";
+}
-if [ $? != 0 ]; then
- echo "$cmd failed, perhaps the following will help figure out why:"
- tail $log
-fi
+if ($RPM)
+{
+ &logger("Found rpm binary: $RPM");
+}
+else
+{
+ &abort("Unable to find RPM binary!");
+}
-if [ x$local_build != x1 ]; then
+#
+# 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`);
- # Build perl RPM (we currently need to be root to do this and that is
- # not possible)
+$SOURCEFILE= "mysql-$VERSION.tar.gz";
+$SPECFILE= "$PWD/$HOST/mysql-$VERSION/support-files/mysql-$VERSION.spec";
- #scp $bpath/Logs/$TMP_SCRIPT_PERL $owner@$bmachine:/tmp/$TMP_SCRIPT_PERL
- #ssh $bmachine -l root bash /tmp/$TMP_SCRIPT_PERL
+&logger("Starting RPM build of MySQL-$VERSION on $HOST");
- # Copy RPMs back to the source dir. We must do this here since the
- # $bmachine may not have permission to access $smachine.
- scp $owner@$bmachine:$rpmdir/RPMS/i386/MySQL*-$VER_NO_DASH*.rpm $bpath/NEW-RPMS
- scp $owner@$bmachine:$rpmdir/SRPMS/MySQL*-$VER_NO_DASH*.rpm $bpath/NEW-RPMS
+foreach $file ($SOURCEFILE, $SPECFILE)
+{
+ &abort("Unable to find $file!") unless (-f "$file");
+}
- # And the perl ones
- #scp $owner@$bmachine:$rpmdir/RPMS/i386/Perl*-*.rpm $bpath/NEW-RPMS
- #scp $owner@$bmachine:$rpmdir/SRPMS/Perl*-*.rpm $bpath/NEW-RPMS
+#
+# Install source and spec file
+#
+&logger("Copying SOURCE and SPEC file to build directories.");
+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" 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*.src.rpm $PWD";
+&run_command($command, "Error moving source RPM!");
+
+$command= "mv";
+$command.= " -v " if ($opt_verbose);
+$command.= "$RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD";
+&run_command($command, "Error moving binary RPMs!");
+
+#
+# Clean up
+#
+if ($opt_clean)
+{
+ &logger("Removing spec file and source package");
+ unlink("$SPECDIR/" . basename($SPECFILE));
+ unlink("$SOURCEDIR/$SOURCEFILE");
+}
- #Remove some of the files that can interfere with future builds
+&logger("SUCCESS: RPM files successfully created.") if (!$opt_dry_run);
+exit 0;
- rm -rf /var/tmp/mysql
-fi
-) > $log 2>&1
+sub print_help
+{
+ my $message= $_[0];
+ if ($message ne "")
+ {
+ print "\n";
+ print "ERROR: $message\n\n}";
+ }
+ print <<EOF;
+
+Usage: Do-rpm <options> <version>
+
+Creates a binary RPM package out of a MySQL source distribution and moves the
+resulting RPMs into the current directory. <version> is the MySQL version
+number (e.g. 4.0.11-gamma)
+
+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>]
+ (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
+-v, --verbose Verbose execution
+
+EOF
+ exit 1;
+}