Creating .deb and RPM packages

Since I’ve managed to get it to work for GSSMP, I thought I might share how I am generating .deb and RPM packages using a Makefile. These make it much easier for Ubuntu and Fedora Linux users (respectively) to install the program. It should also be helpful for people using Debian, who can try the .deb, and other RPM-based distros, who can try the RPM.

This project is all autotooled-up, so this may not be very helpful if you don’t use autotools.

(Side tip: I don’t understand autotools at all, but since I created the project with glade, it did all the hard work for me.)

I created these files for the Ubuntu .deb package:

changelog:

gssmp (0.8-0ubuntu1) edgy; urgency=low

  * First release packaged for ubuntu

 -- Andy Balaam <myemailaddress>  Thu, 15 Feb 2007 12:33:11 +0000

copyright:

This package was debianized by Andy Balaam <myemailaddress> on
Thu, 15 Feb 2007 12:33:11 +0000.

It was downloaded from
http://sourceforge.net/project/showfiles.php?group_id=187144&package_id=219138

Copyright Holder: Andy Balaam <myemailaddress>

License:
   This package is free software; you can redistribute it and/or modify
   blah blah blah GPL boilerplate

control:

Source: gssmp
Section: sound
Priority: optional
Maintainer: Andy Balaam <myemailaddress>
Build-Depends: debhelper (>= 4.0.0), autotools-dev, libgstreamer0.10-dev, libgnomeui-dev
Standards-Version: 3.6.2

Package: gssmp
Architecture: any
Depends: libgstreamer0.10-0, libgnomeui-0
Description: Gnome Simple Stateful Music Player
 GSSMP is a music player designed to work with Gnome.  It does not store a
 database of all your music, but is designed to work with music files organised
 into directories.  It is small, unobtrusive, and tries to do what you would
 expect, instead of asking you questions.
 .
 It remembers which file was playing on exit, and continues that file from the
 same place when you start again.  It remembers tracks you have been listening
 to recently and displays them in the "Recent" menu.

I put those three files in my source tree under install/deb/.

For the RPM, I just needed one file, gssmp.spec:

###
### RPM spec file for Gnome Simple Stateful Music Player
###
### Adapted from jEdit's spec file http://www.jedit.org
###
Summary: A music player that doesn't interfere.
Name: gssmp
Provides: gssmp
Version: 0.8
Release: 1
License: GPL
Group: Applications/Multimedia/
Source0: %{name}-%{version}.tar.bz2
URL: http://gssmp.sourceforge.net/
Vendor: Andy Balaam <myemailaddress>
Packager: Andy Balaam <myemailaddress>
BuildArch: i386
BuildRoot: %{_builddir}/%{name}-root
Requires: libgnomeui, gstreamer
BuildRequires: libgnomeui-devel, gstreamer-devel

%description
GSSMP is a music player designed to work with Gnome.  It does not store a
database of all your music, but is designed to work with music files organised
into directories.  It is small, unobtrusive, and tries to do what you would
expect, instead of asking you questions.

It remembers which file was playing on exit, and continues that file from the
same place when you start again.  It remembers tracks you have been listening
to recently and displays them in the "Recent" menu.

%prep
%setup -n %{name}-%{version}

%build
./configure --prefix=/usr
make

%install
make DESTDIR=%{buildroot} install

%clean
rm -rf %{buildroot}

%files
/usr/bin/gssmp
/usr/share/doc/gssmp/AUTHORS
/usr/share/doc/gssmp/COPYING
/usr/share/doc/gssmp/INSTALL
/usr/share/doc/gssmp/NEWS
/usr/share/doc/gssmp/README
/usr/share/doc/gssmp/TODO

which I put in install/rpm

Then I modified my Makefile.am to build the deb and RPM when I told it to:

APP_NAME=gssmp

# Create a deb package
pkg-deb: pkg-src
        - rm -r $(TMP_DIR)
        mkdir -p $(TMP_DIR)
        cp pkg/$(APP_NAME)-$(VERSION).tar.bz2 $(TMP_DIR)/
        tar --directory $(TMP_DIR)/ \
                -xjf $(TMP_DIR)/$(APP_NAME)-$(VERSION).tar.bz2
        cd $(TMP_DIR)/$(APP_NAME)-$(VERSION)/; \
                echo | dh_make --single --copyright gpl -e myemailaddress -f \
                        ../$(APP_NAME)-$(VERSION).tar.bz2
        cp install/deb/changelog install/deb/control \
                install/deb/copyright $(TMP_DIR)/$(APP_NAME)-$(VERSION)/debian/
        cd $(TMP_DIR)/$(APP_NAME)-$(VERSION)/; \
                rm debian/README.Debian debian/*.ex debian/*.EX; \
                ./configure; \
                dpkg-buildpackage -rfakeroot; \
                mv ../*.deb $(PWD)/pkg/
        rm -r $(TMP_DIR);

# Create an RPM package
pkg-rpm: pkg-src
        mkdir -p $(HOME)/.rpm/RPMS/i386
        mkdir -p $(HOME)/.rpm/SRPMS
        mkdir -p $(HOME)/.rpm/BUILD
        mkdir -p $(HOME)/.rpm/SOURCES
        mkdir -p $(HOME)/.rpm/tmp
        - rm -r $(HOME)/.rpm/BUILD/$(APP_NAME)-root
        - rm -r $(HOME)/.rpm/RPMS/$(APP_NAME)-*
        - rm -r $(HOME)/.rpm/SRPMS/$(APP_NAME)-*
        - rm -r $(HOME)/.rpm/SOURCES/$(APP_NAME)-*
        cp pkg/$(APP_NAME)-$(VERSION).tar.bz2 $(HOME)/.rpm/SOURCES/
        rpmbuild --quiet --nodeps --define="_topdir $(HOME)/.rpm" \
            -ba install/rpm/gssmp.spec
        mv $(HOME)/.rpm/RPMS/i386/$(APP_NAME)-$(VERSION)-*.i386.rpm pkg/

Now I just needed to run ./autogen.sh to regenerate my Makefile, and then make pkg-deb or make pkg-rpm and the deb or RPM appears magically in the pkg/ directory.

Autotools, for all its faults, does make this stuff relatively easy. All the code for installing in different places (installing at all) and general flexibility is done for you. Of course, it’s at the expense of ever understanding what’s going on, but you can’t have everything.

Now I just need to make a man page … and fix all the bugs … oh, and make an icon … and make it accept a filename on the command line … and sort out MIME types … etc … so it should be finished really soon.

Two new babies

I have 2 new babies to tell you about:

1. Gnome Simple Stateful Music Player which is a music player that just stays out of your face, playing music off your hard drive without making a database or anything like that. It uses GNOME/GTK, GConf and gstreamer and is written in C, which is great fun.

I think C and Python are actually very similar: they are direct languages that are designed to be simple, and allow you to specify what you want to happen in a very straightforward way.

GSSMP is nearly ready for a 0.1 release – it’s simple, but it does most of what I want. Its killer feature is that it remembers what you were listening to and continues from there when you restart. Sounds simple, I know, but sorely lacking from some music programs. It also starts quickly, as opposed to, say, slowly or, for example, very slowly.

2. Another one:

Scan

New games!

I’ve been really enjoying the GP2X I got for our 5-year anniversary (!) and have got DVD ripping working, along with Quake playing at a decent speed, and lots of downloadable games, notably Spout, which is excellent, and (unlike many games which are really too visually complex to see on a small screen) simple enough to work on a handheld. There are a few other good games too, and lots that I immediately deleted off my SD card. I’d like to see some of the very polished LGames ported – maybe I’ll get around to it myself sometime.

Anyway, all of that is peripheral really, because what I really like doing is writing games, not playing them. So far I have imposed two games on the unsuspecting public:

mop(e)snake – a classic snake game with no featuritis – just a snake, apples (pain, actually – read the plot if you’re interested…) and you. Try to “fill the screen with green”TM. It’s reasonably mature now and works on GP2X, Windows and Linux. There’s not a lot left to do, except a bit of polish and fixing any bugs that come up.

duckmaze – a maze game where you can move walls. This is based on a game I played years ago on a handheld, whose name I have forgotten. It’s potentially quite fun, but I need to design some more levels – so far it only has 8, and several of them are pretty noddy. The first release includes a level editor (go me), so you can help out with designing more. Actually, you don’t even really need the level editor, since the level file format is designed to be fairly human-readable, so potentially you could create levels in a text editor. I’m quite pleased with that, even though no-one is ever going to appreciate it now I’ve written the level editor.

Download, enjoy, write to the mailing lists with ideas, bugs, code etc.