Tuesday, January 16, 2007

Building mySQL into a RPM from Source

bkf clone -rmysql-5.0.33 bk://mysql.bkbits.net/mysql-5.0-community mysql-5.0.33

cd mysql-5.0.33

BUILD/autorun.sh

cd ../

tar cvzf /usr/src/redhat/SOURCES/mysql-5.0.33.tar.gz mysql-5.0.33

export CC=/usr/bin/gcc
export CXX=/usr/bin/gcc
export LD_LIBARY_PATH=$LD_LIBARY_PATH:/lib64:/usr/lib64
export CFLAGS="-O2 -static -fomit-frame-pointer -ffixed-ebp"
export CXXFLAGS="-02 -felide-constructors -fno-exceptions -fno-rtti"

rpmbuild -ba --define '_with_static 1' mysql-5.0.33.spec

Now mysql-5.0.33.spec is just any spec file distributed with the RHEL source RPM - if requested I can upload it.


UPDATE: Lenz left a refinement in a comment here

Really good stuff

4 comments:

Anonymous said...

Instead of BUILD/autorun.sh you should probably use the BUILD/compile-dist script, followed by "make dist". This will create a source tarball in the same way as they are built by MySQL AB. Tarring up the entire BK clone is not the appropriate way to do it. And I would not recommed to set the static build flag, it's not really useful on todays Linux systems based on glibc 2.3 or higher. The RPM spec file is acutally included in the source tree as well - look into the "support-files" directory. This is the MySQL uses to create the "generic" RPMs, which should fit very well on a broad range of distributions.

Dathan Pattishall said...

Thanks lenz, this is very helpfull

Anonymous said...

What is the significance of using -O3 against -O2. Did you do any performance comparisions of -O2 against -O3? Just curious to know

Dathan Pattishall said...

O3 is a force of habbit mySQL forces O2