[Pkg-ocaml-maint-commits] r1222 - in trunk/tools/dh_ocaml: . doc
Stefano Zacchiroli
zack@costa.debian.org
Fri, 08 Apr 2005 18:18:55 +0000
Author: zack
Date: 2005-04-08 18:18:55 +0000 (Fri, 08 Apr 2005)
New Revision: 1222
Added:
trunk/tools/dh_ocaml/doc/substvar_filling.txt
Modified:
trunk/tools/dh_ocaml/dh_ocaml
trunk/tools/dh_ocaml/doc/registry_feeding.txt
trunk/tools/dh_ocaml/ocaml-md5sums.ml
Log:
snapshot
(at the moment:
- registry format should be changed, an additional field is needed
read doc/substvar_filling.txt for more info)
Modified: trunk/tools/dh_ocaml/dh_ocaml
===================================================================
--- trunk/tools/dh_ocaml/dh_ocaml 2005-04-08 18:11:24 UTC (rev 1221)
+++ trunk/tools/dh_ocaml/dh_ocaml 2005-04-08 18:18:55 UTC (rev 1222)
@@ -23,10 +23,7 @@
#
# TODO check how dh_ocaml work when multiple binary packages are being built
-# TODO for libraries: add proper dependencies on ocaml (and findlib?)
-# TODO for binaries: check if package is shipping any bytecode binaries (head -1
-# should be enough) and add proper dependencies on ocaml
-# TODO complete POD documentation
+# TODO add proper dependencies on ocaml (and findlib?)
# TODO check if dh_ocaml md5sums calculation works with -pack -ed units (e.g.
# Foo.Bar)
@@ -64,19 +61,27 @@
the ${ocaml:Depends} substitutions and adding them to substvars files. It will
also add a postinst and prerm script if required.
-The program will look at ocaml objects (files matching *.cm[ao]) shipped by your
-package. From them, dh_ocaml uses ocamlobjinfo for collecting information about
-ocaml modules (or units, in ocamlobjinfo terminology) defined and used by your
-package. Collected information will be used both for extracting dependencies
-information from the local ocaml md5sums registry (stored in
-/var/lib/ocaml/md5sums/MD5SUMS) and for creating libfoo-ocaml-dev.md5sums entry
-for the registry.
+dh_ocaml acts both on ocaml library packages (having name libXXX-ocaml-dev) and
+on packages shipping ocaml bytecode non-custom binaries (i.e. executables
+interpreted by /usr/bin/ocamlrun).
-Dependencies information will be used for filling the ${ocaml:Depends}
-subtitution while .md5sums entry will be installed in /var/lib/ocaml/md5sums/.
-If such an entry gets installed, postinst and prerm script will also be created
-in order to update the registry at package install/removal time.
+On ocaml library packages dh_ocaml will firstly look at ocaml objects (files
+matching *.cm[ao]) shipped by the package. Then, dh_ocaml uses ocamlobjinfo on
+them for collecting information about ocaml modules (or units, in ocamlobjinfo
+terminology) defined and used by them. Information about defined units will be
+used to automatically create the ocaml md5sums registry entry for your package,
+e.g. /var/lib/ocaml/md5sums/libXXX-ocaml-dev.md5sums. dh_ocaml will also take
+care of creating autoscripts (postrm and postinst) which update the global
+system registry (/var/lib/ocaml/md5sums/MD5SUMS) with the shipped entry.
+Information about imported units will instead be used as keys in the ocaml
+md5sums registry for retrieving dependency information for the package. Those
+information will then be used to fill the ${ocaml:Depends} substvar.
+On non-library packages, dh_ocaml tries to guess the ocaml objects corresponding
+to shipped bytecode binaries and extract from them information about imported
+units. Extracted information will then be used for filling the ${ocaml:Depends}
+as discussed for the library case.
+
=head1 CONFORMS TO
Debian policy, version 3.6.1.1
@@ -93,7 +98,7 @@
foreach my $bin (@binaries) {
my $line = `/usr/bin/head -1 $bin` or next;
chomp $line;
- push @bc_binaries, $line if $line eq $ocaml_magic_line;
+ push @bc_binaries, $bin if $line eq $ocaml_magic_line;
}
return @bc_binaries;
}
@@ -106,9 +111,11 @@
open DEPS, "< $fname" or die "Can't open $fname";
while (my $line = <DEPS>) {
chomp $line;
- my ($dep_package, $dep_version) = split /\s+/, $line;
- next unless $dep_package and $dep_version;
- addsubstvar($package, "ocaml:Depends", $dep_package, ">= $dep_version");
+ if ($line =~ /^\s*(\S+)\s+(\S+)\s*$/) {
+ addsubstvar($package, "ocaml:Depends", $1, ">= $2");
+ } elsif ($line =~ /^\s*(\S+)\s*$/) {
+ addsubstvar($package, "ocaml:Depends", $1);
+ }
}
close DEPS;
}
@@ -141,7 +148,7 @@
complex_doit "> $ocamldeps";
foreach my $bin (@binaries) { # try to find .cmo of bc binaries
my $guess = basename($bin) . ".cm[ao]";
- complex_doit("/usr/bin/find . -type f -name '$guess' >> $ocamldeps");
+ complex_doit("/usr/bin/find . -type f -name '$guess' >> $objlist");
}
complex_doit("$ocaml_md5sums $flags dep < $objlist > $ocamldeps");
}
Modified: trunk/tools/dh_ocaml/doc/registry_feeding.txt
===================================================================
--- trunk/tools/dh_ocaml/doc/registry_feeding.txt 2005-04-08 18:11:24 UTC (rev 1221)
+++ trunk/tools/dh_ocaml/doc/registry_feeding.txt 2005-04-08 18:18:55 UTC (rev 1222)
@@ -1,6 +1,16 @@
entries which should be pre-fed into the registry at ocaml package installation
time:
+- ocaml-nox-VERSION
+ registry entry can be generated with:
+
+ ocaml-md5sums compute --package ocaml-nox-3.08.3 /usr/lib/ocaml/3.08.3/stdlib.cma
+
+- ocaml-VERSION
+ registry entry can be generated with:
+
+ dpkg -L ocaml ocaml | grep .cma | ocaml-md5sums compute --package ocaml-3.08.3
+
71f888453b0f26895819460a72f07493 Pervasives ocaml-nox-3.08.3 3.08.3-3
TODO entry for ocaml-3.08.3
Added: trunk/tools/dh_ocaml/doc/substvar_filling.txt
===================================================================
--- trunk/tools/dh_ocaml/doc/substvar_filling.txt 2005-04-08 18:11:24 UTC (rev 1221)
+++ trunk/tools/dh_ocaml/doc/substvar_filling.txt 2005-04-08 18:18:55 UTC (rev 1222)
@@ -0,0 +1,20 @@
+informal description of the ${ocaml:Depends} filling algorithm
+- delsubstvar("ocaml:Depends")
+- if pkgname is "libfoo-ocaml-dev"
+ (handle also "ocaml:Depends" for "libfoo-ocaml" if it does exist)
+ - find all installed .cm[ao]
+ - run "ocaml-md5sums dep" on them
+ - let D be the set of resulting dependencies
+ - foreach d in D of the form <dev-dependency, runtime-dependency, version>
+ - addsubstvar("ocaml:Depends", "libfoo-ocaml-dev", dev-dependency, version)
+ - if exists package "libfoo-ocaml" and exists runtime-dependency
+ - addsubstvar("ocaml:Depends", "libfoo-ocaml", runtime-dependency, version)
+- if pkgname is something else
+ - find all installed ocaml bytecode binaries
+ - guess corresponding .cm[ao]
+ - run "ocaml-md5sums dep" on them
+ - let D be the set of resulting dependencies
+ - foreach d in D of the form <dev-dependency, runtime-dependency, version>
+ - if exists runtime-dependency
+ - addsubstvar("ocaml:Depends", pkgname, runtime-dependency, version)
+
Modified: trunk/tools/dh_ocaml/ocaml-md5sums.ml
===================================================================
--- trunk/tools/dh_ocaml/ocaml-md5sums.ml 2005-04-08 18:11:24 UTC (rev 1221)
+++ trunk/tools/dh_ocaml/ocaml-md5sums.ml 2005-04-08 18:18:55 UTC (rev 1222)
@@ -37,6 +37,7 @@
let md5sum_line_RE =
Str.regexp "^[ \t]*\\([a-f0-9]+\\)[ \t]+\\([a-zA-Z0-9_]+\\)[ \t]*$"
let blanks_RE = Str.regexp "[ \t]+"
+let ignorable_line_RE = Str.regexp "^[ \t]*\\(#.*\\)?"
let md5sums_ext_RE = Str.regexp (sprintf "^.*%s$" (Str.quote md5sums_ext))
(** {2 Argument parsing} *)
@@ -52,15 +53,15 @@
let usage_msg =
"Use and maintain system registry of ocaml md5sums\n"
^ "Usage:\n"
- ^ " ocaml-md5sum compute --package <name> --version <version> [options] file ...\n"
- ^ " ocaml-md5sum dep --package <name> --version <version> [options] file ...\n"
+ ^ " ocaml-md5sum compute --package <name> [option ...] file ...\n"
+ ^ " ocaml-md5sum dep --package <name> [option ...] file ...\n"
^ " ocaml-md5sum update\n"
^ "Options:"
let cmdline_spec = [
"--package", Arg.Set_string pkg_name,
"set package name (required by compute and dep actions)";
"--version", Arg.Set_string pkg_version,
- "set package version (required by compute and dep actions)";
+ "set package version";
"--dump-info", Arg.Set_string dump_info_to,
"dump ocamlobjinfo to file";
"--load-info", Arg.Set_string load_info_from,
@@ -172,11 +173,16 @@
dump_info ~defined ~imported !dump_info_to;
(defined, imported)
+type registry_callback =
+ md5sum:string -> unit_name:string -> package:string -> ?version:string ->
+ unit ->
+ unit
+
(** iter a function over the entries of a registry file
* @param f function to be executed for each entries, it takes 4 labeled
- * arguments: ~md5sum ~unit_name ~package ~version
+ * arguments: ~md5sum ~unit_name ~package ?version
* @param fname file containining the registry *)
-let iter_registry f fname =
+let iter_registry (f: registry_callback) fname =
info ("processing registry " ^ fname);
let lineno = ref 0 in
iter_file
@@ -184,7 +190,9 @@
incr lineno;
(match Str.split blanks_RE line with
| [ md5sum; unit_name; package; version ] ->
- f ~md5sum ~unit_name ~package ~version
+ f ~md5sum ~unit_name ~package ~version ()
+ | [ md5sum; unit_name; package ] -> f ~md5sum ~unit_name ~package ()
+ | _ when Str.string_match ignorable_line_RE line 0 -> ()
| _ ->
warning (sprintf "ignoring registry entry (%s, line %d)"
fname !lineno)))
@@ -197,7 +205,7 @@
let parse_registry fname =
let registry = Hashtbl.create 1024 in
iter_registry
- (fun ~md5sum ~unit_name ~package ~version ->
+ (fun ~md5sum ~unit_name ~package ?(version = "") () ->
Hashtbl.replace registry (unit_name, md5sum) (package, version))
fname;
registry
@@ -241,7 +249,7 @@
&& ((Unix.stat fname).Unix.st_kind = Unix.S_REG)
then
iter_registry
- (fun ~md5sum ~unit_name ~package ~version ->
+ (fun ~md5sum ~unit_name ~package ?(version = "") () ->
fprintf registry "%s %s %s %s\n" md5sum unit_name package version)
fname
done
@@ -264,7 +272,7 @@
| Some "update" -> update ()
| Some action ->
let package, version = !pkg_name, !pkg_version in
- if (package = "" || version = "") then die_usage ();
+ if package = "" then die_usage ();
let objects =
match !objects with
| [] when !load_info_from = "" -> read_stdin ()