Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
options: remove %Od and %OD they where never used and populated
Baptiste Daroussin committed 22 days ago
commit 903337f70eb05ee161ece7e1936dc861101fb2eb
parent 63c7804
14 files changed +6 -237
modified docs/pkg-query.8
@@ -265,18 +265,12 @@ for mode (permissions), and
for file flags. Same as
.Cm \&%D
but allows specifying suboptions.
-
.It Cm \&%O Ns Op kvdD
+
.It Cm \&%O Ns Op kv
Expands to the list of options of the matched package, where
.Cm k
-
stands for option key,
+
stands for option key and
.Cm v
-
for option value,
-
.Cm d
-
for option default value and
-
.Cm D
-
for option description.
-
Option default values and descriptions are optional metadata and may
-
be blank for certain packages.
+
for option value.
.It Cm \&%L
Expands to the list of license(s) for the matched package.
.It Cm \&%U
modified docs/pkg-rquery.8
@@ -225,18 +225,12 @@ for the package origin, and
for the package version.
.It Cm \&%C
Expands to the list of categories the matched package belongs to.
-
.It Cm \&%O Ns Op Cm kvdD
+
.It Cm \&%O Ns Op Cm kv
Expands to the list of options of the matched package, where
.Cm k
-
stands for option key
+
stands for option key and
.Cm v
-
for option value,
-
.Cm d
-
for option default value, and
-
.Cm D
-
for option description.
-
Option default values and descriptions are optional metadata and may
-
be blank for certain packages or repositories.
+
for option value.
.It Cm \&%L
Expands to the list of license(s) for the matched package.
.It Cm \&%B
modified docs/pkg_printf.3
@@ -571,14 +571,6 @@ Option name [string]
.It Cm %Ov
Option value [string]
.Vt struct pkg_option *
-
.It Cm %Od
-
Option default value [string] (if known: will produce an empty string
-
if not.)
-
.Vt struct pkg_option *
-
.It Cm %OD
-
Option description [string] (if known: will produce an empty string
-
if not.)
-
.Vt struct pkg_option *
.It Cm \^%R
Repository path - the path relative to the repository root that
package may be downloaded from [string].
modified libpkg/pkg.c
@@ -816,74 +816,6 @@ pkg_addoption(struct pkg *pkg, const char *key, const char *value)
	return (EPKG_OK);
}

-
int
-
pkg_addoption_default(struct pkg *pkg, const char *key,
-
		      const char *default_value)
-
{
-
	struct pkg_option *o = NULL;
-

-
	assert(pkg != NULL);
-
	assert(key != NULL && key[0] != '\0');
-
	assert(default_value != NULL && default_value[0] != '\0');
-

-
	/* There might be a value or description for the option
-
	   already, so we only count it as a duplicate if the
-
	   default_value field is already set. Which implies there
-
	   could be a default value or description for an option but
-
	   no actual value. */
-

-
	if (pkghash_get(pkg->optionshash, key) != NULL) {
-
		if (ctx.developer_mode) {
-
			pkg_emit_error("duplicate default value for option: %s, fatal (developer mode)", key);
-
			return (EPKG_FATAL);
-
		} else {
-
			pkg_emit_error("duplicate default value for option: %s, ignoring", key);
-
			return (EPKG_OK);
-
		}
-
	}
-
	o = xcalloc(1, sizeof(*o));
-
	o->key = xstrdup(key);
-
	o->default_value = xstrdup(default_value);
-
	pkghash_safe_add(pkg->optionshash, o->key, o, NULL);
-
	DL_APPEND(pkg->options, o);
-

-
	return (EPKG_OK);
-
}
-

-
int
-
pkg_addoption_description(struct pkg *pkg, const char *key,
-
			  const char *description)
-
{
-
	struct pkg_option *o = NULL;
-

-
	assert(pkg != NULL);
-
	assert(key != NULL && key[0] != '\0');
-
	assert(description != NULL && description[0] != '\0');
-

-
	/* There might be a value or default for the option already,
-
	   so we only count it as a duplicate if the description field
-
	   is already set. Which implies there could be a default
-
	   value or description for an option but no actual value. */
-

-
	if (pkghash_get(pkg->optionshash, key) != NULL) {
-
		if (ctx.developer_mode) {
-
			pkg_emit_error("duplicate description for option: %s, fatal (developer mode)", key);
-
			return (EPKG_FATAL);
-
		} else {
-
			pkg_emit_error("duplicate description for option: %s, ignoring", key);
-
			return (EPKG_OK);
-
		}
-
	}
-

-
	o = xcalloc(1, sizeof(*o));
-
	o->key = xstrdup(key);
-
	o->description = xstrdup(description);
-
	pkghash_safe_add(pkg->optionshash, o->key, o, NULL);
-
	DL_APPEND(pkg->options, o);
-

-
	return (EPKG_OK);
-
}
-

enum pkg_shlib_flags
pkg_shlib_flags_from_abi(const struct pkg_abi *shlib_abi)
{
modified libpkg/pkg_attributes.c
@@ -106,8 +106,6 @@ pkg_option_free(struct pkg_option *option)

	free(option->key);
	free(option->value);
-
	free(option->default_value);
-
	free(option->description);
	free(option);
}

modified libpkg/pkg_manifest.c
@@ -38,8 +38,6 @@ enum {
	MANIFEST_LICENSES,
	MANIFEST_LUA_SCRIPTS,
	MANIFEST_OPTIONS,
-
	MANIFEST_OPTION_DEFAULTS,
-
	MANIFEST_OPTION_DESCRIPTIONS,
	MANIFEST_PROVIDES,
	MANIFEST_REQUIRES,
	MANIFEST_SCRIPTS,
@@ -146,12 +144,6 @@ static const struct pkg_manifest_key {
	{ "options",             MANIFEST_OPTIONS,
			TYPE_SHIFT(UCL_OBJECT), pkg_obj},

-
	{ "option_defaults",     MANIFEST_OPTION_DEFAULTS,
-
			TYPE_SHIFT(UCL_OBJECT), pkg_obj},
-

-
	{ "option_descriptions", MANIFEST_OPTION_DESCRIPTIONS,
-
			TYPE_SHIFT(UCL_OBJECT), pkg_obj},
-

	{ "origin",              offsetof(struct pkg, origin),
			TYPE_SHIFT(UCL_STRING), pkg_string},

@@ -521,22 +513,6 @@ pkg_obj(struct pkg *pkg, const ucl_object_t *obj, uint32_t attr)
				pkg_addoption(pkg, key, ucl_object_toboolean(cur) ? "on" : "off");
			}
			break;
-
		case MANIFEST_OPTION_DEFAULTS:
-
			if (cur->type != UCL_STRING)
-
				pkg_emit_error("Skipping malformed option default %s",
-
				    key);
-
			else
-
				pkg_addoption_default(pkg, key,
-
				    ucl_object_tostring(cur));
-
			break;
-
		case MANIFEST_OPTION_DESCRIPTIONS:
-
			if (cur->type != UCL_STRING)
-
				pkg_emit_error("Skipping malformed option description %s",
-
				    key);
-
			else
-
				pkg_addoption_description(pkg, key,
-
				    ucl_object_tostring(cur));
-
			break;
		case MANIFEST_SCRIPTS:
			if (cur->type != UCL_STRING)
				pkg_emit_error("Skipping malformed scripts %s",
modified libpkg/pkg_printf.c
@@ -465,24 +465,6 @@ static const struct pkg_printf_fmt fmt[] = {
		PP_PKG|PP_O,
		&format_option_value,
	},
-
	[PP_PKG_OPTION_DEFAULT] =
-
	{
-
		'O',
-
		'd',
-
		false,
-
		false,
-
		PP_PKG|PP_O,
-
		&format_option_default,
-
	},
-
	[PP_PKG_OPTION_DESCRIPTION] =
-
	{
-
		'O',
-
		'D',
-
		false,
-
		false,
-
		PP_PKG|PP_O,
-
		&format_option_description,
-
	},
	[PP_PKG_OPTIONS] =
	{
		'O',
@@ -1513,28 +1495,6 @@ format_option_value(xstring *buf, const void *data, struct percent_esc *p)
}

/*
-
 * %Od -- Option default value.
-
 */
-
xstring *
-
format_option_default(xstring *buf, const void *data, struct percent_esc *p)
-
{
-
	const struct pkg_option	*option = data;
-

-
	return (string_val(buf, option == NULL ? NULL: option->value, p));
-
}
-

-
/*
-
 * %OD -- Option description
-
 */
-
xstring *
-
format_option_description(xstring *buf, const void *data, struct percent_esc *p)
-
{
-
	const struct pkg_option	*option = data;
-

-
	return (string_val(buf, option == NULL ? NULL: option->description, p));
-
}
-

-
/*
 * %Q -- pkg architecture a.k.a ABI string.  Accepts field-width, left-align
 */
xstring *
modified libpkg/pkgdb.c
@@ -387,10 +387,6 @@ pkgdb_init(sqlite3 *sdb)
		"option_id INTEGER PRIMARY KEY,"
		"option TEXT NOT NULL UNIQUE"
	");"
-
	"CREATE TABLE option_desc ("
-
		"option_desc_id INTEGER PRIMARY KEY,"
-
		"option_desc TEXT NOT NULL UNIQUE"
-
	");"
	"CREATE TABLE pkg_option ("
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
			"ON DELETE CASCADE ON UPDATE CASCADE,"
@@ -399,24 +395,6 @@ pkgdb_init(sqlite3 *sdb)
		"value TEXT NOT NULL,"
		"PRIMARY KEY(package_id, option_id)"
	");"
-
	"CREATE TABLE pkg_option_desc ("
-
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
-
			"ON DELETE CASCADE ON UPDATE CASCADE,"
-
		"option_id INTEGER NOT NULL REFERENCES option(option_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"option_desc_id INTEGER NOT NULL "
-
			"REFERENCES option_desc(option_desc_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"PRIMARY KEY(package_id, option_id)"
-
	");"
-
	"CREATE TABLE pkg_option_default ("
-
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
-
			"ON DELETE CASCADE ON UPDATE CASCADE,"
-
		"option_id INTEGER NOT NULL REFERENCES option(option_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"default_value TEXT NOT NULL,"
-
		"PRIMARY KEY(package_id, option_id)"
-
	");"
	"CREATE TABLE deps ("
		"origin TEXT NOT NULL,"
		"name TEXT NOT NULL,"
modified libpkg/pkgdb_iterator.c
@@ -776,23 +776,6 @@ pkgdb_load_options(sqlite3 *sqlite, struct pkg *pkg)
			"  ORDER BY option",
			pkg_addoption,
		},
-
		{
-
			"SELECT option, default_value"
-
			"  FROM option"
-
			"    JOIN pkg_option_default USING(option_id)"
-
			"  WHERE package_id = ?1"
-
			"  ORDER BY option",
-
			pkg_addoption_default,
-
		},
-
		{
-
			"SELECT option, description"
-
			"  FROM option"
-
			"    JOIN pkg_option_desc USING(option_id)"
-
			"    JOIN option_desc USING(option_desc_id)"
-
			"  WHERE package_id = ?1"
-
			"  ORDER BY option",
-
			pkg_addoption_description,
-
		}
	};
	const char		 *opt_sql;
	int			(*pkg_addtagval)(struct pkg *pkg,
modified libpkg/private/pkg.h
@@ -413,8 +413,6 @@ struct pkg_dir {
struct pkg_option {
	char	*key;
	char	*value;
-
	char	*default_value;
-
	char	*description;
	struct pkg_option *next, *prev;
};

@@ -885,8 +883,6 @@ int pkg_addrequire(struct pkg *pkg, const char *name);
int pkg_addconfig_file(struct pkg *pkg, const char *name, const char *buf);

int pkg_addoption(struct pkg *pkg, const char *name, const char *value);
-
int pkg_addoption_default(struct pkg *pkg, const char *key, const char *default_value);
-
int pkg_addoption_description(struct pkg *pkg, const char *key, const char *description);

int pkg_arch_to_legacy(const char *arch, char *dest, size_t sz);
bool pkg_is_config_file(struct pkg *p, const char *path, const struct pkg_file **file, struct pkg_config_file **cfile);
modified libpkg/private/pkg_printf.h
@@ -109,8 +109,6 @@ typedef enum _fmt_code_t {
	PP_PKG_REPO_IDENT,
	PP_PKG_OPTION_NAME,
	PP_PKG_OPTION_VALUE,
-
	PP_PKG_OPTION_DEFAULT,
-
	PP_PKG_OPTION_DESCRIPTION,
	PP_PKG_OPTIONS,
	PP_PKG_ALTABI,
	PP_PKG_REPO_PATH,
@@ -204,8 +202,6 @@ _static xstring *format_repo_ident(xstring *, const void *, struct percent_esc *
_static xstring *format_options(xstring *, const void *, struct percent_esc *);
_static xstring *format_option_name(xstring *, const void *, struct percent_esc *);
_static xstring *format_option_value(xstring *, const void *, struct percent_esc *);
-
_static xstring *format_option_default(xstring *, const void *, struct percent_esc *);
-
_static xstring *format_option_description(xstring *, const void *, struct percent_esc *);
_static xstring *format_repo_path(xstring *, const void *, struct percent_esc *);
_static xstring *format_char_string(xstring *, const void *, struct percent_esc *);
_static xstring *format_users(xstring *, const void *, struct percent_esc *);
modified libpkg/repo/binary/binary_private.h
@@ -87,10 +87,6 @@ static const char binary_repo_initsql[] = ""
		"option_id INTEGER PRIMARY KEY,"
		"option TEXT NOT NULL UNIQUE"
	");"
-
	"CREATE TABLE option_desc ("
-
		"option_desc_id INTEGER PRIMARY KEY,"
-
		"option_desc TEXT NOT NULL UNIQUE"
-
	");"
	"CREATE TABLE pkg_option ("
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
			"ON DELETE CASCADE ON UPDATE CASCADE,"
@@ -99,24 +95,6 @@ static const char binary_repo_initsql[] = ""
		"value TEXT NOT NULL,"
		"PRIMARY KEY(package_id, option_id)"
	");"
-
	"CREATE TABLE pkg_option_desc ("
-
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
-
			"ON DELETE CASCADE ON UPDATE CASCADE,"
-
		"option_id INTEGER NOT NULL REFERENCES option(option_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"option_desc_id INTEGER NOT NULL "
-
			"REFERENCES option_desc(option_desc_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"PRIMARY KEY(package_id, option_id)"
-
	");"
-
	"CREATE TABLE pkg_option_default ("
-
		"package_id INTEGER NOT NULL REFERENCES packages(id) "
-
			"ON DELETE CASCADE ON UPDATE CASCADE,"
-
		"option_id INTEGER NOT NULL REFERENCES option(option_id) "
-
			"ON DELETE RESTRICT ON UPDATE CASCADE,"
-
		"default_value TEXT NOT NULL,"
-
		"PRIMARY KEY(package_id, option_id)"
-
	");"
	"CREATE TABLE shlibs ("
	    "id INTEGER PRIMARY KEY,"
	    "name TEXT NOT NULL UNIQUE "
modified src/query.c
@@ -288,10 +288,6 @@ format_str(struct pkg *pkg, xstring *dest, const char *qstr, const void *data)
					pkg_fprintf(dest->fp, "%On", data);
				else if (qstr[0] == 'v')
					pkg_fprintf(dest->fp, "%Ov", data);
-
				else if (qstr[0] == 'd') /* default value */
-
					pkg_fprintf(dest->fp, "%Od", data);
-
				else if (qstr[0] == 'D') /* description */
-
					pkg_fprintf(dest->fp, "%OD", data);
				break;
			case 'D':
				pkg_fprintf(dest->fp, "%Dn", data);
modified tests/lib/pkg_printf_test.c
@@ -1356,8 +1356,6 @@ ATF_TC_BODY(format_code, tc)
		{ "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', },
-
		{ "Od", PP_PKG, PP_PKG_OPTION_DEFAULT,      2, '\0', },
-
		{ "OD", PP_PKG, PP_PKG_OPTION_DESCRIPTION,  2, '\0', },
		{ "O",  PP_PKG, PP_PKG_OPTIONS,             1, '\0', },
		{ "R",  PP_PKG, PP_PKG_REPO_PATH,           1, '\0', },
		{ "S",  PP_PKG, PP_PKG_CHAR_STRING,         1, '\0', },
@@ -1822,8 +1820,6 @@ ATF_TC_BODY(format_code, tc)
		{ "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', },
-
		{ "Od", PP_O, PP_PKG_OPTION_DEFAULT,      2, '\0', },
-
		{ "OD", PP_O, PP_PKG_OPTION_DESCRIPTION,  2, '\0', },
		{ "O",  PP_O, PP_UNKNOWN,                 0, 'O',  },
		{ "R",  PP_O, PP_PKG_REPO_PATH,           1, '\0', },
		{ "S",  PP_O, PP_UNKNOWN,                 0, 'S',  },