[Libguestfs] [PATCH 05/10] dib: cleanup logs at end of build

Pino Toscano ptoscano at redhat.com
Tue Feb 14 08:12:06 UTC 2017


Recently, diskimage-builder moved the log cleanup from the 'base'
element to disk-image-create proper; the cleanup done is:
- truncate any file in /var/log
- remove *.log files in /root

This was implemented in diskimage-builder upstream as
commit 022d93ee822e71245af52c4cf8f8a8e82f599af3.
---
 dib/dib.ml | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dib/dib.ml b/dib/dib.ml
index ff2298d..b578750 100644
--- a/dib/dib.ml
+++ b/dib/dib.ml
@@ -895,6 +895,13 @@ let main () =
   flush_all ();
   g#mount blockdev "/";
   Array.iter (fun x -> g#rm_rf ("/tmp/" ^ x)) (g#ls "/tmp");
+  (* Truncate /var/log files in preparation for first boot. *)
+  truncate_recursive g "/var/log";
+  let non_log fn =
+    not (String.is_suffix fn ".log")
+  in
+  (* Remove root logs. *)
+  rm_rf_only_files g ~filter:non_log "/root";
 
   flush_all ();
 
-- 
2.9.3




More information about the Libguestfs mailing list