[Pkg-ocaml-maint-commits] [SCM] oasis2debian project branch, master, updated. 94ae27000298101188a629fbcc6b28420021fe10

Sylvain Le Gall gildor at debian.org
Sat Nov 20 00:58:46 UTC 2010


The following commit has been merged in the master branch:
commit 58081558679218aefa5e5ae2dcf227a064d3f136
Author: Sylvain Le Gall <gildor at debian.org>
Date:   Thu Nov 18 16:55:57 2010 +0000

    Match hand written ocaml-data-notation debian/
    
    With this commit, we almost match an hand written debian/ directory:
    * Generate debhelper files to manage install from debian/tmp to
      package directories
    * Fix debian/rules to use debhelper files
    * Generate .ocamldoc if no API documentation is shipped
    
    We also add a field pkg_generic to Common.t, which filters out
    non-installed section.

diff --git a/_tags b/_tags
index 4019c9e..f135e7c 100644
--- a/_tags
+++ b/_tags
@@ -7,3 +7,4 @@
 "src/Control.ml": syntax_camlp4o
 "src/Copyright.ml": syntax_camlp4o
 "src/Rules.ml": syntax_camlp4o
+"src/DhFiles.ml": syntax_camlp4o
diff --git a/src/BuildDepends.ml b/src/BuildDepends.ml
index 8f40bc1..aad09fb 100644
--- a/src/BuildDepends.ml
+++ b/src/BuildDepends.ml
@@ -26,6 +26,15 @@ module SetDepends =
          String.compare nm1 nm2
      end)
 
+let cmp_opt_merge v1_opt v2_opt = 
+  match v1_opt, v2_opt with
+    | Some v1, Some v2 -> 
+        Some 
+          (OASISVersion.comparator_reduce 
+             (OASISVersion.VAnd (v1, v2)))
+    | None, opt | opt, None ->
+        opt
+
 let add_depends ?(arch_spec=`All) nm ver_opt st =
   let ver_opt, arch_spec =
     try 
@@ -35,13 +44,7 @@ let add_depends ?(arch_spec=`All) nm ver_opt st =
           (SetDepends.elements st)
       in
       let ver_opt = 
-        match ver_opt', ver_opt with
-          | Some v1, Some v2 -> 
-              Some 
-                (OASISVersion.comparator_reduce 
-                   (OASISVersion.VAnd (v1, v2)))
-          | None, opt | opt, None ->
-              opt
+        cmp_opt_merge ver_opt' ver_opt 
       in
         ver_opt, Arch.Spec.merge arch_spec arch_spec'
 
@@ -318,13 +321,23 @@ let get ~ctxt pkg =
   in
 
   let debian_depends = 
-    List.fold_right 
-      SetDepends.add 
-      [
-        "ocaml-findlib", pkg.findlib_version, `All;
-        "ocaml-nox", pkg.ocaml_version, `All;
-      ]
-      SetDepends.empty
+    let cos = 
+      OASISVersion.comparator_of_string 
+    in
+      List.fold_right 
+        SetDepends.add 
+        [
+          "debhelper",     Some (cos ">= 7.0.50~"), `All;
+          "dh-ocaml",      Some (cos ">= 0.9~"),    `All;
+          "ocaml-findlib", pkg.findlib_version,     `All;
+
+          "ocaml-nox",
+          cmp_opt_merge
+            pkg.ocaml_version
+            (Some (cos ">= 3.11.1-3~")),
+          `All;
+        ]
+        SetDepends.empty
   in
 
   let debian_depends = 
diff --git a/src/Common.ml b/src/Common.ml
index 45283a4..8dbe220 100644
--- a/src/Common.ml
+++ b/src/Common.ml
@@ -15,16 +15,26 @@ type t =
     description:   string;
     homepage:      string;
     uploader:      string;
+
+    (** Pristine OASIS package *)
     pkg:           OASISTypes.package;
+
+    (** OASIS package with section filtered.
+        A section is removed if it is not installed
+        or built on all arches
+      *)
+    pkg_generic:   OASISTypes.package; 
+
+    (** Evaluation environment for OASISExpr *)
     expr:          Expr.t;
 
-    (* Standard Debian package *)
+    (** Standard Debian package *)
     deb_std:       deb_pkg option;
 
-    (* Library + runtime package *)
+    (** Library + runtime package *)
     deb_dev:       (deb_pkg * deb_pkg) option;
 
-    (* Doc package *)
+    (** Doc package *)
     deb_doc:       deb_pkg option;
   }
 
diff --git a/src/Control.ml b/src/Control.ml
index 4e0bad4..5080471 100644
--- a/src/Control.ml
+++ b/src/Control.ml
@@ -12,7 +12,7 @@ let create t =
     match t.build_depends with 
       | [] -> ""
       | lst ->
-          sep^(String.concat sep t.build_depends)
+          String.concat sep t.build_depends
   in
 
   let src_name = 
@@ -69,8 +69,7 @@ Maintainer: Debian OCaml Maintainers <debian-ocaml-maint at lists.debian.org>
 Uploaders: 
   $t.uploader
 Build-Depends:
-  debhelper (>= 7.0.50~),
-  dh-ocaml (>= 0.9.0~)$build_depends
+  $build_depends
 Standards-Version: 3.9.1
 Homepage: $t.homepage
 Vcs-Git: git://git.debian.org/git/pkg-ocaml-maint/packages/${src_name}.git
diff --git a/src/DhFiles.ml b/src/DhFiles.ml
new file mode 100644
index 0000000..7143dd8
--- /dev/null
+++ b/src/DhFiles.ml
@@ -0,0 +1,157 @@
+
+(** Create debhelper files for generated packages
+  *)
+
+open OASISTypes
+open OASISLibrary 
+open ExtString
+open Common
+
+let create ~ctxt t = 
+  let dh_with_fn deb_pkg ext = 
+    debian_with_fn (deb_pkg.name^"."^ext)
+  in
+
+  let findlib_roots = 
+    OASISLibrary.group_libs t.pkg_generic 
+  in
+
+  let roots = 
+    List.rev_map 
+      (fun grp ->
+         let findlib_name = 
+           OASISLibrary.findlib_of_group grp 
+         in
+
+         let libs = 
+           let rec fold acc =
+             function
+               | Container (_, lst) ->
+                   List.fold_left fold acc lst
+               | Package (_, cs, bs, lib, lst) ->
+                   List.fold_left fold ((cs, bs, lib) :: acc) lst
+           in
+             fold [] grp
+         in
+
+         (* We compute the set of possible generated files to test
+          * them for certain properties.
+          *)
+         let generated_files = 
+           List.flatten
+             (List.flatten 
+                (List.fold_left
+                  (fun acc e -> 
+                     let fns = 
+                       OASISLibrary.generated_unix_files
+                         ~ctxt
+                         e
+                         Sys.file_exists
+                         (fun () -> true)
+                         (fun () -> ".a")
+                         (fun () -> ".so")
+                     in
+                       fns :: acc) 
+                  []
+                  libs))
+         in
+           
+         (* Has_dll *)
+         let has_dll = 
+           List.exists (fun fn -> String.ends_with fn ".so") generated_files
+         in
+
+           findlib_name, has_dll)
+
+      findlib_roots
+  in
+
+  let has_apidoc = 
+    List.exists
+      (function
+         | Doc (cs, doc) ->
+             (* We estimate that a doc is an API reference * if it uses
+              * ocamldoc.
+              *)
+             List.mem 
+               (ExternalTool "ocamldoc") 
+               doc.doc_build_tools
+
+         | Flag _ | Library _ | Executable _ | SrcRepo _ | Test _ ->
+             false)
+      t.pkg_generic.sections
+  in
+
+  let mk_ocamldoc deb_pkg =
+    if not has_apidoc then
+      begin
+        dh_with_fn deb_pkg "ocamldoc"
+          (output_content "# Nothing")
+      end
+  in
+    
+    begin 
+      match t.deb_dev with 
+        | Some (deb_dev, deb_runtime) ->
+            begin
+              dh_with_fn deb_dev "install.in"
+                (fun chn -> 
+                   List.iter 
+                     (fun (findlib_name, has_dll) ->
+                        
+                        output_content 
+                          (interpolate 
+                             "\
+ at OCamlStdlibDir@/$findlib_name/*.cm*
+ at OCamlStdlibDir@/$findlib_name/*.ml*")
+                          chn;
+
+                        output_content
+                          (if has_dll then
+                             (interpolate 
+                                "@OCamlStdlibDir@/$findlib_name/*.a")
+                           else
+                             (interpolate 
+                                "#OPT: @OCamlStdlibDir@/$findlib_name/*.a"))
+                          chn)
+                     roots);
+              
+              dh_with_fn deb_runtime "install.in"
+                (fun chn ->
+                   (* At least one findlib root has a dll *)
+                   if List.exists snd roots then
+                     output_content "@OCamlDllDir@/*.so" chn;
+
+                   List.iter 
+                     (fun (findlib_name, has_dll) ->
+                        output_content 
+                          (interpolate 
+                             "\
+ at OCamlStdlibDir@/$findlib_name/META
+ at OCamlStdlibDir@/$findlib_name/*.cma")
+                          chn)
+                     roots)
+            end
+
+        | None ->
+            ()
+    end;
+
+    begin
+      match t.deb_doc with 
+        | Some deb_pkg ->
+            mk_ocamldoc deb_pkg;
+
+            (* TODO *)
+            ()
+
+        | None ->
+            begin
+              (* We need to attach the ocamldoc to some package *)
+              match t.deb_dev with 
+                | Some (deb_pkg, _) ->
+                    mk_ocamldoc deb_pkg
+                | None ->
+                    ()
+            end
+    end
diff --git a/src/GenPkg.ml b/src/GenPkg.ml
index 841c283..cde0dbe 100644
--- a/src/GenPkg.ml
+++ b/src/GenPkg.ml
@@ -14,39 +14,24 @@ let library_name =
           failwith "Not set"))
 
 let set ~ctxt t = 
-  let eval = 
-    Expr.choose 
-      ~ctxt 
-      t.expr 
-      (`All (fun x y -> x || y))
-  in
 
   let lib, doc, bin =
     List.fold_left
       (fun ((lib, doc, bin) as acc) ->
          function
            | Library (cs, bs, lib') ->
-               if eval bs.bs_build && eval bs.bs_install then
-                 ((cs, bs, lib') :: lib), doc, bin
-               else
-                 acc
+               ((cs, bs, lib') :: lib), doc, bin
 
            | Executable (cs, bs, exec) ->
-               if eval bs.bs_build && eval bs.bs_install then
-                 lib, doc, ((cs, bs, exec) :: bin)
-               else
-                 acc
+               lib, doc, ((cs, bs, exec) :: bin)
 
            | Doc (cs, doc') ->
-               if eval doc'.doc_build && eval doc'.doc_install then
-                 lib, ((cs, doc') :: doc), bin
-               else
-                 acc
+               lib, ((cs, doc') :: doc), bin
 
            | Flag _ | Test _ | SrcRepo _ ->
                acc)
       ([], [], [])
-      t.pkg.sections
+      t.pkg_generic.sections
   in
 
   let arch lst = 
@@ -79,7 +64,7 @@ let set ~ctxt t =
       end
     else
       begin
-        match OASISLibrary.group_libs t.pkg with 
+        match OASISLibrary.group_libs t.pkg_generic with 
           | [hd] ->
               (* First method: if there is a single findlib library use its name
                *)
@@ -93,7 +78,7 @@ let set ~ctxt t =
                    Pcre.replace ~pat ~templ:"" name)
 
                 (* Start with the package name *)
-                t.pkg.OASISTypes.name
+                t.pkg_generic.OASISTypes.name
                 ["^ocaml-?"; "-?ocaml$"]
       end
   in
@@ -120,7 +105,7 @@ let set ~ctxt t =
           begin
             (* Only a binary package, name = source name *)
             let base_name = 
-              t.pkg.OASISTypes.name
+              t.pkg_generic.OASISTypes.name
             in
               add_doc 
                 (base_name^"-doc")
diff --git a/src/Main.ml b/src/Main.ml
index 978c072..b529869 100644
--- a/src/Main.ml
+++ b/src/Main.ml
@@ -31,6 +31,12 @@ let uploader =
           with _ ->
             failwith "Unable to guess uploader"))
 
+let itp =
+  Conf.create
+    ~cli:"--itp"
+    "Bug number of the ITP for the package"
+    Conf.ShortInput
+
 let () = 
   let () = 
     (* Clean ENV *)
@@ -53,6 +59,10 @@ let () =
     Expr.create ~ctxt pkg
   in
 
+  let pkg_generic =
+    PkgGeneric.create ~ctxt expr pkg
+  in
+
   let dflt r x =
     match x, Conf.is_set r with 
       | Some e, false -> 
@@ -86,6 +96,7 @@ let () =
       homepage      = Conf.get ~ctxt homepage;
       uploader      = Conf.get ~ctxt uploader;
       pkg           = pkg;
+      pkg_generic   = pkg_generic;
       expr          = expr;
       deb_std       = None;
       deb_dev       = None;
@@ -117,15 +128,21 @@ let () =
     in
 
     if debian_not_exist "changelog" then
-      assert_command ~ctxt  
-        (interpolate 
-           "dch --create --package $pkg.OASISTypes.name --newversion $pkg_version-1")
+      begin
+        let itp = 
+          Conf.get ~ctxt itp 
+        in
+          assert_command ~ctxt  
+            (interpolate 
+               "dch --create --package $pkg.OASISTypes.name --newversion $pkg_version-1 --closes $itp")
+      end
   in
 
   let () = 
-    Rules.create t;
     Control.create t;
     Copyright.create ~ctxt t;
+    Rules.create t;
+    DhFiles.create ~ctxt t
   in 
 
     ()
diff --git a/src/PkgGeneric.ml b/src/PkgGeneric.ml
new file mode 100644
index 0000000..6016388
--- /dev/null
+++ b/src/PkgGeneric.ml
@@ -0,0 +1,41 @@
+
+(** Translate the provided package into its generic counterpart
+  * See {!Common.t.pkg_generic} for a definition of what section
+  * will be kept.
+  *)
+
+open OASISTypes
+
+let create ~ctxt expr pkg = 
+
+  let eval = 
+    Expr.choose 
+      ~ctxt 
+      expr 
+      (`All (fun x y -> x || y))
+  in
+
+  let sections =
+    List.fold_left
+      (fun acc e ->
+         match e with 
+           | Library (_, bs, _)
+           | Executable (_, bs, _) ->
+               if eval bs.bs_build && eval bs.bs_install then
+                 e :: acc
+               else
+                 acc
+
+           | Doc (_, doc) ->
+               if eval doc.doc_build && eval doc.doc_install then
+                 e :: acc
+               else
+                 acc
+
+           | Flag _ | Test _ | SrcRepo _ ->
+               e :: acc)
+      []
+      pkg.sections
+  in
+
+    {pkg with sections = List.rev sections}
diff --git a/src/Rules.ml b/src/Rules.ml
index e0d5a68..ea01f2d 100644
--- a/src/Rules.ml
+++ b/src/Rules.ml
@@ -15,7 +15,7 @@ let create t =
           (* More than 1 package, we need to install files
            * in different packages 
            *)
-          "temp"
+          "tmp"
   in
     debian_with_fn "rules"
       (output_content 
@@ -30,23 +30,36 @@ DESTDIR=\$(CURDIR)/debian/$destdir
 
 include /usr/share/ocaml/ocamlvars.mk
 
+OCAMLFIND_DESTDIR=\$(DESTDIR)/\$(OCAML_STDLIB_DIR)
+export OCAMLFIND_DESTDIR
+
 %:
 	dh --with ocaml \$@
 
 .PHONY: override_dh_auto_configure
 override_dh_auto_configure:
-	ocaml setup.ml -configure --prefix /usr --destdir '\$(DESTDIR)' --enable-debug
+	ocaml setup.ml -configure --prefix /usr --destdir '\$(DESTDIR)' 
 
 .PHONY: override_dh_auto_build
 override_dh_auto_build:
 	ocaml setup.ml -build
+	ocaml setup.ml -doc
+
+.PHONY: override_dh_auto_test
+override_dh_auto_test:
+	ocaml setup.ml -test
 
 .PHONY: override_dh_auto_install
 override_dh_auto_install:
 	mkdir -p '\$(DESTDIR)/usr/bin'
+	mkdir -p '\$(OCAMLFIND_DESTDIR)'
 	ocaml setup.ml -install 
 
+.PHONY: override_dh_install
+override_dh_install:
+	dh_install --fail-missing
+
 .PHONY: override_dh_auto_clean
 override_dh_auto_clean:
 	ocaml setup.ml -distclean"));
-    Unix.chmod (debian_fn "rules") 0o655 
+    Unix.chmod (debian_fn "rules") 0o0755 

-- 
oasis2debian project



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