[Pkg-ocaml-maint-commits] r3882 - in /trunk/packages/ocaml/branches: ./ new-ocaml-md5sum/ new-ocaml-md5sum/debian/ocaml-md5sums/

zack at users.alioth.debian.org zack at users.alioth.debian.org
Wed Jul 4 09:51:30 UTC 2007


Author: zack
Date: Wed Jul  4 09:51:30 2007
New Revision: 3882

URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/?sc=1&rev=3882
Log:
ongoing work (to be completed), for the new ocaml-md5sums with support for ABI number generation

Added:
    trunk/packages/ocaml/branches/new-ocaml-md5sum/
      - copied from r3881, trunk/packages/ocaml/trunk/
    trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/main.ml   (contents, props changed)
      - copied, changed from r3872, trunk/packages/ocaml/trunk/debian/ocaml-md5sums/ocaml-md5sums.ml.in
    trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml_md5sums_conf.ml.in
Removed:
    trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml-md5sums.ml.in
    trunk/packages/ocaml/branches/ocaml-md5sums.diff
Modified:
    trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/Makefile
    trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/configure.in

Modified: trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/Makefile
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/Makefile?rev=3882&op=diff
==============================================================================
--- trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/Makefile (original)
+++ trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/Makefile Wed Jul  4 09:51:30 2007
@@ -7,6 +7,7 @@
 NAME = ocaml-md5sums
 BYTE = $(NAME)
 OPT = $(NAME).opt
+MODULES = ocaml_md5sums_conf
 
 all: $(BYTE)
 opt: $(OPT)
@@ -20,10 +21,14 @@
 		exit 2;						\
 	fi
 
-$(BYTE): $(NAME).ml
-	$(OCAMLC) $(patsubst %,%.cma,$(OCAML_LIBS)) -o $@ $<
-$(OPT): $(NAME).ml
-	$(OCAMLOPT) $(patsubst %,%.cmxa,$(OCAML_LIBS)) -o $@ $<
+%.cmo: %.ml
+	$(OCAMLC) -c $<
+%.cmx: %.ml
+	$(OCAMLOPT) -c $<
+$(BYTE): $(patsubst %, %.cmo, $(MODULES)) main.ml
+	$(OCAMLC) $(patsubst %,%.cma,$(OCAML_LIBS)) -o $@ $^
+$(OPT): $(patsubst %, %.cmx, $(MODULES)) main.ml
+	$(OCAMLOPT) $(patsubst %,%.cmxa,$(OCAML_LIBS)) -o $@ $^
 
 clean:
 	rm -f ocaml-md5sums ocaml-md5sums.opt *.cm[aiox] *.cmxa *.[ao]

Modified: trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/configure.in
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/configure.in?rev=3882&op=diff
==============================================================================
--- trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/configure.in (original)
+++ trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/configure.in Wed Jul  4 09:51:30 2007
@@ -8,8 +8,8 @@
 else
   MD5SUMS_DIR="$1"
 fi
-echo -n "Creating ocaml-md5sums.ml ... "
+echo -n "Creating ocaml_md5sums_conf.ml ... "
 sed -e "s:@MD5SUMS_DIR@:$MD5SUMS_DIR:" \
   -e "s:@VERSION@:$VERSION:" \
-  < ocaml-md5sums.ml.in > ocaml-md5sums.ml
+  < ocaml_md5sums_conf.ml.in > ocaml_md5sums_conf.ml
 echo "done."

Copied: trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/main.ml (from r3872, trunk/packages/ocaml/trunk/debian/ocaml-md5sums/ocaml-md5sums.ml.in)
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/main.ml?rev=3882&op=diff
==============================================================================
--- trunk/packages/ocaml/trunk/debian/ocaml-md5sums/ocaml-md5sums.ml.in (original)
+++ trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/main.ml Wed Jul  4 09:51:30 2007
@@ -1,10 +1,10 @@
 (*
  * ocaml-md5sums - use and maintain debian registry of ocaml md5sums
  *
- * Copyright (C) 2005, Stefano Zacchiroli <zack at debian.org>
+ * Copyright (C) 2005-2007, Stefano Zacchiroli <zack at debian.org>
  *
  * Created:        Wed, 06 Apr 2005 16:55:39 +0200 zack
- * Last-Modified:  Fri, 12 Aug 2005 10:28:10 +0200 zack
+ * Last-Modified:  $Date$
  *
  * This is free software, you can redistribute it and/or modify it under the
  * terms of the GNU General Public License version 2 as published by the Free
@@ -20,15 +20,10 @@
  * Place, Suite 330, Boston, MA  02111-1307  USA
  *)
 
+open Big_int
 open Printf
 
-(** {2 Constants} *)
-
-let my_version = "@VERSION@"
-let md5sums_dir = "@MD5SUMS_DIR@"
-let md5sums_index = "MD5SUMS"
-let md5sums_ext = ".md5sums"
-let registry_file = sprintf "%s/%s" md5sums_dir md5sums_index
+open Ocaml_md5sums_conf
 
 (** {2 System requirements} *)
 
@@ -46,6 +41,12 @@
 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))
+let byteobj_ext_RE = Str.regexp "\\.cm[ioa]$"
+let nativeobj_ext_RE = Str.regexp "\\.cmx\\(a\\)?"
+
+(** {2 Types} *)
+
+type obj_kind = [ `Bytecode | `Nativecode ] (** compilation unit kind *)
 
 (** {2 Argument parsing} *)
 
@@ -98,6 +99,19 @@
   close_in ic
 let iter_table f = iter_file (fun line -> f (Str.split blanks_RE line))
 
+let (++) = add_big_int
+let ( *** ) = power_big_int_positive_int
+let big_int_of_hex_string s =
+  let len = String.length s in
+  let rec aux acc index =
+    if index = -1 then acc
+    else
+      let digit =
+        big_int_of_int (int_of_string("0x" ^ String.make 1 (s.[index]))) in
+      aux (acc ++ digit *** (len - index - 1)) (index - 1)
+  in
+  aux zero_big_int (len - 1)
+
 module Strings = Set.Make (String)
 
 (** read until the end of standard input
@@ -112,6 +126,16 @@
 let is_dir fname = (Unix.stat fname).Unix.st_kind = Unix.S_DIR
 
 (** {2 Auxiliary functions} *)
+
+let kind_of_fname fname =
+  if Str.string_match fname byteobj_ext_RE fname 0 then
+    `Bytecode
+  else if Str.string_match fname nativeobj_ext_RE fname 0 then
+    `Nativecode
+  else begin
+    prerr_endline ("unknown OCaml compilation unit type: " ^ fname);
+    assert false
+  end
 
 (** loads info previously stored in a file using --dump-info and stores them in
  * two hashtables
@@ -125,12 +149,12 @@
     (fun fields ->
       incr lineno;
       match fields with
-      | [ "defined"; md5; unit_name ] ->
+      | [ "defined"; kind; md5; unit_name ] ->
           info ~level:2 (String.concat " " fields);
-          Hashtbl.replace defined unit_name md5
-      | [ "imported"; md5; unit_name ] ->
+          Hashtbl.replace defined unit_name (parse_obj_kind kind, md5)
+      | [ "imported"; kind; md5; unit_name ] ->
           info ~level:2 (String.concat " " fields);
-          Hashtbl.replace imported unit_name md5
+          Hashtbl.replace imported unit_name (parse_obj_kind kind, md5)
       | _ ->
           warning (sprintf "ignoring dump entry (%s, line %d)" fname !lineno))
     fname
@@ -143,17 +167,19 @@
   info ("dumping ocamlobjinfo information to " ^ fname);
   let oc = open_out fname in
   Hashtbl.iter
-    (fun unit_name md5sum -> fprintf oc "defined  %s %s\n" md5sum unit_name)
+    (fun unit_name (kind, md5sum) ->
+      fprintf oc "defined  %-8s %s %s\n" (pp_obj_kind kind) md5sum unit_name)
     defined;
   Hashtbl.iter
-    (fun unit_name md5sum -> fprintf oc "imported %s %s\n" md5sum unit_name)
+    (fun unit_name (kind, md5sum) ->
+      fprintf oc "imported %-8ss %s %s\n" (pp_obj_kind kind) md5sum unit_name)
     imported;
   close_out oc
 
-(** @param fnames list of *.cm[ao] file names
+(** @param fnames list of *.cm[aox] or *.cmxa file names
  * @return a pair of hash tables <defined_units, imported_units>. Both tables
- * contains mappings <unit_name, md5sum>. defined_units lists units defined in
- * given files while imported_units imported ones *)
+ * contains mappings <unit_name, (obj_kind, md5sum)>. defined_units lists units
+ * defined in given files while imported_units imported ones *)
 let unit_info fnames =
   let (defined, imported) = (Hashtbl.create 1024, Hashtbl.create 1024) in
   if !load_info_from <> "" then
@@ -161,26 +187,33 @@
   List.iter
     (fun fname ->
       info ("getting unit info from " ^ fname);
-      let current_unit = ref "" in
-      let ic = Unix.open_process_in (sprintf "%s %s" ocamlobjinfo fname) in
-      iter_in
-        (fun line ->
-          if Str.string_match unit_name_line_RE line 0 then
-            current_unit := Str.matched_group 1 line
-          else if Str.string_match md5sum_line_RE line 0 then
-            let md5sum = Str.matched_group 1 line in
-            let unit_name = Str.matched_group 2 line in
-            if unit_name = !current_unit then begin (* defined unit *)
-              let dump_entry = sprintf "defined %s %s" md5sum unit_name in
-              info ~level:2 dump_entry;
-              Hashtbl.replace defined unit_name md5sum
-            end else begin  (* imported unit *)
-              let dump_entry = sprintf "imported %s %s" md5sum unit_name in
-              info ~level:2 dump_entry;
-              Hashtbl.replace imported unit_name md5sum
-            end)
-        ic;
-      close_in ic)
+      match kind_of_fname fname with
+      | `Bytecode as kind ->
+          let current_unit = ref "" in
+          let ic = Unix.open_process_in (sprintf "%s %s" ocamlobjinfo fname) in
+          iter_in
+            (fun line ->
+              if Str.string_match unit_name_line_RE line 0 then
+                current_unit := Str.matched_group 1 line
+              else if Str.string_match md5sum_line_RE line 0 then
+                let md5sum = Str.matched_group 1 line in
+                let unit_name = Str.matched_group 2 line in
+                if unit_name = !current_unit then begin (* defined unit *)
+                  let dump_entry =
+                    sprintf "defined bytecode  %s %s" md5sum unit_name in
+                  info ~level:2 dump_entry;
+                  Hashtbl.replace defined unit_name (kind, md5sum)
+                end else begin  (* imported unit *)
+                  let dump_entry =
+                    sprintf "imported bytecode %s %s" md5sum unit_name in
+                  info ~level:2 dump_entry;
+                  Hashtbl.replace imported unit_name (kind, md5sum)
+                end)
+            ic;
+            close_in ic
+      | `Nativecode ->
+          prerr_endline ("native code objects not (yet) supported: " ^ fname);
+          assert false)
     fnames;
   Hashtbl.iter  (* imported := imported - defined *)
     (fun unit_name _ -> Hashtbl.remove imported unit_name)
@@ -193,6 +226,18 @@
 let pp_entry outchan ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version =
   fprintf outchan "%s %s %s %s %s\n"
     md5sum unit_name dev_dep runtime_dep dep_version
+
+let pp_obj_kind = function
+  | `Nativecode -> "native"
+  | `Bytecode -> "bytecode"
+
+let parse_obj_kind = function
+  | "native" -> `Nativecode
+  | "bytecode" -> `Bytecode
+  | s ->
+      eprintf "not an object kind: \"%s\" (expected \"native\" or \"bytecode\")"
+        s;
+      assert false
 
 (** iter a function over the entries of a registry file
  * @param f function to be executed for each entries, it takes 4 labeled
@@ -216,8 +261,9 @@
 (** @param fname file name of the registry file, if fname does not exists an
  * empty registry will be returned
  * @return an hashtbl mapping pairs <unit_name, md5sum> to pairs <package_name,
- * version_info>. E.g. ("Foo_bar", "74be7fa4320ebd9415f1c7cfc04c2d7b") ->
- * ("libfoo-ocaml-dev", ">= 1.2.3-4") *)
+ * version_info (dev), version_info (runtime), abi>. E.g. ("Foo_bar",
+ * "74be7fa4320ebd9415f1c7cfc04c2d7b") -> ("libfoo-ocaml-dev", ">= 1.2-3", ">=
+ * 1.2-3", "4517") *)
 let parse_registry fname =
   let registry = Hashtbl.create 1024 in
   if Sys.file_exists fname then
@@ -228,14 +274,19 @@
       fname;
   registry
 
+let compute_abi defined =
+  FINQUI
+
 (** {2 Main functions, one for each command line action} *)
 
 (** compute registry entry for a set of ocaml objects *)
 let compute dev_dep runtime_dep dep_version objects () =
   let defined, _ = unit_info objects in
+  let abi_version = compute_abi defined in
   Hashtbl.iter
-    (fun unit_name md5sum ->
-       pp_entry stdout ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version)
+    (fun unit_name (obj_kind, md5sum) ->
+      pp_entry stdout ~md5sum ~unit_name ~dev_dep ~runtime_dep ~dep_version
+        ~obj_kind ~abi_version)
     defined
 
 (** compute package dependencies for a set of ocaml objects *)

Propchange: trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/main.ml
------------------------------------------------------------------------------
    svn:keywords = Date

Added: trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml_md5sums_conf.ml.in
URL: http://svn.debian.org/wsvn/pkg-ocaml-maint/trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml_md5sums_conf.ml.in?rev=3882&op=file
==============================================================================
--- trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml_md5sums_conf.ml.in (added)
+++ trunk/packages/ocaml/branches/new-ocaml-md5sum/debian/ocaml-md5sums/ocaml_md5sums_conf.ml.in Wed Jul  4 09:51:30 2007
@@ -1,0 +1,14 @@
+(*
+ * This is free software, you can redistribute it and/or modify it under the
+ * terms of the GNU General Public License version 2 as published by the Free
+ * Software Foundation.
+ *)
+
+(** {2 Constants} *)
+
+let my_version = "@VERSION@"
+let md5sums_dir = "@MD5SUMS_DIR@"
+let md5sums_index = "MD5SUMS"
+let md5sums_ext = ".md5sums"
+let registry_file = sprintf "%s/%s" md5sums_dir md5sums_index
+




More information about the Pkg-ocaml-maint-commits mailing list