[Libguestfs] [supermin PATCH] rebuild the output it when SUPERMIN_KERNEL or SUPERMIN_MODULES are defined

Masayoshi Mizuma msys.mizuma at gmail.com
Mon Mar 4 11:18:58 UTC 2019


SUPERMIN_KERNEL and SUPERMIN_MODULES don't work to guestfish.

Since guestfish sets --if-newer parameter to supermin, so the environment
variables are not used under the following conditions.
  - the output directory exists and,
  - the dates of both input files and package database are
    older than the output

To solve that, rebuild the output it when SUPERMIN_KERNEL or
SUPERMIN_MODULES are defined even if --if-newer is set.

Signed-off-by: Masayoshi Mizuma <msys.mizuma at gmail.com>
---
 src/supermin.ml | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/supermin.ml b/src/supermin.ml
index 7c7135b3..b997643 100644
--- a/src/supermin.ml
+++ b/src/supermin.ml
@@ -236,13 +236,17 @@ appliance automatically.
    *)
   if if_newer then (
     try
-      let odate = (lstat outputdir).st_mtime in
-      let idates = List.map (fun d -> (lstat d).st_mtime) inputs in
-      let pdate = (get_package_handler ()).ph_get_package_database_mtime () in
-      if List.for_all (fun idate -> idate < odate) (pdate :: idates) then (
-        if debug >= 1 then
-          printf "supermin: if-newer: output does not need rebuilding\n%!";
-        exit 0
+      let kernel = try getenv "SUPERMIN_KERNEL" with Not_found -> "" in
+      let modules = try getenv "SUPERMIN_MODULES" with Not_found -> "" in
+      if kernel = "" && modules = "" then (
+        let odate = (lstat outputdir).st_mtime in
+        let idates = List.map (fun d -> (lstat d).st_mtime) inputs in
+        let pdate = (get_package_handler ()).ph_get_package_database_mtime () in
+        if List.for_all (fun idate -> idate < odate) (pdate :: idates) then (
+          if debug >= 1 then
+            printf "supermin: if-newer: output does not need rebuilding\n%!";
+          exit 0
+        )
       )
     with
       Unix_error _ -> () (* just continue *)
-- 
2.20.1




More information about the Libguestfs mailing list