adding --enable-curl configuation to configure.ac
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sat, 27 Dec 2008 17:26:46 +0000 (17:26 +0000)
committerticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Sat, 27 Dec 2008 17:26:46 +0000 (17:26 +0000)
Basically it apply opkg_wget.patch from OE but I add something to the configure.ac

http://cgit.openembedded.net/cgit.cgi?url=openembedded/tree/packages/opkg/files/opkg_wget.patch&id=1bbdc74a5384c81d0bdeb96f6acdfef91430d35d

Thanks Mike Westerhof <mwester@dls.net>

git-svn-id: http://opkg.googlecode.com/svn/trunk@191 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

configure.ac
libopkg/opkg.c
libopkg/opkg_download.c

index 45e7b07ee497eb0c621045926a2741eed49e212e..315e13974d114ea62fc66050b0a032739ee1fd8e 100644 (file)
@@ -27,8 +27,15 @@ AC_PROG_LIBTOOL
 # Checks for libraries
 
 # check for libcurl
 # Checks for libraries
 
 # check for libcurl
-PKG_CHECK_MODULES(CURL, libcurl)
+AC_ARG_ENABLE(curl,
+              AC_HELP_STRING([--enable-curl], [Enable downloading with curl
+      [[default=yes]] ]),
+    [want_curl="$enableval"], [want_curl="yes"])
 
 
+if test "x$want_curl" = "xyes"; then
+  PKG_CHECK_MODULES(CURL, libcurl)
+  AC_DEFINE(HAVE_CURL, 1, [Define if you want CURL support])
+fi
 
 
 dnl **********
 
 
 dnl **********
index 521072dac6d6bb3159a964ed52cee48383e2a337..d69721b3cc5496b21c6f19b662ce548128b17783 100644 (file)
@@ -1018,7 +1018,9 @@ opkg_find_package (opkg_t *opkg, const char *name, const char *ver, const char *
   return package;
 }
 
   return package;
 }
 
+#ifdef HAVE_CURL
 #include <curl/curl.h>
 #include <curl/curl.h>
+#endif
 /**
  * @brief Check the accessibility of repositories. It will try to access the repository to check if the respository is accessible throught current network status. 
  * @param opkg The opkg_t
 /**
  * @brief Check the accessibility of repositories. It will try to access the repository to check if the respository is accessible throught current network status. 
  * @param opkg The opkg_t
@@ -1068,12 +1070,16 @@ int opkg_repository_accessibility_check(opkg_t *opkg)
     repositories--;
 
     err = opkg_download(opkg->conf, iter1->data, "/dev/null", NULL, NULL);
     repositories--;
 
     err = opkg_download(opkg->conf, iter1->data, "/dev/null", NULL, NULL);
+#ifdef HAVE_CURL
     if (!(err == CURLE_OK || 
                err == CURLE_HTTP_RETURNED_ERROR || 
                err == CURLE_FILE_COULDNT_READ_FILE ||
                err == CURLE_REMOTE_FILE_NOT_FOUND || 
                err == CURLE_TFTP_NOTFOUND
                )) {
     if (!(err == CURLE_OK || 
                err == CURLE_HTTP_RETURNED_ERROR || 
                err == CURLE_FILE_COULDNT_READ_FILE ||
                err == CURLE_REMOTE_FILE_NOT_FOUND || 
                err == CURLE_TFTP_NOTFOUND
                )) {
+#else
+    if (!(err == 0)) {
+#endif
            ret++;
     }
     str_list_elt_deinit(iter1);
            ret++;
     }
     str_list_elt_deinit(iter1);
index bc1cfafc3e3bbaeca8ff6be7f7883e8f51508344..93b5084b7f15e7a36220cda787fa942cadcd9208 100644 (file)
@@ -17,7 +17,9 @@
    General Public License for more details.
 */
 #include "config.h"
    General Public License for more details.
 */
 #include "config.h"
+#ifdef HAVE_CURL
 #include <curl/curl.h>
 #include <curl/curl.h>
+#endif
 #ifdef HAVE_GPGME
 #include <gpgme.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);
     }
 
        setenv("no_proxy", conf->no_proxy, 1);
     }
 
+#ifdef HAVE_CURL
     CURL *curl;
     CURLcode res;
     FILE * file = fopen (tmp_file_location, "w");
     CURL *curl;
     CURLcode res;
     FILE * file = fopen (tmp_file_location, "w");
@@ -123,6 +126,27 @@ int opkg_download(opkg_conf_t *conf, const char *src,
         free(src_basec);
        return -1;
     }
         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);
 
 
     err = file_move(tmp_file_location, dest_file_name);