X-Git-Url: http://git.openwrt.org/?a=blobdiff_plain;f=libopkg%2Fopkg.c;h=aba6364c8fa1906fb5b25be87052d5453d295760;hb=9f61f7acf3845d2e09675b49fec5d783d57eb780;hp=9e278cd7af621a1b47eb90fc73a96f146c2aa8e4;hpb=ba12c7133602244bb13dc026a78ea2fababb1967;p=project%2Fopkg-lede.git diff --git a/libopkg/opkg.c b/libopkg/opkg.c index 9e278cd..aba6364 100644 --- a/libopkg/opkg.c +++ b/libopkg/opkg.c @@ -15,8 +15,6 @@ General Public License for more details. */ -#include "config.h" - #include #include #include @@ -76,39 +74,6 @@ static int opkg_configure_packages(char *pkg_name) return err; } -struct _curl_cb_data { - opkg_progress_callback_t cb; - opkg_progress_data_t *progress_data; - void *user_data; - int start_range; - int finish_range; -}; - -int curl_progress_cb(struct _curl_cb_data *cb_data, double t, /* dltotal */ - double d, /* dlnow */ - double ultotal, double ulnow) -{ - int p = (t) ? d * 100 / t : 0; - static int prev = -1; - int progress = 0; - - /* prevent the same value being sent twice (can occur due to rounding) */ - if (p == prev) - return 0; - prev = p; - - if (t < 1) - return 0; - - progress = cb_data->start_range + - (d / t * ((cb_data->finish_range - cb_data->start_range))); - cb_data->progress_data->percentage = progress; - - (cb_data->cb) (cb_data->progress_data, cb_data->user_data); - - return 0; -} - static struct opkg_conf saved_conf; /*** Public API ***/ @@ -122,7 +87,7 @@ int opkg_new() if (opkg_conf_load()) goto err0; - if (pkg_hash_load_feeds()) + if (pkg_hash_load_feeds(0)) goto err1; if (pkg_hash_load_status_files()) @@ -139,9 +104,6 @@ err0: void opkg_free(void) { -#ifdef HAVE_CURL - opkg_curl_cleanup(); -#endif opkg_conf_deinit(); } @@ -243,7 +205,7 @@ opkg_install_package(const char *package_name, opkg_progress_data_t pdata; pkg_t *old, *new; pkg_vec_t *deps, *all; - int i, ndepends; + int i; char **unresolved = NULL; const char *filename; @@ -276,8 +238,7 @@ opkg_install_package(const char *package_name, /* find dependancies and download them */ deps = pkg_vec_alloc(); /* this function does not return the original package, so we insert it later */ - ndepends = pkg_hash_fetch_unsatisfied_dependencies(new, deps, - &unresolved); + pkg_hash_fetch_unsatisfied_dependencies(new, deps, &unresolved); if (unresolved) { char **tmp = unresolved; opkg_msg(ERROR, "Couldn't satisfy the following dependencies" @@ -299,8 +260,7 @@ opkg_install_package(const char *package_name, /* download package and dependencies */ for (i = 0; i < deps->len; i++) { pkg_t *pkg; - struct _curl_cb_data cb_data; - char *url; + char *url, *urlencoded_path; pkg = deps->pkgs[i]; if (pkg_get_string(pkg, PKG_LOCAL_FILENAME)) @@ -316,8 +276,9 @@ opkg_install_package(const char *package_name, } filename = pkg_get_string(pkg, PKG_FILENAME); - - sprintf_alloc(&url, "%s/%s", pkg->src->value, filename); + urlencoded_path = urlencode_path(filename); + sprintf_alloc(&url, "%s/%s", pkg->src->value, urlencoded_path); + free(urlencoded_path); /* Get the filename part, without any directory */ stripped_filename = strrchr(filename, '/'); @@ -329,16 +290,7 @@ opkg_install_package(const char *package_name, pkg_set_string(pkg, PKG_LOCAL_FILENAME, local_filename); - cb_data.cb = progress_callback; - cb_data.progress_data = &pdata; - cb_data.user_data = user_data; - /* 75% of "install" progress is for downloading */ - cb_data.start_range = 75 * i / deps->len; - cb_data.finish_range = 75 * (i + 1) / deps->len; - - err = opkg_download(url, local_filename, - (curl_progress_func) curl_progress_cb, - &cb_data, 0); + err = opkg_download(url, local_filename, 0); free(url); if (err) { @@ -587,13 +539,13 @@ opkg_update_package_lists(opkg_progress_callback_t progress_callback, sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name); - if (opkg_download(url, list_file_name, NULL, NULL, 0)) { + if (opkg_download(url, list_file_name, 0)) { opkg_msg(ERROR, "Couldn't retrieve %s\n", url); result = -1; } free(url); -#if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN) +#if defined(HAVE_USIGN) if (conf->check_signature) { char *sig_file_name; /* download detached signitures to verify the package lists */ @@ -612,7 +564,7 @@ opkg_update_package_lists(opkg_progress_callback_t progress_callback, /* make sure there is no existing signature file */ unlink(sig_file_name); - err = opkg_download(url, sig_file_name, NULL, NULL, 0); + err = opkg_download(url, sig_file_name, 0); if (err) { opkg_msg(ERROR, "Couldn't retrieve %s\n", url); } else { @@ -749,7 +701,7 @@ pkg_t *opkg_find_package(const char *name, const char *ver, const char *arch, /* check architecture */ if (arch) { - if (sstrcmp(pkg_get_string(pkg, PKG_ARCHITECTURE), arch)) + if (sstrcmp(pkg_get_architecture(pkg), arch)) continue; } @@ -816,7 +768,7 @@ int opkg_repository_accessibility_check(void) iter1 = str_list_pop(src); repositories--; - if (opkg_download(iter1->data, "/dev/null", NULL, NULL, 0)) + if (opkg_download(iter1->data, "/dev/null", 0)) ret++; str_list_elt_deinit(iter1); }