From nobody@FreeBSD.org  Mon Feb  6 00:20:23 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id A948516A420
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Feb 2006 00:20:23 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 77F6843D45
	for <freebsd-gnats-submit@FreeBSD.org>; Mon,  6 Feb 2006 00:20:23 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k160KNRi029995
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 6 Feb 2006 00:20:23 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k160KNpM029994;
	Mon, 6 Feb 2006 00:20:23 GMT
	(envelope-from nobody)
Message-Id: <200602060020.k160KNpM029994@www.freebsd.org>
Date: Mon, 6 Feb 2006 00:20:23 GMT
From: Jo Rhett <jrhett@svcolo.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg_add should return a different result code if package is installed
X-Send-Pr-Version: www-2.3

>Number:         92866
>Category:       bin
>Synopsis:       pkg_add(1) should return a different result code if package is installed
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    portmgr
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Feb 06 00:30:04 GMT 2006
>Closed-Date:    Wed May 28 15:17:21 UTC 2014
>Last-Modified:  Wed May 28 15:17:21 UTC 2014
>Originator:     Jo Rhett
>Release:        6.0
>Organization:
Silicon Valley Colocation
>Environment:
FreeBSD [hostname].meer.net 6.0-RELEASE FreeBSD 6.0-RELEASE #4: Fri Nov 11 13:29:33 PST 2005
>Description:
If you try to install a package using pkg_add, and check the return code, pkg_add returns the same result (1) if it can't install the package or the package is already installed.  This makes it problematic to script.

In particular, if you install with a URL, pkg_add will recursively attempt to install the dependancies.  So if you have a list

package1
package2
package3

And you install package1, which requires package2, then both are installed (yay)

However, when you go to the next item, pkg_add will fail and if you are checking error codes it will abort.  

If pkg_add returned a different error code for an already installed package it would be easier to script.


>How-To-Repeat:
pkg_add http://somesite/package1.tbz
package1 requires package2, which it downloads and installs.

pkg_add http://somesite/package2.tbz 
echo $?  (or $status)
>Fix:
Return a different error code if the package is already installed. either 2 or -1 come to mind...
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->krion 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Mon Feb 6 01:31:02 UTC 2006 
Responsible-Changed-Why:  
Make this a 'bin' PR and assign. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92866 

From: Jo Rhett <jrhett@svcolo.com>
To: bug-followup@freebsd.org
Cc:  
Subject: Re: bin/92866: pkg_add(1) should return a different result code if package is installed
Date: Fri, 17 Feb 2006 14:02:15 -0800

 I'd like to note that I'm perfectly willing to write the patch to  
 handle this for you to review.  I just didn't want to write a patch  
 that wouldn't be accepted, or for which you had already come up with  
 a better answer.
 
 -- 
 Jo Rhett
 senior geek
 Silicon Valley Colocation
 

From: Erwin Lansing <erwin@FreeBSD.org>
To: bug-followup@FreeBSD.org, Jo Rhett <jrhett@svcolo.com>
Cc:  
Subject: Re: bin/92866: pkg_add(1)should return a different result code if package is installed
Date: Thu, 23 Nov 2006 21:19:53 +0100

 --ssZxAlvqSOvXAj81
 Content-Type: text/plain; charset=iso-8859-1
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi,
 
 Sorry for the long delay. I'm just wondering that since there are so
 many reasons why an install can fail, setting different exit codes would
 get quite a burden. Wouldn't it be easier to parse STDERR after
 encountering an exit code !=3D 0 in your scripts?
 
 pkg_add: package 'foo-0.5.11' or its older version already installed
 
 Should be enough to distinguish such error from other intall errors.
 
 Cheers,
 -erwin
 
 --=20
 Erwin Lansing                                     http://droso.org
 Security is like an onion.          (o_ _o)
 It's made up of several layers   \\\_\   /_///
 And it makes you cry.            <____) (____>    erwin@lansing.dk
 
 --ssZxAlvqSOvXAj81
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (FreeBSD)
 
 iD8DBQFFZgJpqy9aWxUlaZARAlA0AKDwfoYS0aCmJpR1Dafdd+I+307qYQCggoga
 +bzQ0McWjH5RNhuoWmbiiDE=
 =5Jru
 -----END PGP SIGNATURE-----
 
 --ssZxAlvqSOvXAj81--

From: Jo Rhett <jrhett@svcolo.com>
To: Erwin Lansing <erwin@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/92866: pkg_add(1)should return a different result code if package is installed
Date: Mon, 27 Nov 2006 13:25:33 -0800

 On Nov 23, 2006, at 12:19 PM, Erwin Lansing wrote:
 > Sorry for the long delay. I'm just wondering that since there are so
 > many reasons why an install can fail, setting different exit codes  
 > would
 > get quite a burden.
 
 My suggestion was only to alter the return code for 2 fairly common  
 and significant reasons.  From my reading of the code all of the  
 other error returns are fatal.  The two that I listed are non-fatal  
 and/or retryable errors.  That's why I made the suggestion.
 
 If the system has the exact same version installed, then the script  
 should simply continue.  In no other situation is that true.
 
 If the package was a remote repository, then retrying the package  
 install makes sense.  In no other situation is that true.
 
 > Wouldn't it be easier to parse STDERR after
 > encountering an exit code != 0 in your scripts?
 > pkg_add: package 'foo-0.5.11' or its older version already installed
 > Should be enough to distinguish such error from other intall errors.
 
 Are you being serious?  Do you find pattern matching in shell scripts  
 to be easier than checking a numeric return code?  If so, then please  
 educate me on how you accomplish this in a re-usable manner.
 
 -- 
 Jo Rhett
 senior geek
 Silicon Valley Colocation
 
 
 
 
Responsible-Changed-From-To: krion->portmgr 
Responsible-Changed-By: flz 
Responsible-Changed-When: Fri Jul 17 13:41:53 UTC 2009 
Responsible-Changed-Why:  
pkg_install is maintained by portmgr. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92866 
State-Changed-From-To: open->closed 
State-Changed-By: bapt 
State-Changed-When: Wed May 28 15:17:20 UTC 2014 
State-Changed-Why:  
pkg_install is not being worked on anymore 

http://www.freebsd.org/cgi/query-pr.cgi?pr=92866 
>Unformatted:
