Lines 638-644
add_repo(const ucl_object_t *obj, struct
Link Here
|
638 |
} |
638 |
} |
639 |
|
639 |
|
640 |
static void |
640 |
static void |
641 |
walk_repo_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) |
641 |
add_repo_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) |
|
|
642 |
{ |
643 |
struct pkg_repo *r; |
644 |
const char *key; |
645 |
|
646 |
key = ucl_object_key(obj); |
647 |
pkg_debug(1, "PkgConfig: parsing repo key '%s' in file '%s'", key, file); |
648 |
r = pkg_repo_find(key); |
649 |
if (r != NULL) |
650 |
pkg_debug(1, "PkgConfig: overwriting repository %s", key); |
651 |
add_repo(obj, r, key, flags); |
652 |
} |
653 |
|
654 |
static void |
655 |
walk_repofile_obj(const ucl_object_t *obj, const char *file, pkg_init_flags flags) |
642 |
{ |
656 |
{ |
643 |
const ucl_object_t *cur; |
657 |
const ucl_object_t *cur; |
644 |
ucl_object_iter_t it = NULL; |
658 |
ucl_object_iter_t it = NULL; |
Lines 646-658
walk_repo_obj(const ucl_object_t *obj, c
Link Here
|
646 |
const char *key; |
660 |
const char *key; |
647 |
|
661 |
|
648 |
while ((cur = ucl_iterate_object(obj, &it, true))) { |
662 |
while ((cur = ucl_iterate_object(obj, &it, true))) { |
649 |
key = ucl_object_key(cur); |
|
|
650 |
pkg_debug(1, "PkgConfig: parsing key '%s'", key); |
651 |
r = pkg_repo_find(key); |
652 |
if (r != NULL) |
653 |
pkg_debug(1, "PkgConfig: overwriting repository %s", key); |
654 |
if (cur->type == UCL_OBJECT) |
663 |
if (cur->type == UCL_OBJECT) |
655 |
add_repo(cur, r, key, flags); |
664 |
add_repo_obj(cur, file, flags); |
656 |
else |
665 |
else |
657 |
pkg_emit_error("Ignoring bad configuration entry in %s: %s", |
666 |
pkg_emit_error("Ignoring bad configuration entry in %s: %s", |
658 |
file, ucl_object_emit(cur, UCL_EMIT_YAML)); |
667 |
file, ucl_object_emit(cur, UCL_EMIT_YAML)); |
Lines 688-694
load_repo_file(const char *repofile, pkg
Link Here
|
688 |
return; |
697 |
return; |
689 |
|
698 |
|
690 |
if (obj->type == UCL_OBJECT) |
699 |
if (obj->type == UCL_OBJECT) |
691 |
walk_repo_obj(obj, repofile, flags); |
700 |
walk_repofile_obj(obj, repofile, flags); |
692 |
|
701 |
|
693 |
ucl_object_unref(obj); |
702 |
ucl_object_unref(obj); |
694 |
} |
703 |
} |
Lines 782-788
pkg_ini(const char *path, const char *re
Link Here
|
782 |
const char *useragent = NULL; |
791 |
const char *useragent = NULL; |
783 |
const char *evpipe = NULL; |
792 |
const char *evpipe = NULL; |
784 |
const ucl_object_t *cur, *object; |
793 |
const ucl_object_t *cur, *object; |
785 |
ucl_object_t *obj = NULL, *o, *ncfg; |
794 |
ucl_object_t *obj = NULL, *o, *ncfg, *repos; |
786 |
ucl_object_iter_t it = NULL; |
795 |
ucl_object_iter_t it = NULL; |
787 |
struct sbuf *ukey = NULL; |
796 |
struct sbuf *ukey = NULL; |
788 |
bool fatal_errors = false; |
797 |
bool fatal_errors = false; |
Lines 905-910
pkg_ini(const char *path, const char *re
Link Here
|
905 |
} |
914 |
} |
906 |
|
915 |
|
907 |
ncfg = NULL; |
916 |
ncfg = NULL; |
|
|
917 |
repos = NULL; |
908 |
while (obj != NULL && (cur = ucl_iterate_object(obj, &it, true))) { |
918 |
while (obj != NULL && (cur = ucl_iterate_object(obj, &it, true))) { |
909 |
sbuf_init(&ukey); |
919 |
sbuf_init(&ukey); |
910 |
key = ucl_object_key(cur); |
920 |
key = ucl_object_key(cur); |
Lines 924-932
pkg_ini(const char *path, const char *re
Link Here
|
924 |
continue; |
934 |
continue; |
925 |
} |
935 |
} |
926 |
|
936 |
|
927 |
/* ignore unknown keys */ |
937 |
/* |
928 |
if (object == NULL) |
938 |
* Save UCL_OBJECTs for later processing as potential embedded |
|
|
939 |
* repos and ignore other types of unknown keys. |
940 |
*/ |
941 |
if (object == NULL) { |
942 |
if (cur->type == UCL_OBJECT) { |
943 |
if (repos == NULL) |
944 |
repos = ucl_object_typed_new(UCL_OBJECT); |
945 |
ucl_object_insert_key(repos, ucl_object_copy(cur), |
946 |
key, strlen(key), true); |
947 |
pkg_debug(1, "potential repo: %s", key); |
948 |
} |
929 |
continue; |
949 |
continue; |
|
|
950 |
} |
930 |
|
951 |
|
931 |
if (object->type != cur->type) { |
952 |
if (object->type != cur->type) { |
932 |
pkg_emit_error("Malformed key %s, ignoring", key); |
953 |
pkg_emit_error("Malformed key %s, ignoring", key); |
Lines 1081-1086
pkg_ini(const char *path, const char *re
Link Here
|
1081 |
useragent = pkg_object_string(pkg_config_get("HTTP_USER_AGENT")); |
1100 |
useragent = pkg_object_string(pkg_config_get("HTTP_USER_AGENT")); |
1082 |
setenv("HTTP_USER_AGENT", useragent, 1); |
1101 |
setenv("HTTP_USER_AGENT", useragent, 1); |
1083 |
|
1102 |
|
|
|
1103 |
/* Process any repos that were embedded in pkg.conf */ |
1104 |
if (repos != NULL) { |
1105 |
it = NULL; |
1106 |
while ((cur = ucl_iterate_object(repos, &it, true))) { |
1107 |
key = ucl_object_key(cur); |
1108 |
add_repo_obj(cur, path, flags); |
1109 |
} |
1110 |
ucl_object_unref(repos); |
1111 |
} |
1112 |
|
1084 |
/* load the repositories */ |
1113 |
/* load the repositories */ |
1085 |
load_repositories(reposdir, flags); |
1114 |
load_repositories(reposdir, flags); |
1086 |
|
1115 |
|