From: Richard W.M. Jones Date: Thu, 3 Nov 2011 10:45:58 +0000 (+0000) Subject: resize: Remove requirement for ocaml Pcre library. X-Git-Tag: 1.14.2~11 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=a0a575767e23de1e2cf357e7c8743ebcba57bd68;p=libguestfs.git resize: Remove requirement for ocaml Pcre library. This library is not available in RHEL 6, and in any case removing the dependency is a simple change. (cherry picked from commit ffbafadcb8dfebcaba529cb8d7e2da52dd032d8a) --- diff --git a/Makefile.am b/Makefile.am index 388cdeb..bcafa22 100644 --- a/Makefile.am +++ b/Makefile.am @@ -69,10 +69,7 @@ SUBDIRS += csharp # virt-resize (new version) and virt-sparsify are written in OCaml. if HAVE_OCAML -if HAVE_OCAML_PCRE -SUBDIRS += resize -endif -SUBDIRS += sparsify +SUBDIRS += resize sparsify endif # Perl tools. diff --git a/README b/README index 9d18eeb..510798d 100644 --- a/README +++ b/README @@ -101,10 +101,6 @@ To build FUSE support (guestmount): - FUSE libraries and kernel module (optional) -To build virt-resize: - -- OCaml PCRE bindings (ocaml-pcre) (optional) - To build language bindings: - Perl if you want to build the perl bindings (optional) diff --git a/configure.ac b/configure.ac index eca45e6..dc8264a 100644 --- a/configure.ac +++ b/configure.ac @@ -652,14 +652,9 @@ AS_IF([test "x$enable_ocaml" != "xno"], OCAMLFIND= AC_PROG_OCAML AC_PROG_FINDLIB - - AS_IF([test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"], - [AC_CHECK_OCAML_PKG([pcre])]) ]) AM_CONDITIONAL([HAVE_OCAML], [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno"]) -AM_CONDITIONAL([HAVE_OCAML_PCRE], - [test "x$OCAMLC" != "xno" && test "x$OCAMLFIND" != "xno" && test "x$OCAML_PKG_pcre" != "xno"]) AM_CONDITIONAL([HAVE_OCAMLDOC], [test "x$OCAMLDOC" != "xno"]) @@ -1088,7 +1083,7 @@ echo "guestfish and C virt tools .......... yes" echo -n "Perl virt tools ..................... " if test "x$HAVE_TOOLS_TRUE" = "x"; then echo "yes"; else echo "no"; fi echo -n "virt-resize ......................... " -if test "x$HAVE_OCAML_TRUE" = "x" && test "x$HAVE_OCAML_PCRE_TRUE" = "x"; then echo "yes"; else echo "no"; fi +if test "x$HAVE_OCAML_TRUE" = "x"; then echo "yes"; else echo "no"; fi echo "FUSE filesystem ..................... $enable_fuse" echo echo "If any optional component is configured 'no' when you expected 'yes'" diff --git a/debian/control b/debian/control index 8027bda..02c4657 100644 --- a/debian/control +++ b/debian/control @@ -24,8 +24,6 @@ Build-Depends: debhelper (>= 7), dpkg-dev, devscripts, autotools-dev, libsys-virt-perl, libwin-hivex-perl, # FUSE libfuse-dev, fuse-utils, -# virt-resize - libpcre-ocaml-dev, # Debian OCaml dh-ocaml, # to create images in the test suite diff --git a/resize/Makefile.am b/resize/Makefile.am index 32c5325..69103d6 100644 --- a/resize/Makefile.am +++ b/resize/Makefile.am @@ -25,7 +25,6 @@ EXTRA_DIST = \ CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-resize test.img if HAVE_OCAML -if HAVE_OCAML_PCRE # Alphabetical order. SOURCES = \ @@ -49,7 +48,7 @@ bin_SCRIPTS = virt-resize # -I $(top_builddir)/src/.libs is a hack which forces corresponding -L # option to be passed to gcc, so we don't try linking against an # installed copy of libguestfs. -OCAMLPACKAGES = -package pcre -I $(top_builddir)/src/.libs -I ../ocaml +OCAMLPACKAGES = -package str -I $(top_builddir)/src/.libs -I ../ocaml OCAMLCFLAGS = -g -warn-error CDEFLMPSUVYZX $(OCAMLPACKAGES) OCAMLOPTFLAGS = $(OCAMLCFLAGS) @@ -124,7 +123,6 @@ include .depend .PHONY: depend docs endif -endif # Parallel builds don't obey dependencies for some reason we # don't understand. diff --git a/resize/utils.ml b/resize/utils.ml index dc134be..c11740f 100644 --- a/resize/utils.ml +++ b/resize/utils.ml @@ -102,23 +102,16 @@ let feature_available (g : Guestfs.guestfs) names = (* Parse the size field from --resize and --resize-force options. *) let parse_size = - let const_re = Pcre.regexp "^([.\\d]+)([bKMG])$" - and plus_const_re = Pcre.regexp "^\\+([.\\d]+)([bKMG])$" - and minus_const_re = Pcre.regexp "^-([.\\d]+)([bKMG])$" - and percent_re = Pcre.regexp "^([.\\d]+)%$" - and plus_percent_re = Pcre.regexp "^\\+([.\\d]+)%$" - and minus_percent_re = Pcre.regexp "^-([.\\d]+)%$" + let const_re = Str.regexp "^\\([.0-9]+\\)\\([bKMG]\\)$" + and plus_const_re = Str.regexp "^\\+\\([.0-9]+\\)\\([bKMG]\\)$" + and minus_const_re = Str.regexp "^-\\([.0-9]+\\)\\([bKMG]\\)$" + and percent_re = Str.regexp "^\\([.0-9]+\\)%$" + and plus_percent_re = Str.regexp "^\\+\\([.0-9]+\\)%$" + and minus_percent_re = Str.regexp "^-\\([.0-9]+\\)%$" in fun oldsize field -> - let subs = ref None in - let matches rex = - try subs := Some (Pcre.exec ~rex field); true - with Not_found -> false - in - let sub i = - match !subs with None -> assert false - | Some subs -> Pcre.get_substring subs i - in + let matches rex = Str.string_match rex field 0 in + let sub i = Str.matched_group i field in let size_scaled f = function | "b" -> Int64.of_float f | "K" -> Int64.of_float (f *. 1024.)