Thursday 13 January 2011

Bacula - Building from source

I like Bacula! - I'm no expert, but I am trying to become one. I'm getting my head around how this project works, and this blog entry will help me, and others.

Just to note, I am running CentOS 5.5 64 bit edition, and 32 bit edition

It's pretty neat when you think about it. It does what it says on the tin. Once configured, Bacula goes about backing up all your data without you noticing. Nice.

The first hurdle is compiling it. This is my experience, (well, one of them) - (Disclaimer: I must make it clear, that I read through a number of sites, and have just put down my notes in this guide that I took from those sites, as well as my own knowledge.

I have to compile my own RPMS so that I can have the latest code, and because I'm running CentOS, which doesn't have 5.0.3

So, first start by installing all the prerequisites:

# sudo yum install mysql-devel rpm-build libX11-devel libXext-devel GConf2-devel freetype-devel libtermcap-devel shadow-utils gcc gcc-c++ make autoconf glibc glibc-devel ncurses ncurses-devel perl  readline-devel libstdc++-devel zlib-devel openssl-devel libacl-devel pkgconfig tcp_wrappers openssl-devel fontconfig-devel libpng-devel openssl fontconfig libgcc libpng libstdc++ zli

Now you should have no problems later on. You need a build environment. I usually create a user called "builder" on the target machine.

# sudo useradd builder
# su builder

And now I can build packages in a safe environment, as a non privileged user. Mr Builder, needs to have a build environment.

# echo "%_topdir /home/${USER}/redhat/" > ~/.rpmmacros
# mkdir -p ~/redhat/{BUILD,RPMS/{i386,i686,noarch},SOURCES,SPECS,SRPMS}

And voila - build environment. Now, at this point, you are ready to build, but to build we need sources. The sources can be found on sourceforge. At the time of writing this was the latests source could be found http://sourceforge.net/projects/bacula/files/rpms/5.0.3/ From here, you need to download

# cd /tmp
# wget http://sourceforge.net/projects/bacula/files/rpms/5.0.3/bacula-5.0.3-1.src.rpm/download
# wget http://sourceforge.net/projects/bacula/files/rpms/5.0.3/bacula-bat-5.0.3-2.src.rpm/download
# wget http://sourceforge.net/projects/bacula/files/rpms/5.0.3/bacula-docs-5.0.3-1.src.rpm/download
# wget http://sourceforge.net/projects/bacula/files/rpms/5.0.3/bacula-mtx-5.0.3-1.src.rpm/download

Now we can begin:

# rpmbuild --rebuild --define "_vendor redhat" --define "build_mysql 1" --define "build_centos5 1" ./bacula-5.0.3-1.src.rpm

# rpmbuild --rebuild --define "_vendor redhat" --define "build_mysql 1" --define "build_centos5 1" ./bacula-bat-5.0.3-2.src.rpm

# pmbuild --rebuild --define "_vendor redhat" --define "build_mysql 1" --define "build_centos5 1" ./bacula-docs-5.0.3-1.src.rpm

# rpmbuild --rebuild --define "_vendor redhat" --define "build_mysql 1" --define "build_centos5 1" ./bacula-mtx-5.0.3-1.src.rpm


This will create the RPMS, in the following directory,

/home/builder/redhat/RPMS/

which has seperate folders for x86_64 i386, and i686, pick the right one for your system, (I built on a x86_64 system, so I found the RPMS there). I'm 70% sure that there is a way to compile for all architectures at the same time, or at least on the same machine, I'm looking into that, and I'll update in due course.

Well, feel free to comment, and point out my mistakes and I'll update :)

No comments:

Post a Comment