Bug#596379: unblock: kgb-bot/1.05-1
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock
Please unblock package kgb-bot/1.05-1
At first glance this looks like a new upstream release, but we are
upstream, so it is all under control. The "upstream" diff is attached.
1.05-1 fixes two bugs:
#593631 -- can't access /usr/bin/polygen (moved to /usr/games)
#593633 -- dies when polygen is removed after daemon startup
Changelog:
* kgb-bot: use File::Which to find polygen binary; split out the
polygen-finding function; add libfile-which-perl to Suggests;
closes: #593631 -- can't access /usr/bin/polygen
* kgb-bot: check existence of polygen binary just before using it;
closes: #593633 -- dies when polygen is removed after daemon startup
* any problems in finding/running polygen binary are logged only when debug
is enabled as a counter-measure against remotely-assisted log abuse
Thanks in advance,
dam
diff --git a/Changes b/Changes
index d30fa6b..b254e97 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,19 @@
+
+1.05:
+ * kgb-bot: use File::Which to find polygen binary; split out the
+ polygen-finding function; closes: #593631
+ * kgb-bot: check existence of polygen binary before using it;
+ closes: #593633
+ * add gregor to copyright holders
+ * move polygen detection entirely at runtime
+ * any problems in finding polygen binary are logged only when debug is
+ enabled as a counter-measure against remotely-assisted log abuse
+
+1.04:
+ * use Digest::SHA from core instead of ::SHA1
+ * remove references to Svn::* from Build.PL
+ Closes: #582739 (by working around #589812)
+
1.03:
* Synchronized versions of kgb-bot and KGB
diff --git a/debian/changelog b/debian/changelog
index 90d18a3..810efc8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,16 @@
+kgb-bot (1.05-1) unstable; urgency=low
+
+ [ gregor herrmann, Damyan Ivanov ]
+ * kgb-bot: use File::Which to find polygen binary; split out the
+ polygen-finding function; add libfile-which-perl to Suggests;
+ closes: #593631 -- can't access /usr/bin/polygen
+ * kgb-bot: check existence of polygen binary just before using it;
+ closes: #593633 -- dies when polygen is removed after daemon startup
+ * any problems in finding/running polygen binary are logged only when debug
+ is enabled as a counter-measure against remotely-assisted log abuse
+
+ -- Damyan Ivanov <dmn@debian.org> Fri, 10 Sep 2010 22:49:25 +0300
+
kgb-bot (1.04-1) unstable; urgency=low
* use Digest::SHA from core instead of ::SHA1
diff --git a/debian/control b/debian/control
index 073e777..53bb807 100644
--- a/debian/control
+++ b/debian/control
@@ -36,7 +36,7 @@ Depends: ${misc:Depends}, ${perl:Depends}, adduser, perl (>= 5.10),
libproc-pid-file-perl,
libyaml-perl,
kgb-client
-Suggests: polygen, libipc-run-perl
+Suggests: polygen, libipc-run-perl, libfile-which-perl
Description: IRC collaboration bot
KGB is an IRC bot, helping people work together by notifying an IRC channel
when a commit occures.
diff --git a/debian/copyright b/debian/copyright
index 8ab2b89..b902410 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -3,10 +3,12 @@ Upstream source is available frop http://alioth.debian.org/projects/kgb
Upstream authors:
Martín Ferrari <tincho@debian.org>
Damyan Ivanov <dmn@debian.org>
+ gregor herrmann <gregoa@debian.org>
Copyright:
# Copyright © 2008 Martín Ferrari
# Copyright © 2008,2009,2010 Damyan Ivanov
+# Copyright © 2010 gregor herrmann
License:
# This program is free software; you can redistribute it and/or modify it under
diff --git a/lib/App/KGB.pm b/lib/App/KGB.pm
index 2d3294d..be9c5b8 100644
--- a/lib/App/KGB.pm
+++ b/lib/App/KGB.pm
@@ -29,7 +29,7 @@ App::KGB - collabourative IRC helper
=cut
-our $VERSION = '1.04';
+our $VERSION = '1.05';
=head1 DESCRIPTION
diff --git a/script/kgb-bot b/script/kgb-bot
index 4fede8a..92b3aa2 100755
--- a/script/kgb-bot
+++ b/script/kgb-bot
@@ -6,6 +6,7 @@ use utf8;
# KGB - an IRC bot helping collaboration
# Copyright © 2008 Martín Ferrari
# Copyright © 2008,2009,2010 Damyan Ivanov
+# Copyright © 2010 gregor herrmann
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -53,7 +54,7 @@ use warnings;
use encoding 'utf8';
use open ':encoding(utf8)';
-our $VERSION = '1.04';
+our $VERSION = '1.05';
use Cwd;
@@ -79,6 +80,30 @@ sub save_progname () {
$progname = Cwd::realpath($0);
}
+sub polygen_available () {
+ unless ( eval { require IPC::Run } ) {
+ KGB->debug("error loading IPC::Run\n");
+ KGB->debug($@);
+ return undef;
+ }
+
+ unless ( eval { require File::Which } ) {
+ KGB->debug("error loading File::Which\n");
+ KGB->debug($@);
+ return undef;
+ }
+
+ my $oldpath = $ENV{PATH};
+ $ENV{PATH}='/usr/bin/:/usr/games';
+ my $polygen;
+ unless ( $polygen = File::Which::which('polygen') ) {
+ KGB->debug("missing polygen binary\n");
+ }
+ $ENV{PATH} = $oldpath;
+
+ return $polygen;
+}
+
sub read_conf ($) {
my $file = shift;
@@ -112,23 +137,6 @@ sub read_conf ($) {
unless ( defined $conf->{min_protocol_ver} );
$conf->{smart_answers} ||= ["My master told me to not respond."];
- if ( $conf->{smart_answers_polygen} ) {
- unless ( eval { require IPC::Run } ) {
- KGB->out(
- "Disabling smart_answers_polygen due to an error loading IPC::Run\n"
- );
- KGB->out($@);
- $conf->{smart_answers_polygen} = 0;
- }
-
- unless ( -x '/usr/bin/polygen' ) {
- KGB->out(
- "Disabling smart_answers_polygen due to missing /usr/bin/polygen\n"
- );
- $conf->{smart_answers_polygen} = 0;
- }
- }
-
$conf->{admins} //= [];
ref( $conf->{admins} ) and ref( $conf->{admins} ) eq 'ARRAY'
or die "Invalid config key: 'admins'. Must be an array";
@@ -164,23 +172,6 @@ sub read_conf ($) {
unless ( $conf->{repositories}{$repo} );
push @{ $conf->{repositories}{$repo}{channels} }, $_->{name};
}
-
- if ( $_->{smart_answers_polygen} ) {
- unless ( eval { require IPC::Run; 1 } ) {
- KGB->out(
- "smart_answers_polygen disabled becouse of an error while loading IPC::Run\n"
- );
- KGB->out($@);
- $_->{smart_answers_polygen} = 0;
- }
-
- unless ( -x '/usr/bin/polygen' ) {
- KGB->out(
- "Disabling smart_answers_polygen due to missing /usr/bin/polygen\n"
- );
- $conf->{smart_answers_polygen} = 0;
- }
- }
}
my %chanidx
= map ( { $conf->{channels}[$_]{name} => $conf->{channels}[$_] }
@@ -901,28 +892,50 @@ sub irc_001 {
sub get_polygen_joke {
my ( $out, $err );
+
+ my $polygen = polygen_available();
+ return undef unless $polygen;
+
my $grammar = 'manager';
my @polygen
- = ( '/usr/bin/polygen', "/usr/share/polygen/eng/$grammar.grm" );
+ = ( $polygen, "/usr/share/polygen/eng/$grammar.grm" );
- if ( IPC::Run::run( \@polygen, \undef, \$out, \$err ) ) {
+ my $result = eval { IPC::Run::run( \@polygen, \undef, \$out, \$err ) };
+ if ($@) {
+ KGB->debug( "Error while running " . join( ' ', @polygen ) . ": $@" );
+ return undef;
+ }
+ elsif ($result) {
return $out;
}
else {
- KGB->out( "Error while running " . join( ' ', @polygen ) . ": $err" );
- return "poly error";
+ KGB->debug( "Error while running " . join( ' ', @polygen ) . ": $err" );
+ return undef;
}
}
sub get_smart_answer {
my $chan = shift;
- return get_polygen_joke
- if $KGB::config->{chanidx}{$chan}{smart_answers_polygen};
+
+ # Channel config
+ if ( $KGB::config->{chanidx}{$chan}{smart_answers_polygen} ) {
+ my $polygen_joke = get_polygen_joke;
+
+ return $polygen_joke if $polygen_joke;
+ }
+
my $smart_answers = $KGB::config->{chanidx}{$chan}{smart_answers}
if $chan;
return $smart_answers->[ ( int( rand( scalar(@$smart_answers) ) ) ) ]
if $smart_answers;
- return get_polygen_joke if $KGB::config->{smart_answers_polygen};
+
+ # Global config
+ if ( $KGB::Config->{smart_answers_polygen} ) {
+ my $polygen_joke = get_polygen_joke;
+
+ return $polygen_joke if $polygen_joke;
+ }
+
$smart_answers = $KGB::config->{smart_answers};
return $smart_answers->[ ( int( rand( scalar(@$smart_answers) ) ) ) ]
if $smart_answers;
Reply to: