diff --git a/repos/libports/recipes/src/fetchurl/content.mk b/repos/libports/recipes/src/fetchurl/content.mk index 42efd776aa..84c6183fbd 100644 --- a/repos/libports/recipes/src/fetchurl/content.mk +++ b/repos/libports/recipes/src/fetchurl/content.mk @@ -1,45 +1,10 @@ MIRROR_FROM_REP_DIR := src/app/fetchurl -# -# Copy of lwIP ingredients -# -MIRROR_FROM_REP_DIR += include/libc-plugin \ - src/lib/libc_lwip \ - src/lib/libc_lwip_nic_dhcp \ - lib/mk/lwip.mk \ - lib/mk/libc_lwip.mk \ - lib/mk/libc_lwip_nic_dhcp.mk \ - lib/import/import-lwip.mk - - -LWIP_PORT_DIR := $(call port_dir,$(REP_DIR)/ports/lwip) - -content: $(MIRROR_FROM_REP_DIR) LICENSE include/lwip src/lib/lwip - -include/lwip: - mkdir -p $@ - cp -r $(LWIP_PORT_DIR)/include/lwip/* $@ - cp -r $(REP_DIR)/include/lwip/* $@ - -src/lib/lwip: - mkdir -p $@ - cp -r $(LWIP_PORT_DIR)/src/lib/lwip/* $@ - cp -r $(REP_DIR)/src/lib/lwip/* $@ +content: $(MIRROR_FROM_REP_DIR) LICENSE $(MIRROR_FROM_REP_DIR): $(mirror_from_rep_dir) -MIRROR_FROM_OS := lib/mk/timed_semaphore.mk \ - include/os/timed_semaphore.h \ - src/lib/timed_semaphore - -content: $(MIRROR_FROM_OS) - -$(MIRROR_FROM_OS): - mkdir -p $(dir $@) - cp -r $(GENODE_DIR)/repos/os/$@ $(dir $@) - LICENSE: cp $(GENODE_DIR)/LICENSE $@ - diff --git a/repos/libports/run/fetchurl.run b/repos/libports/run/fetchurl.run index 6d2b897106..0987af0888 100644 --- a/repos/libports/run/fetchurl.run +++ b/repos/libports/run/fetchurl.run @@ -5,10 +5,11 @@ # set build_components { - core init app/fetchurl + core init drivers/nic drivers/timer + lib/vfs/lxip } source ${genode_dir}/repos/base/run/platform_drv.inc @@ -19,7 +20,7 @@ build $build_components create_boot_directory append config { - + @@ -49,14 +50,18 @@ append config { - + + + nameserver 213.73.91.35 + 2000-01-01 00:00 + - + @@ -74,11 +79,12 @@ set boot_modules { libcrypto.lib.so libssh.lib.so libssl.lib.so - lwip.lib.so + lxip.lib.so nic_drv - timer - zlib.lib.so pthread.lib.so + timer + vfs_lxip.lib.so + zlib.lib.so } # platform-specific modules diff --git a/repos/libports/src/app/fetchurl/component.cc b/repos/libports/src/app/fetchurl/component.cc index 8d255b064b..6913d7e6fd 100644 --- a/repos/libports/src/app/fetchurl/component.cc +++ b/repos/libports/src/app/fetchurl/component.cc @@ -5,7 +5,7 @@ */ /* - * Copyright (C) 2016 Genode Labs GmbH + * Copyright (C) 2016-2018 Genode Labs GmbH * * This file is part of the Genode OS framework, which is distributed * under the terms of the GNU Affero General Public License version 3. @@ -27,16 +27,6 @@ #include #include -struct Stats -{ - Timer::Connection &timer; - unsigned long next = 0; - unsigned long remain = 0; - char const *url; - - Stats(Timer::Connection &t, char const *u) - : timer(t), url(u) { } -}; static size_t write_callback(char *ptr, size_t size, @@ -48,47 +38,20 @@ static size_t write_callback(char *ptr, } -int progress_callback(void *clientp, - double dltotal, - double dlnow, - double ultotal, - double ulnow) +static int fetchurl(Genode::Xml_node config_node) { - Stats *stats = (Stats*)clientp; - - unsigned long now = stats->timer.elapsed_ms(); - unsigned long remain = dltotal-dlnow; - - if ((now > stats->next) && (remain != stats->remain)) { - stats->next = now + 1000; - stats->remain = remain; - Genode::log(stats->url, ": ", remain, " bytes remain"); - } - return CURLE_OK; -} - -void Libc::Component::construct(Libc::Env &env) -{ - Genode::Attached_rom_dataspace config(env, "config"); - - Timer::Connection timer(env); - - /* wait for DHCP */ - timer.msleep(4000); - Genode::String<256> url; Genode::Path<256> path; CURLcode res = CURLE_OK; Libc::with_libc([&]() { curl_global_init(CURL_GLOBAL_DEFAULT); }); - Genode::Xml_node config_node = config.xml(); - bool verbose = config_node.attribute_value("verbose", false); config_node.for_each_sub_node("fetch", [&] (Genode::Xml_node node) { if (res != CURLE_OK) return; + try { node.attribute("url").value(&url); node.attribute("path").value(path.base(), path.capacity()); @@ -141,8 +104,8 @@ void Libc::Component::construct(Libc::Env &env) default: Genode::error("creation of ", out_path, " failed (errno=", errno, ")"); } - env.parent().exit(errno); - throw Genode::Exception(); + res = CURLE_FAILED_INIT; + return; } CURL *curl = curl_easy_init(); @@ -152,8 +115,6 @@ void Libc::Component::construct(Libc::Env &env) return; } - Stats stats(timer, url.string()); - curl_easy_setopt(curl, CURLOPT_URL, url.string()); curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); @@ -163,9 +124,7 @@ void Libc::Component::construct(Libc::Env &env) curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &fd); - curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback); - curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &stats); - curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); + curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); @@ -192,7 +151,14 @@ void Libc::Component::construct(Libc::Env &env) Genode::warning("SSL certificates not verified"); - env.parent().exit(res ^ CURLE_OK); + return res ^ CURLE_OK; +} + +void Libc::Component::construct(Libc::Env &env) +{ + env.config([&env] (Genode::Xml_node config) { + env.parent().exit( fetchurl(config) ); + }); } /* dummies to prevent warnings printed by unimplemented libc functions */ diff --git a/repos/libports/src/app/fetchurl/target.mk b/repos/libports/src/app/fetchurl/target.mk index 4e1ef5dd2b..35e5c65ca5 100644 --- a/repos/libports/src/app/fetchurl/target.mk +++ b/repos/libports/src/app/fetchurl/target.mk @@ -1,5 +1,3 @@ TARGET = fetchurl -LIBS += curl lwip libc_lwip libc_lwip_nic_dhcp libc ld pthread +LIBS += curl libc ld pthread SRC_CC = component.cc - -CC_CXX_WARN_STRICT =