[kgb-bot] Initial import.

averi averi at fedoraproject.org
Mon May 13 14:04:39 UTC 2013


commit ef189b94b6d10a24e80f0bf4a6e85de2bccf7e98
Author: Andrea Veri <av at gnome.org>
Date:   Mon May 13 16:04:28 2013 +0200

    Initial import.

 .gitignore                           |    1 +
 JSON-RPC-to-JSON-Legacy-Client.patch |   75 +++++++++++++
 kgb-bot.init                         |  190 ++++++++++++++++++++++++++++++++++
 kgb-bot.service                      |   14 +++
 kgb-bot.spec                         |  190 ++++++++++++++++++++++++++++++++++
 sources                              |    1 +
 6 files changed, 471 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..3485ddd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/kgb-bot-1.26-20130512svn880.tar.gz
diff --git a/JSON-RPC-to-JSON-Legacy-Client.patch b/JSON-RPC-to-JSON-Legacy-Client.patch
new file mode 100644
index 0000000..f207097
--- /dev/null
+++ b/JSON-RPC-to-JSON-Legacy-Client.patch
@@ -0,0 +1,75 @@
+--- App-KGB-1.26/Build.PL	2013-05-12 23:22:50.000000000 +0200
++++ App-KGB-1.26-modified/Build.PL	2013-05-12 23:30:24.589191261 +0200
+@@ -34,7 +34,7 @@
+         'IPC::Run'                     => 0,
+         'IPC::System::Simple'          => 0,
+         'JSON'                         => 0,
+-        'JSON::RPC::Client'            => 0,
++        'JSON::RPC::Legacy::Client'    => 0,
+         'POE'                          => 0,
+         'POE::Component::IRC'          => '5.56',
+         'POE::Component::Server::SOAP' => 0,
+--- App-KGB-1.26/lib/App/KGB/Client/ServerRef.pm	2013-05-12 23:22:50.000000000 +0200
++++ App-KGB-1.26-modified/lib/App/KGB/Client/ServerRef.pm	2013-05-12 23:31:26.733572730 +0200
+@@ -264,8 +264,8 @@
+     my ( $self, $repo_id, $message ) = @_;
+ 
+     require JSON;
+-    require JSON::RPC::Client;
+-    my $rpc = JSON::RPC::Client->new();
++    require JSON::RPC::Legacy::Client;
++    my $rpc = JSON::RPC::Legacy::Client->new();
+     $rpc->ua->timeout($self->timeout // 15);
+     $message->{id} = 1;
+     $message->{version} = '1.1';
+--- App-KGB-1.26/lib/WWW/Shorten/Debli.pm	2013-05-12 23:22:50.000000000 +0200
++++ App-KGB-1.26-modified/lib/WWW/Shorten/Debli.pm	2013-05-12 23:32:26.423977755 +0200
+@@ -27,7 +27,7 @@
+ our $VERSION = '0.1';
+ 
+ use Carp;
+-use JSON::RPC::Client;
++use JSON::RPC::Legacy::Client;
+ 
+ our $RPC_URL = 'http://deb.li/rpc/json';
+ 
+@@ -44,7 +44,7 @@
+ 
+ sub makeashorterlink {
+     my $url = shift or croak 'No URL passed to makeashorterlink';
+-    my $rpc = JSON::RPC::Client->new();
++    my $rpc = JSON::RPC::Legacy::Client->new();
+     my $res
+         = $rpc->call( $RPC_URL => { method => 'add_url', params => [$url] } );
+     return undef unless $res;
+@@ -66,7 +66,7 @@
+ sub makealongerlink {
+     my $key = shift or croak 'No key / URL passed to makealongerlink';
+     $key =~ s,^http://deb.li/,,;
+-    my $rpc = JSON::RPC::Client->new();
++    my $rpc = JSON::RPC::Legacy::Client->new();
+     my $res
+         = $rpc->call( $RPC_URL => { method => 'get_url', params => [$key] } );
+     return undef unless $res;
+--- App-KGB-1.26/META.json	2013-05-12 23:22:49.000000000 +0200
++++ App-KGB-1.26-modified/META.json	2013-05-12 23:32:44.680795635 +0200
+@@ -48,7 +48,7 @@
+             "IPC::Run" : "0",
+             "IPC::System::Simple" : "0",
+             "JSON" : "0",
+-            "JSON::RPC::Client" : "0",
++            "JSON::RPC::Legacy::Client" : "0",
+             "POE" : "0",
+             "POE::Component::IRC" : "5.56",
+             "POE::Component::Server::SOAP" : "0",
+--- App-KGB-1.26/META.yml	2013-05-12 23:22:49.000000000 +0200
++++ App-KGB-1.26-modified/META.yml	2013-05-12 23:33:03.268610154 +0200
+@@ -74,7 +74,7 @@
+   IPC::Run: 0
+   IPC::System::Simple: 0
+   JSON: 0
+-  JSON::RPC::Client: 0
++  JSON::RPC::Legacy::Client: 0
+   POE: 0
+   POE::Component::IRC: 5.56
+   POE::Component::Server::SOAP: 0
diff --git a/kgb-bot.init b/kgb-bot.init
new file mode 100644
index 0000000..0c755e2
--- /dev/null
+++ b/kgb-bot.init
@@ -0,0 +1,190 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides:          kgb-bot
+# Required-Start:    $remote_fs $network
+# Required-Stop:     $remote_fs $network
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Collaborative IRC helper
+# Description:       KGB is an IRC bot, helping people work together by
+#                    notifying an IRC channel when a commit occures.
+### END INIT INFO
+
+# Author: Damyan Ivanov <dmn at debian.org>
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="Collaborative IRC helper"
+NAME=kgb-bot
+DAEMON=/usr/sbin/$NAME
+DAEMON_ARGS="--config /etc/kgb-bot/kgb.conf"
+PIDFILE=/var/run/kgb-bot/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+RUN_AS='Fedora-kgb'
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# create /var/run/kgb-bot and ensure right permissions
+#
+init_run_dir()
+{
+    RUN_DIR="/var/run/$NAME"
+    [ -d "$RUN_DIR" ] || mkdir "$RUN_DIR" || return 1
+
+    chown "$RUN_AS":root "$RUN_DIR"
+    chmod 0775 "$RUN_DIR"
+
+    return 0
+}
+
+#
+# create /var/log/kgb-bot.log and ensure right permissions
+#
+init_log_file() {
+    LOG=/var/log/kgb-bot.log
+
+    if ! test -e $LOG; then
+        touch $LOG
+        chown "$RUN_AS":root $LOG
+        chmod 0644 $LOG
+    fi
+}
+
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+	# Return
+	#   0 if daemon has been started
+	#   1 if daemon was already running
+	#   2 if daemon could not be started
+        init_run_dir || return 2
+        init_log_file || return 2
+	start-stop-daemon --start --quiet --chuid $RUN_AS --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+		|| return 1
+	start-stop-daemon --start --quiet --chuid $RUN_AS --pidfile $PIDFILE --exec $DAEMON -- \
+		$DAEMON_ARGS \
+		|| return 2
+	# Add code here, if necessary, that waits for the process to be ready
+	# to handle requests from services started subsequently which depend
+	# on this one.  As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+	# Return
+	#   0 if daemon has been stopped
+	#   1 if daemon was already stopped
+	#   2 if daemon could not be stopped
+	#   other if a failure occurred
+	start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+	RETVAL="$?"
+	[ "$RETVAL" = 2 ] && return 2
+	# Wait for children to finish too if this is a daemon that forks
+	# and if the daemon is only ever run from this initscript.
+	# If the above conditions are not satisfied then add some other code
+	# that waits for the process to drop all resources that could be
+	# needed by services started subsequently.  A last resort is to
+	# sleep for some time.
+	start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+	[ "$?" = 2 ] && return 2
+	# Many daemons don't delete their pidfiles when they exit.
+	rm -f $PIDFILE
+	return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+	init_log_file || return 2
+	start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+	return 0
+}
+
+#
+# Function that sends a SIGQUIT to the daemon/service
+#
+do_soft_restart() {
+	init_log_file || return 2
+	start-stop-daemon --stop --signal 3 --quiet --pidfile $PIDFILE --name $NAME
+	return 0
+}
+
+case "$1" in
+  start)
+	[ "$BOT_ENABLED" != "1" ] && echo $DAEMON disabled in /etc/default/$NAME>&2 && exit 0
+
+	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+	do_start
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  stop)
+	[ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+	do_stop
+	case "$?" in
+		0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+		2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+	esac
+	;;
+  status)
+	status_of_proc -p "$PIDFILE" "$DAEMON" "$NAME" && exit 0 || exit $?
+	;;
+  soft-restart)
+	log_daemon_msg "Reloading $DESC" "$NAME"
+	do_soft_restart
+	log_end_msg $?
+	;;
+  reload|force-reload)
+	log_daemon_msg "Reloading $DESC" "$NAME"
+	do_reload
+	log_end_msg $?
+	;;
+  restart)
+	log_daemon_msg "Restarting $DESC" "$NAME"
+	do_stop
+	case "$?" in
+	  0|1)
+		do_start
+		case "$?" in
+			0) log_end_msg 0 ;;
+			1) log_end_msg 1 ;; # Old process is still running
+			*) log_end_msg 1 ;; # Failed to start
+		esac
+		;;
+	  *)
+		# Failed to stop
+		log_end_msg 1
+		;;
+	esac
+	;;
+  *)
+	echo "Usage: $SCRIPTNAME {start|stop|restart|force-restart|reload|force-reload}" >&2
+	#echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/kgb-bot.service b/kgb-bot.service
new file mode 100644
index 0000000..df9110f
--- /dev/null
+++ b/kgb-bot.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=IRC Collaboration Bot
+After=syslog.target network.target
+
+[Service]
+Type=forking
+User=Fedora-kgb
+Group=Fedora-kgb
+PIDFile=/var/run/kgb-bot/kgb-bot.pid
+ExecStart=/usr/sbin/kgb-bot
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/kgb-bot.spec b/kgb-bot.spec
new file mode 100644
index 0000000..f495d3d
--- /dev/null
+++ b/kgb-bot.spec
@@ -0,0 +1,190 @@
+Name:		kgb-bot
+Summary:	IRC Collaboration Bot
+Version:	1.26
+Release:	20130512svn880%{dist}
+License:	GPLv2+
+Group:		Applications/Internet
+URL:		http://kgb.alioth.debian.org
+Buildarch:	noarch
+# Produce via 'svn export -r880 svn://anonscm.debian.org/kgb/ App-KGB-1.26'
+# tar -czvf kgb-bot-1.26-20130512svn880.tar.gz App-KGB-1.26
+Source:		%{name}-%{version}-20130512svn880.tar.gz
+Source1:	%{name}.service
+Source2:	%{name}.init
+Patch0:		JSON-RPC-to-JSON-Legacy-Client.patch
+AutoReq:	0
+BuildRequires:	perl
+BuildRequires:	perl(Module::Build)
+BuildRequires:	perl(Class::Accessor)
+BuildRequires:	perl(File::Touch)
+BuildRequires:	perl(IPC::Run)
+BuildRequires:	perl(IPC::System::Simple)
+BuildRequires:	perl(JSON)
+BuildRequires:	perl(JSON::RPC::Legacy::Client)
+BuildRequires:	perl(POE)
+BuildRequires:	perl(POE::Component::IRC)
+BuildRequires:	perl(POE::Component::Server::SOAP)
+BuildRequires:	perl(Proc::PID::File)
+BuildRequires:	perl(SOAP::Lite)
+BuildRequires:	perl(Schedule::RateLimiter)
+BuildRequires:	perl(Time::Piece)
+BuildRequires:	perl(WWW::Shorten)
+BuildRequires:	perl(YAML)
+BuildRequires:	subversion-perl
+BuildRequires:	git-core
+BuildRequires:	perl(Digest::SHA)
+BuildRequires:	perl(Test::Compile)
+BuildRequires:	perl(Test::Perl::Critic)
+BuildRequires:	perl(Test::Pod)
+BuildRequires:	perl(Test::Pod::Coverage)
+BuildRequires:	%{_sbindir}/useradd
+BuildRequires:	%{_sbindir}/groupadd
+Requires:	perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+Requires:	%{name}-client = %{version}-%{release}
+%if 0%{?fedora} >= 15
+BuildRequires:	systemd-units
+Requires(post):	systemd-units
+Requires(preun):	systemd-units
+Requires(postun):	systemd-units
+%else
+Requires(post):	chkconfig
+Requires(preun):	chkconfig
+Requires(preun):	initscripts
+%endif
+
+%description
+KGB is an IRC bot, helping people work together by notifying an IRC channel
+when a commit occurs. It supports multiple repositories/IRC channels and is
+fully configurable.
+
+%package client
+Summary:	The kgb-bot's client	
+Group:		Applications/Internet
+AutoReq:	0
+Requires:	perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+Requires:	perl(Class::Accessor)
+Requires:	perl(SOAP::Lite)
+Requires:	subversion-perl
+Requires:	perl(YAML)
+
+%description client
+This package contains the client-side program, kgb-client, which is supposed
+to be used as an hook in your version control system and sends the
+notifications to the KGB daemon. Currently supported version control
+systems are: Subversion, Git (via kgb-client-git package), CVS.
+
+%package client-git
+Summary:	The kgb-bot's client
+Group:		Applications/Internet
+AutoReq:	0
+Requires:	perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+Requires:	git-core
+Requires:	%{name}-client = %{version}-%{release}
+Requires:	perl(IPC::Run)
+
+%description client-git
+This package adds support of Git version control system to kgb-client.
+
+%prep
+%setup -q -n App-KGB-%{version}
+%patch0 -p1
+
+%pre
+getent group Fedora-kgb >/dev/null || groupadd -r Fedora-kgb
+getent passwd Fedora-kgb >/dev/null || useradd -r -g Fedora-kgb -M -s /sbin/nologin Fedora-kgb
+exit 0
+
+%preun
+%if 0%{?fedora} >= 15
+if [ $1 -eq 0 ] ; then
+    # Package removal, not upgrade
+    /bin/systemctl --no-reload disable %{name}.service > /dev/null 2>&1 || :
+    /bin/systemctl stop %{name}.service > /dev/null 2>&1 || :
+fi
+%else
+if [ $1 -eq 0 ] ; then
+   /sbin/service %{name} stop > /dev/null 2>&1 ||:
+   /sbin/chkconfig --del %{name}
+fi
+%endif
+
+%post
+%if 0%{?fedora} >= 15
+if [ $1 -eq 1 ] ; then 
+    /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%else
+/sbin/chkconfig --add %{name}
+%endif
+
+%postun
+%if 0%{?fedora} >= 15
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+if [ $1 -ge 1 ] ; then
+    # Package upgrade, not uninstall
+    /bin/systemctl try-restart %{name}.service >/dev/null 2>&1 || :
+fi
+%else
+if [ $1 -ge 1 ] ; then
+   /sbin/service %{name} condrestart >/dev/null 2>&1 ||:
+fi
+%endif
+
+%build
+perl Build.PL --destdir .
+./Build --installdirs vendor
+make %{?_smp_mflags}
+
+%install
+./Build install --installdirs vendor --destdir $RPM_BUILD_ROOT
+
+%if 0%{?fedora} >= 15
+%{__install} -Dp -m0644 %{SOURCE1} $RPM_BUILD_ROOT/%{_unitdir}/%{name}.service
+%else
+mkdir -p $RPM_BUILD_ROOT/%{_initrddir}/
+%{__install} -Dp -m0644 %{SOURCE2} $RPM_BUILD_ROOT/%{_sysconfdir}/init.d/%{name}
+%endif
+
+find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
+%{_fixperms} $RPM_BUILD_ROOT/*
+
+%check
+# Export an UTF8 locale since the tests demand them.
+LANG=en_US.utf8 LC_ALL=en_US.utf8
+./Build test
+
+%files
+%doc Changes LICENSE
+%config(noreplace) %{_sysconfdir}/%{name}/kgb.conf
+%attr(640, Fedora-kgb, Fedora-kgb) %{_sysconfdir}/%{name}/kgb.conf
+%{_sbindir}/kgb-split-config
+%{_sbindir}/%{name}
+%{_sbindir}/kgb-add-project
+%{_mandir}/man1/%{name}.*
+%{_mandir}/man1/kgb-split-config.*
+%{_mandir}/man1/kgb-add-project.*
+%{_mandir}/man5/kgb.conf.*
+%{_mandir}/man7/kgb-protocol.7*
+%if 0%{?fedora} >= 15
+%{_unitdir}/%{name}.service
+%else
+%{_initrddir}/%{name}
+%endif
+
+%files client
+%doc Changes eg/kgb-client.conf.sample eg/post-commit LICENSE
+%{_bindir}/kgb-client
+%{_mandir}/man1/kgb-client.*
+%{_mandir}/man3/App::KGB*
+%{_mandir}/man3/WWW::Shorten*
+%{_mandir}/man5/kgb-client.conf.*
+%{perl_vendorlib}/*
+
+%files client-git
+%doc Changes LICENSE
+%{_mandir}/man3/App::KGB::Client::Git.3pm*
+%{perl_vendorlib}/App/KGB/Client/Git.pm
+
+%changelog
+* Sat May 11 2013 Andrea Veri <averi at fedoraproject.org> - 1.26-20130512svn880
+- First package release.
diff --git a/sources b/sources
index e69de29..bcf8300 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+5c46f83aef4139fb46414b8131ae4415  kgb-bot-1.26-20130512svn880.tar.gz


More information about the scm-commits mailing list