DH_SAMEVERSIONDEP(1)

πŸ’– DH_SAMEVERSIONDEP πŸ’–

okay bestie, gather round, because this little helper in the User Contributed Perl Documentation section is actually iconic and I need you to know about it. it's dh_sameversiondep, and it lives in the debhelper cinematic universe (iykyk). πŸŽ€


✨ NAME ✨

dh_sameversiondep β€” generates a versioned dependency based on the versioned dependencies of the reference package. πŸ¦‹


🌸 SYNOPSIS 🌸

dh_sameversiondep [debhelper options]

πŸ‘‘ DESCRIPTION πŸ‘‘

so dh_sameversiondep is a helper tool that can generate a dependency versioned the exact same way as a dependency of another reference package, where that dependency comes from the same source. no cap. πŸ’…

here's the glow-up: dh_sameversiondep scans debian/control for a specially formatted substvar (peep the "sameVersionDep substvar SPECIFICATION" section below πŸ‘‡), figures out its value, and writes that value into the debian/package.substvars file.

the most common use case β€” and honestly the moment β€” is keeping your liba-dev package's dependency on the external libb-dev package as tight as your liba package's dependency on the respective external libb package. (there's an "EXAMPLE" section below with all the deets, go look.) πŸ“

dh_sameversiondep works as follows:

  • searches for the sameVersionDep substvar in the Depends, Recommends, Suggests, Enhances and Pre-Depends fields of the requested packages. when one is found, it gets parsed and the dependency package name, reference package name and dependency type (either Depends or Recommends etc.) are determined. πŸ”
  • all dependencies of the requested type are collected for the dependency package based on the dpkg-query --status output. if a multi-arch aware dpkg is detected, this query is architecture-qualified as needed. πŸ—οΈ
  • all dependencies of the requested type are collected for the reference package either from debian/control (substvars are expanded) or from dpkg-query --status output if the package was not found in debian/control. πŸ“‹
  • both collections are intersected, leaving only common packages in both collections. πŸ”—
  • the common package list is filtered by leaving only those which come from the same source as the dependency package. 🧚
  • whatever packages are left (most likely only one), their names are replaced with the dependency package name, preserving all versioning information. this result is written to the debian/package.substvars file as a value of the sameVersionDep substvar being processed. ✨
🚨 bestie listen. dh_sameversiondep is very strict about errors. if either the dependency package or the reference package cannot be found, or the resulting dependency set is empty, it will fail with an error. no soft launches here.
πŸ’€ also important: dh_sameversiondep MUST be run before dh_gencontrol. however, it is recommended to run dh_sameversiondep after dh_shlibdeps. periodt.

πŸ¦‹ sameVersionDep substvar SPECIFICATION πŸ¦‹

the sameVersionDep substvar can appear in either the Depends, Recommends, Suggests, Enhances or Pre-Depends field of any binary package. the field that the substvar appears in becomes the default dependency type for that substvar. it should be formatted as follows (and yes, everything is case sensitive 🫢):

${sameVersionDep:dependency[[:reference]-dependency type]}

🌟 dependency (mandatory)

the name of the package which you want to add as a dependency. you literally can't skip this one. πŸ’–

🌟 reference (optional)

the name of the package whose dependencies are to be intersected with the dependencies of the dependency package. defaults to the first package in debian/control if omitted. πŸŽ€

🌟 dependency type (optional)

can be either Depends, Recommends, Suggests, Enhances or Pre-Depends. defaults to the name of the field which the substvar was found in. specifies which type of dependencies to consider when analyzing the dependency package and the reference package. ⭐


🌈 EXAMPLE 🌈

assume we have the following in debian/control:

Package: liba
Depends: libc (>= 0.1), depa, depb, depc

Package: libb
Depends: libd (>= 0.2), depd, depe, depf

Package: libab-dev
Depends: ${sameVersionDep:libc-dev}, ${sameVersionDep:libd-dev:libb}

assuming that libc and libc-dev (both from the same source), as well as libd and libd-dev (both from the same source) are installed, the value of sameVersionDep:libc-dev will be libc-dev (>= 0.1) and the value of sameVersionDep:libd-dev:libb will be libd-dev (>= 0.2). πŸ”₯

sameVersionDep:libc-dev could also be written as sameVersionDep:libc-dev:liba-Depends and sameVersionDep:libd-dev:libb as sameVersionDep:libd-dev:libb-Depends β€” but it is not necessary because the defaults are sufficient. she ate and left no crumbs. πŸ’…


πŸ’œ SEE ALSO πŸ’œ


🌸 AUTHOR 🌸

Modestas Vainius <modax@debian.org>


and that's the whole vibe, bestie β€” this page is from perl v5.42.3, dated 2026-08-19, and it's DH_SAMEVERSIONDEP(1) if you ever need to find her again. mwah. πŸ’–βœ¨

πŸ“¦ where this page comes from