Packaging for Debian/Ubuntu
Relevant source files
The following files were used as context for generating this wiki page:
The Steam Online Fix Launcher (SOFL) project provides support for creating Debian (.deb) packages, enabling straightforward installation on Debian, Ubuntu, and derivative Linux distributions. The packaging process is automated through a series of shell scripts that handle dependency installation, application building, package structuring, and final .deb creation.
This system is one of several packaging formats supported by the project, alongside Flatpak and Arch Linux. The Debian build process is integrated into a higher-level build script, build_all.sh, which can orchestrate the creation of all package types.
Sources: packaging/README.md, README.md, scripts/build_all.sh
Build Process Overview
The core of the Debian packaging is the packaging/debian/build.sh script. This script automates the entire lifecycle of creating a .deb package from the source code.
The following diagram illustrates the high-level workflow of the build.sh script.
Sources: packaging/debian/build.sh
Script Usage
The build can be initiated by directly running the script.
cd packaging/debian
./build.sh [version]
[version]: (Optional) The version string for the package. If not provided, it defaults to0.0.3.
The script can also be invoked via the master build script scripts/build_all.sh.
Sources: packaging/debian/build.sh:4, packaging/README.md:37-38, scripts/build_all.sh:50-54
Key Variables
The script uses several variables to control the build process.
| Variable | Default Value | Description |
|---|---|---|
VERSION | 0.0.3 | The package version, taken from the first script argument. |
PACKAGE_NAME | sofl | The name of the package. |
BUILD_DIR | deb-build | The staging directory where the package contents are assembled. |
DEBIAN_DIR | packaging/debian | The location of the source Debian control files. |
OUTPUT_DIR | dist | The directory where the final .deb package is placed. |
Sources: packaging/debian/build.sh:6-11
Dependencies
The build script automatically checks for and installs required tools and build dependencies using apt.
Build Tools:
dpkg-debmesonninja-build
Build Dependencies:
python3-gipython3-gi-cairogir1.2-gtk-4.0gir1.2-adw-1python3-requestspython3-pillowpython3-cairopython3-psutilpython3-xdglibgtk-4-devlibadwaita-1-dev
Sources: packaging/debian/build.sh:17-31
Application and Package Construction
The script follows a standard procedure for building the application with Meson and then packaging it.
- Meson Build: The application is configured, compiled, and installed into a temporary staging directory (
$BUILD_DIR) using Meson. The prefix is set to/usrto ensure files are installed to the correct locations within the final package.
Sources: packaging/debian/build.sh:45-49 - Package Structure: A
DEBIANdirectory is created inside the staging area to hold package metadata and control scripts.
Sources: packaging/debian/build.sh:52-53 - Package Creation: Finally,
dpkg-deb --buildis called on the staging directory to create the.debfile.
Sources: packaging/debian/build.sh:100-101
Package Metadata and Control Scripts
The .deb package includes standard control files that manage installation and removal. These are generated dynamically by the build.sh script.
DEBIAN/control File
This file contains the package's metadata, such as its name, version, and dependencies. The build.sh script copies a template control file and updates the version string using sed.
# Update version in control file
sed -i "s/Version: .*/Version: $VERSION/" "$BUILD_DIR/DEBIAN/control"
Sources: packaging/debian/build.sh:56-57
The scripts/update_version.sh script also modifies this file to ensure version consistency across all package types when performing a release build.
Sources: scripts/update_version.sh:28-31
DEBIAN/postinst Script
A post-installation script is generated to perform necessary setup tasks after the package is installed. Its primary functions are:
- Update the desktop application database (
update-desktop-database). - Update the GTK icon cache (
gtk-update-icon-cache). - Compile GSettings schemas (
glib-compile-schemas).
This ensures the application icon, .desktop file, and settings schemas are correctly registered with the system.
Sources: packaging/debian/build.sh:60-77
DEBIAN/prerm Script
A pre-removal script is also generated to clean up system registrations before the package files are removed. It performs the same database and cache updates as the postinst script to ensure the system state is clean after removal.
Sources: packaging/debian/build.sh:81-96
Integration with the Overall Build System
The Debian packaging is not a standalone process but is part of a larger, unified build system.
The following diagram shows how the main build script build_all.sh interacts with the Debian-specific scripts.
scripts/build_all.sh: A top-level script that can build "flatpak", "deb", and "arch" packages. It calls the respectivebuild.shscript for each specified package type.scripts/update_version.sh: A utility script called bybuild_all.shto set a consistent version number acrossmeson.build, the Debiancontrolfile, and the ArchPKGBUILD.
Sources: scripts/build_all.sh, scripts/update_version.sh
Installation
Once the .deb package is built, it can be installed using dpkg. The packaging/README.md file recommends the following commands:
# Install the package
sudo dpkg -i sofl_VERSION_all.deb
# Install any missing dependencies
sudo apt install -f
Sources: packaging/README.md:78-81