The following commit has been merged in the master branch:
commit 00ec3102fffee6c7e98b392b074c17f743c85726
Author: Niels Thykier <[email protected]>
Date:   Tue Jul 12 01:24:42 2011 +0200

    Moved handling of collect status into Lab::Package
    
    This was a "simple" code relocation; for now the new methods are
    "not-public" (but with frontend/lintian using them).

diff --git a/frontend/lintian b/frontend/lintian
index f62536a..32cb8dc 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1484,21 +1484,13 @@ sub unpack_group {
                    next;
                }
 
-               # If a file named .SCRIPT-VERSION already exists, we've already
-               # collected this information and we can skip it.  Otherwise,
-               # remove any .SCRIPT-* files (which are old version 
information).
-               if (-f "$base/.${coll}-$ci->{'version'}") {
+               # check if it has been run previously
+               if ($lpkg->_is_coll_finished($coll, $ci->{'version'})) {
                    $collmap->satisfy($req);
                    next;
                }
-               opendir(BASE, $base)
-                   or fail("cannot read directory $base: $!");
-               for my $file (readdir BASE) {
-                   if ($file =~ /^\.\Q$coll-/) {
-                       unlink("$base/$file");
-                   }
-               }
-               closedir(BASE);
+               # Not run before (or out of date)
+               $lpkg->_clear_coll_status($coll);
 
                # collect info
                $collmap->select($req);
@@ -1523,11 +1515,8 @@ sub unpack_group {
                delete $running_jobs{$coll};
                if ($cmd->status() == 0) {
                    my $ci = $collection_info{$coll};
-                   open(VERSION, '>', "$base/.${coll}-$ci->{'version'}")
-                       or fail("cannot create $base/.${coll}-$ci->{'version'}: 
$!");
-                   print VERSION "Lintian-Version: $LINTIAN_VERSION\n"
-                       . 'Timestamp: ' . time . "\n";
-                   close(VERSION);
+                   $lpkg->_mark_coll_finished($coll, $ci->{'version'})
+                       or fail("cannot mark $coll for complete: $!");
                    debug_msg(1, "Collection script $coll done");
                } else {
                    warning("collect info $coll about package $pkg_name 
failed");
diff --git a/lib/Lab/Package.pm b/lib/Lab/Package.pm
index b7c881a..f4ac509 100644
--- a/lib/Lab/Package.pm
+++ b/lib/Lab/Package.pm
@@ -227,6 +227,58 @@ sub create_entry(){
     return 1;
 }
 
+# $lpkg->_mark_coll_finished($name, $version)
+#
+#  Record that the collection $name (at version) has been run on this
+#  entry.
+#
+#  returns a truth value on success; otherwise $! will contain the error
+#
+#  This is used by frontend/lintian, but probably should not be.
+sub _mark_coll_finished {
+    my ($self, $collname, $collver) = @_;
+    # In the "old days" we would also write the Lintian version and the time
+    # stamp in these files, but since we never read them it seems like 
overkill.
+    #  - for the timestamp we could use the mtime of the file anyway
+    return touch_file "$self->{base_dir}/.$collname-$collver";
+}
+
+# $lpkg->_is_coll_finished($name, $version)
+#
+#  returns a truth value if a collection with $name at $version has been
+#  marked as completed.
+#
+#  This is used by frontend/lintian, but probably should not be.
+sub _is_coll_finished {
+    my ($self, $collname, $collver) = @_;
+    return -e "$self->{base_dir}/.$collname-$collver";
+}
+
+# $lpkg->_clear_coll_status($name)
+#
+#  Removes all completation status for collection $name.
+#
+#  Returns a truth value on success; otherwise $! will contain the error
+#
+#  This is used by frontend/lintian, but probably should not be.
+sub _clear_coll_status {
+    my ($self, $collname) = @_;
+    my $ok = 1;
+    my $serr;
+    opendir my $d, $self->{base_dir} or return 0;
+    foreach my $file (readdir $d) {
+       next unless $file =~ m,^\.$collname-\d++$,;
+       unless (unlink "$d/$file") {
+           # store the first error
+           next unless $ok;
+           $serr = $!;
+           $ok = 0;
+       }
+    }
+    closedir $d or return 0;
+    $! = $serr unless $ok;
+    return $ok;
+}
 
 sub update_status_file{
     my ($self, $lint_version) = @_;

-- 
Debian package checker


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]

Reply via email to