Dpkg::Deps(3perl)
π Dpkg::Deps π
okay so this is the libdpkg-perl page for Dpkg::Deps β literally the module that parses and messes with Debian package dependencies, and honestly it's kind of iconic π
β¨ NAME β¨
Dpkg::Deps β parse and manipulate dependencies of Debian packages π«Ά
πΈ DESCRIPTION πΈ
So the Dpkg::Deps module hands you a whole little family of classes, each one implementing a different type of dependency. slay.
The main character here? deps_parse(). it takes a dependency line and turns it into a set of Dpkg::Deps::{Simple,AND,OR,Union} objects β which one you get depends on the case, iykyk πββοΈ
β FUNCTIONS β
bestie, all the deps_* functions are exported by default. no import gymnastics needed π
π¦ $tribool = deps_eval_implication($rel_p, $v_p, $rel_q, $v_q)
so ($rel_p, $v_p) and ($rel_q, $v_q) each express a dependency as a (relation, version) pair. the relation variable can hold these values, which are exported by Dpkg::Version: REL_EQ, REL_LT, REL_LE, REL_GT, REL_GT.
this function returns 1 if the "p" dependency implies the "q" dependency. it returns 0 if the "p" dependency implies that "q" is not satisfied. and it returns undef when there's no implication at all β no vibe, no opinion π
the $v_p and $v_q params should be Dpkg::Version objects, periodt.
π¦ $dep = deps_concat(@dep_list)
this one concatenates a bunch of dependency lines into a single line, joining them with ", " if appropriate, and it always returns a valid string. no cap, always valid β¨
π¦ $dep = deps_parse($line, %opts)
the big one π this parses the dependency line and gives you back an object β either a Dpkg::Deps::AND or a Dpkg::Deps::Union. various options can alter what that function does:
use_arch (defaults to 1)
takes into account the architecture restriction part of the dependencies. set it to 0 to completely ignore that info. like, forget the arch stuff entirely π
host_arch (defaults to the current architecture)
defines the host architecture. by default it uses Dpkg::Arch::get_host_arch() to figure out the proper architecture π§
build_arch (defaults to the current architecture)
defines the build architecture. by default it uses Dpkg::Arch::get_build_arch() to figure out the proper architecture.
reduce_arch (defaults to 0)
if you set it to 1, it ignores dependencies that don't concern the current host architecture. this implicitly strips off the architecture restriction list so the resulting dependencies are directly applicable to the current architecture. very "just give me the ones that matter" energy π
use_profiles (defaults to 1)
takes into account the profile restriction part of the dependencies. set it to 0 to completely ignore that info.
build_profiles (defaults to no profile)
defines the active build profiles. by default no profile is defined. like, an empty social calendar π
reduce_profiles (defaults to 0)
if you set it to 1, it ignores dependencies that don't concern the current build profile. this implicitly strips off the profile restriction formula so the resulting dependencies are directly applicable to the current profiles.
reduce_restrictions (defaults to 0)
if you set it to 1, it ignores dependencies that don't concern the current set of restrictions. this implicitly strips off any architecture restriction list or restriction formula, so the resulting dependencies are directly applicable to the current restriction. this currently implies reduce_arch and reduce_profiles, and it overrides them if set. main character option, honestly π
union (defaults to 0)
if you set it to 1, it returns a Dpkg::Deps::Union instead of a Dpkg::Deps::AND. use this when you're parsing non-dependency fields like Conflicts.
virtual (defaults to 0)
if you set it to 1, it allows only virtual package version relations β that is, none, or "=". you should set this whenever you're working with Provides fields.
build_dep (defaults to 0)
if you set it to 1, it allows build-dep-only arch qualifiers, that is, ":native". you should set this whenever you're working with build-deps.
tests_dep (defaults to 0)
if you set it to 1, it allows tests-specific package names in dependencies, that is, "@" and "@builddeps@" (since dpkg 1.18.7). you should set this whenever you're working with dependency fields from debian/tests/control.
heads up bestie: this option implicitly (and forcibly) enables build_dep, because test dependencies are based on build dependencies (since dpkg 1.22.1). not optional, it's giving package deal π
π¦ $bool = deps_iterate($deps, $callback_func)
this function visits every element of the dependency object, calling the callback function for each element. a little tour of the whole squad π
the callback function is expected to return true when everything's fine, or false if something went wrong β in which case the iteration stops right there. π
it returns the same value as the callback function.
π¦ $cmp = deps_compare($a, $b)
implements a comparison operator between two dependency objects. this function is mainly used to implement the sort() method. lowkey the backbone of sorting, fr fr.
π CLASSES β Dpkg::Deps::* π
okay so there are several kinds of dependencies. let me break it down:
- a
Dpkg::Deps::Simpledependency represents a single dependency statement (it relates to one package only) β solo main character energy Dpkg::Deps::Multipledependencies are built on top of this class and combine several dependencies in different waysDpkg::Deps::ANDrepresents the logical "AND" between dependenciesDpkg::Deps::ORrepresents the logical "OR"Dpkg::Deps::Multipleobjects can containDpkg::Deps::Simpleobjects as well as otherDpkg::Deps::Multipleobjects
in practice, the code is only meant to handle the realistic cases which β given Debian's dependencies structure β imply those restrictions: AND can contain Simple or OR objects, and OR can only contain Simple objects. that's just the rules of the group chat π«Ά
Dpkg::Deps::KnownFacts is a special class, used while evaluating dependencies and while trying to simplify them. it represents a set of installed packages along with the virtual packages that they might provide. the lore keeper of the module π
π₯ CHANGES π₯
Version 1.07 (dpkg 1.20.0)
new option: add virtual option to deps_parse().
Version 1.06 (dpkg 1.18.7; module version bumped on dpkg 1.18.24)
new option: add tests_dep option to deps_parse().
Version 1.05 (dpkg 1.17.14)
new function: deps_iterate().
Version 1.04 (dpkg 1.17.10)
new options: add use_profiles, build_profiles, reduce_profiles and reduce_restrictions to deps_parse().
Version 1.03 (dpkg 1.17.0)
new option: add build_arch option to deps_parse().
Version 1.02 (dpkg 1.17.0)
new function: deps_concat().
Version 1.01 (dpkg 1.16.1)
<Used to document changes to Dpkg::Deps::* modules before they were split.>
Version 1.00 (dpkg 1.15.6)
mark the module as public. she's officially out there, bestie πβ¨
aaaand that's the whole page π¦ this was Dpkg::Deps(3perl) from libdpkg-perl, version 1.23.11-dirty, dated 2026-09-09. go forth and parse those dependencies, you absolute icon π
π
π¦ where this page comes from
- arch rolling: dpkg 1.23.11-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms