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

[lintian] 01/06: c/r-sync-state: Prune entries from the lab



This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository lintian.

commit b1b5e169fed51146577e51080cad625323cc4148
Author: Niels Thykier <niels@thykier.net>
Date:   Tue Feb 10 08:51:19 2015 +0100

    c/r-sync-state: Prune entries from the lab
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 commands/reporting-sync-state | 33 ++++++++++++++++++++++++++++++++-
 1 file changed, 32 insertions(+), 1 deletion(-)

diff --git a/commands/reporting-sync-state b/commands/reporting-sync-state
index efc69ff..ce4a6c6 100755
--- a/commands/reporting-sync-state
+++ b/commands/reporting-sync-state
@@ -47,6 +47,7 @@ BEGIN {
     }
 }
 
+use Lintian::Lab;
 use Lintian::Relation::Version qw(versions_comparator);
 use Lintian::Util qw(
   find_backlog
@@ -72,6 +73,7 @@ my %OPT_HASH= (
     'architectures=s@'  =>
       sub { push(@{$OPT{'architectures'}}, split(m/,/, $_[1])); },
     'desired-version=s' => \$OPT{'desired-version'},
+    'lintian-lab=s'     => \$OPT{'lintian-lab'},
     'reschedule-all'    => \$OPT{'reschedule-all'},
     'help|h'            => \&usage,
     'debug|d'           => \$OPT{'debug'},
@@ -113,7 +115,9 @@ sub main {
     cleanup_state($state);
     if (not $OPT{'dry-run'}) {
         save_state_cache($OPT{'state-dir'}, $state);
-        # FIXME: Prune dead entries from the lab
+    }
+    if ($OPT{'lintian-lab'}) {
+        prune_lintian_lab($state, $OPT{'lintian-lab'});
     }
     exit(0);
 }
@@ -421,6 +425,33 @@ sub local_mirror_manifests {
     return;
 }
 
+sub prune_lintian_lab {
+    my ($state, $lintian_lab_dir) = @_;
+    my $lab = Lintian::Lab->new($lintian_lab_dir);
+    my $err;
+    eval {
+        $lab->open;
+        $lab->visit_packages('ALL', sub {
+            my ($lpkg) = @_;
+            my $id = $lpkg->proc_id;
+            if (not exists($state->{'members-to-groups'}{$id})) {
+                log_debug("Removing ${id} from lab");
+                $lpkg->remove if (not $OPT{'dry-run'});
+            }
+        });
+    };
+    $err = $@;
+    eval {
+        $lab->close;
+    };
+    if (my $close_err = $@) {
+        # The first error is most important
+        die($close_err) if not $err;
+    }
+    die($err) if $err;
+    return;
+}
+
 # _open_data_file ($file)
 #
 # Opens $file if it exists, otherwise it tries common extensions (i.e. .gz) and opens

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: