diff options
author | matthew <matthew@FreeBSD.org> | 2012-12-21 20:01:13 +0000 |
---|---|---|
committer | matthew <matthew@FreeBSD.org> | 2012-12-21 20:01:13 +0000 |
commit | 0a2c07efd7e9c79cacd9992d18e5e0ab0c5f1915 (patch) | |
tree | bf2b3257d160758dede7078e55e255ed985d6822 /usr.sbin/pkg | |
parent | cd0363b24b051261804e98b52f52212d3dbcfe3a (diff) | |
download | FreeBSD-src-0a2c07efd7e9c79cacd9992d18e5e0ab0c5f1915.zip FreeBSD-src-0a2c07efd7e9c79cacd9992d18e5e0ab0c5f1915.tar.gz |
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
Diffstat (limited to 'usr.sbin/pkg')
-rw-r--r-- | usr.sbin/pkg/pkg.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/usr.sbin/pkg/pkg.c b/usr.sbin/pkg/pkg.c index 061008c..eec01c2 100644 --- a/usr.sbin/pkg/pkg.c +++ b/usr.sbin/pkg/pkg.c @@ -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 |