Dpkg::Path(3perl)

✨ Dpkg::Path β€” path-handling bestie edition ✨

okay so real talk, this is Dpkg::Path from libdpkg-perl, and it's basically the friend who knows where everything lives πŸ’…

🌸 NAME 🌸

Dpkg::Path β€” some common path handling functions, and yes that's the whole pitch, no cap.

πŸ¦‹ DESCRIPTION πŸ¦‹

It provides some functions to handle various path. That's it, that's the vibe β€” a little toolkit of path helpers πŸŽ€


πŸ”₯ FUNCTIONS πŸ”₯

  • $pathname = get_pkg_root_dir($file) β€” bestie, this one scans upwards through the directory hierarchy to find the directory that contains the "DEBIAN" sub-directory, and then returns that path. That directory is the root directory of a package that's being built. If no DEBIAN subdirectory turns up anywhere on the way up, it returns undef πŸ™ˆ
  • $pathname = relative_to_pkg_root($file) β€” hands you the filename relative to get_pkg_root_dir($file). simple, iconic.
  • $pathname = guess_pkg_root_dir($file) β€” this one tries to guess the root directory of the package build tree. It starts with get_pkg_root_dir(), but if that doesn't work out it falls back to a more imprecise check: namely it uses the parent directory that is a sub-directory of the debian directory. It can still return undef if a file outside of the debian sub-directory is provided 😭 so like, it's guessing, don't be shocked when it guesses.
  • $bool = check_files_are_the_same($file1, $file2, $resolve_symlink) β€” verifies that both files are the same by checking that the device numbers and the inode numbers returned by stat()/lstat() are the same. If $resolve_symlink is true then stat() is used, otherwise lstat() is used. fr fr the realest comparison there is πŸ’€
  • $pathname = canonpath($file) β€” returns a cleaned path. It simplifies double //, and removes /./ and /../ intelligently. For /../ it simplifies the path only if the previous element is not a symlink. So it should only be used on real filenames β€” noted, respected, internalized 🫢
  • $pathname = resolve_symlink($symlink) β€” returns the filename of the file pointed by the symlink. The new name is canonicalized by canonpath(). icon behavior ✨
  • check_directory_traversal($basedir, $dir) β€” verifies that the directory $dir does not contain any symlink that goes beyond $basedir (which should be either equal to or a parent of $dir). lowkey a security queen πŸ‘‘
  • $pathname = find_command($command) β€” returns the path of the command if it's defined and available on an absolute or relative path or on the $PATH, undef otherwise. the way it just finds things 🧚
  • $pathname = get_control_path($pkg, $filetype) β€” returns the path of the control file of type $filetype for the given package.
  • @pathname_list = get_control_path($pkg) β€” returns the path of all available control files for the given package. all of them. every single one πŸ“
  • $file = find_build_file($basename) β€” selects the right variant of the given file: the arch-specific variant ("$basename.$arch") has priority over the OS-specific variant ("$basename.$os"), which has priority over the default variant ("$basename"). If none of the files exists, then it returns undef. a whole hierarchy of priority, we love a main character with a ranking πŸ’…
  • @files = find_build_file($basename) β€” returns the available variants of the given file. Returns an empty list if none of the files exists. no files? no list. periodt.

πŸŽ€ CHANGES πŸŽ€

⭐ Version 1.05 (dpkg 1.20.4)

New function: check_directory_traversal().

⭐ Version 1.04 (dpkg 1.17.11)

Update semantics: find_command() now handles an empty or undef argument.

⭐ Version 1.03 (dpkg 1.16.1)

New function: find_build_file()

⭐ Version 1.02 (dpkg 1.16.0)

New function: get_control_path()

⭐ Version 1.01 (dpkg 1.15.8)

New function: find_command()

⭐ Version 1.00 (dpkg 1.15.6)

Mark the module as public. πŸŽ‰


and that's the whole page bestie, no crumbs left πŸ’– this one's Dpkg::Path(3perl) from libdpkg-perl, version 1.23.11-dirty, dated 2026-09-09 β€” go forth and handle some paths πŸŒˆπŸ¦‹

πŸ“¦ where this page comes from