int
opkg_download(const char *src, const char *dest_file_name,
- curl_progress_func cb, void *data)
+ curl_progress_func cb, void *data, const short hide_error)
{
int err = 0;
{
long error_code;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &error_code);
- opkg_msg(ERROR, "Failed to download %s: %s.\n",
+ opkg_msg(hide_error?DEBUG2:ERROR, "Failed to download %s: %s.\n",
src, curl_easy_strerror(res));
free(tmp_file_location);
return -1;
int err = 0;
if (!conf->cache || str_starts_with(src, "file:")) {
- err = opkg_download(src, dest_file_name, cb, data);
+ err = opkg_download(src, dest_file_name, cb, data, 0);
goto out1;
}
if (file_exists(cache_location))
opkg_msg(NOTICE, "Copying %s.\n", cache_location);
else {
- err = opkg_download(src, cache_location, cb, data);
- if (err) {
- (void) unlink(cache_location);
- goto out2;
+ /* cache file with funky name not found, try simple name */
+ free(cache_name);
+ char *filename = strrchr(dest_file_name,'/');
+ if (filename)
+ cache_name = xstrdup(filename+1); // strip leading '/'
+ else
+ cache_name = xstrdup(dest_file_name);
+ free(cache_location);
+ sprintf_alloc(&cache_location, "%s/%s", conf->cache, cache_name);
+ if (file_exists(cache_location))
+ opkg_msg(NOTICE, "Copying %s.\n", cache_location);
+ else {
+ err = opkg_download(src, cache_location, cb, data);
+ if (err) {
+ (void) unlink(cache_location);
+ goto out2;
+ }
}
}
sprintf_alloc(&url, "%s/%s", pkg->src->value, pkg->filename);
- /* XXX: BUG: The pkg->filename might be something like
+ /* The pkg->filename might be something like
"../../foo.opk". 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. */
char *file_base = basename(file_basec);
sprintf_alloc(&tmp_file, "%s/%s", conf->tmp_dir, file_base);
- err = opkg_download(url, tmp_file, NULL, NULL);
+ err = opkg_download(url, tmp_file, NULL, NULL, 0);
if (err)
return err;
gpgme_signature_t s;
char *trusted_path = NULL;
+ gpgme_check_version (NULL);
+
err = gpgme_new (&ctx);
if (err)