Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Allow yaml format when searching packages.
Vsevolod Stakhov committed 13 years ago
commit 14234d4eddf557ce37cb4c04a4bd2c7a009c7c31
parent 9ea699b
5 files changed +25 -16
modified pkg/info.c
@@ -329,7 +329,7 @@ exec_info(int argc, char **argv)

		/* end of compatibility hacks */

-
		query_flags = info_flags(opt);
+
		query_flags = info_flags(opt, false);
		while ((ret = pkgdb_it_next(it, &pkg, query_flags)) == EPKG_OK) {
			gotone = true;
			const char *version;
modified pkg/pkg-search.8
@@ -15,7 +15,7 @@
.\"     @(#)pkg.8
.\" $FreeBSD$
.\"
-
.Dd March 31, 2013
+
.Dd April 15, 2013
.Dt PKG-SEARCH 8
.Os
.Sh NAME
@@ -30,7 +30,7 @@
.Op Fl Q Ar query-modifier
.Ar pattern
.Nm
-
.Op Fl cDdefgiopqx
+
.Op Fl cDdefgiopqRx
.Op Fl r Ar repo
.Ar pattern
.Sh DESCRIPTION
@@ -134,6 +134,8 @@ In multi-repo mode, select only the repository catalogue from
.Sy repo
to search.
By default all known repository catalogues are searched.
+
.It Fl R
+
Display the full yaml (raw) about the packages matching.
.It Fl S Ar search
Specify the field to search the repository catalogue on.
If unspecified, searches on
modified pkg/pkgcli.h
@@ -230,7 +230,7 @@ void usage_ssh(void);

bool query_yesno(const char *msg, ...);
bool query_tty_yesno(const char *msg, ...);
-
int info_flags(unsigned int opt);
+
int info_flags(unsigned int opt, bool remote);
void print_info(struct pkg * const pkg, unsigned int opt);
char *absolutepath(const char *src, char *dest, size_t dest_len);
void print_jobs_summary(struct pkg_jobs *j, const char *msg, ...);
modified pkg/search.c
@@ -217,7 +217,7 @@ usage_search(void)

	fprintf(stderr, "usage: pkg search [-egix] [-r repo] [-S search] "
	    "[-L label] [-Q mod]... <pkg-name>\n");
-
	fprintf(stderr, "       pkg search [-cDdefgiopqx] [-r repo] "
+
	fprintf(stderr, "       pkg search [-cDdefgiopqRx] [-r repo] "
	    "<pattern>\n\n");
	n = fprintf(stderr, "       Search and Label options:");
	for (i = 0; search_label[i].option != NULL; i++) {
@@ -256,7 +256,7 @@ exec_search(int argc, char **argv)

	pkg_config_bool(PKG_CONFIG_REPO_AUTOUPDATE, &auto_update);

-
	while ((ch = getopt(argc, argv, "cDdefgiL:opqQ:r:S:sUx")) != -1) {
+
	while ((ch = getopt(argc, argv, "cDdefgiL:opqQ:r:RS:sUx")) != -1) {
		switch (ch) {
		case 'c':	/* Same as -S comment */
			search = search_label_opt("comment");
@@ -297,6 +297,9 @@ exec_search(int argc, char **argv)
		case 'r':
			reponame = optarg;
			break;
+
		case 'R':
+
			opt = INFO_RAW;
+
			break;
		case 'S':
			search = search_label_opt(optarg);
			break;
@@ -380,7 +383,7 @@ exec_search(int argc, char **argv)
		return (EX_IOERR);
	}

-
	flags = info_flags(opt);
+
	flags = info_flags(opt, true);
	while ((ret = pkgdb_it_next(it, &pkg, flags)) == EPKG_OK) {
		print_info(pkg, opt);
		atleastone = true;
modified pkg/utils.c
@@ -169,7 +169,7 @@ absolutepath(const char *src, char *dest, size_t dest_len) {

/* what the pkg needs to load in order to display the requested info */
int
-
info_flags(unsigned int opt)
+
info_flags(unsigned int opt, bool remote)
{
	int flags = PKG_LOAD_BASIC;

@@ -204,12 +204,14 @@ info_flags(unsigned int opt)
			 PKG_LOAD_SHLIBS_REQUIRED |
			 PKG_LOAD_SHLIBS_PROVIDED |
			 PKG_LOAD_ANNOTATIONS     |
-
			 PKG_LOAD_DEPS            |
-
			 PKG_LOAD_FILES           |
-
			 PKG_LOAD_DIRS            |
-
			 PKG_LOAD_USERS           |
-
			 PKG_LOAD_GROUPS          |
-
			 PKG_LOAD_SCRIPTS;
+
			 PKG_LOAD_DEPS;
+
		if (!remote) {
+
			flags |= PKG_LOAD_FILES      |
+
				PKG_LOAD_DIRS            |
+
				PKG_LOAD_USERS           |
+
				PKG_LOAD_GROUPS          |
+
				PKG_LOAD_SCRIPTS;
+
		}
	}

	return flags;
@@ -268,9 +270,11 @@ print_info(struct pkg * const pkg, unsigned int options)
	if (!multirepos_enabled)
		pkg_config_string(PKG_CONFIG_REPO, &repourl);

-
	if (options & INFO_RAW) { /* Not for remote packages */
+
	if (options & INFO_RAW) {
		if (pkg_type(pkg) != PKG_REMOTE)
-
			pkg_emit_manifest_file(pkg, stdout, false, NULL);
+
			pkg_emit_manifest_file(pkg, stdout, 0, NULL);
+
		else
+
			pkg_emit_manifest_file(pkg, stdout, PKG_MANIFEST_EMIT_COMPACT, NULL);
		return;
	}