Package: ops2deb
ops2debAre you tired of checking if your favorite devops tools are up-to-date? Are you using a debian based GNU/Linux distribution?ops2debis designed to generate Debian packages for common devops tools such as kubectl, kustomize, helm, ...,
but can be used to package any portable application. In short, it consumes a configuration file and outputs.debpackages.ops2debcan also track new releases of upstream applications and automatically bump application versions in its configuration file.InstallationWithwakemeopsWithpipxDependenciesGetting startedUsage examplesPackaging kubectlCreating a metapackagePackaging ops2deb with ops2debBuilding packages for multiple architectures at onceUsing environment variablesConfiguration fileDevelopmentImportant notesMigration guidesMigrating to v1Breaking changes in v2InstallationWithwakemeopssudoapt-getinstallops2debWithpipxpipxinstallops2debDependenciesPython >= 3.10 if installed withpiporpipxTo build debian packages withops2deb buildyou need the following packages on your host:sudoaptinstallbuild-essentialfakerootdebhelperIf you plan to build packages forarmhfandarm64you will also need the following packages:sudoaptinstallbinutils-aarch64-linux-gnubinutils-arm-linux-gnueabihfGetting startedIn a test directory run:curlhttps://raw.githubusercontent.com/upciti/ops2deb/main/ops2deb.yml
ops2deblock# generate lockfile where downloaded file hashes are storedops2deb# equivalent to ops2deb generate && ops2deb buildTo check for new releases run:ops2debupdateThis command updates each blueprint in theops2deb.ymlconfiguration file with the latest version of the upstream application.By defaultops2debcaches downloaded content in/tmp/ops2deb_cache:tree/tmp/ops2deb_cacheThe cache can be flushed with:ops2debpurgeFor more information about existing subcommands and options runops2deb --help.Usage examplesPackagingkubectlThefetchfield tells ops2deb to download a file.ops2debwill check the hash
of downloaded files against a lockfile. To generate/update this lockfile, runops2dbe lock. By default, the lockfile is namedops2deb.lock.yml.name:kubectlversion:1.20.1summary:command line client for controlling a Kubernetes clusterdescription:|kubectl is a command line client for running commands against Kubernetes clusters.fetch:https://storage.googleapis.com/kubernetes-release/release/v{{version}}/bin/linux/amd64/kubectlinstall:-kubectl:/usr/bin/Creating a metapackageOps2deb can be used to createmetapackages:name:allthethingsversion:0.1.9architecture:allsummary:install various devops toolsdescription:Some great description.depends:-kubectl-kustomize-helm-helmfile-devspacePackaging ops2deb with ops2debNote 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:ops2debversion:0.15.0homepage:https://github.com/upciti/ops2debsummary:debian packaging tool for portable applicationsdescription:|-Ops2deb is primarily designed to easily generate Debian packages for portableapplications such as single binary applications and scripts. Packages aredescribed using a simple configuration file format. Ops2deb can track newreleases of upstream applications and automatically bump application versionsin 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/Building packages for multiple architectures at onceIf the upstream application is released for multiple architectures,
use thematrixobject to generate one source package for each architecture:name:helmmatrix:architectures:-amd64-armhf-arm64version:3.7.2homepage:https://helm.sh/summary:Kubernetes package managerdescription:|-Tool for managing Kubernetes charts.Charts are packages of pre-configured Kubernetes resources.depends:-kubectlfetch:https://get.helm.sh/helm-v{{version}}-linux-{{goarch}}.tar.gzscript:-mv linux-*/helm {{src}}/usr/bin/The blueprint above will generate three packages:helm_3.7.2-1~ops2deb_armhf.deb,helm_3.7.2-1~ops2deb_arm64.debandhelm_3.7.2-1~ops2deb_amd64.debNote the use of the{{goarch}}variable which maps debian architectures to sensible go architectures.You can also define your own architecture maps using thefetch.targetsfield and the{{target}}jinja variable:name:bottommatrix:architectures:-amd64-armhfversion:0.6.6revision:2homepage:https://clementtsang.github.io/bottomsummary:cross-platform graphical process/system monitordescription:|-A cross-platform graphical process/system monitor with a customizable interfaceand a multitude of features. Supports Linux, macOS, and Windows.Inspired by gtop, gotop, and htop.fetch:url:https://github.com/ClementTsang/bottom/releases/download/{{version}}/bottom_{{target}}.tar.gztargets:amd64:x86_64-unknown-linux-gnuarmhf:armv7-unknown-linux-gnueabihfinstall:-btm:/usr/bin/Using environment variablesYou can use{{env("VARIABLE", "a_default")}}in all fields exceptfetch.targets.*.
The example below uses environment variables set by Gitlab CI:name:"{{env('CI_PROJECT_NAME')}}"version:"{{env('CI_COMMIT_TAG','0')}}"homepage:"{{env('CI_PROJECT_URL')}}"summary:awesome application for doing thingsdescription:|-Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod temporincididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quisnostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.script:-install -m 755 build/x86_64-unknown-linux-gnu/release/install/great-app {{src}}/usr/bin/Configuration fileWritten in YAML and composed of a single blueprint object or a list of blueprints objects. A blueprint is defined by the following:FieldMeaningDefaultnameComponent name, e.g.kustomize.matrixGenerate multiple packages from a single blueprint.NoneversionApplication release to package.revisionPackage revistion.1epochPackage epoch.0architecturePackage architecture.amd64homepageUpstream project homepage.NonesummaryPackage short description.descriptionPackage full description.dependsList of package dependencies. Corresponds toDependsentry indebian/control.[]recommendsList of package recommended dependencies. Corresponds toRecommendsentry indebian/control.[]conflictsList of conflicting packages. Corresponds toConflictsentry indebian/control.[]fetchA file to download.tar.gz,tar.xz,tar,zipanddebarchives are extracted automatically.NoneinstallList of here-documents and files/directories to add to the debian package.[]scriptList of build instructions templated with jinja2 and interpreted with the defaultshell.[]DevelopmentYou will needpoetry, and probablypyenvif you don't have python 3.10 on your host.poetryinstallTo run ops2deb test suite run:poetryruntaskcheckTo build a python wheel:poetryrunpoetrybuildNote that thepoetry runis important to enablepoetry-dynamic-versioningwhich is installed as a dev dependency.To build a single binary application:Install required build dependencies:sudoaptinstallbinutilspython3-dev
poetryinstall-EpyinstallerAnd run:poetryruntasksingle_binary_applicationImportant notesops2debDOES NOTsandbox 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.Migration guidesMigrating to v1Lockfileops2deb.lock.ymlwas introduced in ops2deb v1.0.0, before that downloaded file hashes where stored in the configuration file, in the blueprintfetchobject.To migrate from ops2deb <= 1.0.3 to ops2deb > 1.0.3:Install ops2deb 1.0.3Runops2deb migrateBreaking changes in v2GITHUB_TOKENenvironment variable renamed toOPS2DEB_GITHUB_TOKENCommand line argument-kwas removed. Startops2deb.ymlwith# lockfile={path_to_lockfile}to override the default lockfile path.