Scroll to navigation Debian Perl packaging Tools

NAME -- dpt shell library

DESCRIPTION is sourced by dpt(1) and contains a collection of shell functions and variables which can be used by dpt subcommands written in shell. As a side effect, it also sanity checks if the script is run from a source package directory with a .git/ sub directory.


Source the file at the beginning of the shell script as

    . "$DPT__SCRIPTS/lib/"


Parameters: $message

Echos "E: $message" to STDERR and exits.

Parameters: $message

Echos "W: $message" to STDERR.

Parameters: $message

Echos "I: $message" to STDERR.

Parameters: $title

Outputs %title with an empty line before and underlined, kind of like a header.

Tells the user to press any key and waits for a keypress.
Parameters: $command, $package (optional)

Checks if $command can be executed (running "command -v"); returns false, outputs a warning (and optionally a hint to install $package).

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.

Checks if debian/control contains the Debian Perl Group email address.
Offers to show the diff against the last debian/ tag, if there is any.
Parameters: $color, $text

Outputs $text in $color, unless the NO_COLOR environment variable is set.

Available colors are (in capital letters): "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE".

Parameters: $color, $bgcolor, $text

Outputs $text in foreground $color on $bgcolor, unless the NO_COLOR environment variable is set.

Available colors for both foreground and background are (in capital letters): "BLACK", "RED", "GREEN", "YELLOW", "BLUE", "MAGENTA", "CYAN", "WHITE".


Source package name, from debian/changelog.
Source package version, from debian/changelog.
Upstream version, i.e. source package version (from debian/changelog) without epoch and Debian revision.
Source package distribution, from debian/changelog.
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".


dpt-config(5) for discussion of "$DPT__SCRIPTS".


Copyright 2022 gregor herrmann

Copyright 2022 Damyan Ivanov

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

2022-07-20 pkg-perl-tools 0.71