Rebuilding Webalizer RPM to change the default language
Quoting the official Webalizer website:
The Webalizer is a fast, free web server log file analysis program. It produces highly detailed, easily configurable usage reports in HTML format, for viewing with a standard web browser.
By default, the reports generated by Webalizer are in English, and there is no way to change this after it is installed. This is because the language files are statically linked in it’s source code, therefore you need to recompile it if you want to change it’s language.
However, if you installed Webalizer from an RPM package, it’s lame to just recompile it and copy the webalizer binary (if you use Plesk, it is what Parallels suggests) since it would break package verification with rpm -V webalizer. Wouldn’t it be better if your RPM package already provided the software in the desired state? Let’s see how this could be done…
Obtaining the sources and the specfile
To create an RPM package two things are needed: the source package and a specfile. In this case, I’ll use the specfile from Fedora 12, available at http://cvs.fedoraproject.org/viewvc/rpms/webalizer/. You can see that Fedora builds Webalizer with some additional patches, also available in the CVS repository. So here’s my checklist:
- specfile
- patches
- source package in the format required in the specfile (bz2)
Just place the webalizer.spec in the SPECS directory and the patches and source package in the SOURCES dir of your build environment (/usr/src/redhat if you are root – however, you should avoid building RPM packages as root).
Modifying the specfile
If you want to do a custom build of Webalizer, remember that you’ll need to change the release number of your package to avoid version conflicts. The combination of the package name, version and release must represent only one specific build process. If any change is made to your specfile, you MUST do a new release. This is done so that you can easily distinguish different builds of the same package.
In this case, we’ll build Webalizer with Brazilian Portuguese as default language. The specfile is for 2.21_02-3, so I’ll change it to 2.21_02-3_br:
Name: webalizer Summary: A flexible Web server log file analysis program Group: Applications/Internet Version: 2.21_02 Release: 3_br
It is also a Good Thing to describe your changes in the %changelog section:
* Tue Oct 13 2009 Pedro Padron <ppadron@w3p.com.br> - 2.21_02-3_br - Rebuilt with brazilian portuguese as default language
As stated before, the default language for Webalizer is something you define when the software is compiled, as a parameter for the configure script. In the specfile, the configure command line is described in the %build section:
%configure --enable-dns --with-dblib=/lib --enable-bz2
To use a different language, all we need to do is add the –with-language parameter:
%configure --with-language=portuguese_brazil --enable-dns --with-dblib=/lib --enable-bz2
You can check for all the available languages in the lang/ dir of Webalizer source code.
Building and installing the package
With the specfile ready, just issue the rpmbuild command:
$ rpmbuild -ba webalizer.spec
If everything’s fine, the RPM package will be created in the RPMS directory of your build environment.
To install it:
$ rpm -ihv webalizer-2.21_02-3_br.rpm
To upgrade an installed Webalizer package:
$ rpm -Uhv webalizer-2.21_02-3_br.rpm
The source RPM package
Another RPM package is generated in the build process, the source RPM package, located in the SRPMS dir. This package contains everything that is needed to rebuild the package. This is useful if you need to build the same package for different architectures, say i386 and x86_64. Using the source RPM, all you need to do is:
$ rpmbuild --rebuild webalizer-2.21_02-3_br.src.rpm
You can also install the source package and build it from the specfile:
$ rpm -i webalizer-2.21_02-3_br.src.rpm $ rpmbuid -ba /usr/src/redhat/SPECS/webalizer.spec
Download
To make it easy for you, here’s a source RPM package for the 2.21_02-3 build. You can use this as a kickstart to create your own build.
Download webalizer-2.21_02-3.src.rpm




