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

[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-139-ga093e64



The following commit has been merged in the lab-refactor branch:
commit 846a7ba2b3db37d05545b25542d495199925a983
Author: Niels Thykier <niels@thykier.net>
Date:   Sun Oct 23 17:14:15 2011 +0200

    Made L::L::Entry::new able to undefined $pkg_path
    
    Also corrected doc for Lintian::Lab::get_package.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index 0ec7972..6b42a2e 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -199,7 +199,7 @@ used to narrow the search or even to add a new entry.
 
 @extra consists of (in order):
  - version
- - arch (May be omitted $pkg_type is "source")
+ - arch (Ignored if $pkg_type is "source")
  - path to package
 
 If version or arch is omitted (or undef) then that search parameter is
@@ -216,8 +216,8 @@ consider a wildcard for "any".  Example:
  $pkg = $lab->get_package ('eclipse-platform', 'binary', '3.5.2-11', 'i386');
 
 
-If all 3 (2 for source packages) @extra arguments are given, then the
-entry will be created if it does not exists.
+If all 3 @extra arguments are given, then the entry will be created if
+it does not exists.
 
 In list context, this returns a list of matches.  In scalar context
 this returns the first match (if any).
diff --git a/lib/Lintian/Lab/Entry.pm b/lib/Lintian/Lab/Entry.pm
index 6d3ab4e..4f7e8ab 100644
--- a/lib/Lintian/Lab/Entry.pm
+++ b/lib/Lintian/Lab/Entry.pm
@@ -56,6 +56,8 @@ use warnings;
 use Carp qw(croak);
 use File::Spec;
 
+use Cwd();
+
 use Lintian::Lab;
 
 use Util qw(delete_dir read_dpkg_control get_dsc_info);
@@ -79,10 +81,8 @@ sub new {
     my ($type, $lab, $pkg_name, $pkg_version, $pkg_arch, $pkg_type, $pkg_path, $pkg_src, $pkg_src_version, $base_dir) = @_;
     my $self = {};
     bless $self, $type;
-    croak "$pkg_path does not exist." unless -e $pkg_path;
     $self->{pkg_name}        = $pkg_name;
     $self->{pkg_version}     = $pkg_version;
-    $self->{pkg_path}        = $pkg_path;
     $self->{pkg_type}        = $pkg_type;
     $self->{pkg_src}         = $pkg_src;
     $self->{pkg_src_version} = $pkg_src_version;
@@ -95,9 +95,30 @@ sub new {
         $self->{pkg_arch} = 'source';
     }
 
-    # ask the lab to find the base directory of this package.
     $self->{base_dir} = $base_dir;
 
+    if (defined $pkg_path) {
+        croak "$pkg_path does not exist." unless -e $pkg_path;
+    } else {
+        # This error should not happen unless someone (read: me) breaks
+        # Lintian::Lab::get_package
+        croak "$pkg_name $pkg_type ($pkg_version) [$pkg_arch] does not exists"
+            unless $self->entry_exists;
+        my $link;
+        $link = 'deb' if $pkg_type eq 'binary' or $pkg_type eq 'udeb';
+        $link = 'dsc' if $pkg_type eq 'source';
+        $link = 'changes' if $pkg_type eq 'changes';
+
+        croak "Unknown package type $pkg_type" unless $link;
+        # Resolve the link if possible, but else just fall back to the link
+        # - this is not safe in case of a "delete and create", but if
+        #   abs_path fails odds are the package cannot be read anyway.
+        $pkg_path = Cwd::abs_path("$base_dir/$link") // "$base_dir/$link";
+    }
+
+    $self->{pkg_path} = $pkg_path;
+
+
     $self->_init();
     return $self;
 }

-- 
Debian package checker


Reply to: