This howto will explain how to create a CentOS-5 and centOS-6 rpm for hiawatha webserver, a security-centric webserver.
I do all my rpm building in a separate and isolated virtual machine.. you probably will want to do this.. install a CentOS-6 x86_64 virtual machine and then install mock:
I installed mock from the EPEL repository:
yum install mock
Installing our anku repositories for mock
Now a “must”:
The creator of hiawatha requires the use of a cmake version newer, not offered, by CentOS-5 nor CentOS-6, therefore I had to build a cmake rpm for a newer version, version 2.8.4 has been uploaded to our CentOS repositories (http://anku.ecualinux.com) we call those repos: anku (anku means flexible in Quechua Language). You have to add a “new” repository to your mock installation.
To do so, please download the following files into: your /etc/mock directory (as root):
wget http://www.ecualinux.com/anku-5-i386.cfg -O /etc/mock/anku-5-i386.cfg
wget http://www.ecualinux.com/anku-6-i386.cfg -O /etc/mock/anku-6-i386.cfg
wget http://www.ecualinux.com/anku-5-x86_64.cfg -O /etc/mock/anku-5-x86_64.cfg
wget http://www.ecualinux.com/anku-6-x86_64.cfg -O /etc/mock/anku-6-x86_64.cfg
wget http://www.ecualinux.com/anku-7-x86_64.cfg -O /etc/mock/anku-7-x86_64.cfg
Doing this is a must!!! Otherwise the compilation will fail with cmake errors.
Actually all the anku-*.cfg’s files are the very same epel-*cfg ones but with a new repository added (the anku one near the end of each file)
Creating a mock user:
Then created a user to work with mock, for this user to be able to work it must be in the “mock” group.
I then added eperez to the mock group by editing /etc/group. Check this line at the bottom of your /etc/group file containing my username as part of the mock group:
[[email protected] ~]$ egrep mock /etc/group
Good. Then login as your mock user, in my case eperez, all the steps from now on will be made as user eperez, as my mock user
Download the latest hiawatha from there, for example, the latest hiawatha webserver package as of today is 9.12, lets download it:
wget --no-check-certificate https://www.hiawatha-webserver.org/files/hiawatha-9.12.tar.gz
(ok, versions will continue rolling after a few months or years, allways look for the latest hiawatha*tar.gz in the hiawatha webserver’s site)
Now I must get a working hiawatha.spec file, I simply take advantage of a previous hiawatha SRC.RPM from my repos. I store all of them in here: http://anku.ecualinux.com/6/SRPMS/
I then download the latest src.rpm. In this example I will:
- Download the most up to date hiawatha src.rpm from my repo: http://anku.ecualinux.com/6/SRPMS/hiawatha-9.8-ecualinux.2.el6.src.rpm as of today
- Open it (with rpm -Uvh)
- Copy the newest tar.gz I downloaded previously
- Slightly modify the resulting hiawatha.spec to look for this new version (9.12 in this example)
Here are the steps:
rpm -Uvh hiawatha-9.8-ecualinux.2.el6.src.rpm
mv hiawatha-9.12.tar.gz rpmbuild/SOURCES/
Ok, the last line.. this is the spec file for the previous version, 9.8 in this example. You may notice it by looking into the very first lines of hiawatha.spec you will see the version (realver) as 9.8, as Im about to compile version 9.12 I change it to look like this:
%define realver 9.12
Well, well… it is time to create an src.rpm for mock to later compile it for all the CentOS versions (5 and 6 as for the moment). I will create a CentOS-5 src.rpm because CentOS-5 can not easily read CentOS-6’s rpm but the opposite is possible: CentOS-6 can open and work with CentOS-5’s rpms.
mock -r anku-5-i386 --buildsrpm --spec rpmbuild/SPECS/hiawatha.spec --sources rpmbuild/SOURCES/
Good.. after a while I have a resulting hiawatha*src.rpm inside: /var/lib/mock/epel-5-i386/result/, lets move it away from there otherwise it can be deleted the next time we invoke mock for this version and arch:
mv /var/lib/mock/epel-5-i386/result/hiawatha-9.12*.src.rpm .
Now the easiest part of all: let’s recompile this newly obtained hiawatha-9.12*.src.rpm for all current CentOS versions (5 and 6) and architectures (i386 and x86_64):
mock -r anku-6-i386 hiawatha-9.12*.src.rpm
mock -r anku-6-x86_64 hiawatha-9.12*.src.rpm
mock -r anku-5-i386 hiawatha-9.12*.src.rpm
mock -r anku-5-x86_64 hiawatha-9.12*.src.rpm
Here is the trick, anku, our repo, remember it? The files I asked you to download into /etc/mock at the beginning of this post? great!.
The results will be stored in:
That’s it! Don’t forget to move the resulting rpms away from the directories stated above as mock delete their contents the next time you try to compile anything using mock for that version and arch.
What will I do the next time a new hiawatha version comes of? Easy:
- Login as user eperez into this server (it is a virtual server with 10GB of HD)
- Download the new hiawatha version, for example some day we will have hiawatha-9.13.tar.gz
- Move this new tar.gz file to: rpmbuild/SOURCES/
- Edit rpmbuild/SPECS/hiawatha.spec and change the version to 9.13
- Create a new src.rpm for centos-5
- Recompile this src.rpm for all centos versions and arch.