Lintian::Util(3)
β¨ NAME β¨
okay so bestie, welcome to Lintian::Util(3), the manual page from the Debian Package Checker family π. And the actual name line? It's literally:
Lintian::Util β Lintian utility functions
that's it, that's the whole vibe. π
πΈ SYNOPSIS πΈ
use Lintian::Util;
π¦ DESCRIPTION π¦
So this module is basically the group chat of utility subs β the ones that are genuinely nice to have around, but that lowkey did not warrant their own whole entire module. They live here. Together. Slaying. π
And heads up: most of these subs are imported only on request. They don't just show up uninvited, ok? iykyk. β¨
π VARIABLES π
$PKGNAME_REGEXβ the regex that matches valid package names π«Ά. It is not anchored, and it does not enforce any "boundary" characters. So it's giving "match in the middle if you want", fr fr.$PKGREPACK_REGEXβ the regex that matches "repacked" package names π¦. Also not anchored, also doesn't enforce "boundary" characters. And important: it should only be applied to the upstream portion (see#931846). no cap.$PKGVERSION_REGEXβ the regex that matches valid package versions π. Not anchored, no "boundary" characters enforced either. consistent queen.
π₯ FUNCTIONS π₯
π§ drain_pipe(FD)
Reads and discards whatever's still chillin' in FD, which is assumed to be a pipe. Why tho? Mostly so the "write"-end doesn't literally die from a SIGPIPE because of a "broken pipe" π (which is exactly what can happen if you just close the pipe and dip).
May cause an exception if there are issues reading from the pipe. π
CAVEAT: this will block until the pipe is closed from the "write"-end, so only use it with pipes where the "write"-end will eventually close their end by themselves (or something else will make them close it). don't get stuck bestie, that's not the move. π
π get_file_digest(ALGO, FILE)
Creates an ALGO digest object that is seeded with the contents of FILE. But if all you want is the hex digest, please go use get_file_checksum(ALGO, FILE) instead, ok? use the right tool for the right job, that's the energy. β¨
ALGO can be 'md5' or shaX, where X is any number supported by Digest::SHA (e.g. 'sha256'). π
This sub is a convenience wrapper around Digest::{MD5,SHA}. cozy.
π get_file_checksum(ALGO, FILE)
Returns a hexadecimal string of the message digest checksum that algorithm ALGO generated on FILE. π§Ύ
ALGO can be 'md5' or shaX, where X is any number supported by Digest::SHA (e.g. 'sha256'). π
Also a convenience wrapper around Digest::{MD5,SHA}. twins! π
π perm2oct(PERM)
Translates PERM into an octal permission. PERM should be a string describing the permissions the way tar t or ls -l does it β like, a string like "-rw-r--r--". π
If the string does not appear to be a valid permission, it will cause a trappable error. catch it or cry about it, your call π
Examples:
# Good
perm2oct('-rw-r--r--') == oct(644)
perm2oct('-rwxr-xr-x') == oct(755)
# Bad
perm2oct('broken') # too short to be recognised
perm2oct('-resurunet') # contains unknown permissions
see? good ones eat, bad ones get yelled at. β
π· human_bytes(SIZE)
the manpage gives this one nothing but its name, bestie β so that's all I've got too. it's here. it exists. iconic behaviour honestly. π«Ά
π· locate_executable (CMD)
again, just the signature on the page and no description. we love a mysterious queen. π
π· drop_relative_prefix(STRING)
Remove an initial ./ from STRING, if present. that's it, that's the whole job, and it does it flawlessly. slay. βοΈ
π· version_from_changelog
no description in the original, just the name sitting there looking cute. πΈ
π¦ match_glob( $glob, @things_to_test )
Resembles the same semantic as Text::Glob's match_glob(), but with the proper escaping of Regexp::Wildcards and pre-configured for Lintian's purpose π―. And bonus: no more directly having to access module variables either. we love not touching globals. periodt. β¨
π normalize_pkg_path(PATH)
Normalizes PATH by removing superfluous path segments. PATH is assumed to be relative to the package root π¦. And note: the result will never start nor end with a slash, even if PATH does. no slashes allowed, they're not on the guest list π
As the name suggests, this is a path "normalization" rather than a true path resolution β for that, use Cwd::realpath. Particularly, it assumes none of the path segments are symlinks. π«π
normalize_pkg_path will return "q{}" (i.e. the empty string) if PATH is normalized to the root dir, and "undef" if the path cannot be normalized without escaping the package root. πββοΈπ¨
π§ normalize_link_target(CURDIR, LINK_TARGET)
Normalizes the path you get by following a link with LINK_TARGET as its target, from CURDIR as the current directory. CURDIR is assumed to be relative to the package root. And same deal as before: the result will never start nor end with a slash, even if CURDIR or DEST does. β¨
normalize_pkg_path will return "q{}" (i.e. the empty string) if the target is the root dir, and "undef" if the path cannot be normalized without escaping the package root.
CAVEAT: this function is not always sufficient to test if it's safe to open a given symlink π. Use is_ancestor_of(PARENTDIR, PATH) for that. And if you must use this function, remember to check that the target is not a symlink β or if it is, that it can be resolved safely. pls pls pls be careful bestie, this is the serious part π¨
π is_ancestor_of(PARENTDIR, PATH)
Returns true if and only if PATH is PARENTDIR or a path stored somewhere within PARENTDIR (or its subdirs). π§¬
This function will resolve the paths; any failure to resolve the path will cause a trappable error. π
π· read_md5sums
signature only, no description, keeping it mysterious. π
π· unescape_md5sum_filename
also just the name. no notes. π
π· utf8_clean_log
name only again, we respect the mystery β¨
π· utf8_clean_bytes
and this one too β the original page lists it and says nothing else, so I'm not about to make stuff up. fact-checked. π«Ά
π SEE ALSO π
lintian(1)β go read the main character's page too, obviously π
and that's the whole page, no crumbs left π this was Lintian v2.139.0ubuntu2, dated 2026-10-08 β thanks for coming to my TED talk, mwah, stay normalized bestie πβ¨π
π¦ where this page comes from
- ubuntu stonking: lintian 2.139.0ubuntu2 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms