Re: [Pkg-xen-devel] [patch] Packages ocaml libraries
On 08/30/2011 09:44 PM, Ian Campbell wrote:
> I still don't think this can be right. Surely every Ocaml packages
> doesn't open code a bunch of install runes like this (not to mention the
> corresponding "find ... -delete" like you have below). It'd be a
> maintenance nightmare.
>
> Looking at the ocaml-taglib source (picked at random) it appears that at
> least one viable option for doing this properly is to use the dh_install
> functionality which lets you specify a different target directory to
> where the file is found in the staging dir. i.e.
> debian/libtaglib-ocaml.install.in contains:
> @OCamlStdlibDir@/taglib/dlltaglib_stubs.so @OCamlDllDir@
>
> In any case I think whatever solution you come up with should be
> reviewed by the pkg-ocaml team as well as this list.
Hi,
I have asked for help from the Ocaml team, in #debian-ocaml. Mehdi has
been of great help, and he explained me lots of things. I think I got it
a lot better this time.
I have attached a new patch against the current Xen in SID (eg:
4.1.1-2). What I did is that in the debian folder, once Xen is built
once, you can do: cd debian && ./find_ocaml_libs, and it will print the
content that we should put in debian/libxen-ocam[dev].install.in. That
small shell script is just a hackish helper that I used to make sure I
wouldn't forget any file, so I didn't feel comfortable setting it up at
build time, but I think it's ok to ship it in our source package for
later reference (in case a new OCaml lib is later added in upstream source).
Then, once we got debian/libxen-ocaml.install.in and
debian/libxen-ocaml-dev.install.in, we have dh_ocamlinit that does the
magic of the variable substitutions using sed, and finally dh_install
does the rest.
"dh_ocamlinit -d" takes care of deleting leftovers from dh_ocamlinit.
Altogether, the patch looks a lot cleaner. Thanks for insisting so that
I would do it right, and thanks to Medhi for his help yesterday evening.
> Isn't there supposed to be a new Build-Depends on some ocaml stuff
> somewhere?
Yup, I forgot these. This patch also add them.
I have set debian-ocaml-maint@lists.debian.org as Cc: to this email, in
the hope that the Debian OCaml task force can have a last look on my
work. I'd appreciate comments, and I hope I didn't do mistakes this
time. Please keep in mind that I don't know much about OCaml...
Thomas Goirand (zigo)
diff -u -N -r old/xen-4.1.1/debian/find_ocaml_libs new/xen-4.1.1/debian/find_ocaml_libs
--- old/xen-4.1.1/debian/find_ocaml_libs 1970-01-01 00:00:00.000000000 +0000
+++ new/xen-4.1.1/debian/find_ocaml_libs 2011-08-31 11:33:27.000000000 +0000
@@ -0,0 +1,63 @@
+#!/bin/sh
+
+# This small helper is writing the libxen-ocaml.install.in and libxen-ocaml-dev.install.in
+# automatically. It's not meant to be fool proof, so please check for the results before
+# using it's results.
+
+OCAML_LIBS_PATH=build/build-utils_i386/tools/ocaml/libs
+echo "Will search in ${OCAML_LIBS_PATH}"
+
+if ! [ -d ${OCAML_LIBS_PATH} ] ; then
+ echo "Please build Xen first!"
+ exit 1
+fi
+
+CWD=`pwd`
+cd ${OCAML_LIBS_PATH}
+FOLDERS=`find . -maxdepth 1 -mindepth 1 -type d | cut -d'/' -f2`
+
+LIBXEN_OCAML_INSTALL=""
+LIBXEN_OCAML_DEV_INSTALL=""
+
+for folder in ${FOLDERS} ; do
+ echo "===> Searching in ${folder}"
+ cd ${folder}
+ # Do the DLL thing
+ OCAML_DLL=`find . -iname 'dll*.so' | cut -d'/' -f2`
+ if [ -n "${OCAML_DLL}" ] ; then
+ echo "Found DLL: \"${OCAML_DLL}\""
+ LIBXEN_OCAML_INSTALL=${LIBXEN_OCAML_INSTALL}"\n"@XenBuildOcamlLibsDir@/${folder}/${OCAML_DLL}"\t"@OCamlDllDir@
+ fi
+ # Do the .cma and META
+ FOUND=""
+ for ext in META .cma ; do
+ MY_OCAML_FILES=`find . -iname '*'${ext} | cut -d'/' -f2`
+ if [ -n "${MY_OCAML_FILES}" ] ; then
+ for j in ${MY_OCAML_FILES} ; do
+ LIBXEN_OCAML_INSTALL=${LIBXEN_OCAML_INSTALL}"\n"@XenBuildOcamlLibsDir@/${folder}/${j}"\t"@OCamlStdlibDir@/${folder}
+ FOUND="${FOUND} ${j}"
+ done
+ fi
+ done
+ echo "Found for libxen-ocaml: ${FOUND}"
+
+ # All the other files will go in the -dev package
+ FOUND=""
+ for ext in a cmi cmxa mli cmx cmo ; do
+ MY_OCAML_FILES=`find . -iname '*.'${ext} | cut -d'/' -f2`
+ if [ -n "${MY_OCAML_FILES}" ] ; then
+ for j in ${MY_OCAML_FILES} ; do
+ LIBXEN_OCAML_DEV_INSTALL=${LIBXEN_OCAML_DEV_INSTALL}"\n"@XenBuildOcamlLibsDir@/${folder}/${j}"\t"@OCamlStdlibDir@/${folder}
+ FOUND="${FOUND} ${j}"
+ done
+ fi
+ done
+ echo "Found for libxen-ocaml-dev: ${FOUND}"
+ #LIBXEN_OCAML_INSTALL=${LIBXEN_OCAML_INSTALL}"\n"
+ cd ..
+done
+
+echo "Content of the libxen-ocaml.install.in is:"
+echo ${LIBXEN_OCAML_INSTALL}
+echo "Content for the libxen-ocaml-dev.install.in is:"
+echo ${LIBXEN_OCAML_DEV_INSTALL}
diff -u -N -r old/xen-4.1.1/debian/libxen-ocaml-dev.install.in new/xen-4.1.1/debian/libxen-ocaml-dev.install.in
--- old/xen-4.1.1/debian/libxen-ocaml-dev.install.in 1970-01-01 00:00:00.000000000 +0000
+++ new/xen-4.1.1/debian/libxen-ocaml-dev.install.in 2011-08-31 11:33:20.000000000 +0000
@@ -0,0 +1,85 @@
+@XenBuildOcamlLibsDir@/mmap/mmap.a @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/libmmap_stubs.a @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.cmi @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.cmxa @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.mli @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.cmx @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.cmo @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/eventchn/libeventchn_stubs.a @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.a @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.cmi @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.cmxa @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.mli @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.cmx @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.cmo @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/xl/xl.a @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/libxl_stubs.a @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.cmi @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.cmxa @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.mli @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.cmx @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.cmo @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xb/xb.a @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/libxb_stubs.a @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/packet.cmi @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/op.cmi @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xs_ring.cmi @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/partial.cmi @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.cmi @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.cmxa @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.mli @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/partial.cmx @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xs_ring.cmx @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.cmx @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/op.cmx @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/packet.cmx @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/op.cmo @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.cmo @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/partial.cmo @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xs_ring.cmo @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/packet.cmo @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/log/libsyslog_stubs.a @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.a @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/logs.cmi @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.cmi @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/syslog.cmi @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.cmxa @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/logs.mli @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.mli @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/syslog.mli @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.cmx @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/logs.cmx @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/syslog.cmx @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/logs.cmo @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.cmo @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/syslog.cmo @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/xc/xc.a @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/libxc_stubs.a @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.cmi @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.cmxa @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.mli @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.cmx @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.cmo @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/uuid/uuid.a @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.cmi @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.cmxa @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.mli @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.cmx @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.cmo @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/xs/xs.a @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.cmi @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/queueop.cmi @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xsraw.cmi @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xst.cmi @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.cmxa @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xsraw.mli @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.mli @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xst.mli @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/queueop.cmx @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.cmx @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xst.cmx @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xsraw.cmx @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xst.cmo @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.cmo @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xsraw.cmo @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/queueop.cmo @OCamlStdlibDir@/xs
diff -u -N -r old/xen-4.1.1/debian/libxen-ocaml.install.in new/xen-4.1.1/debian/libxen-ocaml.install.in
--- old/xen-4.1.1/debian/libxen-ocaml.install.in 1970-01-01 00:00:00.000000000 +0000
+++ new/xen-4.1.1/debian/libxen-ocaml.install.in 2011-08-31 11:34:02.000000000 +0000
@@ -0,0 +1,22 @@
+@XenBuildOcamlLibsDir@/mmap/dllmmap_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/mmap/META @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/mmap/mmap.cma @OCamlStdlibDir@/mmap
+@XenBuildOcamlLibsDir@/eventchn/dlleventchn_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/eventchn/META @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/eventchn/eventchn.cma @OCamlStdlibDir@/eventchn
+@XenBuildOcamlLibsDir@/xl/dllxl_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/xl/META @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xl/xl.cma @OCamlStdlibDir@/xl
+@XenBuildOcamlLibsDir@/xb/dllxb_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/xb/META @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/xb/xb.cma @OCamlStdlibDir@/xb
+@XenBuildOcamlLibsDir@/log/dllsyslog_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/log/META @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/log/log.cma @OCamlStdlibDir@/log
+@XenBuildOcamlLibsDir@/xc/dllxc_stubs.so @OCamlDllDir@
+@XenBuildOcamlLibsDir@/xc/META @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/xc/xc.cma @OCamlStdlibDir@/xc
+@XenBuildOcamlLibsDir@/uuid/META @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/uuid/uuid.cma @OCamlStdlibDir@/uuid
+@XenBuildOcamlLibsDir@/xs/META @OCamlStdlibDir@/xs
+@XenBuildOcamlLibsDir@/xs/xs.cma @OCamlStdlibDir@/xs
diff -u -N -r old/xen-4.1.1/debian/rules new/xen-4.1.1/debian/rules
--- old/xen-4.1.1/debian/rules 2011-04-11 20:01:54.000000000 +0000
+++ new/xen-4.1.1/debian/rules 2011-08-30 16:28:11.000000000 +0000
@@ -34,6 +34,7 @@
clean: debian/control
dh_testdir
rm -rf $(BUILD_DIR) $(STAMPS_DIR) debian/lib/python/debian_xen/*.pyc
+ dh_ocamlinit -d
dh_clean
binary-indep:
diff -u -N -r old/xen-4.1.1/debian/rules.real new/xen-4.1.1/debian/rules.real
--- old/xen-4.1.1/debian/rules.real 2011-07-18 16:48:10.000000000 +0000
+++ new/xen-4.1.1/debian/rules.real 2011-08-31 11:42:04.000000000 +0000
@@ -1,3 +1,5 @@
+include /usr/share/ocaml/ocamlvars.mk
+
DEB_HOST_ARCH := $(shell dpkg-architecture -a$(ARCH) -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -a$(ARCH) -qDEB_HOST_GNU_TYPE)
DEB_BUILD_ARCH := $(shell dpkg-architecture -a$(ARCH) -qDEB_BUILD_ARCH)
@@ -17,6 +19,8 @@
binary-arch-arch: install-libxenstore_$(ARCH)
binary-arch-arch: install-utils_$(ARCH)
binary-arch-arch: install-xenstore-utils_$(ARCH)
+binary-arch-arch: install-lib-ocaml-dev_$(ARCH)
+binary-arch-arch: install-lib-ocaml_$(ARCH)
binary-arch-flavour: install-hypervisor_$(ARCH)_$(FLAVOUR)
binary-indep: install-docs
@@ -92,6 +96,7 @@
dh_compress
dh_fixperms
dh_installdeb
+ dh_ocaml
dh_gencontrol -- $(GENCONTROL_ARGS)
dh_md5sums
dh_builddeb
@@ -130,6 +135,34 @@
dh_strip
dh_shlibdeps
+$(MAKE_SELF) install-base
+
+install-lib-ocaml_$(ARCH): DIR = $(BUILD_DIR)/install-utils_$(ARCH)
+install-lib-ocaml_$(ARCH): PACKAGE_NAME = libxen-ocaml
+install-lib-ocaml_$(ARCH): DH_OPTIONS = -p$(PACKAGE_NAME)
+install-lib-ocaml_$(ARCH): $(STAMPS_DIR)/install-utils_$(ARCH)
+ dh_testdir
+ dh_testroot
+ dh_prep
+ make -C $(BUILD_DIR)/build-utils_$(ARCH)/tools/ocaml/libs
+ export OCAMLINIT_SED="-e s%@XenBuildOcamlLibsDir@%debian/build/build-utils_$(ARCH)/tools/ocaml/libs%" && dh_ocamlinit
+ dh_install
+ dh_strip
+ dh_shlibdeps
+ +$(MAKE_SELF) install-base
+
+install-lib-ocaml-dev_$(ARCH): DIR = $(BUILD_DIR)/install-utils_$(ARCH)
+install-lib-ocaml-dev_$(ARCH): PACKAGE_NAME = libxen-ocaml-dev
+install-lib-ocaml-dev_$(ARCH): DH_OPTIONS = -p$(PACKAGE_NAME)
+install-lib-ocaml-dev_$(ARCH): $(STAMPS_DIR)/install-utils_$(ARCH)
+ dh_testdir
+ dh_testroot
+ dh_prep
+ make -C $(BUILD_DIR)/build-utils_$(ARCH)/tools/ocaml/libs
+ export OCAMLINIT_SED="-e s%@XenBuildOcamlLibsDir@%debian/build/build-utils_$(ARCH)/tools/ocaml/libs%" && dh_ocamlinit
+ dh_install
+ dh_strip
+ dh_shlibdeps
+ +$(MAKE_SELF) install-base
install-libxenstore_$(ARCH): DIR = $(BUILD_DIR)/install-utils_$(ARCH)
install-libxenstore_$(ARCH): PACKAGE_NAME = libxenstore3.0
diff -u -N -r old/xen-4.1.1/debian/templates/control.main.in new/xen-4.1.1/debian/templates/control.main.in
--- old/xen-4.1.1/debian/templates/control.main.in 2010-03-01 18:29:00.000000000 +0000
+++ new/xen-4.1.1/debian/templates/control.main.in 2011-08-31 11:43:43.000000000 +0000
@@ -7,6 +7,26 @@
includes a description interface (both the API, and a nice explanation of
how XEN works).
+Package: libxen-ocaml
+Architecture: any
+Section: ocaml
+Depends: ${shlibs:Depends}, ${misc:Depends}, ${ocaml:Depends}
+Provides: ${ocaml:Provides}
+Description: interface for remotely configuring and controlling guests (runtime)
+ The Xen Management API is an interface for remotely configuring and
+ controlling virtualised guests running on a Xen-enabled host. This package
+ containst the runtime OCaml library.
+
+Package: libxen-ocaml-dev
+Architecture: any
+Section: ocaml
+Depends: libxen-ocaml (= ${binary:Version}), ${shlibs:Depends}, ocaml-findlib (>= 1.1), ${misc:Depends}, ${ocaml:Depends}
+Provides: ${ocaml:Provides}
+Description: interface for remotely configuring and controlling guests (development files)
+ The Xen Management API is an interface for remotely configuring and
+ controlling virtualised guests running on a Xen-enabled host. This package
+ containst the development files for the OCaml library.
+
Package: libxenstore3.0
Section: libs
Architecture: any
diff -u -N -r old/xen-4.1.1/debian/templates/control.source.in new/xen-4.1.1/debian/templates/control.source.in
--- old/xen-4.1.1/debian/templates/control.source.in 2011-07-18 16:48:10.000000000 +0000
+++ new/xen-4.1.1/debian/templates/control.source.in 2011-08-30 15:40:22.000000000 +0000
@@ -15,7 +15,8 @@
libncurses5-dev,
libpci-dev,
uuid-dev,
- zlib1g-dev
+ zlib1g-dev,
+ ocaml-nox, dh-ocaml, ocaml-findlib
Build-Depends-Indep:
graphviz,
ghostscript,
Reply to: