mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
v2v: Fix kernel detection when multiple kernels are installed (RHBZ#1161250).
Previously we used to try to find the 'vmlinuz' file by running 'rpm -ql kernel' and looking for any file called 'vmlinuz-*'. If there were multiple 'kernel' packages installed, the rpm command would list files from all of them, resulting in a random 'vmlinuz-*' being chosen, not necessarily the one corresponding to the kernel package we were looking at. Use 'rpm -ql kernel-<VERSION>-<RELEASE>' instead so that we only look for files in the right kernel package. Thanks: James Mighion
This commit is contained in:
@@ -148,7 +148,7 @@ let rec convert ~verbose ~keep_serial_console (g : G.guestfs) inspect source =
|
||||
when name = "kernel" || string_prefix name "kernel-" ->
|
||||
(try
|
||||
(* For each kernel, list the files directly owned by the kernel. *)
|
||||
let files = Linux.file_list_of_package verbose g inspect name in
|
||||
let files = Linux.file_list_of_package verbose g inspect app in
|
||||
|
||||
(* Which of these is the kernel itself? *)
|
||||
let vmlinuz = List.find (
|
||||
|
||||
17
v2v/linux.ml
17
v2v/linux.ml
@@ -24,6 +24,8 @@ open Common_utils
|
||||
open Types
|
||||
open Utils
|
||||
|
||||
module G = Guestfs
|
||||
|
||||
(* Wrappers around aug_init & aug_load which can dump out full Augeas
|
||||
* parsing problems when debugging is enabled.
|
||||
*)
|
||||
@@ -115,12 +117,23 @@ let remove verbose g inspect packages =
|
||||
format (String.concat " " packages)
|
||||
)
|
||||
|
||||
let file_list_of_package verbose (g : Guestfs.guestfs) inspect name =
|
||||
let file_list_of_package verbose (g : Guestfs.guestfs) inspect app =
|
||||
let package_format = inspect.i_package_format in
|
||||
|
||||
match package_format with
|
||||
| "rpm" ->
|
||||
let cmd = [| "rpm"; "-ql"; name |] in
|
||||
(* Since RPM allows multiple packages installed with the same
|
||||
* name, always check the full ENVR here (RHBZ#1161250).
|
||||
*)
|
||||
let pkg_name =
|
||||
sprintf "%s-%s-%s" app.G.app2_name
|
||||
app.G.app2_version app.G.app2_release in
|
||||
let pkg_name =
|
||||
if app.G.app2_epoch > 0_l then
|
||||
sprintf "%ld:%s" app.G.app2_epoch pkg_name
|
||||
else
|
||||
pkg_name in
|
||||
let cmd = [| "rpm"; "-ql"; pkg_name |] in
|
||||
if verbose then eprintf "%s\n%!" (String.concat " " (Array.to_list cmd));
|
||||
let files = g#command_lines cmd in
|
||||
let files = Array.to_list files in
|
||||
|
||||
@@ -31,7 +31,7 @@ val install : bool -> Guestfs.guestfs -> Types.inspect -> string list -> unit
|
||||
val remove : bool -> Guestfs.guestfs -> Types.inspect -> string list -> unit
|
||||
(** Uninstall package(s). *)
|
||||
|
||||
val file_list_of_package : bool -> Guestfs.guestfs -> Types.inspect -> string -> string list
|
||||
val file_list_of_package : bool -> Guestfs.guestfs -> Types.inspect -> Guestfs.application2 -> string list
|
||||
(** Return list of files owned by package. *)
|
||||
|
||||
val file_owner : bool -> Guestfs.guestfs -> Types.inspect -> string -> string
|
||||
|
||||
Reference in New Issue
Block a user