Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Merge pull request #855 from dag-erling/query-R
Vsevolod Stakhov committed 11 years ago
commit 9014833584611d53330740f1250d5cd60440f01b
parent b207305
3 files changed +16 -1
modified docs/pkg-query.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd May 26, 2014
+
.Dd July 1, 2014
.Dt PKG-QUERY 8
.Os
.Sh NAME
@@ -128,6 +128,11 @@ Returns 1 if the matched package is locked against modification or deletion, 0 o
message contained in the matched package
.It Cm \&%t
Timestamp that the package was installed
+
.It Cm \&%R
+
The name of the repository from which the package was installed if
+
available, or
+
.Dq unknown-repository
+
otherwise.
.It Cm \&%? Ns Op drCFODLUGBbA
Returns 0 if the list is empty and 1 if the list has information to display
.Bl -tag -width indent
modified libpkg/pkg_printf.c
@@ -1310,9 +1310,18 @@ struct sbuf *
format_repo_ident(struct sbuf *sbuf, const void *data, struct percent_esc *p)
{
	const struct pkg	*pkg = data;
+
	const ucl_object_t	*an, *rn;
	const char		*reponame;

	pkg_get(pkg, PKG_REPONAME, &reponame);
+
	if (reponame == NULL) {
+
		pkg_get(pkg, PKG_ANNOTATIONS, &an);
+
		rn = pkg_object_find(an, "repository");
+
		if (rn != NULL)
+
			reponame = ucl_object_tostring(rn);
+
		else
+
			reponame = "unknown-repository";
+
	}
	return (string_val(sbuf, reponame, p));
}

modified src/query.c
@@ -73,6 +73,7 @@ static struct query_flags accepted_query_flags[] = {
	{ 'k', "",		0, PKG_LOAD_BASIC },
	{ 'M', "",		0, PKG_LOAD_BASIC },
	{ 't', "",		0, PKG_LOAD_BASIC },
+
	{ 'R', "",              0, PKG_LOAD_ANNOTATIONS },
};

static void