r3871 - trunk/src/target/ipkg

thomas at sita.openmoko.org thomas at sita.openmoko.org
Thu Jan 17 18:15:46 CET 2008


Author: thomas
Date: 2008-01-17 18:15:45 +0100 (Thu, 17 Jan 2008)
New Revision: 3871

Modified:
   trunk/src/target/ipkg/Makefile.am
   trunk/src/target/ipkg/configure.ac
   trunk/src/target/ipkg/ipkg_download.c
Log:
ipkg: replace wget with libcurl functions

Modified: trunk/src/target/ipkg/Makefile.am
===================================================================
--- trunk/src/target/ipkg/Makefile.am	2008-01-17 17:14:48 UTC (rev 3870)
+++ trunk/src/target/ipkg/Makefile.am	2008-01-17 17:15:45 UTC (rev 3871)
@@ -52,7 +52,7 @@
 #\ replace/replace.h
 
 #libipkg_la_LIBADD = libbb/libbb.la replace/libreplace.a
-libipkg_la_LIBADD = libbb/libbb.la 
+libipkg_la_LIBADD = libbb/libbb.la $(CURL_LIBS)
 
 ipkg_core_sources = args.c args.h ipkg.c \
 		    user.c user.h 
@@ -97,9 +97,9 @@
 
 ipkg_cl_SOURCES = ipkg-frontend.c
 
-libipkg_la_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS)
+libipkg_la_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS)  $(CURL_CFLAGS)
 
-ipkg_CFLAGS = $(ALL_CFLAGS)
+ipkg_CFLAGS = $(ALL_CFLAGS) $(CURL_CFLAGS)
 
 ipkg_cl_CFLAGS = -DIPKG_LIB $(ALL_CFLAGS)
 

Modified: trunk/src/target/ipkg/configure.ac
===================================================================
--- trunk/src/target/ipkg/configure.ac	2008-01-17 17:14:48 UTC (rev 3870)
+++ trunk/src/target/ipkg/configure.ac	2008-01-17 17:15:45 UTC (rev 3871)
@@ -20,6 +20,7 @@
 AC_PROG_LIBTOOL
 
 # Checks for libraries (hah! ipkg is pretty much self-contained)
+PKG_CHECK_MODULES(CURL, libcurl)
 
 # Checks for header files
 AC_HEADER_DIRENT

Modified: trunk/src/target/ipkg/ipkg_download.c
===================================================================
--- trunk/src/target/ipkg/ipkg_download.c	2008-01-17 17:14:48 UTC (rev 3870)
+++ trunk/src/target/ipkg/ipkg_download.c	2008-01-17 17:15:45 UTC (rev 3871)
@@ -1,3 +1,4 @@
+/* vi: set noexpandtab sw=4 sts=4: */
 /* ipkg_download.c - the itsy package management system
 
    Carl D. Worth
@@ -15,6 +16,8 @@
    General Public License for more details.
 */
 
+#include <curl/curl.h>
+
 #include "ipkg.h"
 #include "ipkg_download.h"
 #include "ipkg_message.h"
@@ -69,6 +72,7 @@
     }
 
     /* XXX: BUG rewrite to use execvp or else busybox's internal wget -Jamey 7/23/2002 */ 
+#if 0
     sprintf_alloc(&cmd, "wget --passive-ftp %s %s%s %s%s %s -P %s %s",
 		  (conf->http_proxy || conf->ftp_proxy) ? "--proxy=on" : "",
 		  conf->proxy_user ? "--proxy-user=" : "",
@@ -91,7 +95,24 @@
 	return EINVAL;
     }
     free(cmd);
+#endif
+    CURL *curl;
+    CURLcode res;
+    FILE * file = fopen (tmp_file_location, "w");
+    
+    curl = curl_easy_init ();
+    if (curl)
+    {
+	curl_easy_setopt (curl, CURLOPT_URL, src);
+	curl_easy_setopt (curl, CURLOPT_WRITEDATA, file);
+	res = curl_easy_perform (curl);
+	curl_easy_cleanup (curl);
+	fclose (file);
 
+    }
+    else
+	return -1;
+
     err = file_move(tmp_file_location, dest_file_name);
 
     free(tmp_file_location);





More information about the commitlog mailing list