Skip to main content

Build debian packages

Project description

cicd codecov MIT license Generic badge Code style: black PyPI version shields.io Downloads

ops2deb

Are you tired of checking if your favorite devops tools are up-to-date? Are you using a debian based GNU/Linux distribution? ops2deb is designed to generate Debian packages for common devops tools such as kubectl, kustomize, helm, ..., but it could be used to package any statically linked application. In short, it consumes a configuration file and outputs .deb packages.

Configuration file

Written in YAML and composed of a single blueprint object or a list of blueprints objects. A blueprint is defined by the following:

Field Meaning Default
name Component name, e.g. kustomize.
version Application release to package.
homepage Upstream project homepage. None
arch Package architecture. amd64
revision Package revistion. 1
summary Package short description.
description Package full description.
fetch A binary to download, and a sha256 checksum. tar.gz, tar.xz, tar and zip (requires unzip) archives are extracted automatically. Null
script List of build instructions templated with jinja2 and intepreted with the default shell. []
depends List of package dependencies. Corresponds to Depends entry in debian/control. []
recommends List of package recommended dependencies. Corresponds to Recommends entry in debian/control. []
conflicts List of conflicting packages. Corresponds to Conflicts entry in debian/control. []

Example of a configuration file a single blueprint:

name: kubectl
version: 1.20.1
summary: Command line client for controlling a Kubernetes cluster
description: |
  kubectl is a command line client for running commands against Kubernetes clusters.
fetch:
  url: https://storage.googleapis.com/kubernetes-release/release/v{{version}}/bin/linux/amd64/kubectl
  sha256: 3f4b52a8072013e4cd34c9ea07e3c0c4e0350b227e00507fb1ae44a9adbf6785
script:
  - mv kubectl {{src}}/usr/bin/

Dependencies

  • Python >= 3.9
  • To build debian packages with ops2deb build you need the following packages on your host:
sudo apt install build-essential fakeroot debhelper

Installation

With wakemeops

sudo apt-get install ops2deb

With pipx

pipx install ops2deb

Getting started

In a test directory run:

curl https://raw.githubusercontent.com/upciti/ops2deb/main/ops2deb.yml
ops2deb generate
ops2deb build

To check for new releases run:

ops2deb update

This command updates each blueprint in the ops2deb.yml configuration file with the latest version of the upstream application (currently only works for applications using semantic versioning).

By default ops2deb caches downloaded content in /tmp/ops2deb_cache:

tree /tmp/ops2deb_cache

The cache can be flushed with:

ops2deb purge

For more information about existing subcommands and options run ops2deb --help.

Usage examples

Creating a metapackage

Ops2deb can be used to create metapackages:

name: allthethings
version: 0.1.9
arch: all
summary: Install various devops tools
description: Some great description.
depends:
  - kubectl
  - kustomize
  - helm
  - helmfile
  - devspace

Packaging ops2deb with ops2deb

Note that when the fetch key is not used, ops2deb will run the build script from the directory where it was called. Hence for the following blueprint to succeed, you have to run ops2deb from the root directory of this github project.

name: ops2deb
version: 0.15.0
homepage: https://github.com/upciti/ops2deb
summary: Debian packaging tool for portable applications
description: |-
  Ops2deb is primarily designed to easily generate Debian packages for portable
  applications such as single binary applications and scripts. Packages are
  described using a simple configuration file format. Ops2deb can track new
  releases of upstream applications and automatically bump application versions
  in its configuration file.
script:
  - poetry install -E pyinstaller
  - poetry run task single_binary_application
  - install -m 755 build/x86_64-unknown-linux-gnu/release/install/ops2deb {{src}}/usr/bin/

Development

You will need poetry, and probably pyenv if you don't have python 3.9 on your host.

poetry install

To run ops2deb test suite run:

poetry run task check

To build a python wheel:

poetry run poetry build

Note that the poetry run is important to enable poetry-dynamic-versioning which is installed as a dev dependency.

To build a single binary applicatin:

Install required build dependencies:

sudo apt install binutils python3-dev
poetry install -E pyinstaller

And run:

poetry run task single_binary_application

Important notes

ops2deb DOES NOT sandbox build instructions so if you do something like:

script:
- rm -rf ~/*

You will loose your files... To make sure that you won't mess with your system, run it within a container.

Project details


Download files

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

Source Distribution

ops2deb-0.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

ops2deb-0-py3-none-any.whl (21.2 kB view details)

Uploaded Python 3

File details

Details for the file ops2deb-0.tar.gz.

File metadata

  • Download URL: ops2deb-0.tar.gz
  • Upload date:
  • Size: 20.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for ops2deb-0.tar.gz
Algorithm Hash digest
SHA256 6fbac6165e288fee2b36a97ed39e4eeeda8a714286fe8251b1ae2a90b7661206
MD5 04d009e52fae2e499d57bd91ac903045
BLAKE2b-256 ab1c572d1eb67025dd51cf5d2772ad03377b31d4a675f66164478be21eacd16f

See more details on using hashes here.

File details

Details for the file ops2deb-0-py3-none-any.whl.

File metadata

  • Download URL: ops2deb-0-py3-none-any.whl
  • Upload date:
  • Size: 21.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for ops2deb-0-py3-none-any.whl
Algorithm Hash digest
SHA256 e9e0b56418a2aeaf2edd04b71ede605a9e5f70963f8aaf0a2c6c6a57e625bd43
MD5 9b0fcaf91c54033d9a19eedb0692ddb0
BLAKE2b-256 d8e67ed8019329cb8f79c032babdde13718613bacba66c93123534a587114932

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page