Differences between revisions 3 and 4
Revision 3 as of 2009-07-26 18:26:17
Size: 3991
Editor: ?Sylvain Le Gall
Revision 4 as of 2009-10-06 10:00:17
Size: 4098
Editor: ?Sylvain Le Gall
Deletions are marked like this. Additions are marked like this.
Line 37: Line 37:
  * don't remove old ocaml dependencies for now, once transition is complete, we will check and remove it


Migration to dh_ocaml

During DebCamp (and DebConf), we have rewritten dh_ocaml (and ocaml-md5sums) to be able to compute automatically dependencies between OCaml packages. Tests have been performed on some packages (OCaml itself, findlib, camlzip, menhir) and the results were very satisfying. We consider that dh_ocaml (and related tools) are ready to be pushed in Debian. The last step, before uploading the new packages to unstable, is to test more packages and upload them to experimental and observe real results.

How it works ?

dh_ocaml uses some tools to gather informations:

  • Low-level tools to inspect imported interfaces and defined modules:
    • ocamlobjinfo for bytecode interfaces and objects(.cmi, .cmo, .cma)

    • ocamlbyteinfo for bytecode binaries

    • ocamldumpapprox for native objects (.cmx, .cmxa)

    • ocamlplugininfo for native plugins (.cmxs)

  • Higher-level tools:
    • ocaml-md5sums which is a kind of wrapper around the forementioned four tools.

ocaml-md5sums receives a list of files and has to inspect them in order to gather some informations regarding imported interfaces and defined modules and md5sum of each of them. It chooses the correct low-level tool depending on the file extension (and on the file header for bytecode binaries). Gathered informations are then stored in a file (namely, /var/lib/ocaml/md5sums/${source_package}.md5sums) which will be used later to compute dependencies.

dh_ocaml proceeds in several stages:

  • Computes a runtime map (an associative list where keys are the -dev packages and the values are their runtime version)
    • This information can be overridden by using dh_ocaml's option --runtime-map (e.g., dh_ocaml --runtime-map liba1-ocaml-dev:liba1-ocaml,liba2-ocaml-dev:-, where "-" says "no runtime package"). But, you have to be very careful when using it and understand why are you are overriding these values since the runtime package will be a runtime dependency for other packages.

  • Inspects files given to him and look for defined modules
    • This can be overridden with --nodefined-map (Particulary useful with packages like cothreads where it exports modules like Thread and Event)

With CDBS, you can specify additional flags for dh_ocaml using the makefile variable OCAML_DHOCAML_FLAGS.

Steps to convert a package

  • whatever buildystem you use:
    • remove all ocaml-*-${F:OCamlABI}, and replace it by ${ocaml:Depends}, the dependency to ocaml-*-${F:OCamlABI} is enforce by dh_ocaml
    • remove dependency on ocaml interpreter for certain native package with compile to bytecode on non-native arches (e.g. ${F:OCamlInterp}), ${ocaml:Depend} will compute the right dependencies on these arches
    • add a Provides:${ocaml:Provides} to runtime and dev packages (e.g. libzip-ocaml and libzip-ocaml-dev)

    • add ${ocaml:Depends} for all packages
    • build-depends on dh-ocaml >= 0.9

    • don't remove old ocaml dependencies for now, once transition is complete, we will check and remove it
  • if you use ocamlinit.mk:
    • replace ocamlinit.mk by ocamlvars if you still use values from it
    • remove -VF OCamlABI from deb_gencontrol
    • replace ocamldoc-api-ref-config by either debian/libzip-ocaml-dev.ocamldoc if you use autogeneration or ... (TODO)
  • if you use CDBS:
    • replace OCAMLDOC_... by debian/libzip-ocaml-dev.ocamldoc
    • place ocaml.mk at the head of the include list (TODO: is it really mandatory, this is due to .debhleper.log left in the debian/ after debclean invocation)
    • invoke ... fakeroot debian/rules clean to regenerate debian/control from debian/control.in (handle dh-ocaml >= 0.9 automatically)

  • if you use dh:
    • add "--with ocaml" to dh invocation
  • if you use debhelper < 7:

    • add dh_ocamldoc before dh_installdoc in binary* target
    • add dh_ocaml before dh_gencontrol in binary* target
    • add dh_ocamlinit at the beginning of binary* target
    • add dh_ocamlinit -d before dh_clean in clean target

TODO list