diff options
author | B. Watson <urchlay@slackware.uk> | 2023-02-03 17:22:18 -0500 |
---|---|---|
committer | B. Watson <urchlay@slackware.uk> | 2023-02-03 17:22:18 -0500 |
commit | 7dd4e0458809ed4d835d94aeaaf349d04a091abd (patch) | |
tree | 31ad4b52488e213221372c63887e178c9e760134 /sbopkglint | |
parent | 01f35ed9fffde74ce22e7fafb336f49fef4427b3 (diff) | |
download | sbo-maintainer-tools-7dd4e0458809ed4d835d94aeaaf349d04a091abd.tar.gz |
sbopkglint: add color, update docs
Diffstat (limited to 'sbopkglint')
-rwxr-xr-x | sbopkglint | 95 |
1 files changed, 71 insertions, 24 deletions
@@ -38,7 +38,7 @@ requirement that these have to be SBo packages, but a couple of the tests (e.g. the check for $PRGNAM.SlackBuild in the doc dir) might not apply to non-SBo builds. -Diagnostics will be logged to stdout and stderr. Exit status will +Diagnostics will be logged to B<stdout> and B<stderr>. Exit status will be 0 if all tests passed, non-zero otherwise. This script must run as root. If you run it as a normal user, it tries @@ -66,6 +66,15 @@ without this option, however. Disable the check for /usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild. For use with non-SBo packages (including core Slackware packages). +=item B<-c>, B<--color> + +Colorize the output (green I<OK>, red I<FAILED>, etc). Default is to use +color only when B<stdout> is a terminal. + +=item B<-m>, B<--mono> + +Do not colorize the output, even if B<stdout> is a terminal. + =item B<--help> Show the short built-in help. @@ -77,11 +86,11 @@ pager (e.g. less(1) or more(1)) to display it. =item B<--man> -Convert this documentation to a man page, on stdout. +Convert this documentation to a man page, on B<stdout>. =item B<--version> -Print the B<sbopkglint> version number on stdout and exit. +Print the B<sbopkglint> version number on B<stdout> and exit. =back @@ -105,6 +114,15 @@ useful comments that go into more detail than the documentation here. =head1 TESTS +=head2 pre-doinst + +This test is done before B<doinst.sh> is run, unlike the rest of +the tests. It checks for the existence of various files that should +not be in the package, but are OK if generated by B<doinst.sh>, +e.g. I</usr/info/dir>. It also checks for the existence of symlinks +in the package (these also must be created by B<doinst.sh>, not +included in the package archive). + =head2 basic-sanity =over 4 @@ -367,17 +385,19 @@ usage() { $SELF v$VER - check SBo binary packages for various problems Usage: - $0 [-k] [-i] [-s] [/path/to/package-file] [...] - $0 --doc | --man + $0 [-k] [-i] [-s] [-c | -m] [/path/to/package-file] [...] + $0 --doc | --man | --version Options: --k Keep (don't delete) the package install directory at exit. --i Do not check for INSTALL in the doc dir. --s Do not check for \$PRGNAM.SlackBuild in doc dir. ---help Show short help message (you're looking at it now). ---doc See the full documentation in your pager. ---man Convert the full documentation to a man page, on stdout. ---version Print the sbopkglint version number on stdout and exit. +-k Keep (don't delete) the package install directory at exit. +-i Do not check for INSTALL in the doc dir. +-s Do not check for \$PRGNAM.SlackBuild in doc dir. +-c, --color Use color, even if stdout is not a tty. +-m, --mono Do not use color, even if stdout is a tty. +--help Show short help message (you're looking at it now). +--doc See the full documentation in your pager. +--man Convert the full documentation to a man page, on stdout. +--version Print the sbopkglint version number on stdout and exit. With no package arguments, it looks for a SlackBuild in the current directory, extracts the PRINT_PACKAGE_NAME information, and tries to @@ -395,6 +415,8 @@ you dislike sudo, you can always run it as root. EOF } +COLOR=${COLOR:-auto} + while true; do case "$1" in --version) echo $VER ; exit 0 ;; @@ -404,6 +426,8 @@ while true; do -i) INSTALL_DOCS_OK=1 ; shift;; -s) SLACKBUILD_MISSING_OK=1 ; shift;; -h*|--h*) usage; exit 0 ;; + -c|--color) COLOR=yes ; shift ;; + -m|--mono*) COLOR=no ; shift ;; -*) echo "$SELF: invalid option '$1', try '$SELF --help'" ; exit 1 ;; *) break ;; esac @@ -432,9 +456,32 @@ if [ "$(id -u)" != "0" ]; then KEEP="$KEEP" \ SBOPKGLINT_PATH="$SBOPKGLINT_PATH" \ SLACKBUILD_MISSING_OK="$SLACKBUILD_MISSING_OK" \ + COLOR="$COLOR" \ "$0" "$@" fi +if [ "$COLOR" = "auto" ]; then + if [ -t 1 ]; then + COLOR=yes + else + COLOR=no + fi +fi + +if [ "$COLOR" = "yes" ]; then + RED="\033[1;31m" + GREEN="\033[1;32m" + COLOR_OFF="\033[0m" +fi + +echo_OK() { + echo -e "${GREEN}OK${COLOR_OFF}" +} + +echo_FAILED() { + echo -e "${RED}FAILED${COLOR_OFF}" +} + warn() { [ "$warncount" = "0" ] && echo : $(( warncount ++ )) @@ -515,21 +562,21 @@ for package in $packages; do explodepkg "$PKG" &> $PKG/.tmp.$$ S="$?" if [ "$S" != "0" ]; then - echo "FAILED" + echo_FAILED echo "explodepkg exited with status $S" rm -rf $PKG exit_status=1 continue fi - echo "OK" + echo_OK echo -n "Running pre-doinst test..." warncount=0 source $testdir/pre-doinst.sh if [ "$warncount" = "0" ]; then - echo "OK" + echo_OK else - echo "FAILED" + echo_FAILED : $(( totalwarns += warncount )) fi cd "$olddir" @@ -542,7 +589,7 @@ for package in $packages; do S="$?" if [ "$S" != "0" ]; then - echo "FAILED" + echo_FAILED cat $PKG/.tmp.$$ echo "installpkg exited with status $S" [ "$KEEP" = "" ] && rm -rf $PKG @@ -550,7 +597,7 @@ for package in $packages; do continue fi - echo "OK" + echo_OK rm -f $PKG/.tmp.$$ olddir="$( pwd )" @@ -563,9 +610,9 @@ for package in $packages; do echo -n "Running test: $( basename $testscript .t.sh )..." source "$testscript" if [ "$warncount" = "0" ]; then - echo "OK" + echo_OK else - echo "FAILED" + echo_FAILED echo "$warncount" > .tmp.warncount fi ) @@ -585,11 +632,11 @@ for package in $packages; do fi if [ "$totalwarns" = "0" ]; then - echo "=== $filename: All tests passed" + echo -e "=== $filename: ${GREEN}All tests passed${COLOR_OFF}" : $(( passcount ++ )) else exit_status=1 - echo "!!! $filename: $totalwarns failures" + echo -e "!!! $filename: ${RED}$totalwarns failures${COLOR_OFF}" : $(( failcount ++ )) faillist+="$filename " fi @@ -600,9 +647,9 @@ if [ "$want_summary" = "1" ]; then count=$(( failcount + passcount )) echo "=== $count packages linted, $passcount passed, $failcount failed" if [ "$failcount" = "0" ]; then - echo "=== All packages check out OK" + echo -e "=== ${GREEN}All packages check out OK${COLOR_OFF}" else - echo "!!! Failed packages:" + echo -e "!!! ${RED}Failed packages:${COLOR_OFF}" for i in $faillist; do echo $i done |