mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 12:01:42 +01:00
194 lines
3.6 KiB
Perl
Executable file
194 lines
3.6 KiB
Perl
Executable file
#!/usr/bin/perl -w
|
|
#
|
|
# (C)opyright Oracle/Innobase Oy. 2007.
|
|
#
|
|
# The purpose of this (simple) script is to create a configure command line
|
|
# that can be used to build the InnoDB dynamic plugin. It makes the assumption
|
|
# that the configure parameters are quoted like so '--with-innodb'. It uses
|
|
# this to split the string on "'".
|
|
#
|
|
# Usage: dynconfig <path/to/mysqlbug>
|
|
#
|
|
# RETURNS: 0 OK
|
|
|
|
my $buffer;
|
|
|
|
# These are the eninges whose config parameters we need to remove.
|
|
my @engines = (
|
|
"ndbcluster",
|
|
"innodb",
|
|
"csv",
|
|
"archive",
|
|
"blackhole",
|
|
"example",
|
|
"federated",
|
|
"embedded-server",
|
|
"partition"
|
|
);
|
|
|
|
# Map the following variables to something else. If you want to remove any
|
|
# parameters from the configure command line, simply add an "" value to the
|
|
# hashtable below.
|
|
my %mapped = (
|
|
"--disable-shared" => "",
|
|
"--enable-static" => "--enable-shared"
|
|
);
|
|
|
|
# Variables to use from the environment if defined
|
|
my @environment = (
|
|
"CC",
|
|
"CXX"
|
|
);
|
|
|
|
sub get_value {
|
|
my ($line) = @_;
|
|
|
|
$line =~ s/^CONFIGURE_LINE="(.*)"$/$1/;
|
|
|
|
return($line);
|
|
}
|
|
|
|
sub is_with_engine {
|
|
my ($param) = @_;
|
|
|
|
foreach my $engine (@engines) {
|
|
|
|
if ($param =~ /--with-$engine/) {
|
|
return($engine);
|
|
} elsif ($param =~ /--with-$engine-storage-engine/) {
|
|
return($engine);
|
|
}
|
|
}
|
|
|
|
return(undef);
|
|
}
|
|
|
|
sub map_param {
|
|
my ($param) = @_;
|
|
my ($name, $value) = split(/=/, $param);
|
|
my $mapped;
|
|
|
|
if (!defined($value)) {
|
|
$mapped = $mapped{$param};
|
|
} else {
|
|
$mapped = $mapped{$name};
|
|
}
|
|
|
|
return(defined($mapped) ? $mapped: $param);
|
|
}
|
|
|
|
# Remove leading whitespace
|
|
sub ltrim($) {
|
|
my $string = shift;
|
|
|
|
$string =~ s/^\s+//;
|
|
|
|
return $string;
|
|
}
|
|
|
|
# Remove trailing whitespace
|
|
sub rtrim($) {
|
|
my $string = shift;
|
|
|
|
$string =~ s/\s+$//;
|
|
|
|
return $string;
|
|
}
|
|
|
|
# Remove leading and trailing whitespace
|
|
sub squeeze($) {
|
|
my $string = shift;
|
|
|
|
return(rtrim(ltrim($string)));
|
|
}
|
|
|
|
if ($#ARGV < 0) {
|
|
print "usage: <patch/to/mysqlbug> [options e.g. CC=xxx]\n";
|
|
exit(1);
|
|
}
|
|
|
|
open(F, $ARGV[0]) ||
|
|
die "Error opening $ARGV[0]: $!";
|
|
read(F, $buffer, 131072) ||
|
|
die "Error reading file $ARGV[0]: $!";
|
|
close(F);
|
|
|
|
my @matched = grep(/^CONFIGURE_LINE=/, split(/\n/, $buffer));
|
|
|
|
# Check for no match
|
|
if ($#matched == -1 ) {
|
|
print "CONFIGURE_LINE= not found in : $ARGV[0]\n";
|
|
exit(1);
|
|
# Check if more than one line matched
|
|
} elsif ($#matched > 0) {
|
|
printf "Error too many matches found.\n";
|
|
exit(1);
|
|
}
|
|
|
|
# Since CONFIGURE_LINE is an environment variable we extract the value,
|
|
# stripping the "" quotes around the value too.
|
|
my $configure = get_value($matched[0]);
|
|
|
|
# Insert the environment variables if found into the hash table
|
|
foreach my $var (@environment) {
|
|
|
|
if (defined($ENV{$var})) {
|
|
$mapped{$var} = "$var=" . $ENV{$var};
|
|
}
|
|
}
|
|
|
|
# Set the value to "" for the parameters to be removed.
|
|
if (defined($ENV{"MYSQL_CONFIG_DEL"})) {
|
|
my $value = $ENV{"MYSQL_CONFIG_DEL"};
|
|
|
|
($value) =~ s/MYSQL_CONFIG_DEL="(.+)"$/$1/;
|
|
|
|
foreach my $param (split(/,/, $value)) {
|
|
$param = squeeze($param);
|
|
|
|
if ($param =~ /^'(.+)'$/) {
|
|
$param = $1;
|
|
}
|
|
$mapped{$param} = "";
|
|
}
|
|
}
|
|
|
|
my @arr = split(/'/, $configure);
|
|
|
|
foreach my $param (@arr) {
|
|
|
|
# Skip blank lines
|
|
if ($param =~ /^\s+$/) {
|
|
next;
|
|
# We don't want to put quotes around the command
|
|
} elsif ($param =~ /.\/configure/) {
|
|
print "$param";
|
|
next;
|
|
# Filter out the --with-engine parameters
|
|
} elsif (is_with_engine($param)) {
|
|
next;
|
|
}
|
|
|
|
$param = map_param($param);
|
|
|
|
if (length($param) > 0) {
|
|
print "'$param' ";
|
|
}
|
|
}
|
|
|
|
if (defined($ENV{"MYSQL_CONFIG_ADD"})) {
|
|
my $value = $ENV{"MYSQL_CONFIG_ADD"};
|
|
|
|
$value =~ s/MYSQL_CONFIG_ADD="(.+)"$/$1/;
|
|
|
|
foreach my $param (split(/,/, $value)) {
|
|
$param = squeeze($param);
|
|
if ($param =~ /^'(.+)'$/) {
|
|
$param = $1;
|
|
}
|
|
print "'$param' ";
|
|
}
|
|
}
|
|
|
|
exit(0);
|
|
|