Mailing List Archive

How should I kill a daemon from an ebuild file?
Hi,

I have an ebuild (see below) for a small keyring daemon. I would like to
kill the daemon process, if it is running, whenever it is emerged again
to ensure that no running daemon process refers to an old install.

Is there a clean and recommended way of doing this in an ebuild or
should I just use killall in pkg_postinst()?

Or is this ultimately a big no-no??

Thanks,
jules



#
# Ebuild file for the Brutus Keyring.
# Copyright (C) 2007 OMC Denmark ApS
#
# 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 Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
# Please see http://gentoo-wiki.com/HOWTO_Installing_3rd_Party_Ebuilds
# on how to use this ebuild file.
#
# $Header: $

inherit eutils

DESCRIPTION="Brutus Keyring daemon"
HOMEPAGE="http://www.omesc.com/"
SRC_URI="http://www.omesc.com/sites/default/files/downloads/dist/brutus-keyring/Gentoo/brutus-keyring-0.9.3.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~x86 ~amd64"

IUSE="debug"
RESTRICT="nomirror"

DEPEND=">=gnome-base/orbit-2.14.1
>=dev-libs/libIDL-0.8.5
>=dev-util/pkgconfig-0.20
>=dev-libs/libgcrypt-1.2.2
gnome-base/gnome-common"

DOCS="COPYING README INSTALL docs/brutus-keyring-guide docs/brutus-keyring-devel-guide"

src_compile() {
BRUTUS_ECONF="--enable-brutus-dist=yes \
--enable-brutus-devel=yes \
--enable-brutus-target=gentoo \
$(use_enable debug brutus-debug yes)"

econf ${BRUTUS_ECONF} || die "econf failed"
emake || die "emake failed"
}

src_install() {
emake DESTDIR="${D}" install || die "emake install failed"
dodoc ${DOCS}
}


pkg_postinst() {
elog "brutus-keyring has been installed"
}

--
gentoo-dev@gentoo.org mailing list
Re: How should I kill a daemon from an ebuild file? [ In reply to ]
Jules Colding <colding@omesc.com> yazmış:
> Hi,
>
> I have an ebuild (see below) for a small keyring daemon. I would like to
> kill the daemon process, if it is running, whenever it is emerged again
> to ensure that no running daemon process refers to an old install.
>
> Is there a clean and recommended way of doing this in an ebuild or
> should I just use killall in pkg_postinst()?
>
> Or is this ultimately a big no-no??
>

Have a look at pkg_setup functions in postfix ebuilds. This can give you
an idea about how to do it properly.

--
ali polatel (hawking)
Re: How should I kill a daemon from an ebuild file? [ In reply to ]
On Fri, 27 Jul 2007 15:52:13 +0200
Jules Colding <colding@omesc.com> wrote:

> Or is this ultimately a big no-no??

I have seen some ebuilds touching "my processes", usually when it goes
wrong and the ebuild messes up. See for example
<https://bugs.gentoo.org/129204>.

To me ebuilds should build, install and uninstall packages, and should
never interfere with the live system when it isn't necessary, i.e. not
when it's just a matter of convenience.

So yes, to me this is a "big no-no".


Kind regards,
JeR
--
gentoo-dev@gentoo.org mailing list
Re: How should I kill a daemon from an ebuild file? [ In reply to ]
On Friday 27 July 2007, Jules Colding wrote:
> Or is this ultimately a big no-no??

it's a big no-no. the only thing that is valid is sending a message to a
running daemon to tell it that it needs to restart itself.

problems with launching a daemon from an ebuild:
- inherits bloated portage environment
- screws up systems when package is:
- emerged into ROOT != /
- cross-compiled
- emerged inside of a chroot

guess i should get this actually documented ...
-mike
Re: Re: How should I kill a daemon from an ebuild file? [ In reply to ]
On Friday 27 July 2007, Ali Polatel wrote:
> Have a look at pkg_setup functions in postfix ebuilds. This can give you
> an idea about how to do it properly.

that isnt half bad, but still not good. i'd propose you should actually be
doing:
/etc/init.d/postgres --quiet status
and using that to determine the state of things

however, that is still incorrect for sure when:
- ROOT != /
- cross-compiling
-mike
Re: Re: How should I kill a daemon from an ebuild file? [ In reply to ]
On Fri, 2007-07-27 at 11:14 -0400, Mike Frysinger wrote:
> On Friday 27 July 2007, Ali Polatel wrote:
> > Have a look at pkg_setup functions in postfix ebuilds. This can give you
> > an idea about how to do it properly.
>
> that isnt half bad, but still not good. i'd propose you should actually be
> doing:
> /etc/init.d/postgres --quiet status
> and using that to determine the state of things

Just to note, baselayout-1 is a little wierd like that as in it's not
exactly quiet if init script dependencies need to be updated.

Also, if the rev-bump relies on a new init script then you're SOL as
it's not etc-updated.

So although what Mike posted is correct, there's also a good chance It
Just Won't Work (TM)

So that's another argument for no.

Thanks

Roy

--
gentoo-dev@gentoo.org mailing list
Re: Re: How should I kill a daemon from an ebuild file? [ In reply to ]
On Friday 27 July 2007, Roy Marples wrote:
> On Fri, 2007-07-27 at 11:14 -0400, Mike Frysinger wrote:
> > On Friday 27 July 2007, Ali Polatel wrote:
> > > Have a look at pkg_setup functions in postfix ebuilds. This can give
> > > you an idea about how to do it properly.
> >
> > that isnt half bad, but still not good. i'd propose you should actually
> > be doing:
> > /etc/init.d/postgres --quiet status
> > and using that to determine the state of things
>
> Just to note, baselayout-1 is a little wierd like that as in it's not
> exactly quiet if init script dependencies need to be updated.

... which will be fixed

> Also, if the rev-bump relies on a new init script then you're SOL as
> it's not etc-updated.

the check is in pkg_setup, so this isnt an issue ... but this could easily be
true for any checking after the package is installed
-mike