mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
v2v: linux: Properly ignore rpm/dpkg-move-aside kernels.
The old virt-v2v code ignored boot kernels with names like "/boot/vmlinuz-*.rpmsave". The transscribed code did not because the Str module requires ‘|’ to be escaped as ‘\|’. This changes the code to use a simpler test. Thanks: Pino Toscano
This commit is contained in:
@@ -157,3 +157,8 @@ let rec file_owner (g : G.guestfs) { i_package_format = package_format } path =
|
||||
and is_file_owned g inspect path =
|
||||
try ignore (file_owner g inspect path); true
|
||||
with Not_found -> false
|
||||
|
||||
let is_package_manager_save_file filename =
|
||||
(* Recognized suffixes of package managers. *)
|
||||
let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in
|
||||
List.exists (Filename.check_suffix filename) suffixes
|
||||
|
||||
@@ -35,3 +35,7 @@ val file_owner : Guestfs.guestfs -> Types.inspect -> string -> string
|
||||
|
||||
val is_file_owned : Guestfs.guestfs -> Types.inspect -> string -> bool
|
||||
(** Returns true if the file is owned by an installed package. *)
|
||||
|
||||
val is_package_manager_save_file : string -> bool
|
||||
(** Return true if the filename is something like [*.rpmsave], ie.
|
||||
a package manager save-file. *)
|
||||
|
||||
@@ -319,9 +319,8 @@ object (self)
|
||||
Array.to_list (g#glob_expand "/boot/kernel-*") @
|
||||
Array.to_list (g#glob_expand "/boot/vmlinuz-*") @
|
||||
Array.to_list (g#glob_expand "/vmlinuz-*") in
|
||||
let rex = Str.regexp ".*\\.\\(dpkg-.*|rpmsave|rpmnew\\)$" in
|
||||
let vmlinuzes = List.filter (
|
||||
fun file -> not (Str.string_match rex file 0)
|
||||
fun filename -> not (Linux.is_package_manager_save_file filename)
|
||||
) vmlinuzes in
|
||||
vmlinuzes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user