mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user