Simutrans, as
I've written before, is a fun game.
Currently it's in active development, with new features and bug fixes arriving several times each year. But Ubuntu's repository system is based on six-month snapshots; it cannot keep up with the pace of Simutrans releases.
That causes a big problem for multiplayer games: The server requires clients to be on a similar pakset and release, and the server operators usually keep up with the releases. So Ubuntu users are locked out of multiplayer games - the versions in the Ubuntu repos are simply too old.
So I want roll my own .deb of the latest version of Simutrans. This is the first step - eventually a PPA of the backported latest release would be cool.
1) Create a VM for the build environment. For this, I used a VM of my current install, Ubuntu 11.10. But you can use anything back to Debian 6, of course.
The VM serves several purposes. It provides the appropriate build environment for each version of Ubuntu. It also provides a safe place to test the final package installation. And, of course, it protects my main system.
Beyond the basic setup, you should probably clean up the desktop shortcut bar; you don't need Software Center or LibreOffice, but you do need Terminal on there. You should also set Software Sources to automatically download-and-apply security updates, you can safely ignore all non-security updates.
Also, install the following packages needed for a useful Simutrans build environment:
$ sudo apt-get install build-essential devscripts debhelper libsdl1.2-dev
libsdl-mixer1.2-dev zlib1g-dev imagemagick libpng-dev libbz2-dev libssl-dev subversion
Do NOT install the
simutrans
package from the Ubuntu repositories. If you do install it, for example to confirm that it works, remove it.
2) Prepare the working directory for Simutrans and download the sources
First, let's set up the Simutrans working directory
~$ mkdir Simutrans_Development
~$ cd Simutrans_Development
~/Simutrans_Development$ wget http://ftp.us.debian.org/debian/pool/main/s/simutrans/simutrans_111.2.2-1.debian.tar.xz
~/Simutrans_Development$ tar -xvf simutrans_111.2.2-1.debian.tar.xz
Increment the version number by editing the changelog in each Debian directory.
~/Pak64_Development$ cd ~/Simutrans_Development
~/Simutrans_Development$ dch -v 111.2.2-0ppa1
simutrans (111.2.1-0ppa1) oneiric; urgency=low
* New upstream release
-- me <me@example.com> Wed, 25 Apr 2012 07:23:32 -0500
Edit the Debian rules file to reflect the most recent upstream release, then download a new source code tarball, uncompress the tarball, and copy the debian folder into the new folder.
~/Pak64_Development$ cd ~/Simutrans_Development
~/Simutrans_Developmen$ nano debian/rules
SVNREV = 5583
VERSION = 111.2.2
~/Simutrans_Development$ make -f debian/rules get-orig-source
tar -xvf simutrans_111.2.2.orig.tar.zx
cp -r debian/ simutrans-111.2.2/
Finally, a progress check: The directory should look something like this:
~$ ls Simutrans_Development/
debian simutrans_111.2.2-1.debian.tar.xz
simutrans-111.2.2 simutrans_111.2.2-1.orig.tar.xz
3) Prepare the working directory for Pak64 and download the sources
~$ mkdir Pak64_Development
~/Simutrans_Development$ cd ~/Pak64_Development
~/Pak64_Development$ wget http://ftp.us.debian.org/debian/pool/main/s/simutrans-pak64/simutrans-pak64_111.2-1.debian.tar.xz
~/Pak64_Development$ tar -xvf simutrans_111.2-1.debian.tar.xz
Increment the version number by editing the changelog in each Debian directory.
~/Simutrans_Development$ cd ~/Pak64_Development
~/Pak64_Development$ dch -v 111.2-0ppa1
simutrans-pak64 (111.2-0ppa1) oneiric; urgency=low
* New upstream release
-- me <me@example.com> Wed, 25 Apr 2012 07:23:32 -0500
Edit the Debian rules file to reflect the most recent upstream release, then download a new source code tarball, uncompress the tarball, and copy the debian folder into the new folder.
~/Simutrans_Development$ cd ~/Pak64_Development
~/Pak64_Development$ nano debian/rules
SVNREV = 811
VERSION = 111.2
UPSTREAM_SVNREV = 810M # see README.source
~/Pak64_Development$ make -f debian/rules get-orig-source
tar -xvf simutrans-pak64_111.2.orig.tar.xz
cp -r debian/ simutrans-pak64-111.2/
Finally, a progress check: The directory should look something like this:
~$ ls Pak64_Development/
debian simutrans-pak64-111.2
simutrans-pak64_111.2-1.debian.tar.xz simutrans-pak64_111.2.orig.tar.xz
4) Build Simutrans
We're ready to try building the package. This is where the troubleshooting really starts.
~$ cd Simutrans_Development/simutrans-111.2.2
~/Simutrans_Development/simutrans-111.2.2$ debuild -us -uc
First Problem: debhelper 9.
dpkg-checkbuilddeps: Unmet build dependencies: debhelper (>= 9)
dpkg-buildpackage: warning: Build dependencies/conflicts unsatisfied; aborting.
dpkg-buildpackage: warning: (Use -d flag to override.)
debuild: fatal error at line 1348:
dpkg-buildpackage -rfakeroot -D -us -uc failed
The debhelper package was originally version 7.x. According to the git log, it incremented up to 9 in March 2012, long after the build environment (that's why we review the log!). We can try the -h flag to avoid this...or unapply the patch that incremented debhelper.
~/Simutrans_Development/simutrans-111.2.1$ debuild -us -uc -d
Second Problem: Lintian errors.
Now running lintian...
W: simutrans source: newer-standards-version 3.9.3 (current is 3.9.2)
W: simutrans: binary-without-manpage usr/games/simutrans-nettool
Finished running lintian.
Lintian errors are a
good sign - it means everything else worked!
Both warnings in this case can be safely ignored...though a good citizen would also file bugs with patches to fix those warnings.
Take a look at the
Simutrans_Development
directory now. See all those ready-to-install deb packages?
ian@VM-11-10:~/Simutrans_Development$ ls
debian simutrans_111.2.2-0ppa1_i386.deb
simutrans-111.2.2 simutrans_111.2.2.debian.tar.gz
simutrans_111.2.2-1.debian.tar.xz simutrans_111.2.2.orig.tar.xz
simutrans_111.2.2-1.dsc simutrans-data_111.2.2-0ppa1_all.deb
simutrans_111.2.2-0ppa1_i386.build simutrans-makeobj_111.2.2-0ppa1_i386.deb
simutrans_111.2.2-0ppa1_i386.changes
Do
not install the
simutrans_111.2.1-1_i386.deb
or
simutrans-data_111.2.1-1_all.deb
packages yet. If you try, they will install a pak64 package from the repositories instead of the one you are about to build.
5) Install makeobj
makeobj is a package (
simutrans-makeobj_111.2.1-1_i386.deb
) that is built with the Simutrans game, and used in turn to create the paks. Install the deb that was just created before building pak64.
~/Simutrans_Development$ sudo dpkg -i simutrans-makeobj_111.2.2-0ppa1_i386.deb
6) Build Pak64
We're ready to try building the pak package.
~$ cd Pak64_Development/simupak-64
~/Pak64_Development/simupak64$ debuild -us -uc
Problem: Makefile patches failed
The file
debian/patches/buildsystem
has several patches that get applied to the makefile. As the makefile changes over time, the patch program may not find the right place to apply some patches. Those changes to the patch must be applied manually.
patching file Makefile
Hunk #2 FAILED at 46.
Hunk #3 succeeded at 65 (offset 2 lines).
Hunk #4 FAILED at 84.
2 out of 4 hunks FAILED -- saving rejects to file Makefile.rej
Hunk #2 was a straightforward change to one line (adding the word "zip").
Hunk #4 had the old version number instead of the new.
Upon the second try, the pak64 build was successful. You can see the deb package in the directory listing:
~$ ls Pak64_Development/
debian simutrans-pak64_111.2.1-1.dsc
simutrans-pak64_111.2-0ppa1.debian.tar.xz simutrans-pak64_111.2.1-1_i386.build
simutrans-pak64-111.2 simutrans-pak64_111.2.1-1_i386.changes
simutrans-pak64_111.2-0ppa1_all.deb simutrans-pak64_111.2-1.orig.tar.xz
simutrans-pak64_111.2-1.debian.tar.xz simutrans-pak64_111.2-1.orig.tar.xz
7) Test Install
When installing package-by-package, make sure to install in the right order!
sudo dpkg -i Pak64_Development/simutrans-pak64_111.2-0ppa1_all.deb
sudo dpkg -i Simutrans_Development/simutrans-data_111.2.2-0ppa1_all.deb
sudo dpkg -i Simutrans_Development/simutrans_111.2.2-0ppa1_i386.deb
I fire up Simutrans...and it works!
8) Removing Simutrans
When the test is complete, and I want to remove simutrans:
sudo dpkg -r simutrans
sudo dpkg -r simutrans-data
sudo dpkg -r simutrans-pak64