From 675e98c127c9b368c1379f6344a9cb6a22a5f946 Mon Sep 17 00:00:00 2001 From: bapt Date: Tue, 15 Jan 2013 09:17:07 +0000 Subject: [PATCH] MFC r244553,244594,244608,244639 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 Submitted by: matthew git-svn-id: svn://svn.freebsd.org/base/stable/8@245452 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- usr.sbin/pkg/pkg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 061008c4f..1b3146b2c 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -452,6 +452,14 @@ 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) + errx(EXIT_FAILURE, "pkg is not installed"); + /* * Do not ask for confirmation if either of stdin or stdout is * not tty. Check the environment to see if user has answer -- 2.45.0