Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Fixes issue #396. Make pkg version auto-update repo catalogue by default. Add -U flag to pkg version to suppress this behaviour.
Matthew Seaman committed 13 years ago
commit aa7b5250d09fe7ff31d6a4dbbcf6f18f228bead4
parent 2b04ec2
2 files changed +24 -2
modified pkg/pkg-version.8
@@ -24,7 +24,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl IPR
-
.Op Fl hoqv
+
.Op Fl hoqvU
.Op Fl l Ar limchar
.Op Fl L Ar limchar
.Op Fl xge Ar pattern
@@ -85,6 +85,17 @@ for more information.
.It Fl R
Use repository catalogue for determining if a package is out of date.
This is the default if no ports tree exists.
+
.It Fl U
+
Suppress the automatic update of the local copy of the repository catalogue
+
from remote.
+
This only has any effect in combination with the
+
.Fl R
+
option.
+
Note: the
+
.Fl L
+
option is comonly used for this purpose in other
+
.Nm pkg
+
applications.
.It Fl r Ar reponame
Use the given
.Ar reponame
modified pkg/version.c
@@ -164,6 +164,7 @@ exec_version(int argc, char **argv)
	const char *reponame = NULL;
	const char *version_remote = NULL;
	bool have_ports;
+
	bool auto_update = false;
	match_t match = MATCH_ALL;
	char *pattern=NULL;
	struct stat sb;
@@ -171,7 +172,7 @@ exec_version(int argc, char **argv)

	SLIST_INIT(&indexhead);

-
	while ((ch = getopt(argc, argv, "hIPRoqvl:L:x:g:e:O:r:tT")) != -1) {
+
	while ((ch = getopt(argc, argv, "hIPRUoqvl:L:x:g:e:O:r:tT")) != -1) {
		switch (ch) {
		case 'h':
			usage_version();
@@ -182,6 +183,9 @@ exec_version(int argc, char **argv)
		case 'R':
			opt |= VERSION_SOURCE_REMOTE;
			break;
+
		case 'U':
+
			auto_update = true;
+
			break;
		case 'P':
			opt |= VERSION_SOURCE_PORTS;
			break;
@@ -311,6 +315,13 @@ exec_version(int argc, char **argv)
		/* Only force remote mode if looking up remote, otherwise
		   user is forced to have a repo.sqlite */
		if (opt & VERSION_SOURCE_REMOTE) {
+
			if (auto_update) {
+
				int retcode;
+

+
				retcode = pkgcli_update(false);
+
				if (retcode != EPKG_OK)
+
					return (updcode);
+
			}
			if (pkgdb_open(&db, PKGDB_REMOTE) != EPKG_OK)
				return (EX_IOERR);
		} else