Add a new hook for Output_format's to check for prerequisites on the
appliance (which can be done only when the appliance is run).
---
dib/dib.ml | 2 ++
dib/output_format.ml | 15 +++++++++++++++
dib/output_format.mli | 9 +++++++++
3 files changed, 26 insertions(+)
diff --git a/dib/dib.ml b/dib/dib.ml
index b578750..df83ba1 100644
--- a/dib/dib.ml
+++ b/dib/dib.ml
@@ -703,6 +703,8 @@ let main () =
g#launch ();
+ Output_format.check_formats_appliance_prerequisites cmdline.formats g;
+
(* Prepare the /aux partition. *)
g#mkfs "ext2" "/dev/sdb";
g#mount "/dev/sdb" "/";
diff --git a/dib/output_format.ml b/dib/output_format.ml
index f311b8d..851cefc 100644
--- a/dib/output_format.ml
+++ b/dib/output_format.ml
@@ -27,6 +27,7 @@ type format = {
extra_args : extra_arg list;
output_to_file : bool;
check_prerequisites : (unit -> unit) option;
+ check_appliance_prerequisites : (Guestfs.guestfs -> unit) option;
run_on_filesystem : (Guestfs.guestfs -> string -> string -> unit) option;
run_on_file : (string -> (string * string) -> string -> unit) option;
}
@@ -39,6 +40,7 @@ let defaults = {
extra_args = [];
output_to_file = true;
check_prerequisites = None;
+ check_appliance_prerequisites = None;
run_on_filesystem = None;
run_on_file = None;
}
@@ -129,6 +131,19 @@ let check_formats_prerequisites ~formats =
| { check_prerequisites = None } -> ()
) formats
+let check_formats_appliance_prerequisites ~formats g =
+ assert !baked;
+
+ (* Run the formats in alphabetical, rather than random order. *)
+ let formats = List.sort compare_formats (FormatSet.elements formats) in
+
+ List.iter (
+ function
+ | { check_appliance_prerequisites = Some fn } ->
+ fn g
+ | { check_appliance_prerequisites = None } -> ()
+ ) formats
+
let run_formats_on_filesystem ~formats g image_name tmpdir =
assert !baked;
diff --git a/dib/output_format.mli b/dib/output_format.mli
index e935f6f..76683ad 100644
--- a/dib/output_format.mli
+++ b/dib/output_format.mli
@@ -44,6 +44,11 @@ type format = {
to check whether the requirements for this format (available
tools, values for command line arguments, etc) are fulfilled. *)
+ check_appliance_prerequisites : (Guestfs.guestfs -> unit) option;
+ (** The function which is called after the appliance start to check
+ whether the requirements in the appliance for this format
+ (available features, filesystems, etc) are fulfilled. *)
+
run_on_filesystem : (Guestfs.guestfs -> string -> string -> unit) option;
(** The function which is called to perform the export while the
guest is mounted.
@@ -108,6 +113,10 @@ val set_cardinal : set -> int
val check_formats_prerequisites : formats:set -> unit
(** Check the prerequisites in all the formats listed in the [formats] set. *)
+val check_formats_appliance_prerequisites : formats:set -> Guestfs.guestfs -> unit
+(** Check the appliance prerequisites in all the formats listed in the
+ [formats] set. *)
+
val run_formats_on_filesystem : formats:set -> Guestfs.guestfs -> string ->
string -> unit
(** Run the filesystem-based export for all the formats listed in the
[formats] set. *)
--
2.9.3