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


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


LenZ 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 said...

Thanks lenz, this is very helpfull

Yogish Baliga 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 said...

O3 is a force of habbit mySQL forces O2

squadra said...


Anonymous said...



A片,色情,成人,做愛,情色文學,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色,情色視訊,免費成人影片,視訊交友,視訊聊天,視訊聊天室,言情小說,愛情小說,AIO,AV片,A漫,av dvd,聊天室,自拍,情色論壇,視訊美女,AV成人網,色情A片,SEX