X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_download.c;h=953627b026cede5646a4c18c2b44837c23a7130d;hp=70d11955d781543933fb688f48652782338aed1c;hb=603bec779ab8f0751bc48b0394aadd261fafdcde;hpb=f032fb5b8c7c73531257331dc1b5489147ca0c85 diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index 70d1195..953627b 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -68,7 +68,6 @@ static X509_STORE *setup_verify(opkg_conf_t *conf, char *CAfile, char *CApath); * each time */ static CURL *curl = NULL; -static void opkg_curl_cleanup(void); static CURL *opkg_curl_init(opkg_conf_t *conf, curl_progress_func cb, void *data); #endif @@ -117,7 +116,6 @@ int opkg_download(opkg_conf_t *conf, const char *src, } #ifdef HAVE_CURL - CURL *curl; CURLcode res; FILE * file = fopen (tmp_file_location, "w"); @@ -149,16 +147,21 @@ int opkg_download(opkg_conf_t *conf, const char *src, #else { int res; - char *wgetcmd; - char *wgetopts; - wgetopts = getenv("OPKG_WGETOPTS"); - sprintf_alloc(&wgetcmd, "wget -q %s%s -O \"%s\" \"%s\"", - (conf->http_proxy || conf->ftp_proxy) ? "-Y on " : "", - (wgetopts!=NULL) ? wgetopts : "", - tmp_file_location, src); - opkg_message(conf, OPKG_INFO, "Executing: %s\n", wgetcmd); - res = xsystem(wgetcmd); - free(wgetcmd); + const char *argv[8]; + int i = 0; + + argv[i++] = "wget"; + argv[i++] = "-q"; + if (conf->http_proxy || conf->ftp_proxy) { + argv[i++] = "-Y"; + argv[i++] = "on"; + } + argv[i++] = "-O"; + argv[i++] = tmp_file_location; + argv[i++] = src; + argv[i++] = NULL; + res = xsystem(argv); + if (res) { opkg_message(conf, OPKG_ERROR, "Failed to download %s, error %d\n", src, res); free(tmp_file_location); @@ -259,9 +262,8 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name { int err = 0; pkg_t *pkg; + pkg = pkg_new(); - if (pkg == NULL) - return ENOMEM; if (str_starts_with(url, "http://") || str_starts_with(url, "ftp://")) { @@ -308,7 +310,7 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name pkg = hash_insert_pkg(&conf->pkg_hash, pkg, 1,conf); if (namep) { - *namep = xstrdup(pkg->name); + *namep = pkg->name; } return 0; } @@ -532,7 +534,7 @@ end: #endif #ifdef HAVE_CURL -static void opkg_curl_cleanup(void){ +void opkg_curl_cleanup(void){ if(curl != NULL){ curl_easy_cleanup (curl); curl = NULL; @@ -637,12 +639,6 @@ static CURL *opkg_curl_init(opkg_conf_t *conf, curl_progress_func cb, void *data curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD, userpwd); free (userpwd); } - - /* add curl cleanup callback */ - if(!atexit(opkg_curl_cleanup)){ - opkg_message(conf,OPKG_DEBUG, "Failed to register atexit curl cleanup function\n"); - } - } curl_easy_setopt (curl, CURLOPT_NOPROGRESS, (cb == NULL));