.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "dpt-lib.sh 5" .TH dpt-lib.sh 5 2024-03-04 "pkg-perl-tools 0.78" "Debian Perl packaging Tools" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME dpt\-lib.sh \- dpt shell library .SH DESCRIPTION .IX Header "DESCRIPTION" \&\fBdpt\-lib.sh\fR is sourced by \fBdpt\fR\|(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 \fI.git/\fR sub directory. .SH USAGE .IX Header "USAGE" Source the file at the beginning of the shell script as .PP .Vb 1 \& . "${DPT_\|_SCRIPTS:\-/usr/share/pkg\-perl\-tools}/lib/dpt\-lib.sh" .Ve .SH "AVAILABLE FUNCTIONS" .IX Header "AVAILABLE FUNCTIONS" .ie n .IP """die""" 4 .el .IP \f(CWdie\fR 4 .IX Item "die" Parameters: \f(CW$message\fR .Sp Echos "E: \f(CW$message\fR" to STDERR and exits 1. .ie n .IP """warn""" 4 .el .IP \f(CWwarn\fR 4 .IX Item "warn" Parameters: \f(CW$message\fR .Sp Echos "W: \f(CW$message\fR" to STDERR. .ie n .IP """info""" 4 .el .IP \f(CWinfo\fR 4 .IX Item "info" Parameters: \f(CW$message\fR .Sp Echos "I: \f(CW$message\fR" to STDERR. .ie n .IP """header""" 4 .el .IP \f(CWheader\fR 4 .IX Item "header" Parameters: \f(CW$title\fR .Sp Outputs \f(CW$title\fR with an empty line before and underlined, kind of like a header. .ie n .IP """anykey""" 4 .el .IP \f(CWanykey\fR 4 .IX Item "anykey" Tells the user to press any key and waits for a keypress. .ie n .IP """promptyesno""" 4 .el .IP \f(CWpromptyesno\fR 4 .IX Item "promptyesno" Parameters: \f(CW$prompt\fR .Sp Issues a \fBread()\fR request with y/N options, printing \f(CW$prompt\fR. Returns true, if 'y' or 'Y' is pressed, false otherwise. .ie n .IP """is_command""" 4 .el .IP \f(CWis_command\fR 4 .IX Item "is_command" Parameters: \f(CW$command\fR, \f(CW$package\fR (optional) .Sp Checks if \f(CW$command\fR can be executed (running "command \-v"); returns false, outputs a warning (and optionally a hint to install \f(CW$package\fR). .ie n .IP """is_installed""" 4 .el .IP \f(CWis_installed\fR 4 .IX Item "is_installed" Parameters: \f(CW$package_name\fR, \f(CW$minimum_package_version\fR (optional) .Sp Checks if \f(CW$package_name\fR is installed, optionally at \&\f(CW$minimum_package_version\fR, and returns false with a warning otherwise. .ie n .IP """is_pkg_perl""" 4 .el .IP \f(CWis_pkg_perl\fR 4 .IX Item "is_pkg_perl" Checks if debian/control contains the Debian Perl Group email address. .ie n .IP """gitddiff""" 4 .el .IP \f(CWgitddiff\fR 4 .IX Item "gitddiff" Offers to show the diff against the last debian/ tag, if there is any. .ie n .IP """colored""" 4 .el .IP \f(CWcolored\fR 4 .IX Item "colored" Parameters: \f(CW$color\fR, \f(CW$text\fR .Sp Outputs \f(CW$text\fR in \f(CW$color\fR, unless the NO_COLOR environment variable is set. .Sp Available colors are (in capital letters): \&\f(CW\*(C`BLACK\*(C'\fR, \f(CW\*(C`RED\*(C'\fR, \f(CW\*(C`GREEN\*(C'\fR, \f(CW\*(C`YELLOW\*(C'\fR, \f(CW\*(C`BLUE\*(C'\fR, \f(CW\*(C`MAGENTA\*(C'\fR, \f(CW\*(C`CYAN\*(C'\fR, \f(CW\*(C`WHITE\*(C'\fR. .ie n .IP """extra_colored""" 4 .el .IP \f(CWextra_colored\fR 4 .IX Item "extra_colored" Parameters: \f(CW$color\fR, \f(CW$bgcolor\fR, \f(CW$text\fR .Sp Outputs \f(CW$text\fR in foreground \f(CW$color\fR on \f(CW$bgcolor\fR, unless the NO_COLOR environment variable is set. .Sp Available colors for both foreground and background are (in capital letters): \&\f(CW\*(C`BLACK\*(C'\fR, \f(CW\*(C`RED\*(C'\fR, \f(CW\*(C`GREEN\*(C'\fR, \f(CW\*(C`YELLOW\*(C'\fR, \f(CW\*(C`BLUE\*(C'\fR, \f(CW\*(C`MAGENTA\*(C'\fR, \f(CW\*(C`CYAN\*(C'\fR, \f(CW\*(C`WHITE\*(C'\fR. .SH "AVAILABLE VARIABLES" .IX Header "AVAILABLE VARIABLES" .ie n .IP """PKG""" 4 .el .IP \f(CWPKG\fR 4 .IX Item "PKG" Source package name, from \fIdebian/changelog\fR. .ie n .IP """VER""" 4 .el .IP \f(CWVER\fR 4 .IX Item "VER" Source package version, from \fIdebian/changelog\fR. .ie n .IP """UVER""" 4 .el .IP \f(CWUVER\fR 4 .IX Item "UVER" Upstream version, i.e. source package version (from \fIdebian/changelog\fR) without epoch and Debian revision. .ie n .IP """DIST""" 4 .el .IP \f(CWDIST\fR 4 .IX Item "DIST" Source package distribution, from \fIdebian/changelog\fR. .IP Colors 4 .IX Item "Colors" Cf. the \f(CWcolored()\fR function above. .Sp For using colors directly, the following variables exist; .Sp \&\f(CW\*(C`C_BLACK\*(C'\fR, \f(CW\*(C`C_RED\*(C'\fR, \f(CW\*(C`C_GREEN\*(C'\fR, \f(CW\*(C`C_YELLOW\*(C'\fR, \f(CW\*(C`C_BLUE\*(C'\fR, \f(CW\*(C`C_MAGENTA\*(C'\fR, \f(CW\*(C`C_CYAN\*(C'\fR, \f(CW\*(C`C_WHITE\*(C'\fR, plus \f(CW\*(C`C_RESET\*(C'\fR to go back from coloring. .Sp For background colors, the same colors exist as \f(CW\*(C`BG_C_foo\*(C'\fR. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" .ie n .IP """OOT""" 4 .el .IP \f(CWOOT\fR 4 .IX Item "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. .Sp Can be used as .Sp .Vb 1 \& OOT=1 . "${DPT_\|_SCRIPTS:\-/usr/share/pkg\-perl\-tools}/lib/dpt\-lib.sh" .Ve .Sp and is useful for scripts which are run on build results etc. .Sp This also means that the variables derived from \&\fIdebian/changelog\fR are not available. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\fBdpt\-config\fR\|(5) for discussion of \f(CW\*(C`$DPT_\|_SCRIPTS\*(C'\fR. .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2022\-2023 gregor herrmann gregoa@debian.org .PP Copyright 2022 Damyan Ivanov dmn@debian.org .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.