Changeset 4808
- Timestamp:
- 11/20/08 11:04:46 (5 years ago)
- Location:
- trunk/src/target/opkg/libopkg
- Files:
-
- 6 edited
-
args.c (modified) (5 diffs)
-
args.h (modified) (1 diff)
-
opkg.c (modified) (1 diff)
-
opkg_conf.c (modified) (3 diffs)
-
opkg_conf.h (modified) (1 diff)
-
opkg_download.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/opkg/libopkg/args.c
r4559 r4808 43 43 ARGS_OPT_VERBOSITY, 44 44 ARGS_OPT_MULTIPLE_PROVIDERS, 45 ARGS_OPT_AUTOREMOVE 45 ARGS_OPT_AUTOREMOVE, 46 ARGS_OPT_CACHE, 46 47 }; 47 48 … … 93 94 free (args->dest); 94 95 free (args->tmp_dir); 96 free (args->cache); 95 97 free(args->conf_file); 96 98 args->conf_file = NULL; … … 105 107 {"query-all", 0, 0, 'A'}, 106 108 {"autoremove", 0, 0, ARGS_OPT_AUTOREMOVE}, 109 {"cache", 1, 0, ARGS_OPT_CACHE}, 107 110 {"conf-file", 1, 0, 'f'}, 108 111 {"conf", 1, 0, 'f'}, … … 180 183 case ARGS_OPT_AUTOREMOVE: 181 184 args->autoremove = 1; 185 break; 186 case ARGS_OPT_CACHE: 187 free(args->cache); 188 args->cache = strdup(optarg); 182 189 break; 183 190 case ARGS_OPT_FORCE_DEFAULTS: … … 278 285 printf("\t 3 debug output\n"); 279 286 printf("\t-f <conf_file> Use <conf_file> as the opkg configuration file\n"); 287 printf("\t--cache <directory> Use a package cache\n"); 280 288 printf("\t-conf <conf_file> Default configuration file location\n"); 281 289 printf(" is %s/%s\n", ARGS_DEFAULT_CONF_FILE_DIR, ARGS_DEFAULT_CONF_FILE_NAME); -
trunk/src/target/opkg/libopkg/args.h
r4440 r4808 43 43 char *offline_root_pre_script_cmd; 44 44 char *offline_root_post_script_cmd; 45 char *cache; 45 46 }; 46 47 typedef struct args args_t; -
trunk/src/target/opkg/libopkg/opkg.c
r4671 r4808 272 272 if (a->offline_root_post_script_cmd) free (a->offline_root_post_script_cmd); 273 273 a->offline_root_post_script_cmd = strdup (c->offline_root_post_script_cmd); 274 } 275 276 if (c->cache) { 277 if (a->cache) 278 free (a->cache); 279 a->cache = strdup(c->cache); 274 280 } 275 281 -
trunk/src/target/opkg/libopkg/opkg_conf.c
r4475 r4808 50 50 { 51 51 opkg_option_t tmp[] = { 52 { "cache", OPKG_OPT_TYPE_STRING, &conf->cache}, 52 53 { "force_defaults", OPKG_OPT_TYPE_BOOL, &conf->force_defaults }, 53 54 { "force_depends", OPKG_OPT_TYPE_BOOL, &conf->force_depends }, … … 271 272 args->offline_root_post_script_cmd); 272 273 274 opkg_conf_override_string(&conf->cache, args->cache); 275 273 276 /* Pigi: added a flag to disable the checking of structures if the command does not need to 274 277 read anything from there. … … 338 341 opkg_conf_free_string(&conf->offline_root_pre_script_cmd); 339 342 opkg_conf_free_string(&conf->offline_root_post_script_cmd); 343 344 opkg_conf_free_string(&conf->cache); 340 345 341 346 if (conf->verbosity > 1) { -
trunk/src/target/opkg/libopkg/opkg_conf.h
r4473 r4808 71 71 int verbosity; 72 72 int noaction; 73 char *cache; 73 74 74 75 /* proxy options */ -
trunk/src/target/opkg/libopkg/opkg_download.c
r4640 r4808 34 34 #include "opkg_defines.h" 35 35 36 int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name, curl_progress_func cb, void *data) 36 static int do_download(opkg_conf_t *conf, const char *src, 37 const char *dest_file_name, curl_progress_func cb, void *data) 37 38 { 38 39 int err = 0; … … 136 137 } 137 138 139 int opkg_download(opkg_conf_t *conf, const char *src, 140 const char *dest_file_name, curl_progress_func cb, void *data) 141 { 142 char *cache_name = strdup(src); 143 char *cache_location, *p; 144 int err = 0; 145 146 if (!conf->cache || str_starts_with(src, "file:")) { 147 err = do_download(conf, src, dest_file_name, cb, data); 148 goto out1; 149 } 150 151 for (p = cache_name; *p; p++) 152 if (*p == '/') 153 *p = ','; /* looks nicer than | or # */ 154 155 sprintf_alloc(&cache_location, "%s/%s", conf->cache, cache_name); 156 if (file_exists(cache_location)) 157 opkg_message(conf, OPKG_NOTICE, "Copying %s\n", cache_location); 158 else { 159 err = do_download(conf, src, cache_location, cb, data); 160 if (err) { 161 (void) unlink(cache_location); 162 goto out2; 163 } 164 } 165 166 err = file_copy(cache_location, dest_file_name); 167 168 169 out2: 170 free(cache_location); 171 out1: 172 free(cache_name); 173 return err; 174 } 175 138 176 int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir) 139 177 {
Note: See TracChangeset
for help on using the changeset viewer.
