From ea2b57870b3f95d738fb5a5792dc117233bfe3d9 Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Mon, 16 Jan 2023 07:55:27 +0100 Subject: [PATCH] warn if a hook is named like one but not executable and if a hook is executable but not named like one --- mmdebstrap | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/mmdebstrap b/mmdebstrap index 0890302..068c85a 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -4526,13 +4526,27 @@ sub main() { opendir(my $dh, $opt_value) or error "Can't opendir($opt_value): $!"; while (my $entry = readdir $dh) { + # skip the "." and ".." entries + next if $entry eq "."; + next if $entry eq ".."; + my $found = 0; foreach my $hook ('setup', 'extract', 'essential', 'customize') { - if ($entry =~ m/^\Q$hook\E/ and -x "$opt_value/$entry") { - push @{ $scripts{$hook} }, "$opt_value/$entry"; - $count += 1; + if ($entry =~ m/^\Q$hook\E/) { + if (-x "$opt_value/$entry") { + push @{ $scripts{$hook} }, "$opt_value/$entry"; + $count += 1; + $found = 1; + } else { + warning("$opt_value/$entry is named like a " + . "hook but not executable"); + } } } + if (!$found && -x "$opt_value/$entry") { + warning("$opt_value/$entry: is executable " + . "but not prefixed with a hook name"); + } } closedir($dh); if ($count == 0) {