On Wed, 2011-01-19 at 16:22 +0100, Denys Vlasenko wrote:
As discussed, here is the patch
which moves (de)installation of abrt-hook-ccpp
into abrt-ccpp service. It is packaged and installed with
abrt-addon-ccpp package.
In order to not install it twice, "old" plugin loading in abrtd
is disabled (pending deletion of entire "old" plugin machinery).
Run-tested.
Updated version.
Main addition is flag file /var/lock/subsys/abrt-ccpp
- it makes GUI service took to properly see "started/stopped"
service status.
Another addition is proper service (de)installation on package
(de)installation.
--
vda
diff -x '*.po' -d -urpN abrt.3/abrt-ccpp.init abrt.4/abrt-ccpp.init
--- abrt.3/abrt-ccpp.init 1970-01-01 01:00:00.000000000 +0100
+++ abrt.4/abrt-ccpp.init 2011-01-19 16:55:53.194817137 +0100
@@ -0,0 +1,129 @@
+#!/bin/bash
+# Install abrt coredump hook
+#
+# chkconfig: 35 82 16
+# description: Installs coredump handler which saves segfault data
+### BEGIN INIT INFO
+# Provides: abrt-ccpp
+# Required-Start: $abrtd
+# Default-Stop: 0 1 2 6
+# Default-Start: 3 5
+# Short-Description: Installs coredump handler which saves segfault data
+# Description: Installs coredump handler which saves segfault data
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# For debugging
+dry_run=false
+verbose=false
+
+# We don't have pid files, therefore have to use
+# a flag file in /var/lock/subsys to enable GUI service tools
+# to figure out our status
+LOCK="/var/lock/subsys/abrt-ccpp"
+
+PATTERN_FILE="/proc/sys/kernel/core_pattern"
+SAVED_PATTERN_FILE="/var/run/abrt/saved_core_pattern"
+HOOK_BIN="/usr/libexec/abrt-hook-ccpp"
+PATTERN="|$HOOK_BIN /var/spool/abrt %s %c %p %u %g %t %h %e"
+
+RETVAL=0
+
+check() {
+ # Check that we're a privileged user
+ [ "`id -u`" = 0 ] || exit 4
+}
+
+start() {
+ check
+
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+
+ $verbose && printf "cur:'%s'\n" "$cur"
+ # Is it already installed?
+ if test x"$cur_first" != x"|$HOOK_BIN"; then # no
+ # It is not installed
+ printf "%s\n" "$cur" >"$SAVED_PATTERN_FILE"
+ OLD_PATTERN=""
+ # Does old pattern start with '|'?
+ if test x"${cur#|}" = x"$cur"; then # no
+ # Encode it as hex string, NUL terminated
+ OLD_PATTERN=`printf "%s" "$cur" | od -tx1 | sed 's/000[^
]*//' | xargs | sed 's/ //g'`
+ $verbose && printf "OLD_PATTERN:'%s'\n"
"$OLD_PATTERN"
+ OLD_PATTERN=" ${OLD_PATTERN}00"
+ fi
+ # Install new handler
+ $verbose && printf "Installing to %s:'%s'\n"
"$PATTERN_FILE" "${PATTERN}${OLD_PATTERN}"
+ $dry_run || echo "${PATTERN}${OLD_PATTERN}" >"$PATTERN_FILE"
+ $dry_run || touch -- "$LOCK"
+ fi
+ return $RETVAL
+}
+
+stop() {
+ check
+
+ if test -f "$SAVED_PATTERN_FILE"; then
+ $verbose && printf "Restoring to %s:'%s'\n"
"$PATTERN_FILE" "`cat "$SAVED_PATTERN_FILE"`"
+ $dry_run || cat "$SAVED_PATTERN_FILE" >"$PATTERN_FILE"
+ fi
+ $dry_run || rm -f -- "$LOCK"
+ return $RETVAL
+}
+
+restart() {
+ stop
+ start
+}
+
+reload() {
+ restart
+}
+
+case "$1" in
+start)
+ start
+ ;;
+stop)
+ stop
+ ;;
+reload)
+ reload
+ ;;
+force-reload)
+ echo "$0: Unimplemented feature."
+ RETVAL=3
+ ;;
+restart)
+ restart
+ ;;
+condrestart)
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+ # Is it already installed?
+ if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
+ $verbose && printf "Installed, re-installing\n"
+ restart
+ fi
+ ;;
+status)
+ cur=`cat "$PATTERN_FILE"`
+ cur_first=`printf "%s" "$cur" | sed 's/ .*//'`
+ # Is it already installed?
+ if test x"$cur_first" = x"|$HOOK_BIN"; then # yes
+ $verbose && printf "Installed\n"
+ RETVAL=0
+ else
+ $verbose && printf "Not installed\n"
+ RETVAL=3 # "stopped normally"
+ fi
+ ;;
+*)
+ echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
+ RETVAL=2
+esac
+
+exit $RETVAL
diff -x '*.po' -d -urpN abrt.3/abrt.init abrt.4/abrt.init
--- abrt.3/abrt.init 2011-01-19 16:14:01.998817628 +0100
+++ abrt.4/abrt.init 2011-01-19 15:22:34.084565885 +0100
@@ -2,7 +2,7 @@
# Starts the abrt daemon
#
# chkconfig: 35 82 16
-# description: Daemon to detect crashing apps
+# description: Saves segfault data, kernel oopses, fatal exceptions
# processname: abrtd
### BEGIN INIT INFO
# Provides: abrt
@@ -10,8 +10,8 @@
# Required-Stop: $syslog $local_fs
# Default-Stop: 0 1 2 6
# Default-Start: 3 5
-# Short-Description: start and stop abrt daemon
-# Description: Listen to and dispatch crash events
+# Short-Description: Saves segfault data, kernel oopses, fatal exceptions
+# Description: Saves segfault data, kernel oopses, fatal exceptions
### END INIT INFO
# Source function library.
diff -x '*.po' -d -urpN abrt.3/abrt.spec abrt.4/abrt.spec
--- abrt.3/abrt.spec 2011-01-17 16:42:11.797308103 +0100
+++ abrt.4/abrt.spec 2011-01-19 16:55:53.196816917 +0100
@@ -28,6 +28,7 @@ Group: Applications/System
URL:
https://fedorahosted.org/abrt/
Source:
https://fedorahosted.org/released/%{name}/%{name}-%{version}.tar.gz
Source1: abrt.init
+Source2: abrt-ccpp.init
BuildRequires: dbus-devel
BuildRequires: gtk2-devel
BuildRequires: curl-devel
@@ -250,6 +251,7 @@ make install DESTDIR=$RPM_BUILD_ROOT man
find $RPM_BUILD_ROOT -name '*.la' -or -name '*.a' | xargs rm -f
mkdir -p ${RPM_BUILD_ROOT}/%{_initrddir}
install -m 755 %SOURCE1 ${RPM_BUILD_ROOT}/%{_initrddir}/abrtd
+install -m 755 %SOURCE2 ${RPM_BUILD_ROOT}/%{_initrddir}/abrt-ccpp
# /var/cache/abrt is to be removed in 1.3.x timeframe
mkdir -p $RPM_BUILD_ROOT/var/cache/abrt
mkdir -p $RPM_BUILD_ROOT/var/cache/abrt-di
@@ -277,29 +279,42 @@ exit 0
%post
if [ $1 -eq 1 ]; then
-/sbin/chkconfig --add %{name}d
+/sbin/chkconfig --add abrtd
fi
#systemd
%if %{?with_systemd}
#if [ $1 -eq 1 ]; then
# Enable (but don't start) the units by default
- /bin/systemctl enable %{name}d.service >/dev/null 2>&1 || :
+ /bin/systemctl enable abrtd.service >/dev/null 2>&1 || :
#fi
%endif
+%post addon-ccpp
+if [ $1 -eq 1 ]; then
+/sbin/chkconfig --add abrt-ccpp
+fi
+#systemd: TODO
+
%preun
if [ "$1" -eq "0" ] ; then
- service %{name}d stop >/dev/null 2>&1
- /sbin/chkconfig --del %{name}d
+ service abrtd stop >/dev/null 2>&1
+ /sbin/chkconfig --del abrtd
fi
#systemd
%if %{?with_systemd}
if [ "$1" -eq "0" ] ; then
- /bin/systemctl stop %{name}d.service >/dev/null 2>&1 || :
- /bin/systemctl disable %{name}d.service >/dev/null 2>&1 || :
+ /bin/systemctl stop abrtd.service >/dev/null 2>&1 || :
+ /bin/systemctl disable abrtd.service >/dev/null 2>&1 || :
fi
%endif
+%preun addon-ccpp
+if [ "$1" -eq "0" ] ; then
+ service abrt-ccpp stop >/dev/null 2>&1
+ /sbin/chkconfig --del abrt-ccpp
+fi
+#systemd: TODO
+
%postun
#systemd
%if %{?with_systemd}
@@ -328,15 +343,21 @@ fi
%posttrans
if [ "$1" -eq "0" ]; then
- service %{name}d condrestart >/dev/null 2>&1 || :
+ service abrtd condrestart >/dev/null 2>&1 || :
fi
#systemd
%if %{?with_systemd}
if [ "$1" -eq "0" ]; then
- /bin/systemctl try-restart %{name}d.service >/dev/null 2>&1 || :
+ /bin/systemctl try-restart abrtd.service >/dev/null 2>&1 || :
fi
%endif
+%posttrans addon-ccpp
+if [ "$1" -eq "0" ]; then
+ service abrt-ccpp condrestart >/dev/null 2>&1 || :
+fi
+#systemd: TODO
+
%files -f %{name}.lang
%defattr(-,root,root,-)
@@ -354,7 +375,7 @@ fi
%config(noreplace) %{_sysconfdir}/%{name}/abrt_event.conf
%config(noreplace) %{_sysconfdir}/%{name}/gpg_keys
%config(noreplace) %{_sysconfdir}/dbus-1/system.d/dbus-abrt.conf
-%{_initrddir}/%{name}d
+%{_initrddir}/abrtd
# /var/cache/abrt is to be removed in 1.3.x timeframe
%dir %attr(0755, abrt, abrt) %{_localstatedir}/cache/%{name}
%dir %attr(0755, abrt, abrt) %{_localstatedir}/spool/%{name}
@@ -414,6 +435,7 @@ fi
%defattr(-,root,root,-)
%config(noreplace) %{_sysconfdir}/%{name}/plugins/CCpp.conf
%dir %{_localstatedir}/cache/abrt-di
+%{_initrddir}/abrt-ccpp
%{_libdir}/%{name}/libCCpp.so*
%{_libexecdir}/abrt-hook-ccpp
%{_bindir}/abrt-action-analyze-c
diff -x '*.po' -d -urpN abrt.3/src/daemon/Daemon.cpp abrt.4/src/daemon/Daemon.cpp
--- abrt.3/src/daemon/Daemon.cpp 2011-01-17 17:07:14.011558651 +0100
+++ abrt.4/src/daemon/Daemon.cpp 2011-01-19 15:51:09.153816135 +0100
@@ -676,10 +676,6 @@ int main(int argc, char** argv)
handle_inotify_cb,
NULL);
- VERB1 log("Loading plugins from "PLUGINS_LIB_DIR);
- g_pPluginManager = new CPluginManager();
- g_pPluginManager->LoadPlugins();
-
/* Add an event source which waits for INT/TERM signal */
VERB1 log("Adding signal pipe watch to glib main loop");
channel_signal = g_io_channel_unix_new(s_signal_pipe[0]);
@@ -771,12 +767,7 @@ int main(int argc, char** argv)
g_io_channel_unref(channel_inotify);
delete g_pCommLayer;
- if (g_pPluginManager)
- {
- /* This restores /proc/sys/kernel/core_pattern, among other things: */
- g_pPluginManager->UnLoadPlugins();
- delete g_pPluginManager;
- }
+
if (pMainloop)
g_main_loop_unref(pMainloop);