Subject: Re: DEINSTALL scripts for daemon packages
To: Thomas Klausner <>
From: Greg A. Woods <>
List: tech-pkg
Date: 05/24/2001 23:43:38
[ On Friday, May 25, 2001 at 04:00:11 (+0200), Thomas Klausner wrote: ]
> Subject: Re: DEINSTALL scripts for daemon packages
> Actually, I don't think this is true. Or anyway, it is exactly as good
> as REQ.
> If you look at src/usr.sbin/pkg_install/delete/perform.c around line
> 604, you see that REQ (if it exists) is executed with a DEINSTALL
> argument exactly one block before DEINSTALL (if it exists, and is not
> ignored by the -D option to pkg_delete) is executed with a DEINSTALL
> argument _after_ which we call delete_package().

uh huh.....
> So DEINSTALL is perfectly capable of replacing REQ in this regard.

No, I don't think so.  At least not unless a PRE-DEINSTALL action is put
in place to replace it.  According to the documentation (which I treat
with more weight in this case than the source since the undocumented
behaiour might change without warning):

     If a deinstall script exists for the package, it is executed before and
     after any files are removed.  It is this script's responsibility to clean
     up any additional messy details around the package's installation, since
     all pkg_delete knows how to do is delete the files created in the origi-
     nal distribution.  The deinstall script is called as:
           deinstall <pkg-name> DEINSTALL
     before deleting all files and as:
           deinstall <pkg-name> POST-DEINSTALL
     after deleting them. Passing the keywords DEINSTALL and POST-DEINSTALL
     lets you potentially write only one program/script that handles all as-
     pects of installation and deletion.

Notice that no mention is made of handing a "failure" of the "deinstall
pkg DEINSTALL" execution -- it just claims to blast onwards (now the
source differs here, and I'm not sure which is wrong).

However all these PRE- and POST- actions are ugly hacks if they're
mis-used in place of the real `require' script:

     If the package contains a require file (see pkg_create(1)), then this is
     executed first as
           require <pkg-name> DEINSTALL
     (where pkg-name is the name of the package in question and DEINSTALL is a
     keyword denoting that this is a deinstallation) to see whether or not de-
     installation should continue.  A non-zero exit status means no, unless
     the -f option is specified.

Perhaps I'm not doing justice to the design I perceive in the pkg* tools
and you should instead ask Jordan Hubbard for his thoughts on the matter.

> Sorry, we don't seem to have a POST-DEINSTALL right now, neither via
> REQ nor via DEINSTALL. The closest thing you can do to work around
> this (if you really need it) is to add some @unexec calls to the

Yes, we sure do!  RTFM!  UTSL!  :-)

/*      $NetBSD: perform.c,v 1.32 2001/03/04 18:16:43 hubertf Exp $     */

just a little further down around line 645:

        if (!NoDeInstall && fexists(DEINSTALL_FNAME)) {
                if (Fake)
                        printf("Would execute post-de-install script at this point (arg: POST-DEINSTALL).\n");
                else {
                        vsystem("chmod +x %s", DEINSTALL_FNAME);        /* make sure */
                        if (vsystem("./%s %s POST-DEINSTALL", DEINSTALL_FNAME, pkg)) {
                                warnx("post-deinstall script returned error status");
                                if (!Force)
                                        return 1;

> So, can we skip discussing the deceased REQ and go back to discussing
> what new functionality we need, if we really need any?

Since it already exists in the form of the `require' script I really
cannot see the point to any further pointless discussion.  Just use it!

							Greg A. Woods

+1 416 218-0098      VE3TCP      <>     <>
Planix, Inc. <>;   Secrets of the Weird <>