[SCM] Debian package checker branch, lab-refactor, updated. 2.5.3-191-g856b0f3
The following commit has been merged in the lab-refactor branch:
commit 856b0f3b07049c433f1cd9548c1dc8f459f0c492
Author: Niels Thykier <niels@thykier.net>
Date: Thu Nov 3 18:23:02 2011 +0100
Renamed methods in L::Lab{,::Entry}
The method names no longer contain "_lab", "lab_", "_entry" or/and
"entry_". The L::Lab::Entry delete_lab_entry was renamed to
"remove" for consistency with the similar L::Lab method.
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/frontend/lintian b/frontend/lintian
index d4cfeb4..52e0305 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -858,7 +858,7 @@ if ($action eq 'setup-lab') {
warning('ignoring additional command line arguments');
}
- $LAB->create_lab()
+ $LAB->create
or fail('There was an error while setting up the static lab.');
exit 0;
@@ -870,7 +870,7 @@ if ($action eq 'setup-lab') {
warning('ignoring additional command line arguments');
}
- $LAB->remove_lab()
+ $LAB->remove
or fail('There was an error while removing the static lab.');
exit 0;
@@ -885,12 +885,12 @@ if ($action eq 'setup-lab') {
if ($LAB->dir) {
# sanity check:
fail('lintian lab has not been set up correctly (perhaps you forgot to run lintian --setup-lab?)')
- unless $LAB->lab_exists;
+ unless $LAB->exists;
} else {
- $LAB->create_lab ( {'keep-lab' => $keep_lab} );
+ $LAB->create ( {'keep-lab' => $keep_lab} );
}
-$LAB->open_lab;
+$LAB->open;
# Update the ENV var as well - unlike the original values,
# $LAB->dir is always absolute
@@ -998,7 +998,7 @@ if($action eq 'remove'){
$TAGS->file_start($pkg_path, $pkg_name, $pkg_ver,
$pkg_arch, $pkg_type);
debug_msg(1, 'Removing package in lab ...');
- unless($lpkg->delete_lab_entry()){
+ unless ($lpkg->remove){
warning("cannot remove entry for $pkg_name: $!");
$exit_code = 2;
}
@@ -1006,7 +1006,7 @@ if($action eq 'remove'){
}
$TAGS->file_end();
# Write the lab state to the disk, so it remembers they are gone.
- $LAB->close_lab();
+ $LAB->close;
exit $exit_code;
}
# }}}
@@ -1174,7 +1174,7 @@ foreach my $gname (sort $pool->get_group_names()) {
}
# Write the lab state to the disk, so it remembers the new packages
-$LAB->close_lab();
+$LAB->close;
$TAGS->file_end();
if ($action eq 'check' and not $opt{'no-override'} and not $opt{'show-overrides'}) {
@@ -1462,7 +1462,7 @@ sub unpack_group {
debug_msg(1, "Unpacking $pkg_name $pkg_ver [$pkg_arch] ($pkg_type) in $base");
# Ensure it has been unpacked
- unless ($lpkg->create_entry()){
+ unless ($lpkg->create){
warning("could not create the package entry in the lab: $!",
"skipping $action of $pkg_type package $pkg_name");
$exit_code = 2;
@@ -1716,7 +1716,7 @@ sub handle_lab_query {
# {{{ Exit handler.
sub END {
- # Prevent Lab->close_lab from affecting the exit code.
+ # Prevent Lab->close from affecting the exit code.
local $?;
$SIG{'INT'} = 'DEFAULT';
@@ -1728,7 +1728,7 @@ sub END {
%running_jobs = ();
}
- $LAB->close_lab if $LAB;
+ $LAB->close if $LAB;
}
sub interrupted {
diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index d56d7e0..8906dcc 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -85,17 +85,17 @@ Lintian::Lab -- Interface to the Lintian Lab
# Static lab
my $lab = Lintian::Lab->new ('/var/lib/lintian/static-lab');
- if (!$lab->lab_exists) {
- $lab->create_lab;
+ if (!$lab->exists) {
+ $lab->create;
}
- $lab->open_lab;
+ $lab->open;
# Fetch a package from the lab
my $pkg = $lab->get_package ('lintian', 'binary', '2.5.4', 'all');
#FIXME: Add more to the synopsis here
- $lab->close_lab;
+ $lab->close;
=head1 DESCRIPTION
@@ -154,7 +154,7 @@ Returns the absolute path to the base of the lab.
Note: This may return the empty string if either the lab has been
deleted or this is a temporary lab that has not been created yet.
-In the latter case, $lab->create_lab should be run to get a
+In the latter case, $lab->create should be run to get a
non-empty value from this method.
=item $lab->is_open
@@ -162,13 +162,13 @@ non-empty value from this method.
Returns a truth value if this lab is open.
Note: If the lab is open, it also exists. However, if the lab is
-closed then the lab may or may not exist (see L</lab_exists>).
+closed then the lab may or may not exist (see L</exists>).
=cut
Lintian::Lab->mk_ro_accessors (qw(dir is_open));
-=item $lab->lab_exists
+=item $lab->exists
Returns a truth value if B<$lab> points to an existing lab.
@@ -177,7 +177,7 @@ the lab is closed (see L</is_open>).
=cut
-sub lab_exists {
+sub exists {
my ( $self ) = @_;
my $dir = $self->dir;
return unless $dir;
@@ -424,7 +424,7 @@ sub generate_diffs {
}
-=item $lab->create_lab ([$opts])
+=item $lab->create ([$opts])
Creates a new lab. It will create $lab->dir if it does not exist.
It will also create a basic empty lab. If this is a temporary
@@ -439,7 +439,7 @@ options are accepted:
If "keep-lab" points to a truth value the temporary directory will
I<not> be removed by closing the lab (nor exiting the application).
-However, explicitly calling $lab->remove_lab will remove the lab.
+However, explicitly calling $lab->remove will remove the lab.
=item mode
@@ -458,13 +458,13 @@ Note: This does nothing if the lab appears to already exists.
=cut
-sub create_lab {
+sub create {
my ($self, $opts) = @_;
my $dir = $self->dir;
my $mid = 0;
my $mode = 0777;
- return 1 if $self->lab_exists;
+ return 1 if $self->exists;
$opts = {} unless $opts;
$mode = $opts->{'mode'} if exists $opts->{'mode'};
@@ -523,7 +523,7 @@ sub create_lab {
# $dir/pool will be created as needed.
# Create the meta-data file - note at this point we can use
- # $lab->remove_lab
+ # $lab->remove
my $ok = 0;
eval {
open my $lfd, '>', "$dir/info/lab-info" or croak "opening $dir/info/lab-info: $!";
@@ -536,49 +536,49 @@ sub create_lab {
};
unless ($ok) {
my $err = $@;
- eval { $self->remove_lab; };
+ eval { $self->remove; };
croak $err;
}
return 1;
}
-=item $lab->open_lab
+=item $lab->open
Opens the lab and reads the contents into caches. If the lab is
temporary this will create a temporary dir to store the contents of
the lab.
This will croak if the lab is already open. It may also croak for
-the same reasons as $lab->create_lab if this is a temporary lab.
+the same reasons as $lab->create if this is a temporary lab.
Note: for static labs, $lab->dir must point to an existing consistent
lab or this will croak. To open a new lab, please use
-$lab->create_lab.
+$lab->create.
Note: It is not possible to pass options to the creation of the
temporary lab. If special options are required, please use
-$lab->create_lab.
+$lab->create.
=cut
-sub open_lab {
+sub open {
my ($self) = @_;
my $dir;
my $msg = "Open Lab failed";
croak ('Lab is already open') if $self->is_open;
if ($self->{'mode'} eq LAB_MODE_TEMP) {
- $self->create_lab unless $self->lab_exists;
+ $self->create unless $self->exists;
$dir = $self->dir;
} else {
$dir = $self->dir;
- unless ($self->lab_exists) {
+ unless ($self->exists) {
croak "$msg: $dir does not exists" unless -e $dir;
croak "$msg: $dir is not a lab or the lab is corrupt";
}
}
unless ( -e "$dir/info/lab-info") {
- if ( $self->lab_exists ) {
+ if ( $self->exists ) {
croak "$msg: The Lab format is not supported";
}
croak "$msg: Lab is corrupt - $dir/info/lab-info does not exist";
@@ -604,23 +604,23 @@ sub open_lab {
return 1;
}
-=item $lab->close_lab
+=item $lab->close
Close the lab - all state caches will be flushed to the disk and the
lab can no longer be used. All references to entries in the lab
should be considered invalid.
Note: if the lab is a temporary one, this will be deleted unless it
-was created with "keep-lab" (see $lab->create_lab).
+was created with "keep-lab" (see $lab->create).
=cut
-sub close_lab {
+sub close {
my ($self) = @_;
- return unless $self->lab_exists;
+ return unless $self->exists;
if ($self->{'mode'} eq LAB_MODE_TEMP && !$self->{'keep-lab'}) {
# Temporary lab (without "keep-lab" property)
- $self->remove_lab;
+ $self->remove;
} else {
my $dir = $self->dir;
while ( my ($pkg_type, $plist) = (each %{ $self->{'state'} }) ) {
@@ -634,7 +634,7 @@ sub close_lab {
return 1;
}
-=item $lab->remove_lab
+=item $lab->remove
Removes the lab and everything in it. Any reference to an entry
returned from this lab will immediately become invalid.
@@ -654,7 +654,7 @@ return a truth value.
=cut
-sub remove_lab {
+sub remove {
my ($self) = @_;
my $dir = $self->dir;
my @subdirs = ();
diff --git a/lib/Lintian/Lab/Entry.pm b/lib/Lintian/Lab/Entry.pm
index eef16b8..6dbb5aa 100644
--- a/lib/Lintian/Lab/Entry.pm
+++ b/lib/Lintian/Lab/Entry.pm
@@ -33,10 +33,10 @@ Lintian::Lab::Entry - A package inside the Lab
my $lpkg = $lab->get_package ("name", "version", "arch", "type", "path");
# create the entry if it does not exist
- $lpkg->create_entry unless $lpkg->entry_exists;
+ $lpkg->create unless $lpkg->exists;
# Remove package from lab.
- $lpkg->delete_lab_entry;
+ $lpkg->remove;
=head1 DESCRIPTION
@@ -104,7 +104,7 @@ sub _new {
# 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;
+ unless $self->exists;
my $link;
$link = 'deb' if $pkg_type eq 'binary' or $pkg_type eq 'udeb';
$link = 'dsc' if $pkg_type eq 'source';
@@ -155,7 +155,7 @@ Overrides info from L<Lintian::Processable>.
sub info {
my ($self) = @_;
my $info;
- croak 'Cannot load info, extry does not exist' unless $self->entry_exists;
+ croak 'Cannot load info, extry does not exist' unless $self->exists;
$info = $self->{info};
if ( ! defined $info ) {
$info = Lintian::Collect->new ($self->pkg_name, $self->pkg_type, $self->base_dir);
@@ -178,14 +178,14 @@ sub clear_cache {
delete $self->{info};
}
-=item $lpkg->delete_lab_entry()
+=item $lpkg->remove
Removes all unpacked parts of the package in the lab. Returns a truth
value if successful.
=cut
-sub delete_lab_entry {
+sub remove {
my ($self) = @_;
my $basedir = $self->{base_dir};
return 1 if( ! -e $basedir);
@@ -197,13 +197,13 @@ sub delete_lab_entry {
return 1;
}
-=item $lpkg->entry_exists()
+=item $lpkg->exists
Returns a truth value if the lab-entry exists.
=cut
-sub entry_exists {
+sub exists {
my ($self) = @_;
my $pkg_type = $self->{pkg_type};
my $base_dir = $self->{base_dir};
@@ -222,7 +222,7 @@ sub entry_exists {
return 0;
}
-=item $lpkg->create_entry()
+=item $lpkg->create
Creates a minimum lab-entry, in which collections and checks
can be run. Note if it already exists, then this will do
@@ -230,7 +230,7 @@ nothing.
=cut
-sub create_entry {
+sub create {
my ($self) = @_;
my $pkg_type = $self->{pkg_type};
my $base_dir = $self->{base_dir};
@@ -239,7 +239,7 @@ sub create_entry {
my $link;
my $madedir = 0;
# It already exists.
- return 1 if ($self->entry_exists());
+ return 1 if $self->exists;
unless (-d $base_dir) {
# In the pool we may have to create multiple directories. On
@@ -255,7 +255,7 @@ sub create_entry {
} elsif ($pkg_type eq 'source'){
$link = "$base_dir/dsc";
} else {
- croak "create_entry cannot handle $pkg_type";
+ croak "create cannot handle $pkg_type";
}
unless (symlink ($pkg_path, $link)){
my $err = $!;
@@ -348,7 +348,7 @@ sub update_status_file {
my $file;
my @sc;
- unless ($self->entry_exists) {
+ unless ($self->exists) {
$! = "Entry does not exists";
return 0;
}
@@ -377,7 +377,7 @@ sub _init {
my @data;
my $head;
my $coll;
- return unless $self->entry_exists;
+ return unless $self->exists;
return unless -e "$base_dir/.lintian-status";
@data = read_dpkg_control ("$base_dir/.lintian-status");
$head = $data[0];
diff --git a/reporting/harness b/reporting/harness
index 8e291fd..26e475b 100755
--- a/reporting/harness
+++ b/reporting/harness
@@ -105,9 +105,9 @@ if ($LINTIAN_GPG_CHECK) {
my $LAB = Lintian::Lab->new ($LINTIAN_LAB);
# purge the old packages
-$LAB->remove_lab if $opt_c;
+$LAB->remove if $opt_c;
-$LAB->create_lab ({ 'mode' => 02775}) unless $LAB->lab_exists;
+$LAB->create ({ 'mode' => 02775}) unless $LAB->exists;
unless ($opt_f || $opt_c) {
unless ($opt_r) {
@@ -120,7 +120,7 @@ unless ($opt_f || $opt_c) {
}
unless ($opt_r) {
- $LAB->open_lab;
+ $LAB->open;
my @manifests = local_mirror_manifests ($LINTIAN_ARCHIVEDIR, [_trim_split ($LINTIAN_DIST)],
[_trim_split ($LINTIAN_AREA)], [_trim_split ($LINTIAN_ARCH)]);
my @diffs = $LAB->generate_diffs (@manifests);
@@ -143,7 +143,7 @@ unless ($opt_r) {
if ($entry) {
my $arch = '';
$arch = " [$pkg_arch]" if $pkg_arch;
- if ($entry->delete_lab_entry) {
+ if ($entry->remove) {
Log ("Removed $type $pkg_name ($pkg_version)$arch");
} else {
Log ("Removing $type $pkg_name ($pkg_version)$arch failed.");
@@ -173,7 +173,7 @@ unless ($opt_r) {
my $arch = '';
$arch = " [$pkg_arch]" if $pkg_arch;
eval {
- $entry->create_entry;
+ $entry->create;
$entry->update_status_file or
die "creating status file: $!";
$ok = 1;
@@ -191,7 +191,7 @@ unless ($opt_r) {
}
# Flushes the changed manifest to the file system - croaks on error
- $LAB->close_lab;
+ $LAB->close;
if ($opt_i) {
# Extra work for the incremental run
diff --git a/reporting/html_reports b/reporting/html_reports
index 31e3ba8..8422c73 100755
--- a/reporting/html_reports
+++ b/reporting/html_reports
@@ -105,7 +105,7 @@ for my $template (qw/head foot clean index maintainer maintainers packages tag
my $LAB = Lintian::Lab->new ($LINTIAN_LAB);
my $source_info;
-$LAB->open_lab;
+$LAB->open;
$source_info = $LAB->_get_lab_index ('source');
@@ -334,6 +334,12 @@ $source_info->visit_all (sub {
$clean{$id} = $maintainer;
});
+# Done with the lab and its metadata
+$LAB->close;
+undef $LAB;
+undef $source_info
+
+
# Now, walk through the tags by source package (sorted by maintainer). Output
# a summary page of errors and warnings for each maintainer, output a full
# page that includes info, experimental, and overriden tags, and assemble the
--
Debian package checker
Reply to: