On Friday, 22 September 2017 09:36:14 CEST Richard W.M. Jones wrote: > diff --git a/v2v/linux_bootloaders.ml b/v2v/linux_bootloaders.ml > index 210cce762..00cb5cd19 100644 > --- a/v2v/linux_bootloaders.ml > +++ b/v2v/linux_bootloaders.ml > @@ -319,9 +319,9 @@ 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 rex = PCRE.compile "\\.(?:dpkg-.*|rpmsave|rpmnew)$" in > let vmlinuzes = List.filter ( > - fun file -> not (Str.string_match rex file 0) > + fun file -> not (PCRE.matches rex file) > ) vmlinuzes in
TBH here I'd just drop the regexp usage, and use a static list of
suffixes (there are not that many, anyway) -- something like:
let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in
let vmlinuzes = List.filter (
fun file -> not (List.exists (Filename.check_suffix file))
) vmlinuxes in
Even better, this can be moved to a separate function in the Linux
module, which is where (most of) the interaction with package managers
happen:
let is_package_manager_file file =
(* Recognized suffixes of package managers. *)
let suffixes = [ ".dpkg-old"; ".dpkg-new"; ".rpmsave"; ".rpmnew"; ] in
List.exists (Filename.check_suffix file)
...
let vmlinuzes = List.filter (
fun file -> not (Linux.is_package_manager_file file)
) vmlinuxes in
(Of course with a better naming for the function.)
--
Pino Toscano
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Libguestfs mailing list [email protected] https://www.redhat.com/mailman/listinfo/libguestfs
