#!/bin/bash #helper functions function copy_to_bmachine { if [ x$local_build = x1 ]; then rm -f $2 cp $1 $2 else scp $1 $owner@$bmachine:$2 fi } function copy_from_bmachine { if [ x$local_build = x1 ]; then rm -f $2 cp $1 $2 else scp $owner@$bmachine:$1 $2 fi } function run_command { if [ x$local_build = x1 ]; then bash $1 else cat $1 | ssh $owner@$bmachine bash fi } #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 < $logdir/$TMP_SCRIPT_PERL < $log 2>&1