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 noDEBIANsubdirectory turns up anywhere on the way up, it returnsundefπ$pathname = relative_to_pkg_root($file)β hands you the filename relative toget_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 withget_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 thedebiandirectory. It can still returnundefif a file outside of thedebiansub-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 bystat()/lstat()are the same. If$resolve_symlinkis true thenstat()is used, otherwiselstat()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 bycanonpath(). icon behavior β¨check_directory_traversal($basedir, $dir)β verifies that the directory$dirdoes 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,undefotherwise. the way it just finds things π§$pathname = get_control_path($pkg, $filetype)β returns the path of the control file of type$filetypefor 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 returnsundef. 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
- 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