From owner-freebsd-bugs@FreeBSD.ORG Tue May 25 06:50:02 2010 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7CA671065675 for ; Tue, 25 May 2010 06:50:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (unknown [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 4098C8FC1D for ; Tue, 25 May 2010 06:50:02 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o4P6o2Ov032090 for ; Tue, 25 May 2010 06:50:02 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o4P6o2ir032089; Tue, 25 May 2010 06:50:02 GMT (envelope-from gnats) Resent-Date: Tue, 25 May 2010 06:50:02 GMT Resent-Message-Id: <201005250650.o4P6o2ir032089@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Garrett Cooper Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 759A51065672 for ; Tue, 25 May 2010 06:45:22 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 59A778FC0A for ; Tue, 25 May 2010 06:45:22 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o4P6jM7N003342 for ; Tue, 25 May 2010 06:45:22 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id o4P6jMFq003341; Tue, 25 May 2010 06:45:22 GMT (envelope-from nobody) Message-Id: <201005250645.o4P6jMFq003341@www.freebsd.org> Date: Tue, 25 May 2010 06:45:22 GMT From: Garrett Cooper To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/146947: [ports] bsd.ports.mk incorrectly using pkg-deinstall for both deinstall and post-deinstall operations X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 May 2010 06:50:02 -0000 >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 <Fix: >Release-Note: >Audit-Trail: >Unformatted: