Lintian::Path(3) | Debian Package Checker | Lintian::Path(3) |
Lintian::Path - Lintian representation of a path entry in a package
my ($name, $type, $dir) = ('lintian', 'source', '/path/to/entry'); my $info = Lintian::Collect->new ($name, $type, $dir); my $path = $info->index('bin/ls'); if ($path->is_file) { # is file (or hardlink) if ($path->is_hardlink) { } if ($path->is_regular_file) { } } elsif ($path->is_dir) { # is dir if ($path->owner eq 'root') { } if ($path->group eq 'root') { } } elsif ($path->is_symlink) { my $normalized = $path->link_normalized; if (defined($normalized)) { my $more_info = $info->index($normalized); if (defined($more_info)) { # target exists in the package... } } }
Argument is a hash containing the data read from the index file.
NB: It will never have any leading "./" (or "/") in it.
NB: If only numerical owner information is available in the package, this may return a numerical owner (except uid 0 is always mapped to "root")
NB: If only numerical owner information is available in the package, this may return a numerical group (except gid 0 is always mapped to "root")
NB: If the uid is not available, 0 will be returned. This usually happens if the numerical data is not collected (e.g. in source packages)
NB: If the gid is not available, 0 will be returned. This usually happens if the numerical data is not collected (e.g. in source packages)
If this is not a link, then this returns undef.
If the path is a symlink this method can be used to determine if the symlink is relative or absolute. This is not true for hardlinks, where the link target is always relative to the root.
NB: Even for symlinks, a leading "./" will be stripped.
NB: Only regular files can have a non-zero file size.
NB: Returns "undef" for the "root" dir.
NB: Returns the empty string for the "root" dir.
NB: Returns the empty string for the "root" dir.
NB: This is only well defined for file entries that are subject to permissions (e.g. files). Particularly, the value is not well defined for symlinks.
The optional RECURSIVE_MODE parameter can be used to control if and how descendants of this directory is selected. The following values are supported:
NB: Returns the empty list for non-dir entries.
For non-dirs, this method always returns "undef".
Example:
$dir_entry->child('foo') => $entry OR undef $dir_entry->child('foo/') => $dir_entry OR undef
NB: The target of a hardlink is always a regular file (and not a dir etc.).
NB: Unlike the "-d $dir" operator this will never return true for symlinks, even if the symlink points to a dir.
NB: Unlike the "-f $file" operator this will never return true for symlinks, even if the symlink points to a file (or hardlink).
This is eqv. to $path->is_file and not $path->is_hardlink.
NB: Unlike the "-f $file" operator this will never return true for symlinks, even if the symlink points to a file.
NB: This method will return the empty string for links pointing to the root dir of the package.
Only available on "links" (i.e. symlinks or hardlinks). On non-links this will croak.
Symlinks only: If you want the symlink target as a Lintian::Path object, use the resolve_path method with no arguments instead.
Note this is only defined for files as Lintian only runs file(1) on files.
This method may fail if:
To test if this is safe to call, if the target is (supposed) to be a:
Returns a truth value if the path may be opened.
Beyond regular issues with opening a file, this method may fail if:
It is possible to test for these by using "is_open_ok".
The returned handle may be a pipe from an external process.
This method may fail for the same reasons as "open([LAYER])".
If PATH starts with a slash and the file hierarchy has a well-defined root directory, then PATH will instead be resolved relatively to the root dir. If the file hierarchy does not have a well-defined root dir (e.g. for source packages), this method will return "undef".
If PATH is omitted, then the entry is resolved and the target is returned if it is valid. Except for symlinks, all entries always resolve to themselves. NB: hardlinks also resolve as themselves.
It is an error to attempt to resolve a PATH against a non-directory and non-symlink entry - as such resolution would always fail (i.e. foo/../bar is an invalid path unless foo is a directory or a symlink to a dir).
The resolution takes symlinks into account and following them provided that the target path is valid (and can be followed safely). If the path is invalid or circular (symlinks), escapes the root directory or follows an unsafe symlink, the method returns "undef". Otherwise, it returns the path entry that denotes the target path.
If PATH contains at least one path segment and ends with a slash, then the resolved path will end in a directory (or fail). Otherwise, the resolved PATH can end in any entry except a symlink.
Examples:
$symlink_entry->resolve_path => $nonsymlink_entry OR undef $x->resolve_path => $x For directory or symlink entries (dol), you can also resolve a path: $dol_entry->resolve_path('some/../where') => $nonsymlink_entry OR undef # Note the trailing slash $dol_entry->resolve_path('some/../where/') => $dir_entry OR undef
Originally written by Niels Thykier <niels@thykier.net> for Lintian.
lintian(1), Lintian::Collect(3), Lintian::Collect::Binary(3), Lintian::Collect::Source(3)
2019-05-26 | Lintian v2.15.0 |