[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.14-26-g1662c3e



The following commit has been merged in the master branch:
commit f1e3a762d56ecd52b7699b78b2e7fdaff1c82b33
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Jun 30 21:16:35 2013 +0200

    c/systemd: Rename and do some "stylistic" changes
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/checks/systemd.desc b/checks/systemd.desc
index a59dc0f..b4f1024 100644
--- a/checks/systemd.desc
+++ b/checks/systemd.desc
@@ -2,7 +2,7 @@ Check-Script: systemd
 Author: Michael Stapelberg <stapelberg@debian.org>
 Type: binary
 Info: Checks various systemd policy things
-Needs-Info: scripts, index, unpacked, file-info
+Needs-Info: scripts, index, unpacked, file-info, bin-pkg-control
 
 Tag: systemd-service-file-outside-lib
 Severity: serious
diff --git a/checks/systemd b/checks/systemd.pm
similarity index 81%
rename from checks/systemd
rename to checks/systemd.pm
index deb8a09..6dd0d95 100644
--- a/checks/systemd
+++ b/checks/systemd.pm
@@ -25,20 +25,22 @@ package Lintian::systemd;
 
 use strict;
 use warnings;
+use autodie;
 
 use File::Basename;
+use List::MoreUtils qw(any);
 use Text::ParseWords qw(shellwords);
 
 use Lintian::Tags qw(tag);
-use Lintian::Util qw(fail is_ancestor_of);
+use Lintian::Util qw(fail is_ancestor_of lstrip rstrip);
 
 sub run {
-    my ($pkg, $type, $info) = @_;
+    my (undef, undef, $info) = @_;
 
     # Figure out whether the maintainer of this package did any effort to
     # make the package work with systemd. If not, we will not warn in case
     # of an init script that has no systemd equivalent, for example.
-    my $ships_systemd_file = (scalar ( grep { m,/systemd/, } $info->sorted_index ) > 0);
+    my $ships_systemd_file = any { m,/systemd/, } $info->sorted_index;
 
     # An array of names which are provided by the service files.
     # This includes Alias= directives, so after parsing
@@ -54,8 +56,8 @@ sub run {
             tag 'systemd-service-file-outside-lib', $file;
         }
         if ($file =~ m,/systemd/system/.*\.service$,) {
-            check_systemd_service_file ($pkg, $info, $file);
-            for my $name (extract_service_file_names ($pkg, $info, $file)) {
+            check_systemd_service_file($info, $file);
+            for my $name (extract_service_file_names($info, $file)) {
                 push @systemd_targets, $name;
             }
         }
@@ -66,7 +68,7 @@ sub run {
     # Verify that each init script includes /lib/lsb/init-functions,
     # because that is where the systemd diversion happens.
     for my $init_script (@init_scripts) {
-        check_init_script ($pkg, $info, $init_script);
+        check_init_script($info, $init_script);
     }
 
     @init_scripts = map { basename($_) } @init_scripts;
@@ -74,16 +76,17 @@ sub run {
     if ($ships_systemd_file) {
         for my $init_script (@init_scripts) {
             tag 'systemd-no-service-for-init-script', $init_script
-                unless grep /\Q$init_script\E\.service/, @systemd_targets;
+                unless any { m/\Q$init_script\E\.service/ } @systemd_targets;
         }
     }
 
     check_maintainer_scripts ($info);
+    return;
 }
 
 sub check_init_script {
-    my ($pkg, $info, $file) = @_;
-    
+    my ($info, $file) = @_;
+
     my $lsb_source_seen;
     my $unpacked_file = $info->unpacked ($file);
     unless (-f $unpacked_file &&
@@ -91,10 +94,9 @@ sub check_init_script {
         tag 'init-script-is-not-a-file', $file;
         return;
     }
-    open(my $fh, '<', $info->unpacked ($file))
-        or fail "cannot open $file: $!";
+    open(my $fh, '<', $unpacked_file);
     while (<$fh>) {
-        s/^\s+//;
+        lstrip;
         next if /^#/;
         if (m,^(?:\.|source)\s+/lib/lsb/init-functions,) {
             $lsb_source_seen = 1;
@@ -106,22 +108,23 @@ sub check_init_script {
     if (!$lsb_source_seen) {
         tag 'init.d-script-does-not-source-init-functions', $file;
     }
+    return;
 }
 
 sub check_systemd_service_file {
-    my ($pkg, $info, $file) = @_;
+    my ($info, $file) = @_;
 
-    my @values = extract_service_file_values ($pkg, $info, $file, 'Unit', 'After');
+    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;
 }
 
 sub service_file_lines {
-    my ($file, $path) = @_;
-    open(my $fh, '<', $path)
-        or fail "cannot open $file: $!";
+    my ($path) = @_;
     my @lines;
     my $continuation;
+    open(my $fh, '<', $path);
     while (<$fh>) {
         chomp;
 
@@ -136,8 +139,7 @@ sub service_file_lines {
             next;
         }
 
-        # equivalent of strstrip(l)
-        $_ =~ s,[ \t\n\r]+$,,g;
+        rstrip;
 
         next if $_ eq '';
 
@@ -152,7 +154,7 @@ sub service_file_lines {
 
 # Extracts the values of a specific Key from a .service file
 sub extract_service_file_values {
-    my ($pkg, $info, $file, $extract_section, $extract_key) = @_;
+    my ($info, $file, $extract_section, $extract_key) = @_;
 
     my @values;
     my $section;
@@ -164,7 +166,7 @@ sub extract_service_file_values {
         return;
     }
     my @lines = service_file_lines($file, $info->unpacked ($file));
-    while (grep { /^\.include / } @lines) {
+    if (any { /^\.include / } @lines) {
         @lines = map {
             if (/^\.include (.+)$/) {
 # XXX: edge case: what should we do when a service file .includes a file in another package? lintian will not have access and therefore cannot properly check the file.
@@ -194,9 +196,9 @@ sub extract_service_file_values {
             if ($value eq '') {
                 # Empty assignment resets the list
                 @values = ();
+            } else {
+                push(@values, shellwords($value));
             }
-
-            @values = (@values, shellwords ($value));
         }
     }
 
@@ -204,17 +206,16 @@ sub extract_service_file_values {
 }
 
 sub extract_service_file_names {
-    my ($pkg, $info, $file) = @_;
+    my ($info, $file) = @_;
 
-    my @aliases = extract_service_file_values ($pkg, $info, $file, 'Install', 'Alias');
+    my @aliases = extract_service_file_values($info, $file, 'Install', 'Alias');
     return (basename ($file), @aliases);
 }
 
 sub check_maintainer_scripts {
     my ($info) = @_;
 
-    open my $fd, '<', $info->lab_data_path('/control-scripts')
-        or fail "cannot open lintian control-scripts file: $!";
+    open(my $fd, '<', $info->lab_data_path('control-scripts'));
 
     while (<$fd>) {
         m/^(\S*) (.*)$/ or fail("bad line in control-scripts file: $_");
@@ -227,7 +228,7 @@ sub check_maintainer_scripts {
         # Don't try to parse the file if it does not appear to be a shell script
         next if $interpreter !~ m/sh\b/;
 
-        open my $sfd, '<', $filename or fail "cannot open maintainer script $filename: $!";
+        open(my $sfd, '<', $filename);
         while (<$sfd>) {
             # skip comments
             next if substr ($_, 0, $-[0]) =~ /#/;
@@ -237,10 +238,11 @@ sub check_maintainer_scripts {
                 tag 'maintainer-script-calls-systemctl', $file;
             }
         }
-        close $sfd;
+        close($sfd);
     }
 
-    close $fd;
+    close($fd);
+    return;
 }
 
 1;
diff --git a/profiles/debian/main.profile b/profiles/debian/main.profile
index c17f856..40c26aa 100644
--- a/profiles/debian/main.profile
+++ b/profiles/debian/main.profile
@@ -7,6 +7,6 @@ Enable-Tags-From-Check: apache2, binaries, changelog-file, changes-file, conffil
  fields, filename-length, files, group-checks, huge-usr-share, infofiles, init.d,
  java, lintian, manpages, md5sums, menu-format, menus, nmu, ocaml, patch-systems,
  po-debconf, rules, scripts, shared-libs, source-copyright, standards-version,
- symlinks, testsuite, version-substvars, watch-file
+ symlinks, systemd, testsuite, version-substvars, watch-file
 Disable-Tags: hardening-no-stackprotector
 
diff --git a/t/tests/systemd-general/tags b/t/tests/systemd-general/tags
index b24bc63..b5bbdee 100644
--- a/t/tests/systemd-general/tags
+++ b/t/tests/systemd-general/tags
@@ -1,6 +1,7 @@
 E: systemd-general: systemd-no-service-for-init-script systemd-general
 E: systemd-general: systemd-service-file-outside-lib etc/systemd/system/test.service
 E: systemd-general: systemd-tmpfiles.d-outside-usr-lib etc/tmpfiles.d/test.conf
+W: systemd-general: init.d-script-call-internal-API etc/init.d/systemd-general
 W: systemd-general: init.d-script-does-not-source-init-functions etc/init.d/systemd-general
 W: systemd-general: maintainer-script-calls-systemctl postrm
 W: systemd-general: systemd-service-file-refers-to-obsolete-target etc/systemd/system/test.service syslog.target

-- 
Debian package checker


Reply to: