From f1b7e4355c01521758cd1d9881c29d07134d1a84 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 19 Jun 2023 14:17:51 -0400 Subject: sbolint: doinst.sh content check. --- NEWS | 5 +++++ sbolint | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/NEWS b/NEWS index b34d598..9bd00f0 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,11 @@ New in 0.9.0: sbopkglint: - Spaces in filenames are now handled correctly. - Permissions and ownership of icons are now checked. +- Shared libraries are now checked for +x permission. + +sbolint: +- If doinst.sh exists, it's checked for correct usage of config(), + preserve_perms(), and gtk-update-icon-cache. New in 0.8.2: ============= diff --git a/sbolint b/sbolint index 6fc644d..1b9d61b 100755 --- a/sbolint +++ b/sbolint @@ -214,6 +214,17 @@ If there is a doinst.sh script, the SlackBuild must install it to I<$PKG/install =item - +If there is a doinst.sh script, and it uses the config() function, the function must +be defined before it's used. Also, config files passed to config() must end with +a B<.new> suffix. + +=item - + +If there is a doinst.sh script, and it calls B, the existence +of the cache must be checked before this command is run. + +=item - + Template boilerplate comments should be removed, e.g. I<"REMOVE THIS ENTIRE BLOCK OF TEXT"> or I<"Automatically determine the architecture we're building on">. @@ -657,6 +668,7 @@ sub run_checks { \&check_slackdesc, \&check_info, \&check_script, + \&check_doinst, \&check_images, \&check_empty_hidden, ); @@ -1464,6 +1476,60 @@ sub check_script { } } +sub check_doinst { + my $file = "doinst.sh"; + return unless -f $file; + my @lines = check_and_read($file); + return unless scalar @lines; + + my $lineno = 0; + my ($config_defined, $icon_theme_check, $pp_defined); + + for(@lines) { + $lineno++; + s,#.*,,; + s,^\s*,,; + s,\s*$,,; + next unless /./; + + if(/^config\(\)/) { + $config_defined = $lineno; + } elsif(/^config\s+/) { + # the [\@\$] is intended to skip stuff like $NEW, or a for loop variable, + # or something intended to be sedded like @PATH@. + if(/^config\s+\//) { + log_error("$file:$lineno: 'config' uses absolute path."); + } + if(!/[\@\$]/ && !/\.new["']?$/) { + log_error("$file:$lineno: 'config' filename missing .new suffix."); + } + if(!$config_defined) { + log_error("$file:$lineno: 'config' function used, but not defined."); + } + } elsif(/^preserve_perms\(\)/) { + $pp_defined = $lineno; + } elsif(/^preserve_perms\s+/) { + if(/^preserve_perms\s+\//) { + log_error("$file:$lineno: 'preserve_perms' uses absolute path."); + } + if(!/[\@\$]/ && !/\.new["']?$/) { + log_error("$file:$lineno: 'preserve_perms' filename missing .new suffix."); + } + if(!$pp_defined) { + log_error("$file:$lineno: 'preserve_perms' function used, but not defined."); + } + } elsif(m,-e\s+usr/share/icons/[^/]*/icon-theme\.cache,) { + $icon_theme_check = $lineno; + } elsif(m,usr/bin/gtk-update-icon-cache.*usr/share/icons,) { + if(!$icon_theme_check) { + log_error("$file:$lineno: icon cache created unconditionally!"); + } + undef $icon_theme_check; # in case there's multiple icon dirs + } + } + +} + sub findem { my ($findcmd, $errmsg) = @_; open my $fh, "-|", "$findcmd"; -- cgit v1.2.3