Re: [Libguestfs] [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.

2017-09-13 Thread Pino Toscano
On Tuesday, 12 September 2017 19:56:30 CEST Richard W.M. Jones wrote:
> On Tue, Sep 12, 2017 at 06:41:36PM +0200, Pino Toscano wrote:
> > On Wednesday, 9 August 2017 19:23:37 CEST Richard W.M. Jones wrote:
> > > This commit bundles the ocaml-augeas library (upstream here:
> > > http://git.annexia.org/?p=ocaml-augeas.git;a=summary).  It's identical
> > > to the upstream version and should remain so.
> > > 
> > > We can work towards using system ocaml-augeas, when it's more widely
> > > available.
> > > ---
> > 
> > IMHO it would be better if the Augeas.Error exception had all the
> > available details, i.e. code, error message, minor message, and details.
> > Right now it does not even include any of those, so it is hard for
> > users to differentiate the error handling depending on the actual error.
> > Also, IMHO failures related to ENOMEM should caml_raise_out_of_memory().
> > 
> > I guess this is not doable anymore, to avoid breaking the ocaml-augeas
> > API?  If it is doable, I'm willing to cook up a patch.
> 
> I'm not really fussed about that API.  The only constraint is that
> this change would have to go into ocaml-augeas (ie. the upstream
> project) first.  If you want to have a go at a patch then please do.

Yes, that was what I had in mind -- will send one then.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

Re: [Libguestfs] [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.

2017-09-12 Thread Richard W.M. Jones
On Tue, Sep 12, 2017 at 06:41:36PM +0200, Pino Toscano wrote:
> On Wednesday, 9 August 2017 19:23:37 CEST Richard W.M. Jones wrote:
> > This commit bundles the ocaml-augeas library (upstream here:
> > http://git.annexia.org/?p=ocaml-augeas.git;a=summary).  It's identical
> > to the upstream version and should remain so.
> > 
> > We can work towards using system ocaml-augeas, when it's more widely
> > available.
> > ---
> 
> IMHO it would be better if the Augeas.Error exception had all the
> available details, i.e. code, error message, minor message, and details.
> Right now it does not even include any of those, so it is hard for
> users to differentiate the error handling depending on the actual error.
> Also, IMHO failures related to ENOMEM should caml_raise_out_of_memory().
> 
> I guess this is not doable anymore, to avoid breaking the ocaml-augeas
> API?  If it is doable, I'm willing to cook up a patch.

I'm not really fussed about that API.  The only constraint is that
this change would have to go into ocaml-augeas (ie. the upstream
project) first.  If you want to have a go at a patch then please do.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW

___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs


Re: [Libguestfs] [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.

2017-09-12 Thread Pino Toscano
On Wednesday, 9 August 2017 19:23:37 CEST Richard W.M. Jones wrote:
> This commit bundles the ocaml-augeas library (upstream here:
> http://git.annexia.org/?p=ocaml-augeas.git;a=summary).  It's identical
> to the upstream version and should remain so.
> 
> We can work towards using system ocaml-augeas, when it's more widely
> available.
> ---

IMHO it would be better if the Augeas.Error exception had all the
available details, i.e. code, error message, minor message, and details.
Right now it does not even include any of those, so it is hard for
users to differentiate the error handling depending on the actual error.
Also, IMHO failures related to ENOMEM should caml_raise_out_of_memory().

I guess this is not doable anymore, to avoid breaking the ocaml-augeas
API?  If it is doable, I'm willing to cook up a patch.

-- 
Pino Toscano

signature.asc
Description: This is a digitally signed message part.
___
Libguestfs mailing list
Libguestfs@redhat.com
https://www.redhat.com/mailman/listinfo/libguestfs

[Libguestfs] [PATCH v12 02/11] common: Bundle the ocaml-augeas library for use by the daemon.

2017-08-09 Thread Richard W.M. Jones
This commit bundles the ocaml-augeas library (upstream here:
http://git.annexia.org/?p=ocaml-augeas.git;a=summary).  It's identical
to the upstream version and should remain so.

We can work towards using system ocaml-augeas, when it's more widely
available.
---
 .gitignore|   1 +
 Makefile.am   |   1 +
 common/mlaugeas/Makefile.am   |  91 +
 common/mlaugeas/augeas-c.c| 288 ++
 common/mlaugeas/augeas.README |   8 ++
 common/mlaugeas/augeas.ml |  59 +
 common/mlaugeas/augeas.mli|  95 ++
 configure.ac  |   1 +
 daemon/Makefile.am|   7 +-
 daemon/daemon-c.c |   2 +
 docs/C_SOURCE_FILES   |   1 +
 docs/guestfs-hacking.pod  |   5 +
 ocaml-dep.sh.in   |   1 +
 13 files changed, 559 insertions(+), 1 deletion(-)

diff --git a/.gitignore b/.gitignore
index 4d738d10f..8446d3af5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -123,6 +123,7 @@ Makefile.in
 /common/errnostring/errnostring-gperf.gperf
 /common/errnostring/errnostring.h
 /common/miniexpect/miniexpect.3
+/common/mlaugeas/.depend
 /common/mlpcre/.depend
 /common/mlpcre/pcre_tests
 /common/mlprogress/.depend
diff --git a/Makefile.am b/Makefile.am
index e71328a58..e62f2678e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -45,6 +45,7 @@ SUBDIRS += lib docs examples po
 
 # The daemon and the appliance.
 SUBDIRS += common/mlutils
+SUBDIRS += common/mlaugeas
 SUBDIRS += common/mlpcre
 if ENABLE_DAEMON
 SUBDIRS += daemon
diff --git a/common/mlaugeas/Makefile.am b/common/mlaugeas/Makefile.am
new file mode 100644
index 0..ed1abe7ec
--- /dev/null
+++ b/common/mlaugeas/Makefile.am
@@ -0,0 +1,91 @@
+# libguestfs OCaml tools common code
+# Copyright (C) 2011-2017 Red Hat Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+include $(top_srcdir)/subdir-rules.mk
+
+EXTRA_DIST = \
+   $(SOURCES_MLI) \
+   $(SOURCES_ML) \
+   $(SOURCES_C)
+
+SOURCES_MLI = \
+   augeas.mli
+
+SOURCES_ML = \
+   augeas.ml
+
+SOURCES_C = \
+   augeas-c.c
+
+# We pretend that we're building a C library.  automake handles the
+# compilation of the C sources for us.  At the end we take the C
+# objects and OCaml objects and link them into the OCaml library.
+# This C library is never used.
+
+noinst_LIBRARIES = libmlaugeas.a
+
+if !HAVE_OCAMLOPT
+MLAUGEAS_CMA = mlaugeas.cma
+else
+MLAUGEAS_CMA = mlaugeas.cmxa
+endif
+
+noinst_DATA = $(MLAUGEAS_CMA)
+
+libmlaugeas_a_SOURCES = $(SOURCES_C)
+libmlaugeas_a_CPPFLAGS = \
+   -I. \
+   -I$(top_builddir) \
+   -I$(shell $(OCAMLC) -where)
+libmlaugeas_a_CFLAGS = \
+   $(WARN_CFLAGS) $(WERROR_CFLAGS) \
+   $(LIBVIRT_CFLAGS) $(LIBXML2_CFLAGS) \
+   -fPIC
+
+BOBJECTS = $(SOURCES_ML:.ml=.cmo)
+XOBJECTS = $(BOBJECTS:.cmo=.cmx)
+
+OCAMLPACKAGES =
+OCAMLFLAGS = $(OCAML_FLAGS) $(OCAML_WARN_ERROR)
+
+if !HAVE_OCAMLOPT
+OBJECTS = $(BOBJECTS)
+else
+OBJECTS = $(XOBJECTS)
+endif
+
+libmlaugeas_a_DEPENDENCIES = $(OBJECTS)
+
+$(MLAUGEAS_CMA): $(OBJECTS) libmlaugeas.a
+   $(OCAMLFIND) mklib $(OCAMLPACKAGES) \
+   $(OBJECTS) $(libmlaugeas_a_OBJECTS) -cclib -laugeas -o mlaugeas
+
+# Dependencies.
+depend: .depend
+
+.depend: $(wildcard $(abs_srcdir)/*.mli) $(wildcard $(abs_srcdir)/*.ml)
+   rm -f $@ $@-t
+   $(OCAMLFIND) ocamldep -I ../../ocaml -I $(abs_srcdir) $^ | \
+ $(SED) 's/ *$$//' | \
+ $(SED) -e :a -e '/ *\\$$/N; s/ *\\\n */ /; ta' | \
+ $(SED) -e 's,$(abs_srcdir)/,$(builddir)/,g' | \
+ sort > $@-t
+   mv $@-t $@
+
+-include .depend
+
+.PHONY: depend docs
diff --git a/common/mlaugeas/augeas-c.c b/common/mlaugeas/augeas-c.c
new file mode 100644
index 0..c06bf92da
--- /dev/null
+++ b/common/mlaugeas/augeas-c.c
@@ -0,0 +1,288 @@
+/* Augeas OCaml bindings
+ * Copyright (C) 2008-2012 Red Hat Inc., Richard W.M. Jones
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty o