v2v: linux: Fix uninstallation of kmod-xenpv from /etc/rc.local script.

In the original conversion of virt-v2v from Perl
(commit 0131d6f666), the Perl regular
expression was incorrectly transscribed.  ‘\b’ was not converted to
‘\\b’ so the new regexp was looking for an ASCII BEL character, not a
word boundary.  Also ‘|’ was used, but Str requires ‘\|’ (ie. "\\|"
in the final source).

To fix these problems I converted the code to use PCRE, and went back
to the original virt-v2v code (virt-v2v.git:
lib/Sys/VirtConvert/Converter/Linux.pm) to find out what the Perl
regular expression should have been.

Note I have also removed ‘.*’ at the beginning and end of the regexp
because PCRE regexps are not anchored.
This commit is contained in:
Richard W.M. Jones
2017-09-21 11:55:53 +01:00
parent 843ea53af0
commit 95b0da8f37

View File

@@ -173,10 +173,10 @@ let convert (g : G.guestfs) inspect source output rcaps =
(try
let lines = g#read_lines "/etc/rc.local" in
let lines = Array.to_list lines in
let rex = Str.regexp ".*\\b\\(insmod|modprobe\\)\b.*\\bxen-vbd.*" in
let rex = PCRE.compile "\\b(insmod|modprobe)\\b.*\\bxen-vbd" in
let lines = List.map (
fun s ->
if Str.string_match rex s 0 then
if PCRE.matches rex s then
"#" ^ s
else
s