Fed up of manually rebuilding Mangos? Look no further, follow these simple steps and you will have your very own Mangos-RPM-Producing-Machine!
First, we need to make sure we have the necessary environment to build everything, as root run the following:
Code:
yum install gcc gcc-c++ autoconf automake bin-utils make rpmbuild libtool git zlib-devel mysql-devel
Next, we need to create our "build_mangos.sh" build script, if you place this in "$HOME/bin" or "~/bin" then it will already be in your PATH for added convenience. This script will initially create, and later update the source tree from GIT, extract the revision number and feed that into the rpmbuild process. Such that Mangos revision 9406 will produce an RPM like e.g. mangos-9406-0.fc11.x86_64.rpm
~/bin/build_mangos.sh
Code:
#!/bin/bash
echo "Checking if git has updated..."
if [ ! -d mangos ]; then
git clone git://github.com/mangos/mangos.git mangos
fi
cd mangos
git pull
REV=`grep 'REVISION_NR \"[0-9]*\"' src/shared/revision_nr.h | tr -d '"' | awk '{print $3}'`
cd ..
if [ -f mangos-${REV}.tar.gz ]; then
echo " - no change!"
exit
fi
echo "Preparing the source tarball..."
cd mangos
if [ -d build ]; then
echo " - cleaning..."
cd build
make clean
cd ..
rm -Rf build
fi
echo " - configuring..."
autoreconf --install --force
mkdir build
cd ..
echo " - compressing..."
tar -czf mangos-${REV}.tar.gz mangos
# Prepare a dummy rpmbuild tree
mkdir -p rpmbuild/SOURCES
cp mangos-${REV}.tar.gz rpmbuild/SOURCES
# Build
rpmbuild -ba rpmbuild/SPECS/mangos.spec --define "REVISION $REV"
You can manually call this script at any time, set it up as a daily cronjob, or integrate with something like Hudson.
Now, we just need our RPM spec file.
~/rpmbuild/SPECS/mangos.spec
Code:
Name: mangos
Summary: MaNGOS is a free, Open Source implementation of a game server compatible with the original World of Warcraft client.
Version: %REVISION
Release: 0%{?dist}
License: GPLv2
Group: Games
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%description
The MaNGOS project is a full featured World of Warcraft server suite, including servers for authentication, client updates, world content serving, and battlegrounds. Additional features include tools to build and develop game content. MaNGOS is an educational project. This means, our primary interest is to learn and teach us and our users more about C++ project development in a large scale. Our software is not intended for running public servers, and we do not support that.
%prep
%setup -q -n %{name}
%build
cd build
ln -s ../configure configure
%configure --with-mysql
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
cd build
make install DESTDIR=%{buildroot}
%clean
rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
%exclude %_bindir/genrevision
%config %_sysconfdir/mangosd.conf.dist
%config %_sysconfdir/realmd.conf.dist
%_bindir/mangos-realmd
%_bindir/mangos-worldd
%_libdir/*
%_datadir/mangos/*
%changelog
Run a test build "build_mangos.sh" and make sure everything succeeds, I have just tested this on two of my Fedora 11 machines and can confirm it works on i686 & x86_64 architectures just fine. Your successful RPM builds will appear in the ~/rpmbuild/RPMS subdirectories.