[PATCH 4/6] discover/paths: Set --quiet for wget according to flags
Samuel Mendoza-Jonas
sam at mendozajonas.com
Tue Oct 25 14:44:46 AEDT 2016
wget is by default set to quiet mode, but in the case where process IO
is being actively watched it would be ideal to have some output. If a
custom IO callback is defined, do not set --quiet.
Signed-off-by: Samuel Mendoza-Jonas <sam at mendozajonas.com>
---
discover/paths.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/discover/paths.c b/discover/paths.c
index e2213a0..f083ced 100644
--- a/discover/paths.c
+++ b/discover/paths.c
@@ -307,8 +307,9 @@ static void load_tftp(struct load_task *task)
}
enum wget_flags {
- wget_empty = 0,
- wget_no_check_certificate = 1,
+ wget_empty = 0x1,
+ wget_no_check_certificate = 0x2,
+ wget_verbose = 0x4,
};
/**
@@ -332,9 +333,16 @@ static void load_wget(struct load_task *task, int flags)
int i;
i = 3;
-#if !defined(DEBUG)
- argv[i++] = "--quiet";
+#if defined(DEBUG)
+ flags |= wget_verbose;
#endif
+ if ((flags & wget_verbose) == 0) {
+ argv[i++] = "--quiet";
+ } else {
+ task->process->add_stderr = true;
+ task->process->keep_stdout = true;
+ }
+
if (flags & wget_no_check_certificate)
argv[i++] = "--no-check-certificate";
@@ -382,6 +390,7 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
{
struct load_url_result *result;
struct load_task *task;
+ int flags = 0;
if (!url)
return NULL;
@@ -397,16 +406,20 @@ struct load_url_result *load_url_async(void *ctx, struct pb_url *url,
task->async_data = async_data;
task->process->exit_cb = load_url_process_exit;
task->process->data = task;
- task->process->custom_stdout_cb = stdout_cb;
+ if (stdout_cb) {
+ task->process->custom_stdout_cb = stdout_cb;
+ flags |= wget_verbose;
+ }
}
switch (url->scheme) {
case pb_url_ftp:
case pb_url_http:
- load_wget(task, 0);
+ load_wget(task, flags);
break;
case pb_url_https:
- load_wget(task, wget_no_check_certificate);
+ flags |= wget_no_check_certificate;
+ load_wget(task, flags);
break;
case pb_url_nfs:
load_nfs(task);
--
2.10.0
More information about the Petitboot
mailing list