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

[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-91-g0a10ba8



The following commit has been merged in the lab-refactor branch:
commit 0a10ba82ce8f1a8a972013170d84442d779f77d5
Author: Niels Thykier <niels@thykier.net>
Date:   Thu Sep 29 22:09:58 2011 +0200

    Made Lintian::Lab::Entry extend Lintian::Processable
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/lib/Lintian/Lab/Entry.pm b/lib/Lintian/Lab/Entry.pm
index 7ebf633..897db60 100644
--- a/lib/Lintian/Lab/Entry.pm
+++ b/lib/Lintian/Lab/Entry.pm
@@ -48,7 +48,7 @@ Lintian::Lab::Entry - A package inside the Lab
 
 =cut
 
-use base qw(Class::Accessor);
+use base qw(Lintian::Processable Class::Accessor);
 
 use strict;
 use warnings;
@@ -64,7 +64,7 @@ sub new {
     my ($type, $lab, $pkg_name, $pkg_version, $pkg_type, $pkg_path, $base_dir) = @_;
     my $self = {};
     bless $self, $type;
-    croak("$pkg_path does not exist.") unless( -e $pkg_path );
+    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;
@@ -79,35 +79,20 @@ sub new {
     return $self;
 }
 
-=item $lpkg->pkg_name()
-
-Returns the package name.
-
-=item $lpkg->pkg_version();
-
-Returns the version of the package.
-
-=item $lpkg->pkg_path()
-
-Returns the path to the packaged version of actual package.  This path
-is used in case the data needs to be extracted from the package.
-
-=item $lpkg->pkg_type()
-
-Returns the type of package (e.g. binary, source, udeb ...)
-
-=item $lpkg->base_dir()
+=item $lpkg->base_dir
 
 Returns the base directory of this package inside the lab.
 
 =cut
 
-Lintian::Lab::Entry->mk_ro_accessors(qw(pkg_name pkg_version pkg_path pkg_type base_dir));
+Lintian::Lab::Entry->mk_ro_accessors (qw(base_dir));
 
-=item $lpkg->info()
+=item $lpkg->info
 
 Returns the L<Lintian::Collect|info> object associated with this entry.
 
+Overrides info from L<Lintian::Processable>.
+
 =cut
 
 sub info {
@@ -116,7 +101,7 @@ sub info {
     croak 'Cannot load info, extry does not exists' unless $self->entry_exists;
     $info = $self->{info};
     if ( ! defined $info ) {
-        $info = Lintian::Collect->new($self->pkg_name, $self->pkg_type, $self->base_dir);
+        $info = Lintian::Collect->new ($self->pkg_name, $self->pkg_type, $self->base_dir);
         $self->{info} = $info;
     }
     return $info;
@@ -127,6 +112,8 @@ sub info {
 
 Clears any caches held; this includes discarding the L<Lintian::Collect|info> object.
 
+Overrides clear_cache from L<Lintian::Processable>.
+
 =cut
 
 sub clear_cache {
@@ -198,9 +185,8 @@ sub create_entry {
     return 1 if ($self->entry_exists());
 
     unless (-d $base_dir) {
-        # if we are in a multi-arch or/and multi-version lab we may
-        # need to make more than one dir.  On error we will only kill
-        # the "top dir" and that is enough.
+        # In the pool we may have to create multiple directories On
+        # error we only remove the "top dir" and that is enough.
         system ('mkdir', '-p', $base_dir) == 0
             or return 0;
         $madedir = 1;
@@ -221,7 +207,7 @@ sub create_entry {
     }
     if ($pkg_type eq 'source'){
         # If it is a source package, pull in all the related files
-#  - else unpacked will fail or we would need a separate
+        #  - else unpacked will fail or we would need a separate
         #    collection for the symlinking.
         my $data = get_dsc_info($pkg_path);
         my (undef, $dir, undef) = File::Spec->splitpath($pkg_path);
diff --git a/lib/Lintian/Processable.pm b/lib/Lintian/Processable.pm
index 5e1416a..3cac9ee 100644
--- a/lib/Lintian/Processable.pm
+++ b/lib/Lintian/Processable.pm
@@ -26,8 +26,6 @@ use warnings;
 
 use Carp qw(croak);
 
-use Util;
-
 # Black listed characters - any match will be replaced with a _.
 use constant EVIL_CHARACTERS => qr,[/&|;\$"'<>],o;
 
@@ -128,10 +126,12 @@ to less dangerous (but possibly invalid) values.
 
 Lintian::Processable->mk_ro_accessors (qw(pkg_name pkg_version pkg_src pkg_arch pkg_path pkg_type pkg_src_version tainted));
 
-=item $proc->info()
+=item $proc->info
 
 Returns L<Lintian::Collect|$info> element for this processable.
 
+Note: This method is must implemented by sub-classes.
+
 =cut
 
 sub info {
@@ -139,24 +139,25 @@ sub info {
     my $info = $self->{info};
     if (! defined $info) {
         my $lpkg = $self->lab_pkg();
-        fail "Need a Lab package before creating a Lintian::Collect\n"
+        croak "Need a Lab package before creating a Lintian::Collect\n"
             unless defined $lpkg;
         return $lpkg->info;
     }
     return $info;
 }
 
-=item $proc->clear_cache()
+=item $proc->clear_cache
 
 Discard the info element, so the memory used by it can be reclaimed.
 Mostly useful when checking a lot of packages (e.g. on lintian.d.o).
 
+Note: By default this does nothing, but it may (and should) be
+overriden by sub-classes.
+
 =cut
 
 sub clear_cache {
     my ($self) = @_;
-    my $lpkg = $self->lab_pkg;
-    $lpkg->clear_cache if defined $lpkg;
 }
 
 sub _init {
diff --git a/lib/Lintian/Processable/Package.pm b/lib/Lintian/Processable/Package.pm
index 7819c3a..8dbad9c 100644
--- a/lib/Lintian/Processable/Package.pm
+++ b/lib/Lintian/Processable/Package.pm
@@ -149,6 +149,36 @@ sub _init {
     return 1;
 }
 
+=item $proc->info
+
+Overrides info from L<Lintian::Processable>.
+
+=cut
+
+sub info {
+    my ($self) = @_;
+    my $info = $self->{info};
+    if (! defined $info) {
+        my $lpkg = $self->lab_pkg();
+        croak "Need a Lab package before creating a Lintian::Collect\n"
+            unless defined $lpkg;
+        return $lpkg->info;
+    }
+    return $info;
+}
+
+=item $proc->clear_cache
+
+Overrides clear_cache from L<Lintian::Processable>.
+
+=cut
+
+sub clear_cache {
+    my ($self) = @_;
+    my $lpkg = $self->lab_pkg;
+    $lpkg->clear_cache if defined $lpkg;
+    delete $self->{info};
+}
 
 =back
 

-- 
Debian package checker


Reply to: