Debmagic
Unified and futuristic developer tools for increased productivity in the Debian/Ubuntu ecosystem.
- create package build instructions in Python with
debian/rules.py - tooling do perform packaging itself: building and testing in isolated container environments
Important
Debmagic's goal: make Debian packaging modern, robust & easy - while being backwards compatible.
Included features:
- for
debian/rules.py- optional
dhbackward compatibility module - language and buildsystem helper modules
- optional
- maintainer tools
debmagic build- isolated package buildingdebmagic check- isolated package lintingdebmagic test- isolated package testing
- debugging tools
debmagic shell- enter current running/finished package environment
Debmagic packaging
Usually, debian/rules is written as shell-oneliners in a Makefile.
Debmagic allows straight-forward conversion to Python, which is especially useful if the packaging is more complex, like openldap, dovecot, samba or gcc.
Example debian/rules.py
For example, the htop rules file from Ubuntu 24.04 equivalent in debmagic native Python code could look like this:
from debmagic.v0 import Build, autotools, dh, package
pkg = package(
preset=[dh],
maint_options="hardening=+all",
)
if pkg.buildflags.DEB_HOST_ARCH_OS == "linux":
configure_params = ["--enable-affinity", "--enable-delayacct"]
else:
configure_params = ["--enable-hwloc"]
# hurd-i386 can open /proc (nothing there) and /proc/ which works
if pkg.buildflags.DEB_HOST_ARCH_OS == "hurd":
configure_params += ["--with-proc=/proc/"]
else:
configure_params += ["--enable-sensors"]
@pkg.stage
def configure(build: Build):
autotools.configure(
build,
["--enable-openvz", "--enable-vserver", "--enable-unicode", *configure_params],
)
pkg.pack()
debhelper compatibility
For even more straightforward conversion of debian/rules Makefiles, Debmagic can use dh and provides dh overrides:
# specify dh arguments:
dhp = dh.Preset("--with=python3 --builddirectory=build")
pkg = package(preset=dhp)
# if needed, define optional overrides:
@dhp.override
def dh_auto_install(build: Build):
print("dh override worked :)")
build.cmd("dh_auto_install --max-parallel=1")
pkg.pack()
Custom functions
To add custom functions directly usable from CLI (like custom debian/rules targets for maintainers):
@pkg.custom_function
def something_custom(some_param: int, another_param: str = "some default"):
print(f"you passed {some_param=} {another_param=}")
pkg.pack()
This function can be directly called with:
you passed some_param=test another_param=1337
And generates automatic help for:
Documentation
To do packaging with debmagic, please read the documentation!.
Contributing
Debmagic can always use more features and modules! You can also just request features or report bugs - this project is happy about your contributions!
Contact
To directly reach developers and other users, we have chat rooms. For questions, suggestions, problem support, please join and just ask!
| Contact | Where? |
|---|---|
| Issue Tracker | SFTtech/debmagic |
| Matrix Chat | #sfttech:matrix.org |
| Support us |
License
Released under the GNU General Public License version 2 or later, LICENSE for details.