Package debby

Debby

Create .deb files easily using python package metadata

Installation

You can install this package with pip.

$ pip install debby

Documentation

Source Code - GitHub

PyPI - debby

Usage

This tool creates the directory structure (including the control file) to then create a .deb package with dpkg-deb.

You may provide a template for the control file (see Control File Template) or provide the metadata directly via the command line or environment variables.

You may also provide files to include in the package with -f/--file option, which may be passed multiple times.

You may also provide a source for the metadata (see Metadata Sources). You can also specify specific metadata values via the command line. If no metadata source is provided, and all the required metadata is not provided via the command line, an error will be raised.

OUT_DIR=$(debby -f path/to/binary /usr/bin/binary -f path/to/config /etc/config --pyproject pyproject.toml)
dpkg-deb --build $OUT_DIR

Scripts

You may provide installation scripts with --preinst, --postinst, --prerm, and --postrm. These scripts will be included in the package and run before and after installation and removal of the package.

Using a script flag without a path is equivalent to providing a path to a script in the current directory with the same name as the flag. For example, --preinst is equivalent to --preinst ./preinst.

Alternatively, you may directly provide commands to run at the appropriate stage with --preinst-cmd, --postinst-cmd, --prerm-cmd, and --postrm-cmd. An appropriate script will be generated and included in the package. For example, --preinst-cmd 'echo hello' --preinst-cmd 'echo world' will generate a script that runs echo hello and echo world in sequence as the pre-installation script.

Metadata Sources

Currently, the following metadata sources are supported:

  • --pyproject: Reads the metadata from the given pyproject.toml file, according to the PEP 621 specification.
  • --poetry: Reads the metadata from the given pyproject.toml file, according to Poetry's specification.

Control File Template

It is possible to provide a template for the control file with -t/--template path/to/control.template. If provided, this template will be used to generate the control file instead of creating one from scratch. The template should be a text file with the following allowed placeholders.

Placeholder Description Examples
{meta.name} The name of the package debby
{meta.source} The source of the package debby
{meta.version} The version of the package 0.1.0
{meta.section} The section of the package misc, python
{meta.priority} The priority of the package optional
{meta.architecture} The architecture of the package all
{meta.eessential} The essential status of the package yes, no
{meta.maintainer} The maintainer of the package Abraham Murciano <abrahammurciano@gmail.com>
{meta.description} The description of the package Create .deb debby.files easily using python debby.package metadata
{meta.homepage} The homepage of the package https://abrahammurciano.github.io/debby/debby
{meta.depends} The dependencies of the package python3, jq, pv (>= 1.0.0)
{meta.recommends} The recommended packages of the package jq, pv (>= 1.0.0)
{meta.suggests} The suggested packages of the package jq, pv (>= 1.0.0)
{meta.enhances} The enhanced packages of the package jq, pv (>= 1.0.0)
{meta.breaks} The packages that this package breaks jq, pv (>= 1.0.0)
{meta.conflicts} The packages that this package conflicts with jq, pv (>= 1.0.0)
{files.total_size} The total size of all the files given with the -f/--file option 123456

Sub-modules

debby.args
debby.control_file
debby.exceptions
debby.files
debby.meta
debby.package
debby.scripts

Classes

class ControlFile (meta: Meta, files: Files, template: Optional[pathlib.Path] = None, include_size: bool = True)

Methods

def create(self, path: pathlib.Path) ‑> None
class Files (files: Iterable[Tuple[pathlib.Path, pathlib.Path]])

A mapping of target paths in the package to source paths on the filesystem.

Args

files
An iterable of pairs of source paths and destination paths.

Ancestors

  • collections.abc.Mapping
  • collections.abc.Collection
  • collections.abc.Sized
  • collections.abc.Iterable
  • collections.abc.Container
  • typing.Generic

Instance variables

prop destinations : Iterable[pathlib.Path]
prop sources : Iterable[pathlib.Path]
var total_size

Methods

def package(self, path: pathlib.Path) ‑> None
class Meta (name: str, version: str, maintainer: str, description: str, architecture: str, source: Optional[str] = None, section: Optional[str] = None, priority: Optional[str] = None, essential: Optional[Literal['yes', 'no']] = None, homepage: Optional[str] = None, depends: Optional[str] = None, pre_depends: Optional[str] = None, recommends: Optional[str] = None, suggests: Optional[str] = None, enhances: Optional[str] = None, breaks: Optional[str] = None, conflicts: Optional[str] = None)

Metadata for a Debian package.

Class variables

var architecture : str

The type of the None singleton.

var breaks : Optional[str]

The type of the None singleton.

var conflicts : Optional[str]

The type of the None singleton.

var depends : Optional[str]

The type of the None singleton.

var description : str

The type of the None singleton.

var enhances : Optional[str]

The type of the None singleton.

var essential : Optional[Literal['yes', 'no']]

The type of the None singleton.

var homepage : Optional[str]

The type of the None singleton.

var maintainer : str

The type of the None singleton.

var name : str

The type of the None singleton.

var pre_depends : Optional[str]

The type of the None singleton.

var priority : Optional[str]

The type of the None singleton.

var recommends : Optional[str]

The type of the None singleton.

var section : Optional[str]

The type of the None singleton.

var source : Optional[str]

The type of the None singleton.

var suggests : Optional[str]

The type of the None singleton.

var version : str

The type of the None singleton.

Instance variables

prop full_name : str
class Package (metadata: Meta, control: ControlFile, files: Files, scripts: Scripts)

A directory containing a Debian package.

Args

metadata
The metadata for the package.
control
The control file for the package.
files
The files to put in the package.

Methods

def create(self, out_dir: pathlib.Path) ‑> pathlib.Path

Create the directory structure of the package, which can be packaged into a .deb file with dpkg-deb.