[SCM] Debian package checker branch, master, updated. 2.5.4-20-gc452b09
The following commit has been merged in the master branch:
commit 82d8d32cd372cc3ea268d2150a038c18a93686b4
Author: Niels Thykier <niels@thykier.net>
Date: Fri Dec 2 22:52:01 2011 +0100
Lintian::Lab: Added is_temp method
Signed-off-by: Niels Thykier <niels@thykier.net>
diff --git a/debian/changelog b/debian/changelog
index 636c4aa..6211485 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,9 @@ lintian (2.5.5) UNRELEASED; urgency=low
* lib/Lintian/Collect/Source.pm:
+ [NT] Removed assumption that source packages always have a
format field.
+ * lib/Lintian/Lab.pm:
+ + [NT] Added "is_temp" method to identify temp labs from static
+ labs.
* lib/Lintian/Processable/Package.pm:
+ [NT] Use part of the file name as package name if the mandatory
"Package" or "Source" fields are missing rather than choking.
diff --git a/frontend/lintian b/frontend/lintian
index cc71bb3..7517c1b 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -879,7 +879,7 @@ if ($action eq 'setup-lab') {
fail("bad action $action specified");
}
-if ($LAB->dir) {
+if ($LAB->is_temp) {
# sanity check:
fail('lintian lab has not been set up correctly (perhaps you forgot to run lintian --setup-lab?)')
unless $LAB->exists;
diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index 36d1c70..034ff3d 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -472,8 +472,8 @@ sub create {
$opts = {} unless $opts;
$mode = $opts->{'mode'} if exists $opts->{'mode'};
- if ( !$dir or $self->{'mode'} eq LAB_MODE_TEMP) {
- if ($self->{'mode'} eq LAB_MODE_TEMP) {
+ if ( !$dir or $self->is_temp) {
+ if ($self->is_temp) {
my $keep = $opts->{'keep-lab'}//0;
my $topts = { CLEAN => !$keep, TMPDIR => 1 };
my $t = tempdir ('temp-lintian-lab-XXXXXX', $topts);
@@ -570,7 +570,7 @@ sub open {
my $dir;
my $msg = "Open Lab failed";
croak ('Lab is already open') if $self->is_open;
- if ($self->{'mode'} eq LAB_MODE_TEMP) {
+ if ($self->is_temp) {
$self->create unless $self->exists;
$dir = $self->dir;
} else {
@@ -622,7 +622,7 @@ was created with "keep-lab" (see $lab->create).
sub close {
my ($self) = @_;
return unless $self->exists;
- if ($self->{'mode'} eq LAB_MODE_TEMP && !$self->{'keep-lab'}) {
+ if ($self->is_temp && !$self->{'keep-lab'}) {
# Temporary lab (without "keep-lab" property)
$self->remove;
} else {
@@ -695,7 +695,7 @@ sub remove {
}
# dynamic lab?
- if ($self->{'mode'} eq LAB_MODE_TEMP) {
+ if ($self->is_temp) {
rmdir $dir or croak "rmdir $dir: $!";
$self->{'dir'} = '';
}
@@ -704,6 +704,20 @@ sub remove {
return 1;
}
+=item $lab->is_temp
+
+Returns a truth value if $lab is a temporary lab.
+
+Note: This returns a truth value, even if the lab was created with the
+"keep-lab" property.
+
+=cut
+
+sub is_temp {
+ my ($self) = @_;
+ return $self->{'mode'} eq LAB_MODE_TEMP ? 1 : 0;
+}
+
# initialize the instance
#
# May be overriden by a sub-class.
--
Debian package checker
Reply to: