Date: Tue, 25 May 2010 06:45:22 GMT From: Garrett Cooper <gcooper@FreeBSD.org> To: freebsd-gnats-submit@FreeBSD.org Subject: misc/146947: [ports] bsd.ports.mk incorrectly using pkg-deinstall for both deinstall and post-deinstall operations Message-ID: <201005250645.o4P6jMFq003341@www.freebsd.org> Resent-Message-ID: <201005250650.o4P6o2ir032089@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 146947 >Category: misc >Synopsis: [ports] bsd.ports.mk incorrectly using pkg-deinstall for both deinstall and post-deinstall operations >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue May 25 06:50:01 UTC 2010 >Closed-Date: >Last-Modified: >Originator: Garrett Cooper >Release: 9-CURRENT >Organization: Cisco Systems, Inc. >Environment: FreeBSD bayonetta.local 9.0-CURRENT FreeBSD 9.0-CURRENT #0 r206173M: Mon Apr 26 22:45:06 PDT 2010 root@bayonetta.local:/usr/obj/usr/src/sys/BAYONETTA.ata amd64 >Description: pkg-deinstall as specified by the ports infrastructure is being incorrectly used as both the deinstall and post-deinstall script instead of just being the deinstall script. Example: $ sudo make deinstall ===> Deinstalling for devel/py-ctypes ===> Deinstalling py26-ctypes-1.0.2 cd: can't cd to /usr/local/lib/python%%PYVER%%/ pkg_delete: deinstall script returned error status cd: can't cd to /usr/local/lib/python%%PYVER%%/ pkg_delete: post-deinstall script returned error status $ cat pkg-deinstall #!/bin/sh PYVER='%%PYVER%%' set -e cd "$PKG_PREFIX/lib/python${PYVER}/" find -s -X . -name '*.py[co]' | xargs rm -f find -s -X . -type d | xargs rmdir -p The error was unintentional, but the outcome was interesting nonetheless. The actual problem appears to be pkg_install though (note the Note: clause): -k dscript Set dscript to be the de-install procedure for the package. This can be any executable program (or shell script). It will be invoked automatically when the package is later (if ever) de- installed. It will be passed the package's name as the first argument. Note: if the -K option is not given, this script will serve as both the de-install and the post-deinstall script for the pack- age, differentiating between the functionality by passing the keywords DEINSTALL and POST-DEINSTALL respectively, along with the package's name. This behavior doesn't make sense; the deinstall script should be executed once and only once as executing these scripts twice only serves to cause confusion in the overall execution flow. I believe that the code causing this is appears to be in delete/perform.c (in particular the second conditional block): /* * Test whether to use the old method of passing tokens to deinstallation * scripts, and set appropriate variables.. */ if (fexists(POST_DEINSTALL_FNAME)) { new_m = 1; post_script = POST_DEINSTALL_FNAME; pre_arg = post_arg = ""; } else if (fexists(DEINSTALL_FNAME)) { post_script = DEINSTALL_FNAME; pre_arg = "DEINSTALL"; post_arg = "POST-DEINSTALL"; } else { post_script = pre_arg = post_arg = NULL; } Whether or not this behavior should be deprecated is one thing, but I find it to be incredibly confusing. >How-To-Repeat: 1. Create a package with pkg_create -k foo, like the following script: cat > foo <<EOF #!/bin/sh echo "my name is \${0##*/}"; false EOF 2. Add the package. 3. Delete the package. The output from package delete will be: "my name is POST-INSTALL" >Fix: >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201005250645.o4P6jMFq003341>