This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Build DPKGs natively with Python.

Project Description

Build Debian Packages (.deb/DPKGs) natively in Python.

Install

Using pip:

pip install deb-constrictor

Usage

Define directories, links, scripts and dependencies:

from constrictor import DPKGBuilder, BinaryControl

dirs = [
    {
        'source': '~/python/beneboyit/frontend/src',
        'destination': '/srv/python/bbit-web-frontend',
        'uname': 'www-data'
    }
]

maintainer_scripts = {
    'postinst': '~/python/beneboyit/frontend/scripts/after-install',
    'preinst': '~/python/beneboyit/frontend/scripts/before-install'
}

links =  [
    {
        'source': '/etc/nginx/sites-enabled/bbit-web-frontend',
        'destination': '../sites-available/bbit-web-frontend'
    },
    {
        'source': '/etc/uwsgi/apps-enabled/bbit-web-frontend.ini',
        'destination': '../apps-available/bbit-web-frontend.ini'
    },
]

depends = ('nginx', 'uwsgi')

output_directory = '~/build'

c = BinaryControl('bbit-web-frontend',  '1.5', 'all', 'Ben Shaw', 'BBIT Web Frontend')

c.set_control_field('Depends', depends)

c.set_control_fields({'Section': 'misc', 'Priority': 'optional'})

d = DPKGBuilder(output_directory, c, dirs, links, maintainer_scripts)
d.build_package()

Output file is named in the format <packagename>_<version>_<architecture>.deb and placed in the destination_dir. Alternatively, provide a name for your package as the output_name argument, and the package will be created with this name in the output_directory.

constrictor-build tool

constrictor-build is a command line tool that will build a package based on information in a JSON file. By default, this file is in the current directory and called “build-config.json”.

It loads the following fields and expects them to be in the same format as above:

  • package (string, required)
  • version (string, required)
  • architecture (string, required)
  • maintainer (string, required)
  • description (string, required)
  • extra_control_fields (dictionary of standard DPKG control field pairs, optional)
  • directories (array of dictionaries as per example above, optional)
  • links (array of dictionaries as per example above, optional)
  • maintainer_scripts (dictionary as per example above, optional)

You can also provide a “parent” field, which is a path to another build JSON file (path is relative to the config file) from which to read config values. For example, you might want to define the maintainer only in a parent config rather than in each child config.

Child values will replace parent values. “extra_control_fields” is not replaced as a whole, but the items in the child “extra_control_fields” will override those of the parents (i.e. they are merged with child items have precedence).

The parent lookup is recursive so a parent can have a parent, and so on.

Environment variables in the form ${var_name} or $var_name will be substituted.

Known Issues

  • Can only make Binary packages
  • Lintian will complain about missing control file fields due to those not having the ability to be created (yet). For example copyright, changelog, extended-description. Packages still install OK without these.
  • Can’t mark files as “config”
  • As with any tar based archive, ownership of files based on uname/gname can be wrong if the user does not exist. Use with caution or create postinst scripts to fix.
Release History

Release History

This version
History Node

0.2.2

History Node

0.2.1

History Node

0.2

History Node

0.1.8

History Node

0.1.6

History Node

0.1.5

History Node

0.1.4

History Node

0.1.3

History Node

0.1.2

History Node

0.1.1

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
deb-constrictor-0.2.2.tar.gz (7.8 kB) Copy SHA256 Checksum SHA256 Source Nov 3, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting