Package: deb-pkg-tools
The Python packagedeb-pkg-toolsis a collection of functions to build and
inspectDebian binary packagesand repositories of binary packages. Its
primary use case is to automate builds.Some of the functionality is exposed in the command line interface (documented below)
because it’s very convenient to use in shell scripts, while other functionality
is meant to be used as a Python API. The package is currently tested on cPython
2.7, 3.5+ and PyPy (2.7).Please note thatdeb-pkg-toolsis quite opinionated about how Debian binary
packages should be built and it enforces some of these opinions on its users.
Most of this can be avoided with optional function arguments and/or environment
variables. If you find something that doesn’t work to your liking and you can’t
work around it, feel free to ask for an additional configuration option; I try
to keep an open mind about the possible use cases of my projects.ContentsStatusInstallationUsageDependenciesPlatform compatibilityDisabling sudo usageContactLicenseStatusOn the one hand thedeb-pkg-toolspackage is based on my experiences with
Debian packages and repositories over the past couple of years, on the other
handdeb-pkg-toolsitself is quite young. Then again most functionality is
covered by automated tests; at the time of writing coverage is around 90% (some
of the error handling is quite tricky to test if we also want to test the
non-error case, which is of course the main focus :-)InstallationThedeb-pkg-toolspackage is available onPyPIwhich means installation
should be as simple as:$pipinstalldeb-pkg-toolsThere’s actually a multitude of ways to install Python packages (e.g. theper
user site-packages directory,virtual environmentsor just installing
system wide) and I have no intention of getting into that discussion here, so
if this intimidates you then read up on your options before returning to these
instructions ;-).Whendeb-pkg-toolsis being used to scan thousands of*.debarchives a
significant speedup may be achieved using memcached:$pipinstall"deb-pkg-tools[memcached]"Under the hooddeb-pkg-toolsuses several programs provided by Debian, the
details are available in thedependenciessection. To install these programs:$sudoapt-getinstalldpkg-devfakerootlintianUsageThere are two ways to use thedeb-pkg-toolspackage: As a command line
program and as a Python API. For details about the Python API please refer to
the API documentation available onRead the Docs. The command line interface
is described below.Usage:deb-pkg-tools [OPTIONS] …Wrapper for the deb-pkg-tools Python project that implements various tools to
inspect, build and manipulate Debian binary package archives and related
entities like trivial repositories.Supported options:OptionDescription-i,--inspect=FILEInspect the metadata in the Debian binary package archive given byFILE(similar to “dpkg--info”).-c,--collect=DIRCopy the package archive(s) given as positional arguments (and all package
archives required by the given package archives) into the directory given
byDIR.-C,--check=FILEPerform static analysis on a package archive and its dependencies in order
to recognize common errors as soon as possible.-p,--patch=FILEPatch fields into the existing control file given byFILE. To be used
together with the-s,--setoption.-s,--set=LINEA line to patch into the control file (syntax: “Name: Value”). To be used
together with the-p,--patchoption.-b,--build=DIRBuild a Debian binary package with “dpkg-deb--build” (and lots of
intermediate Python magic, refer to the API documentation of the project
for full details) based on the binary package template in the directory
given byDIR. The resulting archive is located in the system wide
temporary directory (usually /tmp).-u,--update-repo=DIRCreate or update the trivial Debian binary package repository in the
directory given byDIR.-a,--activate-repo=DIREnable “apt-get” to install packages from the trivial repository (requires
root/sudo privilege) in the directory given byDIR. Alternatively you can
use the-w,--with-repooption.-d,--deactivate-repo=DIRCleans up after--activate-repo(requires root/sudo privilege).
Alternatively you can use the-w,--with-repooption.-w,--with-repo=DIRCreate or update a trivial package repository, activate the repository, run
the positional arguments as an external command (usually “apt-get install”)
and finally deactivate the repository.--gc,--garbage-collectForce removal of stale entries from the persistent (on disk) package
metadata cache. Garbage collection is performed automatically by the
deb-pkg-tools command line interface when the last garbage collection
cycle was more than 24 hours ago, so you only need to do it manually
when you want to control when it happens (for example by a daily
cron job scheduled during idle hours :-).-y,--yesAssume the answer to interactive questions is yes.-v,--verboseMake more noise! (useful during debugging)-h,--helpShow this message and exit.One thing to note is that the operation ofdeb-pkg-tools--update-repocan
be influenced by a configuration file. For details about this, please refer to
the documentation ondeb_pkg_tools.repo.select_gpg_key().DependenciesThe following external programs are required bydeb-pkg-tools(depending on
which functionality you want to use of course):ProgramPackageapt-ftparchiveapt-utilsapt-getaptcpcoreutilsdpkg-debdpkgdpkg-architecturedpkg-devducoreutilsfakerootfakerootgpggnupggzipgziplintianlintianThe majority of these programs/packages will already be installed on most
Debian based systems so you should only need the following to get started:$sudoapt-getinstalldpkg-devfakerootlintianPlatform compatibilitySeveral things can be tweaked via environment variables if they don’t work for
your system or platform. For example on Mac OS X thecpcommand doesn’t
have an-lparameter and therootuser and group may not exist, but
despite these things it can still be useful to test package builds on Mac OS
X. The following environment variables can be used to adjust such factors:Environment variableDefault value$DPT_ALLOW_FAKEROOT_OR_SUDOtrue$DPT_CHOWN_FILEStrue$DPT_FORCE_ENTROPYfalse$DPT_HARD_LINKStrue$DPT_PARSE_STRICTtrue$DPT_RESET_SETGIDtrue$DPT_ROOT_GROUProot$DPT_ROOT_USERroot$DPT_SUDOtrueEnvironment variables for boolean options support the stringsyes,true,1,no,falseand0(case is ignored).Disabling sudo usageTo disable any use ofsudoyou can use the following:exportDPT_ALLOW_FAKEROOT_OR_SUDO=falseexportDPT_CHOWN_FILES=falseexportDPT_RESET_SETGID=falseexportDPT_SUDO=falseContactThe latest version ofdeb-pkg-toolsis available onPyPIandGitHub. The
documentation is hosted onRead the Docs. For bug reports please create an
issue onGitHub. If you have questions, suggestions, etc. feel free to send me
an e-mail atpeter@peterodding.com.LicenseThis software is licensed under theMIT license.© 2020 Peter Odding.