Radish alpha
H
HardenedBSD Package Manager
Radicle
Git (anonymous pull)
Log in to clone via SSH
Add support for querying provided shared libraries to pkg query and rquery
Matthew Seaman committed 13 years ago
commit d3423d45dea83f8026095dfd2a979758a59c855c
parent cc23cbe61fdf213e9ea3745aed05ae93e18f3ca4
4 files changed +49 -17
modified pkg/pkg-query.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 25, 2013
+
.Dd March 3, 2013
.Dt PKG-QUERY 8
.Os
.Sh NAME
@@ -104,7 +104,7 @@ Returns 1 if the matched package is locked against modification or deletion, 0 o
message contain in the matched package
.It Cm \&%t
Timestamp that the package was installed
-
.It Cm \&%? Ns Op drCFODLUGB
+
.It Cm \&%? Ns Op drCFODLUGBb
Returns 0 if the list is empty and 1 if the list has information to display
.Bl -tag -width indent
.It Cm d
@@ -126,9 +126,11 @@ for users
.It Cm G
for groups
.It Cm B
-
for shared libraries
+
for required shared libraries
+
.It Cm b
+
for provided shared libraries
.El
-
.It Cm \&%# Ns Op drCFODLUGB
+
.It Cm \&%# Ns Op drCFODLUGBb
Returns the number of element in the list
.Bl -tag -width indent
.It Cm d
@@ -149,8 +151,12 @@ for licenses
for users
.It Cm G
for groups
+
.It Cm b
+
for shared 
.It Cm B
-
for shared libraries
+
for required shared libraries
+
.It Cm b
+
for provided shared libraries
.El
.El
.Ss Multiline patterns:
@@ -195,6 +201,8 @@ Expands to the list of users needed by the matched package.
Expands to the list of groups needed by the matched package.
.It Cm \&%B
Expands to the list of shared libraries used by programs from the matched package.
+
.It Cm \&%b
+
Expands to the list of shared libraries provided by the matched package.
.El
.Sh EVALUATION FORMAT
Packages can be selected by using expressions comparing
@@ -235,7 +243,7 @@ Message of the package (type string)
Timestamp that the package was installed (type integer)
.It Cm \&%i
Additionnal information about the package (type string)
-
.It Cm \&%# Ns Op drCFODLUGB
+
.It Cm \&%# Ns Op drCFODLUGBb
Number of elements in the list of information (type integer).
See
.Cm %?
modified pkg/pkg-rquery.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd February 25, 2013
+
.Dd March 3, 2013
.Dt PKG-RQUERY 8
.Os
.Sh NAME
@@ -103,7 +103,7 @@ is in bytes, and
is in human readable format.
.It Cm \&%M
message contain in the matched package
-
.It Cm \&%? Ns Op drCOLB
+
.It Cm \&%? Ns Op drCOLBb
Returns 0 if the list is empty and 1 if the list has information to display
.Bl -tag -width indent
.It Cm d
@@ -117,8 +117,10 @@ for options
.It Cm L
for licenses
.It Cm B
-
for shared libraries
-
.It Cm \&%# Ns Op drCOLB
+
for required shared libraries
+
.It Cm b
+
for provided shared libraries
+
.It Cm \&%# Ns Op drCOLBb
Returns the number of elements in the list
.Bl -tag -width indent
.It Cm d
@@ -132,7 +134,9 @@ for options
.It Cm L
for licenses
.It Cm B
-
for shared libraries
+
for required shared libraries
+
.It Cm b
+
for provided shared libraries
.El
.El
.El
@@ -166,6 +170,8 @@ for option value.
Expands to the list of license(s) for the matched package.
.It Cm \&%B
Expands to the list of shared libraries used by programs from the matched package.
+
.It Cm \&%b
+
Expands to the list of shared libraries provided by the matched package.
.El
.Sh EVALUATION FORMAT
.Ss Variables
@@ -188,7 +194,7 @@ Flatsize of the package (type integer)
Automatic status of the package (type integer)
.It Cm \&%M
Message of the package (type string)
-
.It Cm \&%# Ns Op drCOLB
+
.It Cm \&%# Ns Op drCOLBb
Number of elements in the list of information (type integer).
See
.Cm %?
modified pkg/query.c
@@ -53,8 +53,9 @@ static struct query_flags accepted_query_flags[] = {
	{ 'U', "",		1, PKG_LOAD_USERS },
	{ 'G', "",		1, PKG_LOAD_GROUPS },
	{ 'B', "",		1, PKG_LOAD_SHLIBS_REQUIRED },
-
	{ '?', "drCFODLUGB",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
-
	{ '#', "drCFODLUGB",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
+
	{ 'b', "",		1, PKG_LOAD_SHLIBS_PROVIDED },
+
	{ '?', "drCFODLUGBb",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
+
	{ '#', "drCFODLUGBb",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
	{ 's', "hb",		0, PKG_LOAD_BASIC },
	{ 'n', "",		0, PKG_LOAD_BASIC },
	{ 'v', "",		0, PKG_LOAD_BASIC },
@@ -65,7 +66,7 @@ static struct query_flags accepted_query_flags[] = {
	{ 'w', "",		0, PKG_LOAD_BASIC },
	{ 'l', "",		0, PKG_LOAD_BASIC },
	{ 'a', "",		0, PKG_LOAD_BASIC },
-
	{ 'k', "",              0, PKG_LOAD_BASIC },
+
	{ 'k', "",		0, PKG_LOAD_BASIC },
	{ 'M', "",		0, PKG_LOAD_BASIC },
	{ 'i', "",		0, PKG_LOAD_BASIC },
	{ 't', "",		0, PKG_LOAD_BASIC },
@@ -188,6 +189,9 @@ format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
				case 'B':
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_SHLIBS_REQUIRED) > 0);
					break;
+
				case 'b':
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_SHLIBS_PROVIDED) > 0);
+
					break;
				}
				break;
			case '#':
@@ -223,6 +227,9 @@ format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
				case 'B':
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_SHLIBS_REQUIRED));
					break;
+
				case 'b':
+
					sbuf_printf(dest, "%d", pkg_list_count(pkg, PKG_SHLIBS_PROVIDED));
+
					break;
				}
				break;
			case 'l':
@@ -287,6 +294,7 @@ format_str(struct pkg *pkg, struct sbuf *dest, const char *qstr, void *data)
				sbuf_cat(dest, pkg_group_name((struct pkg_group *)data));
				break;
			case 'B':
+
			case 'b':
				sbuf_cat(dest, pkg_shlib_name((struct pkg_shlib *)data));
				break;
			case 'M':
@@ -406,6 +414,12 @@ print_query(struct pkg *pkg, char *qstr, char multiline)
			printf("%s\n", sbuf_data(output));
		}
		break;
+
	case 'b':
+
		while (pkg_shlibs_provided(pkg, &shlib) == EPKG_OK) {
+
			format_str(pkg, output, qstr, shlib);
+
			printf("%s\n", sbuf_data(output));
+
		}
+
		break;
	default:
		format_str(pkg, output, qstr, dep);
		printf("%s\n", sbuf_data(output));
@@ -539,6 +553,9 @@ format_sql_condition(const char *str, struct sbuf *sqlcond, bool for_remote)
						case 'B':
							sbuf_printf(sqlcond, "(SELECT COUNT(*) FROM %spkg_shlibs_required AS d WHERE d.package_id=p.id)", dbstr);
							break;
+
						case 'b':
+
							sbuf_printf(sqlcond, "(SELECT COUNT(*) FROM %spkg_shlibs_provided AS d WHERE d.package_id=p.id)", dbstr);
+
							break;
						default:
							goto bad_option;
					}
modified pkg/rquery.c
@@ -49,8 +49,9 @@ static struct query_flags accepted_rquery_flags[] = {
	{ 'O', "kv",		1, PKG_LOAD_OPTIONS },
	{ 'L', "",		1, PKG_LOAD_LICENSES },
	{ 'B', "",		1, PKG_LOAD_SHLIBS_REQUIRED },
-
	{ '?', "drCOLB",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
-
	{ '#', "drCOLB",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
+
	{ 'b', "",		1, PKG_LOAD_SHLIBS_PROVIDED },
+
	{ '?', "drCOLBb",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
+
	{ '#', "drCOLBb",	1, PKG_LOAD_BASIC },	/* dbflags handled in analyse_query_string() */
	{ 's', "hb",		0, PKG_LOAD_BASIC },
	{ 'n', "",		0, PKG_LOAD_BASIC },
	{ 'v', "",		0, PKG_LOAD_BASIC },