Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Actually, change %N to produce the repo identity -- the tag that is used in pkg.conf(5) -- rather than repo name: the basename of the sqlite file and the name the database is mounted as (which is properly of interest only to the inernals of pkg, and not what we want pkg query etc. to display).
Matthew Seaman committed 12 years ago
commit 230613248b9363b4052b61bb7f07d227c531dada
parent e5ff66b
7 files changed +32 -25
modified libpkg/pkg.h.in
@@ -1377,6 +1377,7 @@ int pkg_repos(struct pkg_repo **);
const char *pkg_repo_url(struct pkg_repo *r);
const char *pkg_repo_ident(struct pkg_repo *r);
const char *pkg_repo_name(struct pkg_repo *r);
+
const char * pkg_repo_ident_from_name(const char *repo_name);
const char *pkg_repo_key(struct pkg_repo *r);
bool pkg_repo_enabled(struct pkg_repo *r);
mirror_t pkg_repo_mirror_type(struct pkg_repo *r);
modified libpkg/pkg_config.c
@@ -1211,6 +1211,13 @@ pkg_repo_ident(struct pkg_repo *r)
	return (r->name + strlen(REPO_NAME_PREFIX));
}

+
/* Ditto: The repo identifier from pkg.conf(5): without the 'repo-' prefix */
+
const char *
+
pkg_repo_ident_from_name(const char *repo_name)
+
{
+
	return (repo_name + strlen(REPO_NAME_PREFIX));
+
}
+

/* The basename of the sqlite DB file and the database name */
const char *
pkg_repo_name(struct pkg_repo *r)
modified libpkg/pkg_printf.3
@@ -584,7 +584,7 @@ Licence name [string]
Package message [string]
.Vt struct pkg *
.It Cm %N
-
Repository name [string]
+
Repository identity [string]
.Vt struct pkg *
.It Cm \^%O
Options [array]
modified libpkg/pkg_printf.c
@@ -423,14 +423,14 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_ALL,
		&format_message,
	},
-
	[PP_PKG_REPO_NAME] =
+
	[PP_PKG_REPO_IDENT] =
	{
		'N',
		'\0',
		false,
		true,
		PP_ALL,
-
		&format_repo_name,
+
		&format_repo_ident,
	},
	[PP_PKG_OPTION_NAME] =
	{
@@ -1264,16 +1264,16 @@ format_message(struct sbuf *sbuf, const void *data, struct percent_esc *p)
}

/*
-
 * %N -- Repository name. string.  Accepts field-width, left-align
+
 * %N -- Repository identity. string.  Accepts field-width, left-align
 */
struct sbuf *
-
format_repo_name(struct sbuf *sbuf, const void *data, struct percent_esc *p)
+
format_repo_ident(struct sbuf *sbuf, const void *data, struct percent_esc *p)
{
	const struct pkg	*pkg = data;
-
	const char		*repo_name;
+
	const char		*reponame;

-
	pkg_get(pkg, PKG_REPONAME, &repo_name);
-
	return (string_val(sbuf, repo_name, p));
+
	pkg_get(pkg, PKG_REPONAME, &reponame);
+
	return (string_val(sbuf, pkg_repo_ident_from_name(reponame), p));
}

/*
modified libpkg/private/pkg_printf.h
@@ -102,7 +102,7 @@ typedef enum _fmt_code_t {
	PP_PKG_LICENSE_NAME,
	PP_PKG_LICENSES,
	PP_PKG_MESSAGE,
-
	PP_PKG_REPO_NAME,
+
	PP_PKG_REPO_IDENT,
	PP_PKG_OPTION_NAME,
	PP_PKG_OPTION_VALUE,
	PP_PKG_OPTIONS,
@@ -187,7 +187,7 @@ _static struct sbuf *format_row_counter(struct sbuf *, const void *, struct perc
_static struct sbuf *format_licenses(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_license_name(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_message(struct sbuf *, const void *, struct percent_esc *);
-
_static struct sbuf *format_repo_name(struct sbuf *, const void *, struct percent_esc *);
+
_static struct sbuf *format_repo_ident(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_options(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_name(struct sbuf *, const void *, struct percent_esc *);
_static struct sbuf *format_option_value(struct sbuf *, const void *, struct percent_esc *);
modified pkg/utils.c
@@ -223,14 +223,13 @@ print_info(struct pkg * const pkg, unsigned int options)
	bool print_tag = false;
	bool show_locks = false;
	char size[7];
-
	const char *reponame, *repourl;
+
	const char *repourl;
	unsigned opt;
	int64_t flatsize, oldflatsize, pkgsize;
	int cout = 0;		/* Number of characters output */
	int info_num;		/* Number of different data items to print */

	pkg_get(pkg,
-
		PKG_REPONAME,      &reponame,
		PKG_REPOURL,       &repourl,
		PKG_FLATSIZE,      &flatsize,
		PKG_OLD_FLATSIZE,  &oldflatsize,
@@ -331,7 +330,7 @@ print_info(struct pkg * const pkg, unsigned int options)
			    repourl != NULL && repourl[0] != '\0') {
				if (print_tag)
					printf("%-15s: ", "Repository");
-
				printf("%s [%s]\n", reponame, repourl);
+
				pkg_printf("%N [%S]\n", pkg, repourl);
			} else if (!print_tag)
				printf("\n");
			break;
modified tests/lib/pkg_printf_test.c
@@ -1375,7 +1375,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_PKG, PP_PKG_LICENSE_NAME,        2, '\0', },
		{ "L",  PP_PKG, PP_PKG_LICENSES,            1, '\0', },
		{ "M",  PP_PKG, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_PKG, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_PKG, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_PKG, PP_PKG_OPTION_NAME,         2, '\0', },
		{ "Ov", PP_PKG, PP_PKG_OPTION_VALUE,        2, '\0', },
		{ "O",  PP_PKG, PP_PKG_OPTIONS,             1, '\0', },
@@ -1440,7 +1440,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_B, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_B, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_B, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_B, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_B, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_B, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_B, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_B, PP_UNKNOWN,                 0, 'O',  },
@@ -1505,7 +1505,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_C, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_C, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_C, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_C, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_C, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_C, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_C, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_C, PP_UNKNOWN,                 0, 'O',  },
@@ -1570,7 +1570,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_D, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_D, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_D, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_D, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_D, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_D, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_D, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_D, PP_UNKNOWN,                 0, 'O',  },
@@ -1635,7 +1635,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_F, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_F, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_F, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_F, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_F, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_F, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_F, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_F, PP_UNKNOWN,                 0, 'O',  },
@@ -1700,7 +1700,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_G, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_G, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_G, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_G, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_G, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_G, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_G, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_G, PP_UNKNOWN,                 0, 'O',  },
@@ -1765,7 +1765,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_L, PP_PKG_LICENSE_NAME,        2, '\0', },
		{ "L",  PP_L, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_L, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_L, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_L, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_L, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_L, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_L, PP_UNKNOWN,                 0, 'O',  },
@@ -1830,7 +1830,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_O, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_O, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_O, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_O, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_O, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_O, PP_PKG_OPTION_NAME,         2, '\0', },
		{ "Ov", PP_O, PP_PKG_OPTION_VALUE,        2, '\0', },
		{ "O",  PP_O, PP_UNKNOWN,                 0, 'O',  },
@@ -1895,7 +1895,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_U, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_U, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_U, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_U, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_U, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_U, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_U, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_U, PP_UNKNOWN,                 0, 'O',  },
@@ -1960,7 +1960,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_b, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_b, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_b, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_b, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_b, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_b, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_b, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_b, PP_UNKNOWN,                 0, 'O',  },
@@ -2026,7 +2026,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_d, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_d, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_d, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_d, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_d, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_d, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_d, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_d, PP_UNKNOWN,                 0, 'O',  },
@@ -2091,7 +2091,7 @@ ATF_TC_BODY(format_code, tc)
		{ "Ln", PP_r, PP_UNKNOWN,                 0, 'L',  },
		{ "L",  PP_r, PP_UNKNOWN,                 0, 'L',  },
		{ "M",  PP_r, PP_PKG_MESSAGE,             1, '\0', },
-
		{ "N",  PP_r, PP_PKG_REPO_NAME,           1, '\0', },
+
		{ "N",  PP_r, PP_PKG_REPO_IDENT,          1, '\0', },
		{ "On", PP_r, PP_UNKNOWN,                 0, 'O',  },
		{ "Ov", PP_r, PP_UNKNOWN,                 0, 'O',  },
		{ "O",  PP_r, PP_UNKNOWN,                 0, 'O',  },