[Libguestfs] [PATCH] daemon: tweak regexp for file type detection (RHBZ#1575640)

Pino Toscano ptoscano at redhat.com
Mon May 7 15:20:43 UTC 2018


Newer versions of file slightly changed the output, removing the comma
between the type, and the architecture string.

Tweak the regular expression so:
- the comma is optional, but if missing then only the architecture
  string will follow
- the architecture string has no commas
---
 daemon/filearch.ml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/daemon/filearch.ml b/daemon/filearch.ml
index b2c30ae87..a892ba851 100644
--- a/daemon/filearch.ml
+++ b/daemon/filearch.ml
@@ -25,7 +25,7 @@ open Unix_utils
 open Utils
 
 let re_file_elf =
-  PCRE.compile "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable), (.+?),"
+  PCRE.compile "ELF (\\d+)-bit (MSB|LSB).*(?:executable|shared object|relocatable)(?:,)? ([^,]+?),"
 
 let re_file_elf_ppc64 = PCRE.compile ".*64.*PowerPC"
 
-- 
2.14.3




More information about the Libguestfs mailing list