1
0
mirror of https://github.com/MariaDB/server.git synced 2026-01-06 05:22:24 +03:00
Files
mariadb/Build-tools/Do-rpm
lenz@mysql.com 94c7024eaa - enabled embedded server in the binary distributions by default
(Do-compile)
 - added mysql.info to the binary distribution files (BUG#1019)
 - heavily reworked the Do-rpm script to be more in line with Do-pkg
 - create a "docs" subdirectory in the binary distribution and moved the
   manual, ChangeLog and mysql.info file into it to unclutter the top
   directory
2003-08-12 23:21:21 +02:00

168 lines
3.7 KiB
Perl
Executable File

#!/usr/bin/perl -w
#
# Do-rpm - compile RPM packages out of a source tarball and copy 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 Getopt::Long;
Getopt::Long::Configure ("bundling");
$opt_dry_run= undef;
$opt_help= undef;
$opt_log= undef;
$opt_mail= "";
$opt_verbose= undef;
$opt_version= undef;
GetOptions(
"dry-run",
"help|h",
"log|l:s",
"mail|m=s",
"verbose|v",
"version=s",
) || &print_help;
# Include helper functions
chomp($PWD= `pwd`);
$LOGGER= "$PWD/logger.pm";
if (-f "$LOGGER")
{
do "$LOGGER";
}
else
{
die "ERROR: $LOGGER cannot be found!\n";
}
#
# Override predefined Log file name
#
if (defined $opt_log)
{
if ($opt_log ne "")
{
if ($opt_log =~ /^\/.*/)
{
$LOGFILE= $opt_log;
}
else
{
$LOGFILE= $PWD . "/" . $opt_log;
}
}
}
&print_help("") if ($opt_help || !$opt_version);
#
# Newer RPM version ship with a separate tool to build RPMs
#
if (-x "/usr/bin/rpmbuild")
{
$RPM= "/usr/bin/rpmbuild";
}
else
{
$RPM= "/bin/rpm";
}
foreach $DIR ("/usr/src/packages", "/usr/src/redhat")
{
if (-d $DIR)
{
$TOPDIR= $DIR;
last;
}
}
$SPECDIR= $TOPDIR . "/SPECS";
$SOURCEDIR= $TOPDIR . "/SOURCES";
$VERSION= $opt_version;
($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION);
chomp($HOST= `hostname`);
$HOST=~ /^([^.-]*)/;
$HOST= $1;
$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log";
$SOURCEFILE= "mysql-$VERSION.tar.gz";
$SPECFILE= "$PWD/$HOST/mysql-$VERSION/support-files/mysql-$VERSION.spec";
&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.");
$command= "cp";
$command.= " -v" if ($opt_verbose);
$command.= " $SOURCEFILE $SOURCEDIR";
&run_command($command, "Unable to copy $SOURCEFILE to $SOURCEDIR!");
$command= "cp";
$command.= " -v" if ($opt_verbose);
$command.= " $SPECFILE $SPECDIR";
&run_command($command, "Unable to copy $SPECFILE to $SPECDIR!");
#
# Build the RPMs
#
$command= "$RPM";
$command.=" -v" if ($opt_verbose);
$command.=" -ba --clean $SPECDIR/$SPECFILE";
&logger("Builing RPM.");
&run_command($command, "Unable to build RPM!");
&logger("SUCCESS: RPM files successfully 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-rpm <options> --version=<version>
Creates a binary RPM package out of a MySQL source distribution and copy the
resulting RPMs into the current directory.
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
--version=<version> The MySQL version number (e.g. 4.0.11-gamma)
-v, --verbose Verbose execution
EOF
exit 1;
}