dpt-lib.sh(5)
π dpt-lib.sh β the dpt shell library, bestie edition π
okay so welcome to dpt-lib.sh(5), the manual page for the lil shell library that makes dpt subcommands go brrr. section 5, shell library, we're in the file formats zone and honestly? iconic. πΈ
β¨ NAME β¨
dpt-lib.sh β the dpt shell library, no cap π«Ά
π¦ DESCRIPTION π¦
dpt-lib.sh gets sourced by dpt(1) and it's basically a whole collection of shell functions and variables that any dpt subcommand written in shell can just... use. free real estate. π
and as a lil side effect (not me doing extra credit π), it also sanity-checks that the script is being run from a source package directory that has a .git/ sub directory. vibe check: passed or not.
π USAGE π
you source this file at the very beginning of your shell script, like:
. "${DPT__SCRIPTS:-/usr/share/pkg-perl-tools}/lib/dpt-lib.sh"
that's it. that's the whole ritual. β¨
π AVAILABLE FUNCTIONS π
die
Parameters: $message
Echos "E: $message" to STDERR and then exits 1. it said what it said and it left. π
warn
Parameters: $message
Echos "W: $message" to STDERR. gentle lil heads up, no exit. π«Ά
info
Parameters: $message
Echos "I: $message" to STDERR. just passing along the tea. β
header
Parameters: $title
Outputs $title with an empty line before it and underlined, kind of like a header. it's giving title card, it's giving main character energy. π
anykey
Tells the user to press any key and then waits for a keypress. dramatic pause, bestie. βΈοΈ
promptyesno
Parameters: $prompt
Issues a read() request with y/N options, printing $prompt. Returns true if 'y' or 'Y' is pressed, false otherwise. y = slay, N = not today. π
is_command
Parameters: $command, $package (optional)
Checks if $command can be executed (it's running command -v under the hood); returns false and outputs a warning otherwise β and if you gave it $package, it'll optionally drop a hint to install that package too. so thoughtful. π
is_installed
Parameters: $package_name, $minimum_package_version (optional)
Checks if $package_name is installed, optionally at $minimum_package_version, and returns false with a warning otherwise. no package, no peace. π€
is_pkg_perl
Checks if debian/control contains the Debian Perl Group email address. are you one of us? π§
gitddiff
Offers to show the diff against the last debian/ tag, if there is any. if there's no tag, there's no diff, that's the rules. π₯
colored
Parameters: $color, $text
Outputs $text in $color β unless the NO_COLOR environment variable is set, in which case we behave. π
The available colors are (in capital letters): "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE". π
extra_colored
Parameters: $color, $bgcolor, $text
Outputs $text in foreground $color on $bgcolor β again, unless the NO_COLOR environment variable is set. double the color, double the slay. β¨
The available colors for both foreground and background are (in capital letters): "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE".
π AVAILABLE VARIABLES π
PKG
Source package name, from debian/changelog. π¦
VER
Source package version, from debian/changelog. π’
UVER
Upstream version, i.e. source package version (from debian/changelog) without epoch and Debian revision. stripped down and thriving. π¦
DIST
Source package distribution, from debian/changelog. πΊοΈ
Colors
Cf. the colored() function above.
For using colors directly, the following variables exist;
"C_BLACK", "C_RED", "C_GREEN", "C_YELLOW", "C_BLUE", "C_MAGENTA", "C_CYAN", "C_WHITE", plus "C_RESET" to go back from coloring. π¨
For background colors, the same colors exist as "BG_C_foo". π
π§ ENVIRONMENT VARIABLES π§
OOT
OOT (as in "out-of-tree"), if set, disables the check if a script is run in a source package directory and a Git repository. yes bestie, the vibe check gets skipped. π
Can be used as
OOT=1 . "${DPT__SCRIPTS:-/usr/share/pkg-perl-tools}/lib/dpt-lib.sh"
and is useful for scripts which are run on build results etc. π οΈ
β οΈ important tea: this also means that the variables derived fromdebian/changelogare not available. so like, don't go looking forPKGand friends whenOOTis on, they ghosted you. π
π SEE ALSO π
dpt-config(5) for discussion of "$DPT__SCRIPTS". go read it, it's the lore. π
π COPYRIGHT & LICENSE π
Copyright 2022-2024 gregor herrmann gregoa@debian.org
Copyright 2022 Damyan Ivanov dmn@debian.org
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, bestie!! this is pkg-perl-tools 0.88, dated 2026-04-01, and you read every single word of dpt-lib.sh(5). not me being so proud of you rn ππ«Ά go source that library and be the main character of your own shell script. periodt. π
β¨π
π¦ where this page comes from
- ubuntu stonking: pkg-perl-tools 0.88 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms