From nobody@FreeBSD.org  Mon Jun 11 14:10:56 2012
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52])
	by hub.freebsd.org (Postfix) with ESMTP id BDB4E1065670
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 11 Jun 2012 14:10:56 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id A8E8B8FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 11 Jun 2012 14:10:56 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q5BEAuZS054028
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 11 Jun 2012 14:10:56 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q5BEAuXx054027;
	Mon, 11 Jun 2012 14:10:56 GMT
	(envelope-from nobody)
Message-Id: <201206111410.q5BEAuXx054027@red.freebsd.org>
Date: Mon, 11 Jun 2012 14:10:56 GMT
From: Oleg Ginzburg <olevole@olevole.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: pkg beta 15 doesn't see package existence with -a and -n options
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         168953
>Category:       ports
>Synopsis:       ports-mgmt/pkg beta 15 doesn't see package existence with -a and -n options
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bapt
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 11 14:20:05 UTC 2012
>Closed-Date:    Wed Jun 27 07:13:03 UTC 2012
>Last-Modified:  Wed Jun 27 07:13:03 UTC 2012
>Originator:     Oleg Ginzburg
>Release:        9-RELENG
>Organization:
>Environment:
>Description:
pkg-create(8) says for -n options: "Do not overwrite already existing packages". However it doesn't work when -a options is used.


>How-To-Repeat:
% pkg -v
1.0-beta15

% ls -la /tmp/GeoIP-1.4.8_2.txz
-rw-r--r--  1 root  wheel  586452 Jun 11 18:01 /tmp/GeoIP-1.4.8_2.txz

% pkg create -n -o /tmp GeoIP-1.4.8_2
GeoIP-1.4.8_2 already packaged skipping...

% pkg create -an -o /tmp
Creating package for GeoIP-1.4.8_2
^C

% ls -la /tmp/GeoIP-1.4.8_2.txz
-rw-r--r--  1 root  wheel  586452 Jun 11 18:02 /tmp/GeoIP-1.4.8_2.txz

packages was recreated

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bapt 
Responsible-Changed-By: bapt 
Responsible-Changed-When: Tue Jun 12 06:46:58 UTC 2012 
Responsible-Changed-Why:  
I'll take it. 

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

From: Bryan Drewery <bryan@shatow.net>
To: bug-followup@FreeBSD.org, olevole@olevole.ru
Cc: Baptiste Daroussin <bapt@FreeBSD.org>
Subject: Re: misc/168953: pkg beta 15 doesn&#39;t see package existence with
 -a and -n options
Date: Wed, 13 Jun 2012 08:20:49 -0500

 This is a multi-part message in MIME format.
 --------------080405050708040809090409
 Content-Type: text/plain; charset=ISO-8859-1
 Content-Transfer-Encoding: 7bit
 
 Fixed for next beta. Patch attached.
 
 --------------080405050708040809090409
 Content-Type: text/plain; charset=windows-1252;
  name="patch-pkg-create-an.txt"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="patch-pkg-create-an.txt"
 
 commit 831f1a842706ffcf05f21bc2f32ce4561b448d25
 Author: Bryan Drewery <bryan@shatow.net>
 Date:   Wed Jun 13 08:17:26 2012 -0500
 
     Fix pkg-create -an to skip existing packages
     
     PR:	ports/168953
 
 diff --git pkg/create.c pkg/create.c
 index 0a28944..adf082a 100644
 --- pkg/create.c
 +++ pkg/create.c
 @@ -59,12 +59,29 @@ pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt, const
  	    PKG_LOAD_DIRS | PKG_LOAD_SCRIPTS | PKG_LOAD_OPTIONS |
  	    PKG_LOAD_MTREE | PKG_LOAD_LICENSES | PKG_LOAD_USERS |
  	    PKG_LOAD_GROUPS | PKG_LOAD_SHLIBS;
 +	const char *format;
  
  	if (pkgdb_open(&db, PKGDB_DEFAULT) != EPKG_OK) {
  		pkgdb_close(db);
  		return (EX_IOERR);
  	}
  
 +	switch (fmt) {
 +		case TXZ:
 +			format = "txz";
 +			break;
 +		case TBZ:
 +			format = "tbz";
 +			break;
 +		case TGZ:
 +			format = "tgz";
 +			break;
 +		case TAR:
 +			format = "tar";
 +			break;
 +	}
 +
 +
  	if (match != MATCH_ALL) {
  		for (i = 0;i < argc; i++) {
  			if ((it = pkgdb_query(db, argv[i], match)) == NULL) {
 @@ -73,22 +90,6 @@ pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt, const
  			while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
  				pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
  				if (!overwrite) {
 -					const char *format;
 -					switch (fmt) {
 -					case TXZ:
 -						format = "txz";
 -						break;
 -					case TBZ:
 -						format = "tbz";
 -						break;
 -					case TGZ:
 -						format = "tgz";
 -						break;
 -					case TAR:
 -						format = "tar";
 -						break;
 -					}
 -
  					snprintf(pkgpath, MAXPATHLEN, "%s/%s-%s.%s", outdir, name, version, format);
  					if (access(pkgpath, F_OK) == 0) {
  						printf("%s-%s already packaged skipping...\n", name, version);
 @@ -106,6 +107,13 @@ pkg_create_matches(int argc, char **argv, match_t match, pkg_formats fmt, const
  		}
  		while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
  			pkg_get(pkg, PKG_NAME, &name, PKG_VERSION, &version);
 +			if (!overwrite) {
 +				snprintf(pkgpath, MAXPATHLEN, "%s/%s-%s.%s", outdir, name, version, format);
 +				if (access(pkgpath, F_OK) == 0) {
 +					printf("%s-%s already packaged skipping...\n", name, version);
 +					continue;
 +				}
 +			}
  			printf("Creating package for %s-%s\n", name, version);
  			if (pkg_create_installed(outdir, fmt, rootdir, pkg) != EPKG_OK)
  				retcode++;
 
 --------------080405050708040809090409--
State-Changed-From-To: open->closed 
State-Changed-By: bapt 
State-Changed-When: Wed Jun 27 07:13:02 UTC 2012 
State-Changed-Why:  
Fix in b16 

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