Richard W.M. Jones
2016-Dec-07 14:04 UTC
[Libguestfs] [PATCH 0/3] Miscellaneous improvements to supermin.
Document what each module does, using *.mli files. Remove the --dtb option, it's obsolete. Rename modules according to their purpose. Rich.
Add documentation for the modules making up supermin. This is just documentation, there is no code change. --- src/Makefile.am | 9 +++++++++ src/build.mli | 23 +++++++++++++++++++++++ src/chroot.mli | 25 +++++++++++++++++++++++++ src/dpkg.mli | 22 ++++++++++++++++++++++ src/ext2.mli | 29 +++++++++++++++++++++++++++++ src/ext2_initrd.mli | 31 +++++++++++++++++++++++++++++++ src/kernel.mli | 35 +++++++++++++++++++++++++++++++++++ src/pacman.mli | 22 ++++++++++++++++++++++ src/prepare.mli | 23 +++++++++++++++++++++++ src/rpm.mli | 22 ++++++++++++++++++++++ 10 files changed, 241 insertions(+) create mode 100644 src/build.mli create mode 100644 src/chroot.mli create mode 100644 src/dpkg.mli create mode 100644 src/ext2.mli create mode 100644 src/ext2_initrd.mli create mode 100644 src/kernel.mli create mode 100644 src/pacman.mli create mode 100644 src/prepare.mli create mode 100644 src/rpm.mli diff --git a/src/Makefile.am b/src/Makefile.am index 767117f..c0e9656 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,14 +52,23 @@ SOURCES = \ 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 \ supermin.ml # Can't use filter for this because of automake brokenness. diff --git a/src/build.mli b/src/build.mli new file mode 100644 index 0000000..6feb4f8 --- /dev/null +++ b/src/build.mli @@ -0,0 +1,23 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** Implements the [--build] subcommand. *) + +val build : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit +(** [build debug (args...) inputs outputdir] performs the + [supermin --build] subcommand. *) diff --git a/src/chroot.mli b/src/chroot.mli new file mode 100644 index 0000000..5bd81c7 --- /dev/null +++ b/src/chroot.mli @@ -0,0 +1,25 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** Implements [--build -f chroot]. *) + +val build_chroot : int -> Package_handler.file list -> string -> string option -> unit +(** [build_chroot debug files outputdir packagelist_file] copies the + list of [files] into the chroot at [outputdir]. The optional + [packagelist] controls creation of [/packagelist] within the + chroot. *) diff --git a/src/dpkg.mli b/src/dpkg.mli new file mode 100644 index 0000000..c21327c --- /dev/null +++ b/src/dpkg.mli @@ -0,0 +1,22 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** dpkg package handler + + Nothing is exported. This module registers callbacks when it + is loaded. *) diff --git a/src/ext2.mli b/src/ext2.mli new file mode 100644 index 0000000..66cf5c2 --- /dev/null +++ b/src/ext2.mli @@ -0,0 +1,29 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** Implements [--build -f chroot]. *) + +val build_ext2 : int -> string -> Package_handler.file list -> string -> string -> string -> int64 option -> string option -> unit +(** [build_ext2 debug basedir files modpath kernel_version appliance size + packagelist_file] copies all the files from [basedir] plus the + list of [files] into a newly created ext2 filesystem called [appliance]. + + Kernel modules are also copied in from the local [modpath] + to the fixed path in the appliance [/lib/modules/<kernel_version>]. + + libext2fs is used to populate the ext2 filesystem. *) diff --git a/src/ext2_initrd.mli b/src/ext2_initrd.mli new file mode 100644 index 0000000..d03ee23 --- /dev/null +++ b/src/ext2_initrd.mli @@ -0,0 +1,31 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** Implements [--build -f ext2] minimal initrd which is required + to mount the ext2 filesystem at runtime. + + See also the {!Ext2} module. *) + +val build_initrd : int -> string -> string -> string -> unit +(** [build_initrd debug tmpdir modpath initrd] creates the minimal + initrd required to mount the ext2 filesystem at runtime. + + A small, whitelisted selection of kernel modules is taken + from [modpath], just enough to mount the appliance. + + The output is the file [initrd]. *) diff --git a/src/kernel.mli b/src/kernel.mli new file mode 100644 index 0000000..36b4ab7 --- /dev/null +++ b/src/kernel.mli @@ -0,0 +1,35 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** For [--build -f ext2] this module chooses a kernel to use + and either links to it or copies it. + + See also the {!Ext2} module. *) + +val build_kernel : int -> string -> string option -> bool -> string -> string -> string * string +(** [build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb] + chooses the kernel to use and links to it or copies it into the + appliance directory. + + The output is written to the file [kernel]. + + The function returns the [kernel_version, modpath] tuple as a + side-effect of locating the kernel. + + The [--dtb] option is also handled here, but that support is + now effectively obsolete and will be removed in future. *) diff --git a/src/pacman.mli b/src/pacman.mli new file mode 100644 index 0000000..5b9be12 --- /dev/null +++ b/src/pacman.mli @@ -0,0 +1,22 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** pacman package handler. + + Nothing is exported. This module registers callbacks when it + is loaded. *) diff --git a/src/prepare.mli b/src/prepare.mli new file mode 100644 index 0000000..404302a --- /dev/null +++ b/src/prepare.mli @@ -0,0 +1,23 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** Implements the [--prepare] subcommand. *) + +val prepare : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit +(** [prepare debug (args...) inputs outputdir] performs the + [supermin --prepare] subcommand. *) diff --git a/src/rpm.mli b/src/rpm.mli new file mode 100644 index 0000000..8b55ad4 --- /dev/null +++ b/src/rpm.mli @@ -0,0 +1,22 @@ +(* supermin 5 + * Copyright (C) 2009-2016 Red Hat Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + *) + +(** RPM package handler + + Nothing is exported. This module registers callbacks when it + is loaded. *) -- 2.10.2
Richard W.M. Jones
2016-Dec-07 14:04 UTC
[Libguestfs] [PATCH 2/3] Remove the --dtb option and all supporting code.
It used to be necessary to specify a DTB manually back in very old versions of qemu on armv7. However qemu has constructed a correct DTB for a very long time and it's almost certainly a mistake if you are using the supermin --dtb parameter to override that. (For this reason, supermin will intentionally give an error now if you try to use --dtb). libguestfs stopped using this parameter in commit af762e43424382d895d3a10aa6632adc601fdbad (2015-03-05). --- src/build.ml | 5 ++-- src/build.mli | 2 +- src/kernel.ml | 70 +------------------------------------------------------- src/kernel.mli | 9 +++----- src/prepare.ml | 2 +- src/prepare.mli | 2 +- src/supermin.ml | 7 ++---- src/supermin.pod | 44 +++-------------------------------- 8 files changed, 14 insertions(+), 127 deletions(-) diff --git a/src/build.ml b/src/build.ml index 83a0d98..43aedc4 100644 --- a/src/build.ml +++ b/src/build.ml @@ -58,7 +58,7 @@ and string_of_file_content = function | Excludefiles -> "excludefiles" let rec build debug - (copy_kernel, dtb_wildcard, format, host_cpu, + (copy_kernel, format, host_cpu, packager_config, tmpdir, use_installed, size, include_packagelist) inputs outputdir @@ -222,11 +222,10 @@ let rec build debug | Ext2 -> let kernel = outputdir // "kernel" - and dtb = outputdir // "dtb" and appliance = outputdir // "root" and initrd = outputdir // "initrd" in let kernel_version, modpath - Kernel.build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb in + 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 diff --git a/src/build.mli b/src/build.mli index 6feb4f8..0f8b956 100644 --- a/src/build.mli +++ b/src/build.mli @@ -18,6 +18,6 @@ (** Implements the [--build] subcommand. *) -val build : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit +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. *) diff --git a/src/kernel.ml b/src/kernel.ml index b4e89da..5d1ae66 100644 --- a/src/kernel.ml +++ b/src/kernel.ml @@ -39,7 +39,7 @@ let patt_of_cpu host_cpu in List.map (fun model -> sprintf "vmlinu?-*-%s" model) models -let rec build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb +let rec build_kernel debug host_cpu copy_kernel kernel (* Locate the kernel. *) let kernel_file, kernel_name, kernel_version, modpath try @@ -84,13 +84,6 @@ let rec build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb ) else find_kernel debug host_cpu kernel in - (* If the user passed --dtb option, locate dtb. *) - (match dtb_wildcard with - | None -> () - | Some wildcard -> - find_dtb debug copy_kernel kernel_name wildcard dtb - ); - if debug >= 1 then ( printf "supermin: kernel: kernel_version %s\n" kernel_version; printf "supermin: kernel: modules %s\n%!" modpath; @@ -161,67 +154,6 @@ installed, try installing a fullvirt kernel (only for supermin use, you shouldn't boot the Xen guest with it)." host_cpu -and find_dtb debug copy_kernel kernel_name wildcard dtb - let dtb_file - try - let dtb_file = getenv "SUPERMIN_DTB" in - if debug >= 1 then - printf "supermin: kernel: SUPERMIN_DTB environment variable = %s\n%!" - dtb_file; - dtb_file - with Not_found -> - (* Replace vmlinuz- with dtb- *) - if not (string_prefix "vmlinuz-" kernel_name) && - not (string_prefix "vmlinuz-" kernel_name) then - no_dtb_dir kernel_name; - let dtb_dir - try - List.find dir_exists ( - List.map (fun prefix -> - prefix ^ String.sub kernel_name 8 (String.length kernel_name - 8) - ) ["/boot/dtb-"; "/usr/lib/linux-image-"]) - with Not_found -> - no_dtb_dir kernel_name; "" - in - - let all_files = Sys.readdir dtb_dir in - let all_files = Array.to_list all_files in - - let files - List.filter (fun filename -> fnmatch wildcard filename [FNM_NOESCAPE]) - all_files in - if files = [] then - no_dtb dtb_dir wildcard; - - let dtb_name = List.hd files in - let dtb_file = dtb_dir // dtb_name in - if debug >= 1 then - printf "supermin: kernel: picked dtb %s\n%!" dtb_file; - dtb_file in - - copy_or_symlink_file copy_kernel dtb_file dtb - -and no_dtb_dir kernel_name - error "\ -failed to find a dtb (device tree) directory. - -I expected to take '%s' and to -replace vmlinuz- with dtb- to form a directory. - -You can set SUPERMIN_KERNEL, SUPERMIN_MODULES and SUPERMIN_DTB -to override automatic selection. See supermin(1)." - kernel_name - -and no_dtb dtb_dir wildcard - error "\ -failed to find a matching device tree. - -I looked for a file matching '%s' in directory '%s'. - -You can set SUPERMIN_KERNEL, SUPERMIN_MODULES and SUPERMIN_DTB -to override automatic selection. See supermin(1)." - wildcard dtb_dir - and find_modpath debug kernel_version try let modpath = getenv "SUPERMIN_MODULES" in diff --git a/src/kernel.mli b/src/kernel.mli index 36b4ab7..35a1273 100644 --- a/src/kernel.mli +++ b/src/kernel.mli @@ -21,15 +21,12 @@ See also the {!Ext2} module. *) -val build_kernel : int -> string -> string option -> bool -> string -> string -> string * string -(** [build_kernel debug host_cpu dtb_wildcard copy_kernel kernel dtb] +val build_kernel : int -> string -> bool -> string -> string * string +(** [build_kernel debug host_cpu copy_kernel kernel] chooses the kernel to use and links to it or copies it into the appliance directory. The output is written to the file [kernel]. The function returns the [kernel_version, modpath] tuple as a - side-effect of locating the kernel. - - The [--dtb] option is also handled here, but that support is - now effectively obsolete and will be removed in future. *) + side-effect of locating the kernel. *) diff --git a/src/prepare.ml b/src/prepare.ml index 830b620..e8cf058 100644 --- a/src/prepare.ml +++ b/src/prepare.ml @@ -21,7 +21,7 @@ open Printf open Package_handler open Utils -let prepare debug (copy_kernel, dtb_wildcard, format, host_cpu, +let prepare debug (copy_kernel, format, host_cpu, packager_config, tmpdir, use_installed, size, include_packagelist) inputs outputdir diff --git a/src/prepare.mli b/src/prepare.mli index 404302a..e2d677a 100644 --- a/src/prepare.mli +++ b/src/prepare.mli @@ -18,6 +18,6 @@ (** Implements the [--prepare] subcommand. *) -val prepare : int -> (bool * string option * Types.format * string * string option * string * bool * int64 option * bool) -> string list -> string -> unit +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. *) diff --git a/src/supermin.ml b/src/supermin.ml index a09b498..6dd75b2 100644 --- a/src/supermin.ml +++ b/src/supermin.ml @@ -86,7 +86,6 @@ let main () let copy_kernel = ref false in let debug = ref 0 in - let dtb_wildcard = ref "" in let format = ref None in let host_cpu = ref Config.host_cpu in let if_newer = ref false in @@ -134,7 +133,6 @@ or upgrade to libguestfs >= 1.26. let argspec = Arg.align [ "--build", Arg.Unit set_build_mode, " Build a full appliance"; "--copy-kernel", Arg.Set copy_kernel, " Copy kernel instead of symlinking"; - "--dtb", Arg.Set_string dtb_wildcard, "WILDCARD Find device tree matching wildcard"; "-f", Arg.String set_format, "chroot|ext2 Set output format"; "--format", Arg.String set_format, ditto; "--host-cpu", Arg.Set_string host_cpu, "ARCH Set host CPU architecture"; @@ -160,7 +158,6 @@ or upgrade to libguestfs >= 1.26. let copy_kernel = !copy_kernel in let debug = !debug in - let dtb_wildcard = match !dtb_wildcard with "" -> None | s -> Some s in let host_cpu = !host_cpu in let if_newer = !if_newer in let inputs = List.rev !inputs in @@ -191,7 +188,7 @@ or upgrade to libguestfs >= 1.26. else outputdir in debug, mode, if_newer, inputs, lockfile, outputdir, - (copy_kernel, dtb_wildcard, format, host_cpu, + (copy_kernel, format, host_cpu, packager_config, tmpdir, use_installed, size, include_packagelist) in @@ -201,7 +198,7 @@ or upgrade to libguestfs >= 1.26. * This fails with an error if one could not be located. *) let () - let (_, _, _, _, packager_config, tmpdir, _, _, _) = args in + let (_, _, _, packager_config, tmpdir, _, _, _) = args in let settings = { debug = debug; tmpdir = tmpdir; diff --git a/src/supermin.pod b/src/supermin.pod index 8c9aca7..4581201 100644 --- a/src/supermin.pod +++ b/src/supermin.pod @@ -143,40 +143,6 @@ the kernel in F</boot>. This is fractionally slower, but is necessary if you want to change the permissions or SELinux label on the kernel or device tree. -=item B<--dtb> WILDCARD - -(I<--build> mode only) - -If specified, search for a device tree which is compatible with the -selected kernel and the name of which matches the given wildcard. You -can use a wildcard such as C<vexpress-*a9*.dtb> which would match -F<vexpress-v2p-ca9.dtb>. - -Notes: - -=over 4 - -=item * - -You may need to quote the wildcard to prevent it from being expanded -by your shell. - -=item * - -If no I<--dtb> option is given, no device tree will be looked for. - -=item * - -You only need a device tree on architectures such as ARM and PowerPC -which use them. On other architectures, don't use this option. - -=item * - -If you use this option and no compatible device tree can be found, -supermin will exit with an error. - -=back - =item B<-f> FORMAT =item B<--format> FORMAT @@ -202,15 +168,15 @@ This is called a C<chroot> because you could literally L<chroot(1)> into this directory afterwards, although it's a better idea to use a container technology (LXC, etc.). -No kernel, initrd or dtb is generated in this mode because it is +No kernel or initrd is generated in this mode because it is assumed that you will be running the appliance using the host kernel. =item ext2 An ext2 filesystem disk image. -The output kernel is written to F<OUTPUTDIR/kernel>, the device tree -(if using) to F<OUTPUTDIR/dtb>, a small initramfs which can mount the +The output kernel is written to F<OUTPUTDIR/kernel>, +a small initramfs which can mount the appliance to F<OUTPUTDIR/initrd>, and the ext2 filesystem image to F<OUTPUTDIR/root>. (Where F<OUTPUTDIR> is specified by the I<-o> option). @@ -543,10 +509,6 @@ This specifies the kernel modules directory to use. The environment variable should point to a module directory, eg. F</lib/modules/3.0.x86_64/> -=item SUPERMIN_DTB - -Force the given device tree file to be used. - =item SUPERMIN_KERNEL_VERSION On non-x86 architectures, you may need to set this environment -- 2.10.2
Richard W.M. Jones
2016-Dec-07 14:04 UTC
[Libguestfs] [PATCH 3/3] Group and rename modules according to their purpose.
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
Pino Toscano
2016-Dec-07 15:01 UTC
Re: [Libguestfs] [PATCH 0/3] Miscellaneous improvements to supermin.
On Wednesday, 7 December 2016 14:04:43 CET Richard W.M. Jones wrote:> Document what each module does, using *.mli files. > > Remove the --dtb option, it's obsolete. > > Rename modules according to their purpose.Generally LGTM. The only note is about the removal of --dtb: wouldn't it better to leave a stub option? It would explicitly print out it was removed, so when specified it's clearer it was not a typo but intentional functionality drop/change. -- Pino Toscano
Richard W.M. Jones
2016-Dec-07 15:04 UTC
Re: [Libguestfs] [PATCH 0/3] Miscellaneous improvements to supermin.
On Wed, Dec 07, 2016 at 04:01:50PM +0100, Pino Toscano wrote:> On Wednesday, 7 December 2016 14:04:43 CET Richard W.M. Jones wrote: > > Document what each module does, using *.mli files. > > > > Remove the --dtb option, it's obsolete. > > > > Rename modules according to their purpose. > > Generally LGTM. > > The only note is about the removal of --dtb: wouldn't it better to > leave a stub option? It would explicitly print out it was removed, > so when specified it's clearer it was not a typo but intentional > functionality drop/change.OK I'll modify this and then push. Thanks, Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
Apparently Analagous Threads
- [supermin PATCH 0/4] Check for output results for --if-newer (RHBZ#1813809)
- [supermin PATCH v2 0/4] Check for output results for --if-newer (RHBZ#1813809)
- [PATCH 1/2] utils: import parse_size from libguestfs
- [PATCH 0/3] supermin: miscellaneous cleanups
- [PATCH 0/3] supermin: add --include-packagelist