[v2v PATCH 1/2] linux: split kernel packages filtering from processing
Split the processing of the kernel packages in two phases: - filtering only (by name) - actual processing This makes the filtering part easier to review/modify, and it is now much easier to see (in the debug log) which packages are processed as kernel packages. There are no behaviour changes (other than an additional debug message). --- v2v/linux_kernels.ml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml index 1bc10948..dc0c285d 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -89,11 +89,19 @@ let detect_kernels (g : G.guestfs) inspect family bootloader = PCRE.compile "^initrd.img-.*$" else PCRE.compile "^initr(?:d|amfs)-.*(?:\\.img)?$" in + let kernel_pkgs = List.filter ( + fun { G.app2_name = name } -> + name = "kernel" + || String.is_prefix name "kernel-" + || String.is_prefix name "linux-image-" + ) inspect.i_apps in + if verbose () then ( + let names = List.map (fun { G.app2_name = name } -> name) kernel_pkgs in + eprintf "candidate kernel packages in this guest: %s%!\n" + (String.concat " " names) + ); List.filter_map ( - function - | { G.app2_name = name } as app - when name = "kernel" || String.is_prefix name "kernel-" - || String.is_prefix name "linux-image-" -> + fun ({ G.app2_name = name } as app) -> (try (* For each kernel, list the files directly owned by the kernel. *) let files = Linux.file_list_of_package g inspect app in @@ -277,9 +285,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader = with Not_found -> None ) - - | _ -> None - ) inspect.i_apps in + ) kernel_pkgs in if verbose () then ( eprintf "installed kernel packages in this guest:\n"; -- 2.26.2
They usually contain only the sources of the kernel, useful to build kernel modules. --- v2v/linux_kernels.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml index dc0c285d..9a41225a 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -92,7 +92,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader = let kernel_pkgs = List.filter ( fun { G.app2_name = name } -> name = "kernel" - || String.is_prefix name "kernel-" + || (String.is_prefix name "kernel-" && not (String.is_suffix name "-devel")) || String.is_prefix name "linux-image-" ) inspect.i_apps in if verbose () then ( -- 2.26.2
On Tue, Sep 22, 2020 at 07:00:45PM +0200, Pino Toscano wrote:
They usually contain only the sources of the kernel, useful to build kernel modules. --- v2v/linux_kernels.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/v2v/linux_kernels.ml b/v2v/linux_kernels.ml index dc0c285d..9a41225a 100644 --- a/v2v/linux_kernels.ml +++ b/v2v/linux_kernels.ml @@ -92,7 +92,7 @@ let detect_kernels (g : G.guestfs) inspect family bootloader = let kernel_pkgs = List.filter ( fun { G.app2_name = name } -> name = "kernel" - || String.is_prefix name "kernel-" + || (String.is_prefix name "kernel-" && not (String.is_suffix name "-devel")) || String.is_prefix name "linux-image-"
ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
participants (2)
-
Pino Toscano -
Richard W.M. Jones