From a folder of files to a program with a menu entry, an icon and a package. Four small steps on a clean Ubuntu 24.04 desktop.
▶Prefer to watch? This short video runs this page's main commands on a real Ubuntu 24.04 desktop, with on-screen captions and a synthetic voiceover (an AI voice trained on the author's own recording). Click to play, or watch it on YouTube.
Episode 9 is the last one. It ends with this: Burger Blaster in the GNOME menu with its icon, the right icon and a running dot in the dock, a manual page (man burger-blaster), a command that works from anywhere, and a single .deb file that anyone on Ubuntu can install, and remove again, with apt.
You will need: your project from episode 8 (a game.py, the art, sounds and music folders), or the starter files below, and a clean Ubuntu 24.04 desktop to try the package on.
You will make: two lines in game.py, six small files in a packaging folder, and a .deb package.
You will learn: what GNOME needs to show a program in the menu and the dock, how a Debian package is laid out, dpkg-deb, and lintian.
Starter files: burger-blaster-ep08.zip is where this episode begins, burger-blaster-ep09.zip is where it ends, with the packaging folder in it.
The commands on this page were run on a clean Ubuntu 24.04 desktop with Python 3.12.3. The package was built, checked with lintian, installed with apt, started from the GNOME menu, and removed again on that machine.
Where we start
Open a terminal, go to the project, turn on the virtual environment and run the game:
$ cd burger-blaster
$ source .venv/bin/activate
(.venv) $ python game.py
The game works, with sound, a title screen, a score and waves. But it only starts from a terminal, in its own folder, and if you look at the dock while it runs there is a plain gear with no name: the desktop does not know what this window is.
Step 1: a class name and an icon
Two small changes in game.py. The first goes above the import of pygame, and the second at the start of Game.__init__, after the pictures are loaded:
#!/usr/bin/env python3
"""Burger Blaster: a hamburger shoots french fries at angry milkshakes."""
import json
import os
import random
import sys
from pathlib import Path
# GNOME groups the window under burger-blaster.desktop by this name.
# SDL reads it when pygame loads, so it has to be set before the import.
os.environ.setdefault("SDL_VIDEO_X11_WMCLASS", "burger-blaster")
import pygame # noqa: E402
WIDTH, HEIGHT = 1280, 720
...
IMG.update(load_images())
pygame.display.set_icon(IMG["burger"]) <- the second change
...
What each does:
SDL_VIDEO_X11_WMCLASS pygame uses a library called SDL for its window. On X11 (and Xorg under GNOME) every window has a class name, and the desktop uses it to decide which program the window belongs to, so which icon to show and which dock entry to group it with. SDL reads the name from this environment variable
os.environ.setdefault(...) sets the variable only if nobody set it already, so you can still override it
above import pygame SDL reads the variable when pygame is first loaded. Set it afterwards and nothing happens. (Found in the lab: with the line below the import the window class was game.py, with the line above it was burger-blaster.)
# noqa: E402 the linter does not like an import after other code. The comment tells it this one is on purpose
pygame.display.set_icon the icon of the window itself, a picture we already have: the burger
Run it:
(.venv) $ python game.py
It still shows a gear in the dock. The desktop knows the window's class name now, but there is nothing yet that says what program goes by that name. The next step adds it.
Step 2: the launcher, the desktop file and the control file
A program needs three things for the desktop and the package manager. Make a folder packaging/ in the project and put these files in it. First the launcher, packaging/burger-blaster: a script that starts the game from wherever it is installed.
#!/bin/sh
exec python3 /usr/share/burger-blaster/game.py "$@"
exec replaces the shell with Python, so there is no extra process left
/usr/share/burger-blaster/game.py where the package will put the game
"$@" passes on any arguments you give the command
The desktop file, packaging/burger-blaster.desktop, is what puts the game in the menu:
[Desktop Entry]
Type=Application
Name=Burger Blaster
Comment=A hamburger shoots french fries at angry milkshakes
Exec=burger-blaster
Icon=burger-blaster
Terminal=false
Categories=Game;ArcadeGame;
StartupWMClass=burger-blaster
Name, Comment what the menu shows
Exec=burger-blaster the command to run (the launcher, found on the path in /usr/games)
Icon=burger-blaster the name of an icon, without the extension. The desktop looks for burger-blaster.png in its icon folders
Terminal=false it is a window, so no terminal around it
Categories=Game;ArcadeGame; where it appears in a menu
StartupWMClass=burger-blaster the class name from step 1. This line is what lets the dock match the window to this entry
The control file, packaging/control, is the package's identity card:
Package: burger-blaster
Version: 1.0.0
Section: games
Priority: optional
Architecture: all
Depends: python3, python3-pygame
Maintainer: TechCommune <admin@techcommune.org>
Description: Hamburger versus milkshakes arcade game
Fly a cute hamburger, fire french fries and splat angry
milkshakes. Built with pygame as a tutorial series for
techcommune.org.
Package, Version, Section the name, the version and where it is filed (games)
Architecture: all it is Python, so one package works on every kind of computer
Depends: python3, python3-pygame what apt installs with it. This is the line that makes the package install pygame for the user
Maintainer who to ask. Change it to yours
Description a short line, then more lines that start with one space
Three more files complete the package. They are plain text too, and they are in the starter zip:
packaging/changelog the history of the package. Debian wants one, even for a first release
packaging/copyright who owns it, and under which licence. Put in what is true for your own game
packaging/burger-blaster.6 the manual page, in the old roff format. The 6 is the section for games
packaging/build_deb.sh the script that builds the package, in the next step
(Checked in the lab: the three files typed in the video are the same as the ones in the ep09 zip, and the package built from them is clean in lintian.)
Step 3: build the package
A .deb file is an archive that holds the files laid out as they will be on the user's machine, plus the control file. The build script makes that layout in a folder, and packs it with dpkg-deb:
#!/bin/sh
# Build burger-blaster_1.0.0_all.deb from this game folder. Run it from anywhere: sh packaging/build_deb.sh
set -e
cd "$(dirname "$0")/.."
V=1.0.0
P=build/burger-blaster_${V}_all
rm -rf build
mkdir -p $P/DEBIAN $P/usr/games $P/usr/share/applications $P/usr/share/doc/burger-blaster \
$P/usr/share/icons/hicolor/128x128/apps $P/usr/share/burger-blaster $P/usr/share/man/man6
cp game.py $P/usr/share/burger-blaster/
cp -r art sounds music $P/usr/share/burger-blaster/
install -m 755 packaging/burger-blaster $P/usr/games/burger-blaster
install -m 644 packaging/burger-blaster.desktop $P/usr/share/applications/
install -m 644 art/burger.png $P/usr/share/icons/hicolor/128x128/apps/burger-blaster.png
install -m 644 packaging/copyright $P/usr/share/doc/burger-blaster/copyright
gzip -9n -c packaging/changelog > $P/usr/share/doc/burger-blaster/changelog.gz
gzip -9n -c packaging/burger-blaster.6 > $P/usr/share/man/man6/burger-blaster.6.gz
install -m 644 packaging/control $P/DEBIAN/control
find $P -type d -exec chmod 755 {} +
find $P/usr/share -type f -exec chmod 644 {} +
dpkg-deb --root-owner-group --build $P
mv build/burger-blaster_${V}_all.deb .
echo "built burger-blaster_${V}_all.deb"
What it does:
P=build/burger-blaster_${V}_all the folder where the layout is made, and the name of the package file
usr/games, usr/share/... the places on a Linux system for games, shared files, documentation, icons, manual pages and desktop files. A package puts files where each kind belongs
the icon the burger picture, installed as a 128x128 icon with the name burger-blaster, the one the desktop file asks for
changelog.gz, burger-blaster.6.gz documentation is stored compressed. gzip -9n gives smaller files and no timestamp inside them
find ... chmod directories get 755 and files 644, so the permissions do not depend on your umask
dpkg-deb --root-owner-group packs the folder. The flag makes everything in the package owned by root, whoever built it
Run it, and look at the result:
$ sh packaging/build_deb.sh
dpkg-deb: building package 'burger-blaster' in 'build/burger-blaster_1.0.0_all.deb'.
built burger-blaster_1.0.0_all.deb
$ dpkg-deb -I burger-blaster_1.0.0_all.deb
new Debian package, version 2.0.
size 1213986 bytes: control archive=344 bytes.
356 bytes, 11 lines control
Package: burger-blaster
Version: 1.0.0
Section: games
Priority: optional
Architecture: all
Depends: python3, python3-pygame
Maintainer: TechCommune <admin@techcommune.org>
Description: Hamburger versus milkshakes arcade game
Fly a cute hamburger, fire french fries and splat angry
milkshakes. Built with pygame as a tutorial series for
techcommune.org.
$ dpkg-deb -c burger-blaster_1.0.0_all.deb | grep -v -e art/ -e sounds/ -e music/
(the list of the 54 files and folders in the package, here without the pictures, sounds and music:)
drwxr-xr-x root/root 0 2026-11-10 15:55 ./
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/games/
-rwxr-xr-x root/root 62 2026-11-10 15:55 ./usr/games/burger-blaster
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/applications/
-rw-r--r-- root/root 226 2026-11-10 15:55 ./usr/share/applications/burger-blaster.desktop
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/burger-blaster/
-rw-r--r-- root/root 12866 2026-11-10 15:55 ./usr/share/burger-blaster/game.py
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/doc/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/doc/burger-blaster/
-rw-r--r-- root/root 141 2026-11-10 15:55 ./usr/share/doc/burger-blaster/changelog.gz
-rw-r--r-- root/root 91 2026-11-10 15:55 ./usr/share/doc/burger-blaster/copyright
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/icons/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/icons/hicolor/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/icons/hicolor/128x128/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/icons/hicolor/128x128/apps/
-rw-r--r-- root/root 9534 2026-11-10 15:55 ./usr/share/icons/hicolor/128x128/apps/burger-blaste
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/man/
drwxr-xr-x root/root 0 2026-11-10 15:55 ./usr/share/man/man6/
-rw-r--r-- root/root 360 2026-11-10 15:55 ./usr/share/man/man6/burger-blaster.6.gz
(Your times will differ, and so will the size.) The last check is lintian, a program that knows the rules of Debian packaging. It is a separate package (sudo apt install lintian):
$ lintian --pedantic burger-blaster_1.0.0_all.deb
$ echo $?
0
No output means no complaints, even with --pedantic, which looks at the small things too. (Checked in the lab. The first version of this package had two complaints: no changelog, and no manual page. Both are in the package now.)
Step 4: install it and start it like any other program
Install the file with apt. The ./ in front matters: it tells apt that this is a file and not the name of a package in the archive.
$ sudo apt install ./burger-blaster_1.0.0_all.deb
apt reads the control file, sees Depends: python3, python3-pygame, and installs those too (python3-pygame comes with a handful of libraries). If the .deb file is in your home folder, apt may end with a notice that begins 'Download is performed unsandboxed as root as file ... couldn't be accessed by user _apt'. It is harmless: apt's own download user cannot read your home folder, so apt reads the file as root. (It appeared in the lab run, and the install worked.) Then:
1 Press the Super key (the one with the Windows logo), type burger, and Burger Blaster is there, with the burger icon. Press Enter.
2 The game starts. In the dock it has the burger icon and the little dot of a running program, because the window's class name matches StartupWMClass in the desktop file.
3 Open a terminal and type burger-blaster: the same game starts, from any folder, because the launcher is in /usr/games.
4 man burger-blaster shows the manual page.
(Checked in the lab, on a clean Ubuntu 24.04 desktop with Xorg: apt installed the package and python3-pygame, desktop-file-validate had nothing to say, the app was found by searching for 'burger', the window class was burger-blaster, and the dock showed the burger icon with the running dot. The package version of pygame from the Ubuntu archive was 2.5.2, and the game ran on it as well as on pip's 2.6.1.)
To remove it again:
$ sudo apt remove burger-blaster
The files are gone, and nothing is left behind except your high score in ~/.local/share/burger-blaster, which is your own file.
Episode 9 running.
Where to go from here
You now have a game made in nine small steps, from an empty window to a package. Some ideas for what to do with it:
a power-up a double shot or a shield, dropped by a shake when it splits
a boss shake one big shake with many hits
a gamepad pygame can read joysticks
your own pictures and sounds the art is drawn with make_art.py, the sounds with make_sounds.py. Change the numbers and see what happens
a new version of the package change the version in control and build_deb.sh, add a line to the changelog, and build again
The series is also a template for any small Python program that you want to give to somebody else: a launcher, a desktop file, a control file, and one script that builds it.
Check your work
If something is different:
dpkg-deb: error: control file ... missing packaging/control is missing or is not in the right folder
lintian: E: no-changelog / W: no-manual-page the changelog.gz and the manual page are missing from the package
the menu does not show the game the desktop file is not in /usr/share/applications, or it has a typo. Run desktop-file-validate on it. A new entry can take a moment to show up: log out and in again if it does not
the menu shows it, but with a gear the Icon= name and the icon file name must match: burger-blaster.png in hicolor/128x128/apps
the dock shows a second, gear icon StartupWMClass must be the same as the class name in game.py, and the os.environ line must be above import pygame
dependency problems on install run: sudo apt install ./burger-blaster_1.0.0_all.deb (with the ./) and read what apt says it cannot find
Not run in the lab: other Linux distributions, Wayland-only sessions (the lab session used Xorg), RPM and other package formats, and uploading the package to a repository. The copyright file in the starter zip is a placeholder: put in the licence you want for your own game.