Add a function for each mode to return the list of potential outputs, so that the existance/timestamp checks done for --if-newer can take those into accounts.
At the moment both modes return no outputs, so there is no behaviour change. --- src/mode_build.ml | 7 +++++++ src/mode_build.mli | 4 ++++ src/mode_prepare.ml | 9 ++++++++- src/mode_prepare.mli | 4 ++++ src/supermin.ml | 9 +++++++-- 5 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/mode_build.ml b/src/mode_build.ml index d54a3cd..4a58460 100644 --- a/src/mode_build.ml +++ b/src/mode_build.ml @@ -462,3 +462,10 @@ and munge files = let files = loop files in files + +and get_outputs + (copy_kernel, format, host_cpu, + packager_config, tmpdir, use_installed, size, + include_packagelist) + inputs = + [] diff --git a/src/mode_build.mli b/src/mode_build.mli index 0f8b956..4fba2ab 100644 --- a/src/mode_build.mli +++ b/src/mode_build.mli @@ -21,3 +21,7 @@ val build : int -> (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit (** [build debug (args...) inputs outputdir] performs the [supermin --build] subcommand. *) + +val get_outputs : (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string list +(** [get_outputs (args...) inputs] gets the potential outputs for the + appliance. *) diff --git a/src/mode_prepare.ml b/src/mode_prepare.ml index 70f9dd4..e0ad1a8 100644 --- a/src/mode_prepare.ml +++ b/src/mode_prepare.ml @@ -21,7 +21,7 @@ open Printf open Package_handler open Utils -let prepare debug (copy_kernel, format, host_cpu, +let rec prepare debug (copy_kernel, format, host_cpu, packager_config, tmpdir, use_installed, size, include_packagelist) inputs outputdir = @@ -175,3 +175,10 @@ let prepare debug (copy_kernel, format, host_cpu, (* No config files to copy, so do not create base.tar.gz. *) if debug >= 1 then printf "supermin: not creating base.tar.gz\n%!"; ) + +and get_outputs + (copy_kernel, format, host_cpu, + packager_config, tmpdir, use_installed, size, + include_packagelist) + inputs = + [] diff --git a/src/mode_prepare.mli b/src/mode_prepare.mli index e2d677a..be45730 100644 --- a/src/mode_prepare.mli +++ b/src/mode_prepare.mli @@ -21,3 +21,7 @@ val prepare : int -> (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit (** [prepare debug (args...) inputs outputdir] performs the [supermin --prepare] subcommand. *) + +val get_outputs : (bool * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string list +(** [get_outputs (args...) inputs] gets the potential outputs for the + appliance. *) diff --git a/src/supermin.ml b/src/supermin.ml index 80c48e6..4091f1d 100644 --- a/src/supermin.ml +++ b/src/supermin.ml @@ -236,10 +236,15 @@ appliance automatically. *) if if_newer then ( try - let odate = (lstat outputdir).st_mtime in + let mode_outputs = + match mode with + | Prepare -> Mode_prepare.get_outputs args inputs + | Build -> Mode_build.get_outputs args inputs in + let mode_outputs = List.map ((//) outputdir) mode_outputs in + let odates = List.map (fun d -> (lstat d).st_mtime) (outputdir :: mode_outputs) 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 List.for_all (fun idate -> List.for_all (fun odate -> idate < odate) odates) (pdate :: idates) then ( if debug >= 1 then printf "supermin: if-newer: output does not need rebuilding\n%!"; exit 0 -- 2.25.1 _______________________________________________ Libguestfs mailing list Libguestfs@redhat.com https://www.redhat.com/mailman/listinfo/libguestfs