[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Automatic dependencies for shared modules

Hi !

2011/5/28 Stéphane Glondu <glondu@debian.org>:
> Le 28/05/2011 06:54, Romain Beauxis a écrit :
>>> I meant building sdl.cmxs in ocaml-sdl package. It's quite easy and can be
>>> done in debian/rules. Have a look at postgresql-ocaml, for example. Then the
>>> META, *.cmxs and *.cma should be moved to the runtime package. dh_ocaml
>>> should then infer the right dependencies.
>> I think this highly impractical. We'd have to implement the whole
>> dependency resolving in order to load the modules in the right order
>> in the application.. Clearly not an option!
> Findlib does most of the job. Have a look at baselib/ocsigen_loader.ml
> in ocsigen for an example.
>>> You said in your original e-mail that you didn't want any ocaml
>>> dependencies. Did you try the --nodefined-map command-line option of
>>> dh_ocaml, then?
>> That does not work for bytecode modules. For instance, the vorbis
>> module include Vorbis and I do want to therefore get a dependency on
>> the right libvorbis-ocaml-xxyyzz..
>> [...] Therefore, I
>> propose to include an option in dh_ocaml that would allow to accept to
>> reference modules that are present in a plugin and are also provided
>> by another package.
> This is what --nodefined-map is supposed to do. But actually, this
> option what thought for packages providing an alternative implementation
> of one module, so it might explain the missing dependency you are
> talking about. I would suggest you to look around --nodefined-map code
> path to implement what you want.

Ok so I have found an easy way to make it work. I have added
*.onodefined files for each liquidsoap-plugin-xxx.

I found two bugs in the parsing of .onodefined files:
 * lines where not chomped, leading to a trailing \n in each defined
unit, which made the call to ocaml-md5sums break:
  ocaml-md5sums (...) --nodefined Foo
--nodefined Bar

 * the array was not properly initialized, leading to merging
individual package's nodefined into one.

Additionally, the only change I did to make it work was to pass
--nodefined option during the computation of binary package

I have attached the patch corresponding to these changes. Let me know
if it is ok for you.

Finally, I wanted to have liquidsoap declare the ABI it provides and
make the plugins depend on liquidsoap-xxyyzz as well as making sure
that all the units imported in each plugins where properly resolved in

It turns out that ocamlobjinfo does not provide enough information
concerning the units exported by liquidsoap: units actually
implemented in the bytecode binary for liquidsoap are marked as

Therefore, I think this is the best that I can do for now..
Please, let me know if the patch is ok for you..

--- /usr/bin/dh_ocaml.orig	2011-04-16 03:57:19.000000000 -0500
+++ /usr/bin/dh_ocaml	2011-06-01 21:27:55.000000000 -0500
@@ -251,8 +251,11 @@
   if ($fn && -e $fn)
     open(FH, "<", $fn);
-    my @nodef = @{$nodefined{$_}} if exists $nodefined{$_};
-    push(@nodef,<FH>);
+    my @nodef = ();
+    @nodef = @{$nodefined{$_}} if exists $nodefined{$_};
+    my @lines = <FH>;
+    chomp(@lines);
+    push(@nodef,@lines);
     $nodefined{$_} = \@nodef;
@@ -296,6 +299,15 @@
+sub nodefined_args ($)
+  my $package = shift;
+  my $args = "";
+  $args .= join(" ",map {("--nodefined", $_)} @{$nodefined{$package}})
+    if exists $nodefined{$package};
+  return ($args);
 verbose_print "+++ Generate .olist.debhelper files +++";
 sub test_bytecode ($)
@@ -369,8 +381,7 @@
   my $local_flags = "$flags --package $package --version $dh{VERSION}";
   $local_flags .= " --runtime ".$runtime if $runtime;
   my $olintian_flags = $local_flags;
-  $local_flags .= " ".join(" ",map {("--nodefined", $_)} @{$nodefined{$package}})
-    if exists $nodefined{$package};
+  $local_flags .= " ". nodefined_args($package);
   # compute md5sums files
   doit(qw/mkdir -p/, dirname $md5sums_fn);
@@ -455,7 +466,8 @@
   delsubstvar $package, "ocaml:Depends";
   # Compute deps
-  my $cmd = "$omd5 $flags --package $package dep < $olist{$package}";
+  my $local_flags = nodefined_args($package);
+  my $cmd = "$omd5 $flags $local_flags --package $package dep < $olist{$package}";
   verbose_print "$cmd";
   if (!$dh{NO_ACT})

Reply to: