X-Git-Url: https://git.librecmc.org/?p=oweals%2Fopkg-lede.git;a=blobdiff_plain;f=libopkg%2Fopkg_download.c;h=d994670dbd66912e81e9194511a74d88721b1546;hp=bbd6efef868bf9deab58b6a58e703df96bd807d2;hb=b9e095a94bd550cea050a3a614e3e370b8c9e466;hpb=4b0b7ca249bfa4ecc099c2ca56527eb91776f198 diff --git a/libopkg/opkg_download.c b/libopkg/opkg_download.c index bbd6efe..d994670 100644 --- a/libopkg/opkg_download.c +++ b/libopkg/opkg_download.c @@ -1,5 +1,5 @@ /* vi: set noexpandtab sw=4 sts=4: */ -/* opkg_download.c - the itsy package management system +/* opkg_download.c - the opkg package management system Carl D. Worth @@ -22,7 +22,7 @@ #include #endif -#include "opkg.h" +#include "includes.h" #include "opkg_download.h" #include "opkg_message.h" #include "opkg_state.h" @@ -31,11 +31,9 @@ #include "xsystem.h" #include "file_util.h" #include "str_util.h" +#include "opkg_defines.h" -#ifdef OPKG_LIB -#include "libopkg.h" opkg_download_progress_callback opkg_cb_download_progress = NULL; -#endif int curl_progress_func (char* url, @@ -44,10 +42,8 @@ curl_progress_func (char* url, double ultotal, double ulnow) { - int i; int p = (t) ? d*100/t : 0; -#ifdef OPKG_LIB if (opkg_cb_download_progress) { static int prev = -1; @@ -61,24 +57,6 @@ curl_progress_func (char* url, opkg_cb_download_progress (p, url); return 0; } -#endif - - /* skip progress bar if we haven't done started yet - * this prevents drawing the progress bar if we receive an error such as - * file not found */ - if (t == 0) - return 0; - - printf ("\r%3d%% |", p); - for (i = 1; i < 73; i++) - { - if (i <= p * 0.73) - printf ("="); - else - printf ("-"); - } - printf ("|"); - fflush(stdout); return 0; } @@ -92,8 +70,6 @@ int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name opkg_message(conf,OPKG_NOTICE,"Downloading %s\n", src); - fflush(stdout); - if (str_starts_with(src, "file:")) { int ret; const char *file_src = src + 5; @@ -125,31 +101,6 @@ int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name setenv("no_proxy", conf->no_proxy, 1); } - /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */ -#if 0 - sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s", - (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "", - conf->proxy_user ? "--proxy-user=" : "", - conf->proxy_user ? conf->proxy_user : "", - conf->proxy_passwd ? "--proxy-passwd=" : "", - conf->proxy_passwd ? conf->proxy_passwd : "", - conf->verbose_wget ? "" : "-q", - conf->tmp_dir, - src); - err = xsystem(cmd); - if (err) { - if (err != -1) { - opkg_message(conf,OPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n", - __FUNCTION__, err, cmd); - } - unlink(tmp_file_location); - free(tmp_file_location); - free(src_basec); - free(cmd); - return EINVAL; - } - free(cmd); -#endif CURL *curl; CURLcode res; FILE * file = fopen (tmp_file_location, "w"); @@ -186,8 +137,6 @@ int opkg_download(opkg_conf_t *conf, const char *src, const char *dest_file_name else return -1; - printf ("\n"); - err = file_move(tmp_file_location, dest_file_name); free(tmp_file_location); @@ -205,6 +154,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir) int err; char *url; char *pkgid; + char *stripped_filename; if (pkg->src == NULL) { opkg_message(conf,OPKG_ERROR, "ERROR: Package %s (parent %s) is not available from any configured src.\n", @@ -213,7 +163,7 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir) } sprintf_alloc (&pkgid, "%s;%s;%s;", pkg->name, pkg->version, pkg->architecture); - opkg_set_current_state (OPKG_STATE_DOWNLOADING_PKG, pkgid); + opkg_set_current_state (conf, OPKG_STATE_DOWNLOADING_PKG, pkgid); free (pkgid); sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename); @@ -222,12 +172,17 @@ int opkg_download_pkg(opkg_conf_t *conf, pkg_t *pkg, const char *dir) "../../foo.ipk". While this is correct, and exactly what we want to use to construct url above, here we actually need to use just the filename part, without any directory. */ - sprintf_alloc(&pkg->local_filename, "%s/%s", dir, pkg->filename); + + stripped_filename = strrchr(pkg->filename, '/'); + if ( ! stripped_filename ) + stripped_filename = pkg->filename; + + sprintf_alloc(&pkg->local_filename, "%s/%s", dir, stripped_filename); err = opkg_download(conf, url, pkg->local_filename); free(url); - opkg_set_current_state (OPKG_STATE_NONE, NULL); + opkg_set_current_state (conf, OPKG_STATE_NONE, NULL); return err; } @@ -297,7 +252,7 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name } int -opkg_verify_file (char *text_file, char *sig_file) +opkg_verify_file (opkg_conf_t *conf, char *text_file, char *sig_file) { #ifdef HAVE_GPGME int status = -1; @@ -340,7 +295,7 @@ opkg_verify_file (char *text_file, char *sig_file) return status; #else - printf ("Signature check skipped because GPG support was not enabled in this build\n"); + opkg_message (conf, OPKG_NOTICE, "Signature check for %s was skipped because GPG support was not enabled in this build\n"); return 0; #endif }