FreeBSD Bugzilla – Attachment 163027 Details for
Bug 204480
ports-mgmt/pkg Allow repo config to be embedded within the pkg.conf file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
patch
local-patch-repos-libpkg_pkg__config.c (text/plain), 3.46 KB, created by
Ian Lepore
on 2015-11-11 22:52:17 UTC
(
hide
)
Description:
patch
Filename:
MIME Type:
Creator:
Ian Lepore
Created:
2015-11-11 22:52:17 UTC
Size:
3.46 KB
patch
obsolete
>Allow repo configuration to be embedded within the pkg.conf file. >Any unrecognized key with an object type of UCL_OBJECT is parsed as if it >were found in a repo config file. > >--- ./libpkg/pkg_config.c.orig 2015-11-11 14:54:50.125248000 -0700 >+++ ./libpkg/pkg_config.c 2015-11-11 15:22:26.890375000 -0700 >@@ -638,7 +638,21 @@ add_repo(const ucl_object_t *obj, struct > } > > static void >-walk_repo_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) >+add_repo_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) >+{ >+ struct pkg_repo *r; >+ const char *key; >+ >+ key = ucl_object_key(obj); >+ pkg_debug(1, "PkgConfig: parsing repo key '%s' in file '%s'", key, file); >+ r = pkg_repo_find(key); >+ if (r != NULL) >+ pkg_debug(1, "PkgConfig: overwriting repository %s", key); >+ add_repo(obj, r, key, flags); >+} >+ >+static void >+walk_repofile_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) > { > const ucl_object_t *cur; > ucl_object_iter_t it = NULL; >@@ -646,13 +660,8 @@ walk_repo_obj(const ucl_object_t *obj, c > const char *key; > > while ((cur = ucl_iterate_object(obj, &it, true))) { >- key = ucl_object_key(cur); >- pkg_debug(1, "PkgConfig: parsing key '%s'", key); >- r = pkg_repo_find(key); >- if (r != NULL) >- pkg_debug(1, "PkgConfig: overwriting repository %s", key); > if (cur->type == UCL_OBJECT) >- add_repo(cur, r, key, flags); >+ add_repo_obj(cur, file, flags); > else > pkg_emit_error("Ignoring bad configuration entry in %s: %s", > file, ucl_object_emit(cur, UCL_EMIT_YAML)); >@@ -688,7 +697,7 @@ load_repo_file(const char *repofile, pkg > return; > > if (obj->type == UCL_OBJECT) >- walk_repo_obj(obj, repofile, flags); >+ walk_repofile_obj(obj, repofile, flags); > > ucl_object_unref(obj); > } >@@ -782,7 +791,7 @@ pkg_ini(const char *path, const char *re > const char *useragent = NULL; > const char *evpipe = NULL; > const ucl_object_t *cur, *object; >- ucl_object_t *obj = NULL, *o, *ncfg; >+ ucl_object_t *obj = NULL, *o, *ncfg, *repos; > ucl_object_iter_t it = NULL; > struct sbuf *ukey = NULL; > bool fatal_errors = false; >@@ -905,6 +914,7 @@ pkg_ini(const char *path, const char *re > } > > ncfg = NULL; >+ repos = NULL; > while (obj != NULL && (cur = ucl_iterate_object(obj, &it, true))) { > sbuf_init(&ukey); > key = ucl_object_key(cur); >@@ -924,9 +934,20 @@ pkg_ini(const char *path, const char *re > continue; > } > >- /* ignore unknown keys */ >- if (object == NULL) >+ /* >+ * Save UCL_OBJECTs for later processing as potential embedded >+ * repos and ignore other types of unknown keys. >+ */ >+ if (object == NULL) { >+ if (cur->type == UCL_OBJECT) { >+ if (repos == NULL) >+ repos = ucl_object_typed_new(UCL_OBJECT); >+ ucl_object_insert_key(repos, ucl_object_copy(cur), >+ key, strlen(key), true); >+ pkg_debug(1, "potential repo: %s", key); >+ } > continue; >+ } > > if (object->type != cur->type) { > pkg_emit_error("Malformed key %s, ignoring", key); >@@ -1081,6 +1100,16 @@ pkg_ini(const char *path, const char *re > useragent = pkg_object_string(pkg_config_get("HTTP_USER_AGENT")); > setenv("HTTP_USER_AGENT", useragent, 1); > >+ /* Process any repos that were embedded in pkg.conf */ >+ if (repos != NULL) { >+ it = NULL; >+ while ((cur = ucl_iterate_object(repos, &it, true))) { >+ key = ucl_object_key(cur); >+ add_repo_obj(cur, path, flags); >+ } >+ ucl_object_unref(repos); >+ } >+ > /* load the repositories */ > load_repositories(reposdir, flags); >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 204480
: 163027