| 1 | --- a/libopkg/opkg.c |
| 2 | +++ b/libopkg/opkg.c |
| 3 | @@ -120,6 +120,9 @@ opkg_new() |
| 4 | if (opkg_conf_init()) |
| 5 | goto err0; |
| 6 | |
| 7 | + if (opkg_conf_load()) |
| 8 | + goto err0; |
| 9 | + |
| 10 | if (pkg_hash_load_feeds()) |
| 11 | goto err1; |
| 12 | |
| 13 | --- a/libopkg/opkg_conf.c |
| 14 | +++ b/libopkg/opkg_conf.c |
| 15 | @@ -91,15 +91,15 @@ opkg_option_t options[] = { |
| 16 | }; |
| 17 | |
| 18 | static int |
| 19 | -resolve_pkg_dest_list(nv_pair_list_t *nv_pair_list) |
| 20 | +resolve_pkg_dest_list(void) |
| 21 | { |
| 22 | nv_pair_list_elt_t *iter; |
| 23 | nv_pair_t *nv_pair; |
| 24 | pkg_dest_t *dest; |
| 25 | char *root_dir; |
| 26 | |
| 27 | - for (iter = nv_pair_list_first(nv_pair_list); iter; |
| 28 | - iter = nv_pair_list_next(nv_pair_list, iter)) { |
| 29 | + for (iter = nv_pair_list_first(&conf->tmp_dest_list); iter; |
| 30 | + iter = nv_pair_list_next(&conf->tmp_dest_list, iter)) { |
| 31 | nv_pair = (nv_pair_t *)iter->data; |
| 32 | |
| 33 | if (conf->offline_root) { |
| 34 | @@ -185,8 +185,7 @@ opkg_conf_set_option(const char *name, c |
| 35 | |
| 36 | static int |
| 37 | opkg_conf_parse_file(const char *filename, |
| 38 | - pkg_src_list_t *pkg_src_list, |
| 39 | - nv_pair_list_t *tmp_dest_nv_pair_list) |
| 40 | + pkg_src_list_t *pkg_src_list) |
| 41 | { |
| 42 | int line_num = 0; |
| 43 | int err = 0; |
| 44 | @@ -269,7 +268,7 @@ opkg_conf_parse_file(const char *filenam |
| 45 | regmatch[11].rm_eo - regmatch[11].rm_so); |
| 46 | } |
| 47 | |
| 48 | - /* We use the tmp_dest_nv_pair_list below instead of |
| 49 | + /* We use the tmp_dest_list below instead of |
| 50 | conf->pkg_dest_list because we might encounter an |
| 51 | offline_root option later and that would invalidate the |
| 52 | directories we would have computed in |
| 53 | @@ -292,7 +291,7 @@ opkg_conf_parse_file(const char *filenam |
| 54 | "Skipping.\n", name, value); |
| 55 | } |
| 56 | } else if (strcmp(type, "dest") == 0) { |
| 57 | - nv_pair_list_append(tmp_dest_nv_pair_list, name, value); |
| 58 | + nv_pair_list_append(&conf->tmp_dest_list, name, value); |
| 59 | } else if (strcmp(type, "lists_dir") == 0) { |
| 60 | conf->lists_dir = xstrdup(value); |
| 61 | } else if (strcmp(type, "arch") == 0) { |
| 62 | @@ -411,9 +410,19 @@ glob_errfunc(const char *epath, int eerr |
| 63 | int |
| 64 | opkg_conf_init(void) |
| 65 | { |
| 66 | + pkg_src_list_init(&conf->pkg_src_list); |
| 67 | + pkg_dest_list_init(&conf->pkg_dest_list); |
| 68 | + pkg_dest_list_init(&conf->tmp_dest_list); |
| 69 | + nv_pair_list_init(&conf->arch_list); |
| 70 | + |
| 71 | + return 0; |
| 72 | +} |
| 73 | + |
| 74 | +int |
| 75 | +opkg_conf_load(void) |
| 76 | +{ |
| 77 | int i, glob_ret; |
| 78 | char *tmp, *tmp_dir_base, **tmp_val; |
| 79 | - nv_pair_list_t tmp_dest_nv_pair_list; |
| 80 | glob_t globbuf; |
| 81 | char *etc_opkg_conf_pattern; |
| 82 | |
| 83 | @@ -423,11 +432,6 @@ opkg_conf_init(void) |
| 84 | conf->check_x509_path = 1; |
| 85 | #endif |
| 86 | |
| 87 | - pkg_src_list_init(&conf->pkg_src_list); |
| 88 | - pkg_dest_list_init(&conf->pkg_dest_list); |
| 89 | - nv_pair_list_init(&conf->arch_list); |
| 90 | - nv_pair_list_init(&tmp_dest_nv_pair_list); |
| 91 | - |
| 92 | if (!conf->offline_root) |
| 93 | conf->offline_root = xstrdup(getenv("OFFLINE_ROOT")); |
| 94 | |
| 95 | @@ -438,7 +442,7 @@ opkg_conf_init(void) |
| 96 | goto err0; |
| 97 | } |
| 98 | if (opkg_conf_parse_file(conf->conf_file, |
| 99 | - &conf->pkg_src_list, &tmp_dest_nv_pair_list)) |
| 100 | + &conf->pkg_src_list)) |
| 101 | goto err1; |
| 102 | } |
| 103 | |
| 104 | @@ -467,7 +471,7 @@ opkg_conf_init(void) |
| 105 | !strcmp(conf->conf_file, globbuf.gl_pathv[i])) |
| 106 | continue; |
| 107 | if ( opkg_conf_parse_file(globbuf.gl_pathv[i], |
| 108 | - &conf->pkg_src_list, &tmp_dest_nv_pair_list)<0) { |
| 109 | + &conf->pkg_src_list)<0) { |
| 110 | globfree(&globbuf); |
| 111 | goto err1; |
| 112 | } |
| 113 | @@ -528,16 +532,16 @@ opkg_conf_init(void) |
| 114 | } |
| 115 | |
| 116 | /* Even if there is no conf file, we'll need at least one dest. */ |
| 117 | - if (nv_pair_list_empty(&tmp_dest_nv_pair_list)) { |
| 118 | - nv_pair_list_append(&tmp_dest_nv_pair_list, |
| 119 | + if (nv_pair_list_empty(&conf->tmp_dest_list)) { |
| 120 | + nv_pair_list_append(&conf->tmp_dest_list, |
| 121 | OPKG_CONF_DEFAULT_DEST_NAME, |
| 122 | OPKG_CONF_DEFAULT_DEST_ROOT_DIR); |
| 123 | } |
| 124 | |
| 125 | - if (resolve_pkg_dest_list(&tmp_dest_nv_pair_list)) |
| 126 | + if (resolve_pkg_dest_list()) |
| 127 | goto err5; |
| 128 | |
| 129 | - nv_pair_list_deinit(&tmp_dest_nv_pair_list); |
| 130 | + nv_pair_list_deinit(&conf->tmp_dest_list); |
| 131 | |
| 132 | return 0; |
| 133 | |
| 134 | @@ -577,7 +581,7 @@ err1: |
| 135 | } |
| 136 | } |
| 137 | err0: |
| 138 | - nv_pair_list_deinit(&tmp_dest_nv_pair_list); |
| 139 | + nv_pair_list_deinit(&conf->tmp_dest_list); |
| 140 | if (conf->dest_str) |
| 141 | free(conf->dest_str); |
| 142 | if (conf->conf_file) |
| 143 | --- a/libopkg/opkg_conf.h |
| 144 | +++ b/libopkg/opkg_conf.h |
| 145 | @@ -46,6 +46,7 @@ struct opkg_conf |
| 146 | { |
| 147 | pkg_src_list_t pkg_src_list; |
| 148 | pkg_dest_list_t pkg_dest_list; |
| 149 | + pkg_dest_list_t tmp_dest_list; |
| 150 | nv_pair_list_t arch_list; |
| 151 | |
| 152 | int restrict_to_default_dest; |
| 153 | @@ -133,6 +134,7 @@ struct opkg_option { |
| 154 | }; |
| 155 | |
| 156 | int opkg_conf_init(void); |
| 157 | +int opkg_conf_load(void); |
| 158 | void opkg_conf_deinit(void); |
| 159 | |
| 160 | int opkg_conf_write_status_files(void); |
| 161 | --- a/src/opkg-cl.c |
| 162 | +++ b/src/opkg-cl.c |
| 163 | @@ -40,6 +40,8 @@ enum { |
| 164 | ARGS_OPT_FORCE_REMOVAL_OF_ESSENTIAL_PACKAGES, |
| 165 | ARGS_OPT_FORCE_SPACE, |
| 166 | ARGS_OPT_FORCE_POSTINSTALL, |
| 167 | + ARGS_OPT_ADD_ARCH, |
| 168 | + ARGS_OPT_ADD_DEST, |
| 169 | ARGS_OPT_NOACTION, |
| 170 | ARGS_OPT_DOWNLOAD_ONLY, |
| 171 | ARGS_OPT_NODEPS, |
| 172 | @@ -82,6 +84,8 @@ static struct option long_options[] = { |
| 173 | {"nodeps", 0, 0, ARGS_OPT_NODEPS}, |
| 174 | {"offline", 1, 0, 'o'}, |
| 175 | {"offline-root", 1, 0, 'o'}, |
| 176 | + {"add-arch", 1, 0, ARGS_OPT_ADD_ARCH}, |
| 177 | + {"add-dest", 1, 0, ARGS_OPT_ADD_DEST}, |
| 178 | {"test", 0, 0, ARGS_OPT_NOACTION}, |
| 179 | {"tmp-dir", 1, 0, 't'}, |
| 180 | {"tmp_dir", 1, 0, 't'}, |
| 181 | @@ -96,6 +100,7 @@ args_parse(int argc, char *argv[]) |
| 182 | int c; |
| 183 | int option_index = 0; |
| 184 | int parse_err = 0; |
| 185 | + char *tuple, *prio; |
| 186 | |
| 187 | while (1) { |
| 188 | c = getopt_long_only(argc, argv, "Ad:f:no:p:t:vV:", |
| 189 | @@ -162,6 +167,21 @@ args_parse(int argc, char *argv[]) |
| 190 | case ARGS_OPT_NODEPS: |
| 191 | conf->nodeps = 1; |
| 192 | break; |
| 193 | + case ARGS_OPT_ADD_ARCH: |
| 194 | + case ARGS_OPT_ADD_DEST: |
| 195 | + tuple = xstrdup(optarg); |
| 196 | + if ((prio = strchr(tuple, ':')) != NULL) { |
| 197 | + *prio++ = 0; |
| 198 | + if ((strlen(tuple) > 0) && (strlen(prio) > 0)) { |
| 199 | + nv_pair_list_append( |
| 200 | + (c == ARGS_OPT_ADD_ARCH) |
| 201 | + ? &conf->arch_list : &conf->tmp_dest_list, |
| 202 | + tuple, prio |
| 203 | + ); |
| 204 | + } |
| 205 | + } |
| 206 | + free(tuple); |
| 207 | + break; |
| 208 | case ARGS_OPT_NOACTION: |
| 209 | conf->noaction = 1; |
| 210 | break; |
| 211 | @@ -240,6 +260,8 @@ usage() |
| 212 | printf(" directory name in a pinch).\n"); |
| 213 | printf("\t-o <dir> Use <dir> as the root directory for\n"); |
| 214 | printf("\t--offline-root <dir> offline installation of packages.\n"); |
| 215 | + printf("\t--add-arch <arch>:<prio> Register architecture with given priority\n"); |
| 216 | + printf("\t--add-dest <name>:<path> Register destination with given path\n"); |
| 217 | |
| 218 | printf("\nForce Options:\n"); |
| 219 | printf("\t--force-depends Install/remove despite failed dependencies\n"); |
| 220 | @@ -280,6 +302,9 @@ main(int argc, char *argv[]) |
| 221 | int nocheckfordirorfile = 0; |
| 222 | int noreadfeedsfile = 0; |
| 223 | |
| 224 | + if (opkg_conf_init()) |
| 225 | + goto err0; |
| 226 | + |
| 227 | conf->verbosity = NOTICE; |
| 228 | |
| 229 | opts = args_parse(argc, argv); |
| 230 | @@ -317,7 +342,7 @@ main(int argc, char *argv[]) |
| 231 | |
| 232 | conf->pfm = cmd->pfm; |
| 233 | |
| 234 | - if (opkg_conf_init()) |
| 235 | + if (opkg_conf_load()) |
| 236 | goto err0; |
| 237 | |
| 238 | if (!nocheckfordirorfile) { |
| 239 | |