This is an automated email from the git hooks/post-receive script. nthykier pushed a commit to branch master in repository lintian.
commit e10c185c11f2d4c2840b239d3584ca6c01241770 Author: Felipe Sateler <[email protected]> Date: Sat Jun 27 21:56:11 2015 -0300 Check files as we detect them, and discard invalid files prevents duplicate service-file-is-not-a-file Signed-off-by: Niels Thykier <[email protected]> --- checks/systemd.pm | 30 ++++++++++++++++-------------- t/tests/systemd-general/tags | 1 - 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/checks/systemd.pm b/checks/systemd.pm index 1411322..79b413e 100644 --- a/checks/systemd.pm +++ b/checks/systemd.pm @@ -51,16 +51,12 @@ sub run { # This includes Alias= directives, so after parsing # NetworkManager.service, it will contain NetworkManager and # network-manager. - my $services = get_systemd_service_names($info); + my $services = get_systemd_service_names($info, \@service_files); for my $script (@init_scripts) { check_init_script($info, $script, $services); } - for my $service (@service_files) { - check_systemd_service_file($info, $service); - } - check_maintainer_scripts($info); return; } @@ -121,12 +117,18 @@ sub check_init_script { sub get_systemd_service_files { my ($info) = @_; + my @res; + my @potential + = grep { m,/systemd/system/.*\.service$, } $info->sorted_index; - return grep { m,/systemd/system/.*\.service$, } $info->sorted_index; + for my $file (@potential) { + push(@res, $file) if check_systemd_service_file($info, $file); + } + return @res; } sub get_systemd_service_names { - my ($info) = @_; + my ($info,$files_ref) = @_; my %services; my $safe_add_service = sub { @@ -138,7 +140,7 @@ sub get_systemd_service_names { $services{$name} = 1; }; - for my $file (get_systemd_service_files($info)) { + for my $file (@{$files_ref}) { my $name = $file->basename; $name =~ s/\.service$//; $safe_add_service->($name, $file); @@ -161,11 +163,16 @@ sub check_systemd_service_file { tag 'systemd-service-file-outside-lib', $file if ($file =~ m,^usr/lib/systemd/system/,); + unless ($file->is_open_ok + || ($file->is_symlink && $file->link eq '/dev/null')) { + tag 'service-file-is-not-a-file', $file; + return 0; + } my @values = extract_service_file_values($info, $file, 'Unit', 'After'); my @obsolete = grep { /^(?:syslog|dbus)\.target$/ } @values; tag 'systemd-service-file-refers-to-obsolete-target', $file, $_ for @obsolete; - return; + return 1; } sub service_file_lines { @@ -207,11 +214,6 @@ sub extract_service_file_values { my (@values, $section); - unless ($file->is_open_ok - || ($file->is_symlink && $file->link eq '/dev/null')) { - tag 'service-file-is-not-a-file', $file; - return; - } my @lines = service_file_lines($file); my $key_ws = first_index { /^[[:alnum:]]+(\s*=\s|\s+=)/ } @lines; if ($key_ws > -1) { diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags index 47fe757..3223f6a 100644 --- a/t/tests/systemd-general/tags +++ b/t/tests/systemd-general/tags @@ -1,6 +1,5 @@ E: systemd-general: init-script-is-not-a-file etc/init.d/fifo-pipe-as-init E: systemd-general: service-file-is-not-a-file etc/systemd/system/fifo-pipe-as-init.service -E: systemd-general: service-file-is-not-a-file etc/systemd/system/fifo-pipe-as-init.service E: systemd-general: service-key-has-whitespace etc/systemd/system/test.service at line 3 E: systemd-general: service-key-has-whitespace etc/systemd/system/test.service at line 3 E: systemd-general: service-key-has-whitespace usr/lib/systemd/system/test.service at line 3 -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected] Archive: https://lists.debian.org/[email protected]

