From owner-svn-src-all@FreeBSD.ORG Fri Dec 21 20:01:14 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 157196CC; Fri, 21 Dec 2012 20:01:14 +0000 (UTC) (envelope-from matthew@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id EE5358FC0A; Fri, 21 Dec 2012 20:01:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id qBLK1Dxq027190; Fri, 21 Dec 2012 20:01:13 GMT (envelope-from matthew@svn.freebsd.org) Received: (from matthew@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id qBLK1DCQ027189; Fri, 21 Dec 2012 20:01:13 GMT (envelope-from matthew@svn.freebsd.org) Message-Id: <201212212001.qBLK1DCQ027189@svn.freebsd.org> From: Matthew Seaman Date: Fri, 21 Dec 2012 20:01:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r244553 - head/usr.sbin/pkg X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2012 20:01:14 -0000 Author: matthew (ports committer) Date: Fri Dec 21 20:01:13 2012 New Revision: 244553 URL: http://svnweb.freebsd.org/changeset/base/244553 Log: In preparation for making 'pkg -n' the one true method of determining whether a system has been configured to use pkgng, cause /usr/sbin/pkg recognise a -n option and exit with a failure code when the pkg port is not installed. Approved by: bapt MFC after: 2 weeks Modified: head/usr.sbin/pkg/pkg.c Modified: head/usr.sbin/pkg/pkg.c ============================================================================== --- head/usr.sbin/pkg/pkg.c Fri Dec 21 19:36:08 2012 (r244552) +++ head/usr.sbin/pkg/pkg.c Fri Dec 21 20:01:13 2012 (r244553) @@ -452,6 +452,16 @@ main(__unused int argc, char *argv[]) getenv("LOCALBASE") ? getenv("LOCALBASE") : _LOCALBASE); if (access(pkgpath, X_OK) == -1) { + /* + * To allow 'pkg -n' to be used as a reliable test for whether + * a system is configured to use pkg, don't bootstrap pkg + * when that argument is given as argv[1]. + */ + if ( argv[1] != NULL && strcmp(argv[1], "-n") == 0) { + printf("%s", "pkg is not installed\n"); + exit(EXIT_FAILURE); + } + /* * Do not ask for confirmation if either of stdin or stdout is * not tty. Check the environment to see if user has answer