This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=80f820a8c3c0208a90064a237df608011fbc0e01 commit 80f820a8c3c0208a90064a237df608011fbc0e01 (HEAD -> main) Author: Guillem Jover <[email protected]> AuthorDate: Wed Jun 11 02:19:53 2025 +0200 Test::Dpkg: Extend all_shell_files() to return all shell scripts This function looks now for files based on a set of static filenames, based on filename patterns and file contents. --- scripts/Test/Dpkg.pm | 44 ++++++++++++++++++++++++++++++++++++++++---- t/shellcheck.t | 2 +- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm index a15b37642..5dfaedac8 100644 --- a/scripts/Test/Dpkg.pm +++ b/scripts/Test/Dpkg.pm @@ -161,8 +161,9 @@ sub all_po_files return _test_get_files($keep_po_files, [ _test_get_po_dirs() ]); } -sub all_shell_files +sub all_shell_files(@files_todo) { + my %files_todo = map { $_ => 1 } @files_todo; my @files = qw( autogen build-aux/gen-release @@ -173,9 +174,44 @@ sub all_shell_files debian/dpkg.postinst debian/dpkg.postrm debian/dselect.postrm - src/dpkg-db-backup.sh - src/dpkg-db-keeper.sh - src/dpkg-maintscript-helper.sh + ); + + my $keep_shell_file = sub ($file) { + return 0 if exists $files_todo{$file}; + return $file =~ qr{\.sh$}; + }; + my $keep_shebang_file = sub ($file) { + return 0 if exists $files_todo{$file}; + + return 0 if -z $file; + return 0 unless -f $file; + + open my $fh, '<', $file + or die "error: cannot read file $file: $!\n"; + my $shebang = readline $fh; + close $fh; + + chomp $shebang; + + return $shebang =~ m{^#!/bin/sh}; + }; + + + push @files, _test_get_files( + $keep_shell_file, + [ qw( + dselect/methods + src + ) ], + ); + push @files, _test_get_files( + $keep_shebang_file, + [ qw( + debian/tests + lib/dpkg/t/data + scripts/t + tests + ) ], ); return @files; diff --git a/t/shellcheck.t b/t/shellcheck.t index acbc09858..c7329895a 100644 --- a/t/shellcheck.t +++ b/t/shellcheck.t @@ -30,7 +30,7 @@ my @files_todo = qw( dselect/methods/media/setup.sh dselect/methods/media/update.sh ); -my @files = all_shell_files(); +my @files = all_shell_files(@files_todo); my @shellcheck_opts = ( '--external-sources', # Allow checking external source files. -- Dpkg.Org's dpkg

