Alright, here we go. This is not a guide on how to create a stand-alone deb (though I could probably do that as well, if I can remember how). It's a guide on how to set up a PPA. The script I'll provide requires you to have your code available from a remote repository. In my case it's a git repo. You also need to have created a user account on
Launchpad, accepted the Ubuntu Code of Conduct, created a PPA (you can do that in the web UI), and generated a gpg key and uploaded it to Launchpad.
It's been quite a while since me and Bart wrote this, so I don't honestly recall what everything does. Maybe Bart can chime in and explain what I don't remember. I'm not going to go into too much depth on what everything does, so I'd highly recommend that you look things up in
the Ubuntu Wiki Packaging Guide.
In this example, I'm going to be using "appname", "launcher", "iconname" and so on. Replace those with names that are specific to your application.
First of all, we need to set up a directory structure with some metadata and various control files for the package. This is what the directory should look like when we're done:
Code: Select all
├── base
│ ├── icons
│ │ ├── 22x22
│ │ │ └── apps
│ │ │ └── iconname.png
│ │ ├── 24x24
│ │ │ └── apps
│ │ │ └── iconname.png
│ │ ├── 32x32
│ │ │ └── apps
│ │ │ └── iconname.png
│ │ ├── 48x48
│ │ │ └── apps
│ │ │ └── iconname.png
│ │ └── scalable
│ │ └── apps
│ │ └── iconname.svg
│ ├── Makefile
│ ├── launcher
│ └── appname.desktop
└── debian
├── compat
├── control
├── copyright
├── menu
├── rules
└── source
└── format
base
Base contains icons, a launcher script, a desktop file and a makefile. I'll go through each in order.
icons
Within the icons folder, you should basically replicate the structure found in /usr/share/icons/. Not much else to say, really. I've only included a few icon sizes, but you can have as many or as few as you'd like.
launcher
The launcher is what's going to end up in /usr/bin, and is used to launch your game.
Code: Select all
#!/usr/bin/env bash
love /usr/lib/gamename/appname.love
appname.desktop
A desktop file contains information that will be shown in the desktop menu. It gives the menu entry a name, a description, a path to the launcher, an icon, etc. Remember that Exec should point to the launcher, and iconname should be the same as the icons you added to icons/SIZExSIZE/
Code: Select all
[Desktop Entry]
Name=appname
Comment=A description of your game.
Exec=/usr/bin/launcher
Type=Application
Categories=Game;
Terminal=false
Icon=iconname
Makefile
The makefile contains commands to run when the package is installed or removed. What needs to be done is different in every case, but I'll give you an example nonetheless. During the installation, it basically creates the directories we need, as well as copies the files we need into those directories. Similarly, during uninstallation, it removes said files and directories.
Code: Select all
CP=cp -r
ZIP=zip -r
RM=rm -rIf
MKDIR=mkdir -p
RMDIR=rmdir -p --ignore-fail-on-non-empty
appname.love:
cd love; \
$(ZIP) ../appname.love *
install: all
$(MKDIR) $(DESTDIR)/usr/bin/
$(MKDIR) $(DESTDIR)/usr/lib/appname/
$(MKDIR) $(DESTDIR)/usr/share/applications/
$(MKDIR) $(DESTDIR)/usr/share/icons/hicolor
$(CP) appname.love $(DESTDIR)/usr/lib/appname/
$(CP) launcher $(DESTDIR)/usr/bin/
$(CP) appname.desktop $(DESTDIR)/usr/share/applications/
$(CP) icons/* $(DESTDIR)/usr/share/icons/hicolor/
uninstall:
$(RM) $(DESTDIR)/usr/lib/appname/appname.love
$(RM) $(DESTDIR)/usr/bin/launcher
$(RM) $(DESTDIR)/usr/share/applications/appname.desktop
$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/32x32/apps/iconname.png
$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/22x22/apps/iconname.png
$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/24x24/apps/iconname.png
$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/48x48/apps/iconname.png
$(RM) $(DESTDIR)/usr/share/icons/hicolor/icons/scalable/apps/iconname.svg
$(RMDIR) $(DESTDIR)/usr/lib/appname
$(RMDIR) $(DESTDIR)/usr/bin/
$(RMDIR) $(DESTDIR)/usr/share/applications/
$(RMDIR) $(DESTDIR)/usr/share/icons/hicolor
clean:
$(RM) appname.love
distclean: clean
all: appname.love launcher appname.desktop
debian
The debian directory (this is back in the root level. Check the directory tree) contains a bunch of data about the package. Again, I'll go through each file separately.
compat
This sets the debhelper compatibility level. More info on that
here. For now, this is what it should look like:
control
The control file contains data that will be used by the package manager. It's here that you'll list dependencies, for example.
Code: Select all
Source: appname
Section: games
Priority: optional
Maintainer: Your Name <[email protected]>
Build-Depends: debhelper (>= 7), zip
Standards-Version: 3.8.4
Homepage: http://url.to/your-applications-website/
Package: appname
Architecture: any
Depends: love (>= 0.7.2), ${shlibs:Depends}, ${misc:Depends}
Description: App Title On Its Own Line
A multiline description where each line is indented by two spaces.
copyright
Pretty self-explanatory. Just throw your copyright information in here.
menu
In case the window manager doesn't use desktop files, you can use the menu file to define that stuff as well.
Code: Select all
?package(appname):needs="X11|text|vc|wm" section="Games" title="apptitle" command="/usr/bin/launcher"
rules
I'm not even going to pretend that I know what this does. The rules file is a separate makefile for the application that actually builds the package. I'm fairly sure this one just tells dh to go fuck itself.
Code: Select all
#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1
%:
dh $@
source/format
(source is a directory within the debian directory. It contains a file named format)
format contains information regarding the desired format for the source package. We want a native debian package, so it should just contain:
That's it for the directories and shit. Onto the build process itself!
Building
Note: In this example, I'm cloning from a git repo. You can just as well copy from a local directory, download via wget or whatever.
Code: Select all
#!/bin/bash
### Configuration ###
#repo location
REPO="git://github.com/username/yourrepo.git"
#ppa
PPA=ppa:launchpadusername/ppaname
#Here you define the target distribution version. In this example, we're telling Launchpad that this should be for Ubuntu 12.04, Precise Pangolin.
if [ "x$DISTRIBUTION" == "x" ]; then
DISTRIBUTION=precise
DISTRIBVERSION=12.04
fi
#Package version
VERSION=1.0.0
#path to the prepared directories
DEBIANDIR=$HOME/emptypackagedir/debian
BASEDIR=$HOME/emptypackagedir/base
#maintainer data
MAINTAINER="Your Name"
MAINTAINEREMAIL="[email protected]"
### The Script ###
export LC_ALL=C
#Create a temporary directory where we'll put everything together.
TEMPDIR=`mktemp -d /tmp/omgwordsppa.XXXXXX` || exit 1
pushd $TEMPDIR
#Clone the game from the repo
git clone $REPO appname
cd appname
#Prepare a changelog from the latest git commit
REVDESC=$(git log HEAD^1..HEAD | tail -n 1)
cd ..
DIRNAME="appname-${VERSION}~${DISTRIBVERSION}ppa3"
mkdir $DIRNAME
cd $DIRNAME
mkdir love
cp -r ../appname/* love/
cp -r $BASEDIR/* .
#dh_make takes the directory we've just created and "debianizes" it.
#More information: http://manpages.ubuntu.com/manpages/karmic/man8/dh_make.8.html
dh_make -s -e $MAINTAINEREMAIL --createorig
rm -r debian
cp -r $DEBIANDIR .
#Here we actually create the changelog
(echo "omgwords (${VERSION}~${DISTRIBVERSION}ppa3) ${DISTRIBUTION}; urgency=low" && echo "" && echo " * $REVDESC" && echo "" && echo -n " -- $MAINTAINER <$MAINTAINEREMAIL> " && date -R) | cat > debian/changelog
#Now we build. -S specifies that we want to build a source package. I don't remember what -sa does, and I can't seem to find it either.
debuild -S -sa
cd ..
#Upload the changes to the ppa
dput $PPA omgwords_${VERSION}~${DISTRIBVERSION}ppa3_source.changes
popd
#cleanup
rm -rf $TEMPDIR
Packaging is so unlovely. I suggest that you try running each of the commands in the script manually and try to follow along with it. I have a feeling that'll make things more clear.