adding new flag flag_maintainer
[oweals/opkg-lede.git] / libopkg / opkg_download.c
index 04073cf593f3659acd6749d8c76cd6ac888b2fd7..999dc878c02d3d30497308cf5c16f11a12fa0f9b 100644 (file)
@@ -17,7 +17,9 @@
    General Public License for more details.
 */
 #include "config.h"
+#ifdef HAVE_CURL
 #include <curl/curl.h>
+#endif
 #ifdef HAVE_GPGME
 #include <gpgme.h>
 #endif
@@ -77,6 +79,7 @@ int opkg_download(opkg_conf_t *conf, const char *src,
        setenv("no_proxy", conf->no_proxy, 1);
     }
 
+#ifdef HAVE_CURL
     CURL *curl;
     CURLcode res;
     FILE * file = fopen (tmp_file_location, "w");
@@ -108,7 +111,7 @@ int opkg_download(opkg_conf_t *conf, const char *src,
        {
            long error_code;
            curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &error_code);
-           opkg_message(conf, OPKG_ERROR, "Failed to download %s, error %d\n", src, error_code);
+           opkg_message(conf, OPKG_ERROR, "Failed to download %s. \nerror detail: %s\n", src, curl_easy_strerror(res));
            free(tmp_file_location);
             free(src_basec);
            curl_easy_cleanup (curl);
@@ -123,6 +126,27 @@ int opkg_download(opkg_conf_t *conf, const char *src,
         free(src_basec);
        return -1;
     }
+#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);
+      if (res) {
+       opkg_message(conf, OPKG_ERROR, "Failed to download %s, error %d\n", src, res);
+       free(tmp_file_location);
+        free(src_basec);
+       return res;
+      }
+    }
+#endif
 
     err = file_move(tmp_file_location, dest_file_name);
 
@@ -280,6 +304,8 @@ int
 opkg_verify_file (opkg_conf_t *conf, char *text_file, char *sig_file)
 {
 #ifdef HAVE_GPGME
+    if (conf->check_signature == 0 )
+        return 0;
     int status = -1;
     gpgme_ctx_t ctx;
     gpgme_data_t sig, text, key;
@@ -346,7 +372,6 @@ opkg_verify_file (opkg_conf_t *conf, char *text_file, char *sig_file)
 
     return status;
 #else
-    opkg_message (conf, OPKG_NOTICE, "Signature check for %s was skipped because GPG support was not enabled in this build\n");
     return 0;
 #endif
 }