opkg: clarify messages and errors related to downloads
[openwrt/openwrt.git] / package / system / opkg / patches / 290-clarify-download-errors.patch
1 --- a/libopkg/opkg_cmd.c
2 +++ b/libopkg/opkg_cmd.c
3 @@ -85,6 +85,7 @@ opkg_update_cmd(int argc, char **argv)
4 char *tmp;
5 int err;
6 int failures;
7 + int pkglist_dl_error;
8 char *lists_dir;
9 pkg_src_list_elt_t *iter;
10 pkg_src_t *src;
11 @@ -130,15 +131,19 @@ opkg_update_cmd(int argc, char **argv)
12 sprintf_alloc(&url, "%s/%s", src->value, src->gzip ? "Packages.gz" : "Packages");
13
14 sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
15 + pkglist_dl_error = 0;
16 if (opkg_download(url, list_file_name, NULL, NULL, 0)) {
17 failures++;
18 + pkglist_dl_error = 1;
19 + opkg_msg(NOTICE, "*** Failed to download the package list from %s\n\n",
20 + url);
21 } else {
22 - opkg_msg(NOTICE, "Updated list of available packages in %s.\n",
23 + opkg_msg(NOTICE, "Updated list of available packages in %s\n",
24 list_file_name);
25 }
26 free(url);
27 #if defined(HAVE_GPGME) || defined(HAVE_OPENSSL) || defined(HAVE_USIGN)
28 - if (conf->check_signature) {
29 + if (pkglist_dl_error == 0 && conf->check_signature) {
30 /* download detached signitures to verify the package lists */
31 /* get the url for the sig file */
32 if (src->extra_data) /* debian style? */
33 @@ -156,7 +161,7 @@ opkg_update_cmd(int argc, char **argv)
34 err = opkg_download(url, tmp_file_name, NULL, NULL, 0);
35 if (err) {
36 failures++;
37 - opkg_msg(NOTICE, "Signature check failed.\n");
38 + opkg_msg(NOTICE, "Signature file download failed.\n");
39 } else {
40 err = opkg_verify_file (list_file_name, tmp_file_name);
41 if (err == 0)
42 --- a/libopkg/opkg_download.c
43 +++ b/libopkg/opkg_download.c
44 @@ -91,7 +91,7 @@ opkg_download(const char *src, const cha
45 char *src_base = basename(src_basec);
46 char *tmp_file_location;
47
48 - opkg_msg(NOTICE,"Downloading %s.\n", src);
49 + opkg_msg(NOTICE,"Downloading %s\n", src);
50
51 if (str_starts_with(src, "file:")) {
52 const char *file_src = src + 5;
53 @@ -175,6 +175,8 @@ opkg_download(const char *src, const cha
54
55 if (res) {
56 opkg_msg(ERROR, "Failed to download %s, wget returned %d.\n", src, res);
57 + if (res == 4)
58 + opkg_msg(ERROR, "Check your network settings and connectivity.\n\n");
59 free(tmp_file_location);
60 return -1;
61 }