a8ec7c518ac7e28627f2a272fedc9c8eb769a97b
[openwrt-10.03/.git] / package / opkg / patches / 001-use-wget
1 Index: opkg-4561/libopkg/opkg_download.c
2 ===================================================================
3 --- opkg-4561/libopkg/opkg_download.c   (revision 4480)
4 +++ opkg-4561/libopkg/opkg_download.c   (working copy)
5 @@ -17,7 +17,9 @@
6     General Public License for more details.
7  */
8  #include "config.h"
9 +#ifdef HAVE_CURL
10  #include <curl/curl.h>
11 +#endif
12  #ifdef HAVE_GPGME
13  #include <gpgme.h>
14  #endif
15 @@ -74,6 +76,7 @@
16         setenv("no_proxy", conf->no_proxy, 1);
17      }
18  
19 +#ifdef HAVE_CURL
20      CURL *curl;
21      CURLcode res;
22      FILE * file = fopen (tmp_file_location, "w");
23 @@ -119,6 +122,31 @@
24          free(src_basec);
25         return -1;
26      }
27 +#else /* if wget is selected */
28 +    char *cmd;
29 +    /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */
30 +    sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s -P %s %s",
31 +                 (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
32 +                 conf->proxy_user ? "--proxy-user=" : "",
33 +                 conf->proxy_user ? conf->proxy_user : "",
34 +                 conf->proxy_passwd ? "--proxy-passwd=" : "",
35 +                 conf->proxy_passwd ? conf->proxy_passwd : "",
36 +                 conf->tmp_dir,
37 +                 src);
38 +    err = xsystem(cmd);
39 +    if (err) {
40 +       if (err != -1) {
41 +           opkg_message(conf,OPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n",
42 +                   __FUNCTION__, err, cmd);
43 +       } 
44 +       unlink(tmp_file_location);
45 +       free(tmp_file_location);
46 +       free(src_basec);
47 +       free(cmd);
48 +       return EINVAL;
49 +    }
50 +    free(cmd);
51 +#endif
52  
53      err = file_move(tmp_file_location, dest_file_name);
54  
55 Index: opkg-4561/configure.ac
56 ===================================================================
57 --- opkg-4561/configure.ac      (revision 4480)
58 +++ opkg-4561/configure.ac      (working copy)
59 @@ -22,9 +22,16 @@
60  
61  # Checks for libraries
62  
63 -# check for libcurl
64 -PKG_CHECK_MODULES(CURL, libcurl)
65 +AC_ARG_ENABLE(curl,
66 +    AC_HELP_STRING([--enable-curl], [Enable use of libcurl instead of wget
67 +      [[default=yes]] ]),
68 +    [want_curl="$enableval"], [want_curl="yes"])
69  
70 +if test "x$want_curl" = "xyes"; then
71 +  # check for libcurl
72 +  PKG_CHECK_MODULES(CURL, libcurl)
73 +  AC_DEFINE(HAVE_CURL, 1, [Define if you want to use libcurl instead of wget])
74 +fi
75  
76  
77  dnl **********