1Dpkg::Path(3perl) libdpkg-perl Dpkg::Path(3perl)
2
3
4
6 Dpkg::Path - some common path handling functions
7
9 It provides some functions to handle various path.
10
12 get_pkg_root_dir($file)
13 This function will scan upwards the hierarchy of directory to
14 find out the directory which contains the "DEBIAN" sub-
15 directory and it will return its path. This directory is the
16 root directory of a package being built.
17
18 If no DEBIAN subdirectory is found, it will return undef.
19
20 relative_to_pkg_root($file)
21 Returns the filename relative to get_pkg_root_dir($file).
22
23 guess_pkg_root_dir($file)
24 This function tries to guess the root directory of the package
25 build tree. It will first use get_pkg_root_dir(), but it will
26 fallback to a more imprecise check: namely it will use the
27 parent directory that is a sub-directory of the debian
28 directory.
29
30 It can still return undef if a file outside of the debian sub-
31 directory is provided.
32
33 check_files_are_the_same($file1, $file2, $resolve_symlink)
34 This function verifies that both files are the same by checking
35 that the device numbers and the inode numbers returned by
36 stat()/lstat() are the same. If $resolve_symlink is true then
37 stat() is used, otherwise lstat() is used.
38
39 canonpath($file)
40 This function returns a cleaned path. It simplifies double //,
41 and remove /./ and /../ intelligently. For /../ it simplifies
42 the path only if the previous element is not a symlink. Thus it
43 should only be used on real filenames.
44
45 $newpath = resolve_symlink($symlink)
46 Return the filename of the file pointed by the symlink. The new
47 name is canonicalized by canonpath().
48
49 check_directory_traversal($basedir, $dir)
50 This function verifies that the directory $dir does not contain
51 any symlink that goes beyond $basedir (which should be either
52 equal or a parent of $dir).
53
54 $cmdpath = find_command($command)
55 Return the path of the command if defined and available on an
56 absolute or relative path or on the $PATH, undef otherwise.
57
58 $control_file = get_control_path($pkg, $filetype)
59 Return the path of the control file of type $filetype for the
60 given package.
61
62 @control_files = get_control_path($pkg)
63 Return the path of all available control files for the given
64 package.
65
66 $file = find_build_file($basename)
67 Selects the right variant of the given file: the arch-specific
68 variant ("$basename.$arch") has priority over the OS-specific
69 variant ("$basename.$os") which has priority over the default
70 variant ("$basename"). If none of the files exists, then it
71 returns undef.
72
73 @files = find_build_file($basename)
74 Return the available variants of the given file. Returns an
75 empty list if none of the files exists.
76
78 Version 1.05 (dpkg 1.20.4)
79 New function: check_directory_traversal().
80
81 Version 1.04 (dpkg 1.17.11)
82 Update semantics: find_command() now handles an empty or undef
83 argument.
84
85 Version 1.03 (dpkg 1.16.1)
86 New function: find_build_file()
87
88 Version 1.02 (dpkg 1.16.0)
89 New function: get_control_path()
90
91 Version 1.01 (dpkg 1.15.8)
92 New function: find_command()
93
94 Version 1.00 (dpkg 1.15.6)
95 Mark the module as public.
96
97
98
991.20.9 2021-05-10 Dpkg::Path(3perl)