Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
pkg-version: New configuration option VERSION_SOURCE
Michael Gmelin committed 11 years ago
commit 45579c6830cccb51e90d4ba95b757bc95a167f3d
parent 4403355
4 files changed +47 -3
modified docs/pkg-version.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd October 30, 2014
+
.Dd November 09, 2014
.Dt PKG-VERSION 8
.Os
.Sh NAME
@@ -59,7 +59,11 @@ installed packages may be chosen by specifying one of
.Fl P ,
.Fl R
or
-
.Fl I .
+
.Fl I
+
or by by setting
+
.Cm VERSION_SOURCE
+
in
+
.Xr pkg.conf 5 .
If not specified then the ports index file
will be used if it exists
.Fl ( I ) .
modified docs/pkg.conf.5
@@ -15,7 +15,7 @@
.\"     @(#)pkg.1
.\" $FreeBSD$
.\"
-
.Dd October 30, 2014
+
.Dd November 09, 2014
.Dt PKG.CONF 5
.Os
.Sh NAME
@@ -262,6 +262,19 @@ archive.
Normally, timestamps are copied from the staging directory the
package is created from.
Default: NO.
+
.It Cm VERSION_SOURCE: string
+
Default database for comparing version numbers in
+
.Xr pkg-version 8 .
+
Valid values are
+
.Sy I
+
for index,
+
.Sy P ,
+
for ports,
+
.Sy R
+
for remote.
+
Default: If unset, the algorithm described in
+
.Xr pkg-version 8
+
is used to determine the version source automatically.
.It Cm VULNXML_SITE: string
Specifies the URL to fetch the
.Pa vuln.xml
modified libpkg/pkg_config.c
@@ -336,6 +336,11 @@ static struct config_entry c[] = {
		"YES",
		"Automatically merge configuration files"
	}
+
		PKG_STRING,
+
		"VERSION_SOURCE",
+
		NULL,
+
		"Version source for pkg-version (I, P, R), default is auto detect"
+
	},
};

static bool parsed = false;
modified src/version.c
@@ -771,6 +771,7 @@ exec_version(int argc, char **argv)
	const char	*reponame = NULL;
	const char	*portsdir;
	const char	*indexfile;
+
	const char	*versionsource;
	char		 filebuf[MAXPATHLEN];
	match_t		 match = MATCH_ALL;
	char		*pattern = NULL;
@@ -902,6 +903,27 @@ exec_version(int argc, char **argv)
		return (EX_USAGE);
	}

+
	if ( !(opt & VERSION_SOURCES ) ) {
+
		versionsource = pkg_object_string(
+
		    pkg_config_get("VERSION_SOURCE"));
+
		if (versionsource != NULL) {
+
			switch (versionsource[0]) {
+
			case 'I':
+
				opt |= VERSION_SOURCE_INDEX;
+
				break;
+
			case 'P':
+
				opt |= VERSION_SOURCE_PORTS;
+
				break;
+
			case 'R':
+
				opt |= VERSION_SOURCE_REMOTE;
+
				break;
+
			default:
+
				warnx("Invalid VERSION_SOURCE"
+
				    " in configuration.");
+
			}
+
		}
+
	}
+

	if ( (opt & VERSION_SOURCE_INDEX) == VERSION_SOURCE_INDEX ) {
		if (!have_indexfile(&indexfile, filebuf, sizeof(filebuf),
		     argc, argv, true))