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

[SCM] Debian package checker branch, infra-513663, updated. 2.5.0-rc1-129-g6c9fa88



The following commit has been merged in the infra-513663 branch:
commit 6c9fa88d5318b379110469f9f850d608bc98f3bf
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Apr 3 10:04:33 2011 +0200

    Added cross-pkg broken symlink check (for absolute symlinks only)

diff --git a/checks/symlinks b/checks/symlinks
new file mode 100644
index 0000000..946f8b8
--- /dev/null
+++ b/checks/symlinks
@@ -0,0 +1,99 @@
+# symlinks -- lintian check script -*- perl -*-
+#
+# Copyright (C) 2011 Niels Thykier
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::symlinks;
+use strict;
+use warnings;
+
+use Lintian::Relation ();
+use Lintian::Tags qw(tag);
+use Util;
+
+sub run {
+
+my $pkg = shift;
+my $type = shift;
+my $info = shift;
+my $proc = shift;
+my $group = shift;
+
+my $index = $info->index;
+my @brokenlinks;
+my @dindexes;
+my $relation;
+
+foreach my $file (@{$info->sorted_index}) {
+    my $index_info = $index->{$file};
+    my $perm = $index_info->{type};
+    if ($perm =~ m/^l/o){
+        my $target = $index_info->{link}//'';
+        my $mylink = $target;
+        # Should not happen (too often) - but just in case
+        next unless $target or $target =~ m@^/++$@;
+	$mylink =~ s,//+,/,g;
+        $mylink =~ s@/$@@o;
+
+
+        if ($target =~ m@^/@o){
+            # absolute link - remove the initial slash
+            $mylink = substr $mylink, 1;
+        } else {
+            # relative - break down the link
+            # FIXME
+            next;
+        }
+
+        # Ignore links pointing to common things that may exist
+        # even if they are not shipped by any binary from this
+        # source package.
+        next if $mylink =~ m@man/man\d/undocumented@o or
+            $mylink =~ m@^etc/alternatives/@o;
+        
+        # Possibly broken symlink
+        push @brokenlinks, [$file, $mylink, $target] unless $index->{$mylink};
+    }
+
+}
+
+return unless @brokenlinks;
+
+# Check our dependencies:
+$relation = $info->relation('strong');
+foreach my $depproc ($group->get_processables($type)){
+    if ($relation->implies($depproc->pkg_name())){
+	push @dindexes, $depproc->info->index;        
+    }
+}
+
+BLINK:
+foreach my $blink (@brokenlinks){
+    my ($file, $mylink, $target) = @$blink;
+    foreach my $dindex (@dindexes){
+        # Is it in our dependency?
+        next BLINK if $dindex->{$mylink};
+    }
+    # nope - not found in any of our direct dependencies.
+    tag 'package-contains-broken-symlink', $file, $target
+}
+
+}
+
+1;
+__END__
diff --git a/checks/symlinks.desc b/checks/symlinks.desc
new file mode 100644
index 0000000..4df52c7
--- /dev/null
+++ b/checks/symlinks.desc
@@ -0,0 +1,13 @@
+Check-Script: symlinks
+Author: Christian Schwarz <schwarz@debian.org>
+Abbrev: sym
+Type: binary, udeb
+Needs-Info: fields, index
+Info: This script checks for broken symlinks.
+
+Tag: package-contains-broken-symlink
+Severity: normal
+Certainty: possible
+Info: The package contains a symlink but the destination
+ for the link does not exist in the package nor in its
+ direct dependencies.
diff --git a/t/tests/symlinks-broken/debian/debian/broken-links.links b/t/tests/symlinks-broken/debian/debian/broken-links.links
new file mode 100644
index 0000000..e4935e9
--- /dev/null
+++ b/t/tests/symlinks-broken/debian/debian/broken-links.links
@@ -0,0 +1,5 @@
+# broken links
+etc/some.conf usr/lib/broken-links/some.conf
+
+# valid links
+etc/valid.conf usr/lib/data-pkg/valid.conf
diff --git a/t/tests/manpages-dependencies/debian/debian/control.in b/t/tests/symlinks-broken/debian/debian/control.in
similarity index 80%
copy from t/tests/manpages-dependencies/debian/debian/control.in
copy to t/tests/symlinks-broken/debian/debian/control.in
index 9f3301d..230faf0 100644
--- a/t/tests/manpages-dependencies/debian/debian/control.in
+++ b/t/tests/symlinks-broken/debian/debian/control.in
@@ -5,16 +5,18 @@ Maintainer: {$author}
 Standards-Version: {$standards_version}
 Build-Depends: debhelper (>= 7.0.50~)
 
-Package: pecho
+Package: broken-links
 Architecture: all
-Depends: $\{misc:Depends\}, {$srcpkg}-data
-Description: {$description}
+Depends: $\{misc:Depends\}, data-pkg
+Description: {$description} - symlinks
  This is a test package designed to exercise some feature or tag of
  Lintian.  It is part of the Lintian test suite and may do very odd
  things.  It should not be installed like a regular package.  It may
  be an empty package.
+ .
+ Contains only symlinks.
 
-Package: pecho-data
+Package: data-pkg
 Architecture: all
 Depends: $\{misc:Depends\}
 Description: {$description} - data
@@ -23,4 +25,5 @@ Description: {$description} - data
  things.  It should not be installed like a regular package.  It may
  be an empty package.
  .
- Data package.
+ Contains actual files.
+
diff --git a/t/tests/symlinks-broken/debian/debian/data-pkg.install b/t/tests/symlinks-broken/debian/debian/data-pkg.install
new file mode 100644
index 0000000..0268d93
--- /dev/null
+++ b/t/tests/symlinks-broken/debian/debian/data-pkg.install
@@ -0,0 +1 @@
+valid.conf etc/
diff --git a/t/tests/symlinks-broken/debian/valid.conf b/t/tests/symlinks-broken/debian/valid.conf
new file mode 100644
index 0000000..9f51dd6
--- /dev/null
+++ b/t/tests/symlinks-broken/debian/valid.conf
@@ -0,0 +1 @@
+# lalalalal - some conf file
diff --git a/t/tests/symlinks-broken/desc b/t/tests/symlinks-broken/desc
new file mode 100644
index 0000000..ba92554
--- /dev/null
+++ b/t/tests/symlinks-broken/desc
@@ -0,0 +1,6 @@
+Testname: symlinks-broken
+Sequence: 6000
+Version: 1.0
+Description: General tests broken symlinks
+Test-For:
+ package-contains-broken-symlink
diff --git a/t/tests/symlinks-broken/tags b/t/tests/symlinks-broken/tags
new file mode 100644
index 0000000..a04e8b4
--- /dev/null
+++ b/t/tests/symlinks-broken/tags
@@ -0,0 +1 @@
+W: broken-links: package-contains-broken-symlink usr/lib/broken-links/some.conf /etc/some.conf

-- 
Debian package checker


Reply to: