From b76a6efb4668d3fa60905a575d75ade4dcfabb85 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Tue, 30 May 2023 12:26:09 -0400 Subject: sbolint: add douninst.sh checks; sbopkglint: add hardcoded $TMP check. --- TODO | 8 +++----- sbolint | 19 +++++++++++++++++-- sbopkglint | 5 +++-- sbopkglint.d/70-tmp_path.t.sh | 16 ++++++++++++++++ 4 files changed, 39 insertions(+), 9 deletions(-) create mode 100644 sbopkglint.d/70-tmp_path.t.sh diff --git a/TODO b/TODO index 9d1787f..70ad4ed 100644 --- a/TODO +++ b/TODO @@ -1,9 +1,7 @@ -TODO: sbopkglint should disallow new dirs in /usr (other than the - standard ones). -TODO: sbopklint: check libtins and anything-sync-daemon... -TODO: sbolint: same checks for douninst.sh as we have for doinst.sh. +TODO: check for "if [ -x /usr/bin/whatever ]" in doinst.sh, warn + if missing. this could be an ill-defined mess. TODO: sbolint should warn if LIBDIRSUFFIX and/or SLKCFLAGS are - set but never used. And/or, sbopklint could complain if + set but never used. And/or, sbopkglint could complain if the SlackBuild sets SLKCFLAGS but there's no native code. TODO: check for non-executable shared libs. diff --git a/sbolint b/sbolint index 675685f..5dbeb6d 100755 --- a/sbolint +++ b/sbolint @@ -1171,7 +1171,7 @@ sub check_script { } my $lineno = 0; - my ($prgnam, $version, $build, $tag, $need_doinst, $slackdesc, $makepkg, $install); + my ($prgnam, $version, $build, $tag, $need_doinst, $need_douninst, $slackdesc, $makepkg, $install); my ($cdpkg, $codestart, $lint_enabled, $print_pkg_name, $pkg_type, $arch_lineno); my ($old_arch, $old_flags, $have_py2, $have_py3); $lint_enabled = 1; @@ -1254,6 +1254,8 @@ sub check_script { # script dir, but they create one with >> (the jack rt audio stuff # does this). $need_doinst = $lineno; + } elsif(/^[^#]*\$\{?CWD\}?\/douninst\.sh(?:"|'|\s|>)/) { + $need_douninst = $lineno; } elsif(/^[^#]*slack-desc/) { $slackdesc = $lineno; $install = $lineno if m,install/,; # assume OK @@ -1382,16 +1384,29 @@ sub check_script { log_error("$file: nothing gets installed in \$PKG/install"); } - my $have_doinst = (-f "doinst.sh"); + my $have_doinst = (-f "doinst.sh"); + my $have_douninst = (-f "douninst.sh"); + if($have_doinst) { check_and_read("doinst.sh", 0644); } + + if($have_douninst) { + check_and_read("douninst.sh", 0644); + } + if($need_doinst && !$have_doinst) { log_error("$file:$need_doinst: script installs doinst.sh, but it doesn't exist"); } elsif($have_doinst && !$need_doinst) { log_error("$file: doinst.sh exists, but the script doesn't install it"); } + if($need_douninst && !$have_douninst) { + log_error("$file:$need_douninst: script installs douninst.sh, but it doesn't exist"); + } elsif($have_douninst && !$need_douninst) { + log_error("$file: douninst.sh exists, but the script doesn't install it"); + } + if($old_arch) { # checking for the flags is supposed to let us tell the difference between # source builds and binary repacks. since we have 30 or so old binary repack diff --git a/sbopkglint b/sbopkglint index b7648a5..917af58 100755 --- a/sbopkglint +++ b/sbopkglint @@ -469,8 +469,9 @@ die() { exit 1 } -TMP=${TMP:-/tmp} -OUTPUT=${OUTPUT:-$TMP} +# N.B. these need to match the template (and they do) +TMP=${TMP:-/tmp/SBo} +OUTPUT=${OUTPUT:-/tmp} exit_status=0 diff --git a/sbopkglint.d/70-tmp_path.t.sh b/sbopkglint.d/70-tmp_path.t.sh new file mode 100644 index 0000000..9d1f090 --- /dev/null +++ b/sbopkglint.d/70-tmp_path.t.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +# sbopkglint test, must be sourced by sbopkglint (not run standalone). + +# PKG, PRGNAM, VERSION, ARCH are set by sbopkglint. also the current +# directory is the root of the installed package tree. + +####################################################################### +# checks for /tmp/SBo (or the environment TMP) hardcoded in files. +# don't check the SlackBuild in the doc dir, since it's guaranteed to match. + +found="$(find . -type f | grep -v '^\./usr/doc/.*\.SlackBuild$' | xargs fgrep -l "$TMP")" +if [ -n "$found" ]; then + warn "found files with TMP ($TMP) baked in:" + echo "$found" 1>&2 +fi -- cgit v1.2.3