summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2011-11-03 10:45:58 +0000
committerRichard W.M. Jones <rjones@redhat.com>2011-11-09 22:06:32 +0000
commita0a575767e23de1e2cf357e7c8743ebcba57bd68 (patch)
tree891b3d89d5d780e2423b2469f60112ad194eb080
parent57ec81a9f33e0eaabeca50a966f680820c519d52 (diff)
downloadlibguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.tar.gz
libguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.tar.xz
libguestfs-a0a575767e23de1e2cf357e7c8743ebcba57bd68.zip
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)
-rw-r--r--Makefile.am5
-rw-r--r--README4
-rw-r--r--configure.ac7
-rw-r--r--debian/control2
-rw-r--r--resize/Makefile.am4
-rw-r--r--resize/utils.ml23
6 files changed, 11 insertions, 34 deletions
diff --git a/Makefile.am b/Makefile.am
index 388cdeb8..bcafa226 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 9d18eebf..510798d0 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 eca45e62..dc8264ac 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 8027bda0..02c4657c 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 32c5325c..69103d68 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 dc134be6..c11740fd 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.)