From c326426d980378c9c1d6fd2be98a7ee55c2fd3f6 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 20 Jul 2017 01:47:01 +0300 Subject: Add support for install, test installed and uninstall operations --- bbot/agent/agent.cxx | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'bbot/agent/agent.cxx') diff --git a/bbot/agent/agent.cxx b/bbot/agent/agent.cxx index eacd05a..80b4fb7 100644 --- a/bbot/agent/agent.cxx +++ b/bbot/agent/agent.cxx @@ -64,6 +64,17 @@ file_sync (const path& f) throw_system_error (errno); } +static bool +file_not_empty (const path& f) +{ + if (file_exists (f)) + { + file_sync (f); + return !file_empty (f); + } + return false; +} + // The btrfs tool likes to print informational messages, like "Created // snapshot such and such". Luckily, it writes them to stdout while proper // diagnostics to stderr. @@ -226,12 +237,8 @@ bootstrap_machine (const dir_path& md, // for (to = bootstrap_to; to != 0; tftpd.serve (to, 2)) { - if (file_exists (mf)) - { - file_sync (mf); - if (!file_empty (mf)) - break; - } + if (file_not_empty (mf)) + break; } if (to == 0) @@ -615,9 +622,19 @@ try { // Simply wait for the file to appear. // - for (size_t i (0); !file_exists (rf); sleep (1)) + for (size_t i (0);; sleep (1)) + { + if (file_not_empty (rf)) + { + // Wait a bit to make sure we see complete manifest. + // + sleep (2); + break; + } + if (i++ % 10 == 0) l3 ([&]{trace << "waiting for result manifest";}); + } r = parse_manifest (rf, "result"); } @@ -711,12 +728,8 @@ try // for (to = build_to; to != 0; tftpd.serve (to, 2)) { - if (file_exists (rf)) - { - file_sync (rf); - if (!file_empty (rf)) - break; - } + if (file_not_empty (rf)) + break; } if (to == 0) -- cgit v1.1