From romain@blogreen.org  Fri Jan 25 14:38:53 2013
Return-Path: <romain@blogreen.org>
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
	by hub.freebsd.org (Postfix) with ESMTP id 5925BF5F
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Jan 2013 14:38:53 +0000 (UTC)
	(envelope-from romain@blogreen.org)
Received: from marvin.blogreen.org (unknown [IPv6:2001:470:1f12:b9c::2])
	by mx1.freebsd.org (Postfix) with ESMTP id D0DC3F01
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 25 Jan 2013 14:38:52 +0000 (UTC)
Received: by marvin.blogreen.org (Postfix, from userid 1001)
	id 48A49CC16; Fri, 25 Jan 2013 15:38:51 +0100 (CET)
Message-Id: <20130125143851.48A49CC16@marvin.blogreen.org>
Date: Fri, 25 Jan 2013 15:38:51 +0100 (CET)
From: Romain Tartiere <romain@FreeBSD.org>
Reply-To: Romain Tartiere <romain@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] [bsd.pkgng.mk] Enhancement to avoid pkgng "/bin/sh: Argument list too long"
X-Send-Pr-Version: 3.114
X-GNATS-Notify:

>Number:         175561
>Category:       ports
>Synopsis:       [patch] [bsd.pkgng.mk] Enhancement to avoid pkgng "/bin/sh: Argument list too long"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bapt
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 25 14:40:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Fri Jan 25 14:50:33 UTC 2013
>Originator:     Romain Tartiere
>Release:        FreeBSD 9.1-STABLE amd64
>Organization:
>Environment:
System: FreeBSD marvin.blogreen.org 9.1-STABLE FreeBSD 9.1-STABLE #4 r245578: Fri Jan 18 00:14:39 CET 2013 root@marvin.blogreen.org:/usr/obj/usr/src/sys/MARVIN amd64


	
>Description:

When trying to register a port with many dependencies (2141 ports in my case)
using pkgng, it fails with error:

===>   Registering installation for texlive-scheme-full-20110217,1
/bin/sh: Argument list too long
pkg: Invalid manifest format
*** [fake-pkg] Error code 74

Stop in /usr/ports/print/texlive-scheme-full.


The ${ACTUAL-PACKAGE-DEPENDS} generated snippet is too long and this result in
an invalid metadata file to be generated, thus making pkg fail a bit later.

In my case, ${_LIB_RUN_DEPENDS} is 204172 bytes long while the max commandline
length is 262144 bytes, there is therefore no much room for the rest of the
arguments.  However, the " " argument passed to `pkg query` prevent it from
failing if ${_LIB_RUN_DEPENDS} where empty, so the test to "protect" it against
that is useless.

>How-To-Repeat:

One can get the TeXLive ports from
http://code.google.com/p/freebsd-texlive/

and try to install print/texlive-scheme-full with WITH_PKGNG=yes in
/etc/make.conf.

>Fix:

The following patch helps avoiding this situation.

--- bsd.pkgng.mk.diff begins here ---
--- bsd.pkgng.mk.orig	2013-01-25 14:59:31.000000000 +0100
+++ bsd.pkgng.mk	2013-01-25 15:17:32.000000000 +0100
@@ -21,10 +21,8 @@
 PLIST_REINPLACE:=	${PLIST_REINPLACE:Nstopdaemon}
 
 ACTUAL-PACKAGE-DEPENDS?= \
-	if [ "${_LIB_RUN_DEPENDS}" != "  " ]; then \
-		${PKG_QUERY} "%n: {origin: %o, version: \"%v\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} ; \
-		${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} ; \
-	fi
+	${PKG_QUERY} "%n: {origin: %o, version: \"%v\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,} ; \
+	${PKG_QUERY} "%dn: {origin: %do, version: \"%dv\"}" " " ${_LIB_RUN_DEPENDS:C,[^:]*:([^:]*):?.*,\1,:C,${PORTSDIR}/,,}
 
 
 .if !target(fake-pkg)
--- bsd.pkgng.mk.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->portmgr 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Jan 25 14:40:07 UTC 2013 
Responsible-Changed-Why:  
bsd.pkgng.mk is portmgr territory (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=175561 
Responsible-Changed-From-To: portmgr->bapt 
Responsible-Changed-By: romain 
Responsible-Changed-When: Fri Jan 25 14:49:58 UTC 2013 
Responsible-Changed-Why:  
I guess bapt will be interested in this.  Please reassign to somebody 
else if I am wrong. 

Thanks! 

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