aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2023-06-19 14:17:51 -0400
committerB. Watson <urchlay@slackware.uk>2023-06-19 14:17:51 -0400
commitf1b7e4355c01521758cd1d9881c29d07134d1a84 (patch)
tree8b1021133aae0b6e273a4cd0e30f204c2507530d
parent13e6b643cbb46d1f9a8156e401ff33c78509eb64 (diff)
downloadsbo-maintainer-tools-f1b7e4355c01521758cd1d9881c29d07134d1a84.tar.gz
sbolint: doinst.sh content check.
-rw-r--r--NEWS5
-rwxr-xr-xsbolint66
2 files changed, 71 insertions, 0 deletions
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<gtk-update-icon-cache>, 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";