[lintian] 02/02: L::Unpacker: Drop the "unpacker finish hook"
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch master
in repository lintian.
commit 68f1639d6357ffff3fc37bedc878be107e1fc025
Author: Niels Thykier <niels@thykier.net>
Date: Wed Apr 13 18:45:22 2016 +0000
L::Unpacker: Drop the "unpacker finish hook"
The finish hook was optimisiting for some fairly uncommon cases, like
"permanent labs" or "unpack only". These are all "special-case" or
"developer" features that most people will never need.
Signed-off-by: Niels Thykier <niels@thykier.net>
---
commands/lintian | 56 ++++++++++++++++++++++---------------------------
lib/Lintian/Unpacker.pm | 41 ------------------------------------
2 files changed, 25 insertions(+), 72 deletions(-)
diff --git a/commands/lintian b/commands/lintian
index dae5cc6..1d991e3 100755
--- a/commands/lintian
+++ b/commands/lintian
@@ -760,6 +760,7 @@ sub main {
my $success = 1;
my $group = $pool->get_group($gname);
my $total_raw_res = timed_task {
+ my @group_lpkg;
my $raw_res = timed_task {
if (!unpack_group($gname, $group)) {
$success = 0;
@@ -788,6 +789,27 @@ sub main {
# children if they are now done.
1 while waitpid(-1, WNOHANG) > 0;
}
+ @group_lpkg = $group->get_processables;
+ } else {
+ for my $lpkg ($group->get_processables) {
+ my $ret = auto_clean_package($lpkg);
+ next if ($ret == 2);
+ if ($ret < 0) {
+ $exit_code = 2;
+ next;
+ }
+ push(@group_lpkg, $lpkg);
+ }
+ }
+ if (not $LAB->is_temp) {
+ for my $lpkg (@group_lpkg) {
+ $lpkg->update_status_file
+ or
+ warning('could not create status file for package '
+ .$lpkg->pkg_name
+ . ": $!");
+
+ }
}
};
my $total_tres = $format_timer_result->($total_raw_res);
@@ -950,42 +972,14 @@ sub unpack_group {
v_msg("Unpacking packages in group $gname");
- my %timers;
- my %hooks = (
- 'coll-hook' => sub { coll_hook($group, \%timers, @_) or $all_ok = 0; },
- 'finish-hook' => sub { finish_hook(@_) or $all_ok = 0; },
- );
+ my (%timers, %hooks);
+ $hooks{'coll-hook'}
+ = sub { coll_hook($group, \%timers, @_) or $all_ok = 0; };
$unpacker->process_tasks(\%hooks);
return $all_ok;
}
-sub finish_hook {
- my ($lpkg, $state, $changed) = @_;
- my $ok = 1;
- if ($state eq 'sf-error') {
- # The status file could not be written; give a warning.
- my $err = $!;
- my $pkg_name = $lpkg->pkg_name;
- warning("could not create status file for package $pkg_name: $err");
- } elsif ($state eq 'unchanged' or $state eq 'changed') {
- # If we are only unpacking stuff, auto-remove colls
- # immediately.
- if ($action ne 'check' and @auto_remove) {
- # we are done now - start auto-cleaning
- my $ret = auto_clean_package($lpkg);
- # We don't have to remove it from the group if it
- # fails as we are pretty much done.
- if ($ret < 0) {
- $exit_code = 2;
- $ok = 0;
- }
- $changed->() if $ret;
- }
- }
- return $ok;
-}
-
sub coll_hook {
my ($group, $timers, $lpkg, $event, $cs, $pid, $exitval) = @_;
my $coll = $cs->name;
diff --git a/lib/Lintian/Unpacker.pm b/lib/Lintian/Unpacker.pm
index 14a728c..5b50a8a 100644
--- a/lib/Lintian/Unpacker.pm
+++ b/lib/Lintian/Unpacker.pm
@@ -343,27 +343,6 @@ to signal a failure.
STATUS is the exit status of the finishing job. It is only available
if EVENT is "finish" and if STATUS is non-zero is considered an error.
-=item finish-hook (LPKG, STATE[, CHANGED])
-
-Called once or twice for each entry processed at the end of the run.
-The LPKG is the L<entry|Lintian::Lab::Entry> being processed.
-
-For the first call, STATE is one of "changed" (the entry has been
-modified), "unchanged" (the entry was unmodified) or "failed" (at
-least one collection could not be applied). Note that a "failed"
-entry may (or may not) be "changed" depending on where the failure
-happened.
-
-In the first call is done before the status file is written and the
-hook may alter the entry at this point (e.g. auto-remove unused
-collections). If it does so CHANGED should be invoked as a code-ref
-to inform the unpacker of the change.
-
-The second call only happens for entries that has been changed (one
-way or another). STATE will be one of "sf-success" or "sf-error",
-which determined on whether or not status file update was successful.
-On errors (i.e. "sf-error"), $! will contain the error.
-
=back
=cut
@@ -377,7 +356,6 @@ sub process_tasks {
$hooks //= {};
my $coll_hook = $hooks->{'coll-hook'};
- my $finish_hook = $hooks->{'finish-hook'};
my %failed;
my %active = map { $_ => 1 } keys %$worklists;
@@ -524,25 +502,6 @@ sub process_tasks {
}
}
- foreach my $procid (keys %$worklists) {
- my $wlist = $worklists->{$procid};
- my $lpkg = $wlist->{'lab-entry'};
- my $changed = $wlist->{'changed'};
- my $state = 'unchanged';
- $state = 'changed' if $changed;
- $state = 'failed' if exists $failed{$procid};
- # Gracefully handle the hook deleting the entire entry
- $finish_hook->($lpkg, $state, sub { $changed = $lpkg->exists ? 1 : 0 })
- if $finish_hook;
- if ($changed) {
- $state = 'sf-error';
- if ($lpkg->update_status_file) {
- $state = 'sf-success';
- }
- $finish_hook->($lpkg, $state)
- if $finish_hook;
- }
- }
return;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git
Reply to: