summaryrefslogtreecommitdiff
path: root/package/opkg/patches/001-use-wget
blob: e6c7e9ca0e58c6630ea9bcd0bd4aa6273ba921d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
Index: opkg-4561/libopkg/opkg_download.c
===================================================================
--- opkg-4561/libopkg/opkg_download.c	(revision 4480)
+++ opkg-4561/libopkg/opkg_download.c	(working copy)
@@ -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
@@ -74,6 +76,7 @@
 	setenv("no_proxy", conf->no_proxy, 1);
     }
 
+#ifdef HAVE_CURL
     CURL *curl;
     CURLcode res;
     FILE * file = fopen (tmp_file_location, "w");
@@ -119,6 +122,31 @@
         free(src_basec);
 	return -1;
     }
+#else /* if wget is selected */
+    char *cmd;
+    /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */
+    sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s -P %s %s",
+                 (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
+                 conf->proxy_user ? "--proxy-user=" : "",
+                 conf->proxy_user ? conf->proxy_user : "",
+                 conf->proxy_passwd ? "--proxy-passwd=" : "",
+                 conf->proxy_passwd ? conf->proxy_passwd : "",
+                 conf->tmp_dir,
+                 src);
+    err = xsystem(cmd);
+    if (err) {
+       if (err != -1) {
+           opkg_message(conf,OPKG_ERROR, "%s: ERROR: Command failed with return value %d: `%s'\n",
+                   __FUNCTION__, err, cmd);
+       } 
+       unlink(tmp_file_location);
+       free(tmp_file_location);
+       free(src_basec);
+       free(cmd);
+       return EINVAL;
+    }
+    free(cmd);
+#endif
 
     err = file_move(tmp_file_location, dest_file_name);
 
Index: opkg-4561/configure.ac
===================================================================
--- opkg-4561/configure.ac	(revision 4480)
+++ opkg-4561/configure.ac	(working copy)
@@ -22,9 +22,16 @@
 
 # Checks for libraries
 
-# check for libcurl
-PKG_CHECK_MODULES(CURL, libcurl)
+AC_ARG_ENABLE(curl,
+    AC_HELP_STRING([--enable-curl], [Enable use of libcurl instead of wget
+      [[default=yes]] ]),
+    [want_curl="$enableval"], [want_curl="yes"])
 
+if test "x$want_curl" = "xyes"; then
+  # check for libcurl
+  PKG_CHECK_MODULES(CURL, libcurl)
+  AC_DEFINE(HAVE_CURL, 1, [Define if you want to use libcurl instead of wget])
+fi
 
 
 dnl **********
Index: opkg-4561/libopkg/opkg.c
===================================================================
--- opkg-4561/libopkg/opkg.c-orig	2008-07-28 16:27:53.000000000 -0500
+++ opkg-4561/libopkg/opkg.c	2008-07-29 07:46:42.000000000 -0500
@@ -1013,8 +1013,9 @@
 
   return package;
 }
-
+#ifdef HAVE_CURL
 #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
@@ -1064,6 +1065,7 @@
     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 ||
@@ -1072,6 +1074,7 @@
 		)) {
 	    ret++;
     }
+    #endif
     str_list_elt_deinit(iter1);
     free(iter1);
   }