The two mode modules are called Mode_prepare and Mode_build. The two format modules are called Format_chroot and Format_ext2*. The package handler implementations are called Ph_*. This is entirely code motion, except that I removed three 'open' statements in order to make the source location of some functions clearer. --- .gitignore | 2 +- src/Makefile.am | 74 ++++++++++++------------- src/{ext2init-c.c => format-ext2-init-c.c} | 0 src/{chroot.ml => format_chroot.ml} | 0 src/{chroot.mli => format_chroot.mli} | 0 src/{ext2.ml => format_ext2.ml} | 0 src/{ext2.mli => format_ext2.mli} | 0 src/{ext2init.ml => format_ext2_init.ml} | 0 src/{ext2init.mli => format_ext2_init.mli} | 0 src/{ext2_initrd.ml => format_ext2_initrd.ml} | 3 +- src/{ext2_initrd.mli => format_ext2_initrd.mli} | 2 +- src/{kernel.ml => format_ext2_kernel.ml} | 0 src/{kernel.mli => format_ext2_kernel.mli} | 2 +- src/{build.ml => mode_build.ml} | 10 ++-- src/{build.mli => mode_build.mli} | 0 src/{prepare.ml => mode_prepare.ml} | 0 src/{prepare.mli => mode_prepare.mli} | 0 src/{dpkg.ml => ph_dpkg.ml} | 0 src/{dpkg.mli => ph_dpkg.mli} | 0 src/{pacman.ml => ph_pacman.ml} | 0 src/{pacman.mli => ph_pacman.mli} | 0 src/{rpm.ml => ph_rpm.ml} | 0 src/{rpm.mli => ph_rpm.mli} | 0 src/supermin.ml | 6 +- 24 files changed, 48 insertions(+), 51 deletions(-) rename src/{ext2init-c.c => format-ext2-init-c.c} (100%) rename src/{chroot.ml => format_chroot.ml} (100%) rename src/{chroot.mli => format_chroot.mli} (100%) rename src/{ext2.ml => format_ext2.ml} (100%) rename src/{ext2.mli => format_ext2.mli} (100%) rename src/{ext2init.ml => format_ext2_init.ml} (100%) rename src/{ext2init.mli => format_ext2_init.mli} (100%) rename src/{ext2_initrd.ml => format_ext2_initrd.ml} (99%) rename src/{ext2_initrd.mli => format_ext2_initrd.mli} (96%) rename src/{kernel.ml => format_ext2_kernel.ml} (100%) rename src/{kernel.mli => format_ext2_kernel.mli} (96%) rename src/{build.ml => mode_build.ml} (97%) rename src/{build.mli => mode_build.mli} (100%) rename src/{prepare.ml => mode_prepare.ml} (100%) rename src/{prepare.mli => mode_prepare.mli} (100%) rename src/{dpkg.ml => ph_dpkg.ml} (100%) rename src/{dpkg.mli => ph_dpkg.mli} (100%) rename src/{pacman.ml => ph_pacman.ml} (100%) rename src/{pacman.mli => ph_pacman.mli} (100%) rename src/{rpm.ml => ph_rpm.ml} (100%) rename src/{rpm.mli => ph_rpm.mli} (100%) diff --git a/.gitignore b/.gitignore index ff3680e..288950e 100644 --- a/.gitignore +++ b/.gitignore @@ -39,7 +39,7 @@ pod2htm?.tmp /snippet/ /src/.depend /src/config.ml -/src/ext2init-bin.S +/src/format-ext2-init-bin.S /src/supermin /src/supermin.1 /src/supermin-link.sh diff --git a/src/Makefile.am b/src/Makefile.am index c0e9656..5670a0d 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -28,9 +28,6 @@ SOURCES = \ ext2fs-c.c \ ext2fs.ml \ ext2fs.mli \ - ext2init-c.c \ - ext2init.ml \ - ext2init.mli \ fnmatch-c.c \ fnmatch.ml \ fnmatch.mli \ @@ -51,30 +48,32 @@ SOURCES = \ os_release.mli \ package_handler.ml \ package_handler.mli \ - rpm.ml \ - rpm.mli \ - dpkg.ml \ - dpkg.mli \ - pacman.ml \ - pacman.mli \ - prepare.ml \ - prepare.mli \ - chroot.ml \ - chroot.mli \ - kernel.ml \ - kernel.mli \ - ext2_initrd.ml \ - ext2_initrd.mli \ - ext2.ml \ - ext2.mli \ - build.ml \ - build.mli \ + ph_rpm.ml \ + ph_rpm.mli \ + ph_dpkg.ml \ + ph_dpkg.mli \ + ph_pacman.ml \ + ph_pacman.mli \ + mode_prepare.ml \ + mode_prepare.mli \ + format_chroot.ml \ + format_chroot.mli \ + format-ext2-init-c.c \ + format_ext2_init.ml \ + format_ext2_init.mli \ + format_ext2_initrd.ml \ + format_ext2_initrd.mli \ + format_ext2_kernel.ml \ + format_ext2_kernel.mli \ + format_ext2.ml \ + format_ext2.mli \ + mode_build.ml \ + mode_build.mli \ supermin.ml # Can't use filter for this because of automake brokenness. SOURCES_ML = \ ext2fs.ml \ - ext2init.ml \ fnmatch.ml \ glob.ml \ realpath.ml \ @@ -84,20 +83,21 @@ SOURCES_ML = \ types.ml \ os_release.ml \ package_handler.ml \ - rpm.ml \ - dpkg.ml \ - pacman.ml \ - prepare.ml \ - chroot.ml \ - kernel.ml \ - ext2_initrd.ml \ - ext2.ml \ - build.ml \ + ph_rpm.ml \ + ph_dpkg.ml \ + ph_pacman.ml \ + mode_prepare.ml \ + format_chroot.ml \ + format_ext2_init.ml \ + format_ext2_initrd.ml \ + format_ext2_kernel.ml \ + format_ext2.ml \ + mode_build.ml \ supermin.ml SOURCES_C = \ ext2fs-c.c \ - ext2init-c.c \ + format-ext2-init-c.c \ fnmatch-c.c \ glob-c.c \ librpm-c.c \ @@ -132,9 +132,9 @@ OBJECTS = $(XOBJECTS) BEST = opt endif -supermin_DEPENDENCIES = $(OBJECTS) ext2init-bin.o +supermin_DEPENDENCIES = $(OBJECTS) format-ext2-init-bin.o -supermin_LDADD = ext2init-bin.o ../lib/libgnu.a +supermin_LDADD = format-ext2-init-bin.o ../lib/libgnu.a supermin_LINK = \ ./supermin-link.sh \ @@ -148,12 +148,12 @@ supermin_LINK = \ .ml.cmx: $(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ -CLEANFILES += ext2init-bin.S +CLEANFILES += format-ext2-init-bin.S -ext2init-bin.o: ext2init-bin.S +format-ext2-init-bin.o: format-ext2-init-bin.S $(CC) -o $@ -c $< -ext2init-bin.S: ../init/init $(srcdir)/bin2s.pl +format-ext2-init-bin.S: ../init/init $(srcdir)/bin2s.pl strip --strip-all $< ls -l $< @file $< | grep -isq static || \ diff --git a/src/ext2init-c.c b/src/format-ext2-init-c.c similarity index 100% rename from src/ext2init-c.c rename to src/format-ext2-init-c.c diff --git a/src/chroot.ml b/src/format_chroot.ml similarity index 100% rename from src/chroot.ml rename to src/format_chroot.ml diff --git a/src/chroot.mli b/src/format_chroot.mli similarity index 100% rename from src/chroot.mli rename to src/format_chroot.mli diff --git a/src/ext2.ml b/src/format_ext2.ml similarity index 100% rename from src/ext2.ml rename to src/format_ext2.ml diff --git a/src/ext2.mli b/src/format_ext2.mli similarity index 100% rename from src/ext2.mli rename to src/format_ext2.mli diff --git a/src/ext2init.ml b/src/format_ext2_init.ml similarity index 100% rename from src/ext2init.ml rename to src/format_ext2_init.ml diff --git a/src/ext2init.mli b/src/format_ext2_init.mli similarity index 100% rename from src/ext2init.mli rename to src/format_ext2_init.mli diff --git a/src/ext2_initrd.ml b/src/format_ext2_initrd.ml similarity index 99% rename from src/ext2_initrd.ml rename to src/format_ext2_initrd.ml index d4a4e2f..b67bb55 100644 --- a/src/ext2_initrd.ml +++ b/src/format_ext2_initrd.ml @@ -21,7 +21,6 @@ open Printf open Utils open Ext2fs -open Ext2init open Fnmatch module StringSet = Set.Make (String) @@ -155,7 +154,7 @@ let rec build_initrd debug tmpdir modpath initrd = printf "supermin: ext2: wrote %d modules to minimal initrd\n%!" (StringSet.cardinal !visited); (* This is the binary blob containing the init "script". *) - let init = binary_init () in + let init = Format_ext2_init.binary_init () in let initfile = initdir // "init" in let chan = open_out initfile in output_string chan init; diff --git a/src/ext2_initrd.mli b/src/format_ext2_initrd.mli similarity index 96% rename from src/ext2_initrd.mli rename to src/format_ext2_initrd.mli index d03ee23..328a75c 100644 --- a/src/ext2_initrd.mli +++ b/src/format_ext2_initrd.mli @@ -19,7 +19,7 @@ (** Implements [--build -f ext2] minimal initrd which is required to mount the ext2 filesystem at runtime. - See also the {!Ext2} module. *) + See also the {!Format_ext2} module. *) val build_initrd : int -> string -> string -> string -> unit (** [build_initrd debug tmpdir modpath initrd] creates the minimal diff --git a/src/kernel.ml b/src/format_ext2_kernel.ml similarity index 100% rename from src/kernel.ml rename to src/format_ext2_kernel.ml diff --git a/src/kernel.mli b/src/format_ext2_kernel.mli similarity index 96% rename from src/kernel.mli rename to src/format_ext2_kernel.mli index 35a1273..32919bc 100644 --- a/src/kernel.mli +++ b/src/format_ext2_kernel.mli @@ -19,7 +19,7 @@ (** For [--build -f ext2] this module chooses a kernel to use and either links to it or copies it. - See also the {!Ext2} module. *) + See also the {!Format_ext2} module. *) val build_kernel : int -> string -> bool -> string -> string * string (** [build_kernel debug host_cpu copy_kernel kernel] diff --git a/src/build.ml b/src/mode_build.ml similarity index 97% rename from src/build.ml rename to src/mode_build.ml index 43aedc4..2a46dd8 100644 --- a/src/build.ml +++ b/src/mode_build.ml @@ -218,17 +218,17 @@ let rec build debug (match format with | Chroot -> (* chroot doesn't need an external kernel or initrd *) - Chroot.build_chroot debug files outputdir packagelist_file + Format_chroot.build_chroot debug files outputdir packagelist_file | Ext2 -> let kernel = outputdir // "kernel" and appliance = outputdir // "root" and initrd = outputdir // "initrd" in let kernel_version, modpath = - Kernel.build_kernel debug host_cpu copy_kernel kernel in - Ext2.build_ext2 debug basedir files modpath kernel_version appliance size - packagelist_file; - Ext2_initrd.build_initrd debug tmpdir modpath initrd + Format_ext2_kernel.build_kernel debug host_cpu copy_kernel kernel in + Format_ext2.build_ext2 debug basedir files modpath kernel_version + appliance size packagelist_file; + Format_ext2_initrd.build_initrd debug tmpdir modpath initrd ) and read_appliance debug basedir appliance = function diff --git a/src/build.mli b/src/mode_build.mli similarity index 100% rename from src/build.mli rename to src/mode_build.mli diff --git a/src/prepare.ml b/src/mode_prepare.ml similarity index 100% rename from src/prepare.ml rename to src/mode_prepare.ml diff --git a/src/prepare.mli b/src/mode_prepare.mli similarity index 100% rename from src/prepare.mli rename to src/mode_prepare.mli diff --git a/src/dpkg.ml b/src/ph_dpkg.ml similarity index 100% rename from src/dpkg.ml rename to src/ph_dpkg.ml diff --git a/src/dpkg.mli b/src/ph_dpkg.mli similarity index 100% rename from src/dpkg.mli rename to src/ph_dpkg.mli diff --git a/src/pacman.ml b/src/ph_pacman.ml similarity index 100% rename from src/pacman.ml rename to src/ph_pacman.ml diff --git a/src/pacman.mli b/src/ph_pacman.mli similarity index 100% rename from src/pacman.mli rename to src/ph_pacman.mli diff --git a/src/rpm.ml b/src/ph_rpm.ml similarity index 100% rename from src/rpm.ml rename to src/ph_rpm.ml diff --git a/src/rpm.mli b/src/ph_rpm.mli similarity index 100% rename from src/rpm.mli rename to src/ph_rpm.mli diff --git a/src/supermin.ml b/src/supermin.ml index 6dd75b2..014df88 100644 --- a/src/supermin.ml +++ b/src/supermin.ml @@ -21,8 +21,6 @@ open Printf open Types open Utils -open Prepare -open Build open Package_handler type mode = Prepare | Build @@ -249,8 +247,8 @@ or upgrade to libguestfs >= 1.26. ignore (Sys.command cmd)); (match mode with - | Prepare -> prepare debug args inputs new_outputdir - | Build -> build debug args inputs new_outputdir + | Prepare -> Mode_prepare.prepare debug args inputs new_outputdir + | Build -> Mode_build.build debug args inputs new_outputdir ); (* Delete the old output directory if it exists. *) -- 2.10.2