From root@ws092.svzserv.kemerovo.su  Wed Aug 24 06:05:55 2005
Return-Path: <root@ws092.svzserv.kemerovo.su>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E927316A41F;
	Wed, 24 Aug 2005 06:05:54 +0000 (GMT)
	(envelope-from root@ws092.svzserv.kemerovo.su)
Received: from ws092.svzserv.kemerovo.su (ws092.svzserv.kemerovo.su [213.184.65.92])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 486C043D55;
	Wed, 24 Aug 2005 06:05:53 +0000 (GMT)
	(envelope-from root@ws092.svzserv.kemerovo.su)
Received: from ws092.svzserv.kemerovo.su (localhost [127.0.0.1])
	by ws092.svzserv.kemerovo.su (8.13.4/8.13.4) with ESMTP id j7O57CLU005047;
	Wed, 24 Aug 2005 13:07:12 +0800 (KRAST)
	(envelope-from root@ws092.svzserv.kemerovo.su)
Received: (from root@localhost)
	by ws092.svzserv.kemerovo.su (8.13.4/8.13.3/Submit) id j7O57CcL005046;
	Wed, 24 Aug 2005 13:07:12 +0800 (KRAST)
	(envelope-from root)
Message-Id: <200508240507.j7O57CcL005046@ws092.svzserv.kemerovo.su>
Date: Wed, 24 Aug 2005 13:07:12 +0800 (KRAST)
From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc: phk@freebsd.org, krion@freebsd.org
Subject: [patch] nanobsd build breaks on pkg_add
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         85261
>Category:       bin
>Synopsis:       [patch] nanobsd build breaks on pkg_add
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    krion
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 24 06:10:13 GMT 2005
>Closed-Date:    Tue Mar 14 20:33:12 GMT 2006
>Last-Modified:  Wed Mar 15 05:00:38 GMT 2006
>Originator:     Eugene Grosbein
>Release:        FreeBSD 6.0-BETA2 i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD ws092.svzserv.kemerovo.su 6.0-BETA2 FreeBSD 6.0-BETA2 #0: Tue Aug 23 16:37:04 KRAST 2005 root@ws092.svzserv.kemerovo.su:/usr/obj/usr/src/sys/TEST i386

>Description:
	Nanobsd may be customized to include a set of packages.
	Packages should be placed in Pkg/ and nanobsd runs
	'pkg_add -v *' there.

	Assume there are two packages A and B and A depends on B.
	pkg_add adds A (and B as dependency) then it tries to add B
	and fails (B is already installed), so nanobsd fails to complete
	an image.

>How-To-Repeat:

	Try to build nanobsd with gettext-0.14.5.tbz and libiconv-1.9.2_1.tbz.
	pkg_add will try to install libiconv twice and fail.

>Fix:

	Introduce new command line switch -F for pkg_add to consider
	described case as nonfatal error and use 'pkg_add -vF'
	instead of 'pkg_add -v' in src/tools/tools/nanobsd/Customize/pkgs

	The following patch introduces -F. It is made for RELENG_6's
	src/usr.sbin/pkg_install/add

Index: add.h
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/add.h,v
retrieving revision 1.11
diff -u -r1.11 add.h
--- add.h	29 Jun 2004 19:06:41 -0000	1.11
+++ add.h	24 Aug 2005 02:59:22 -0000
@@ -28,6 +28,7 @@
 extern char	*Prefix;
 extern Boolean	NoInstall;
 extern Boolean	NoRecord;
+extern Boolean	FailOnAlreadyInstalled;
 extern char	*Mode;
 extern char	*Owner;
 extern char	*Group;
Index: main.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/main.c,v
retrieving revision 1.61.2.1
diff -u -r1.61.2.1 main.c
--- main.c	11 Jul 2005 16:14:21 -0000	1.61.2.1
+++ main.c	24 Aug 2005 02:59:38 -0000
@@ -27,13 +27,14 @@
 #include "lib.h"
 #include "add.h"
 
-static char Options[] = "hvIRfnrp:SMt:C:";
+static char Options[] = "hvIRfFnrp:SMt:C:";
 
 char	*Prefix		= NULL;
 char	*Chroot		= NULL;
 Boolean	NoInstall	= FALSE;
 Boolean	NoRecord	= FALSE;
 Boolean Remote		= FALSE;
+Boolean FailOnAlreadyInstalled = TRUE;
 
 char	*Mode		= NULL;
 char	*Owner		= NULL;
@@ -120,6 +121,10 @@
 
 	case 'f':
 	    Force = TRUE;
+	    break;
+
+	case 'F':
+	    FailOnAlreadyInstalled = FALSE;
 	    break;
 
 	case 'n':
Index: perform.c
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/perform.c,v
retrieving revision 1.77
diff -u -r1.77 perform.c
--- perform.c	28 Jul 2004 16:03:13 -0000	1.77
+++ perform.c	24 Aug 2005 02:59:01 -0000
@@ -245,9 +245,12 @@
      */
     if ((isinstalledpkg(Plist.name) > 0 ||
          matchbyorigin(Plist.origin, NULL) != NULL) && !Force) {
-	warnx("package '%s' or its older version already installed",
-	      Plist.name);
-	code = 1;
+	warnx("package '%s' or its older version already installed%s",
+	      Plist.name, FailOnAlreadyInstalled ? "" : " (ignored)");
+	if(FailOnAlreadyInstalled)
+		code = 1;
+	else
+		code = 0;
 	goto success;	/* close enough for government work */
     }
 
Index: pkg_add.1
===================================================================
RCS file: /home/ncvs/src/usr.sbin/pkg_install/add/pkg_add.1,v
retrieving revision 1.66
diff -u -r1.66 pkg_add.1
--- pkg_add.1	13 Feb 2005 22:25:30 -0000	1.66
+++ pkg_add.1	24 Aug 2005 03:50:55 -0000
@@ -23,7 +23,7 @@
 .Nd a utility for installing software package distributions
 .Sh SYNOPSIS
 .Nm
-.Op Fl vInfrRMS
+.Op Fl vInfFrRMS
 .Op Fl t Ar template
 .Op Fl p Ar prefix
 .Op Fl C Ar chrootdir
@@ -104,6 +104,11 @@
 .Nm
 will still try to find and auto-install missing prerequisite packages,
 a failure to find one will not be fatal.
+.It Fl F
+Do not regard installation of already installed package as fatal error.
+This option allows
+.Cm pkg_add
+to complete without error when a package is already installed.
 .It Fl p Ar prefix
 Set
 .Ar prefix


Eugene Grosbein
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->krion 
Responsible-Changed-By: fjoe 
Responsible-Changed-When: Tue Sep 27 07:52:44 GMT 2005 
Responsible-Changed-Why:  
Over to maintainer 

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

From: "Kirill Ponomarew" <krion@voodoo.oberon.net>
To: <bug-followup@FreeBSD.org>,
	<eugen@grosbein.pp.ru>
Cc:  
Subject: Re: bin/85261: [patch] nanobsd build breaks on pkg_add
Date: Tue, 27 Sep 2005 11:02:41 +0200

 I don't really like the logic introduced by this patch.  We should
 decrease the number of arguments for pkg_add(1) instead of making it
 spiny further.  I would propose to add the behaviour you described
 by default and ignore the package, if it's already installed as
 dependency and the also specified as an argument.  What do you think
 ?
 
 -Kirill
 

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: Kirill Ponomarew <krion@voodoo.oberon.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/85261: [patch] nanobsd build breaks on pkg_add
Date: Tue, 27 Sep 2005 17:33:31 +0800

 On Tue, Sep 27, 2005 at 11:02:41AM +0200, Kirill Ponomarew wrote:
 
 > I don't really like the logic introduced by this patch.  We should
 > decrease the number of arguments for pkg_add(1) instead of making it
 > spiny further.  I would propose to add the behaviour you described
 > by default and ignore the package, if it's already installed as
 > dependency and the also specified as an argument.  What do you think
 > ?
 
 Why should it check if the package is specified as an argument?
 
 Eugene

From: Kirill Ponomarew <krion@voodoo.oberon.net>
To: Eugene Grosbein <eugen@grosbein.pp.ru>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/85261: [patch] nanobsd build breaks on pkg_add
Date: Tue, 27 Sep 2005 14:09:42 +0200

 On Tue, Sep 27, 2005 at 05:33:31PM +0800, Eugene Grosbein wrote:
 > Why should it check if the package is specified as an argument?
 
 Why not ?  In this case we could prevent adding additional
 arguments.
 
 -Kirill

From: Eugene Grosbein <eugen@grosbein.pp.ru>
To: Kirill Ponomarew <krion@voodoo.oberon.net>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/85261: [patch] nanobsd build breaks on pkg_add
Date: Tue, 27 Sep 2005 20:13:02 +0800

 On Tue, Sep 27, 2005 at 02:09:42PM +0200, Kirill Ponomarew wrote:
 > On Tue, Sep 27, 2005 at 05:33:31PM +0800, Eugene Grosbein wrote:
 > > Why should it check if the package is specified as an argument?
 > 
 > Why not ?  In this case we could prevent adding additional
 > arguments.
 
 It would not fail on adding existent package without additional
 arguments and without check if the package is specified as an argument :-)
 
 Eugene
State-Changed-From-To: open->closed 
State-Changed-By: krion 
State-Changed-When: Tue Mar 14 20:33:08 UTC 2006 
State-Changed-Why:  
It seems, it's committed by phk already 

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

From: Eugene Grosbein <eugen@kuzbass.ru>
To: Kirill Ponomarew <krion@FreeBSD.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/85261: [patch] nanobsd build breaks on pkg_add
Date: Wed, 15 Mar 2006 11:57:35 +0700

 Kirill Ponomarew wrote:
 > 
 > Synopsis: [patch] nanobsd build breaks on pkg_add
 > 
 > State-Changed-From-To: open->closed
 > State-Changed-By: krion
 > State-Changed-When: Tue Mar 14 20:33:08 UTC 2006
 > State-Changed-Why:
 > It seems, it's committed by phk already
 > 
 > http://www.freebsd.org/cgi/query-pr.cgi?pr=85261
 
 Yes, but the PR should be in 'patched' state until MFC, should not it?
 
 Eugene Grosbein
>Unformatted:
