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

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


The following commit has been merged in the master branch:
commit aa6dbc4c8ddebabc821e5d257ce8ee7f67f9b96f
Author: Sylvain Le Gall <gildor at debian.org>
Date:   Fri Nov 19 17:11:09 2010 +0100

    Manage documentation installation

diff --git a/_oasis b/_oasis
index b776dda..b1149d7 100644
--- a/_oasis
+++ b/_oasis
@@ -12,7 +12,8 @@ FilesAB:     src/Version.ml.ab
 Executable oasis2debian
   Path:         src
   MainIs:       Main.ml
-  BuildDepends: oasis (>= 0.2.0), xstrp4, fileutils (>= 0.4.2), pcre
+  BuildDepends: oasis (>= 0.2.0), xstrp4, fileutils (>= 0.4.2), pcre, 
+                oasis.base
   
 Executable test
   Path:         test
diff --git a/src/Common.ml b/src/Common.ml
index 8dbe220..20e1568 100644
--- a/src/Common.ml
+++ b/src/Common.ml
@@ -2,6 +2,7 @@
 open FileUtil
 open OASISUtils
 open OASISMessage
+open OASISTypes
 
 type deb_pkg =
     {
@@ -107,3 +108,18 @@ let output_content str chn =
 
 
 module MapString = Map.Make(String)
+
+let docdir t = 
+  let has_doc = 
+    List.exists 
+      (function Doc _ -> true | _ -> false) 
+      t.pkg.sections
+  in
+    match has_doc, t.deb_doc, t.deb_dev with 
+      | true, Some deb_pkg, _ 
+      | true, None, Some (deb_pkg, _) ->
+          Some ("/usr/share/doc/"^deb_pkg.name)
+
+      | false, _, _
+      | true, None, None ->
+          None
diff --git a/src/DhFiles.ml b/src/DhFiles.ml
index 7fcf307..fb55ed3 100644
--- a/src/DhFiles.ml
+++ b/src/DhFiles.ml
@@ -89,7 +89,92 @@ let create ~ctxt t =
           (output_content "# Nothing")
       end
   in
-    
+
+  let mk_doc_base docdir cs doc chn = 
+    let print s = output_content s chn in
+    let installdir = 
+      (* TODO: something better *)
+      (* Close your eyes *)
+      Unix.putenv "prefix" "/usr";
+      Unix.putenv "docdir" docdir;
+      BaseStandardVar.init t.pkg_generic;
+      BaseEnv.var_expand doc.doc_install_dir
+      (* You can open your eyes again *)
+    in
+      print
+        (interpolate "\
+Document: $t.pkg_generic.OASISTypes.name-$cs.cs_name
+Title: $doc.doc_title
+Section: Programming/OCaml");
+      begin
+        match doc.doc_abstract with 
+          | Some str ->
+              print ("Abstract: "^str) 
+          | None ->
+              ()
+      end;
+
+      begin 
+        match doc.doc_authors with 
+          | [] ->
+              ()
+          | lst ->
+              print 
+                ("Author: "^(String.concat ", " lst)) 
+      end;
+
+      print "";
+
+      begin 
+        match doc.doc_format with 
+          | HTML index ->
+              print "Format: HTML";
+              print ("Index: "^installdir^"/"^index)
+            
+          | DocText ->
+              print "Format: Text"
+
+          | PDF ->
+              print "Format: PDF"
+          | PostScript ->
+              print "Format: PostScript"
+
+          | Info index ->
+              print "Format: Info";
+              print ("Index: "^installdir^"/"^index)
+
+          | DVI ->
+              print "Format: DVI"
+
+          | OtherDoc ->
+              (* Default to HTML with a fake index *)
+              print "Format: HTML";
+              print ("Index: "^installdir^"/index.html")
+      end;
+
+      print ("Files: "^installdir^"/*")
+  in
+
+  let mk_doc_bases deb_pkg docdir =
+    let _i : int =
+      List.fold_left
+        (fun n ->
+           function
+             | Doc (cs, doc) ->
+                 dh_with_fn deb_pkg 
+                   ("doc-base."^(string_of_int n))
+                   (mk_doc_base docdir cs doc);
+                 n + 1
+
+             | Library _ | Executable _ | Flag _ 
+             | Test _ | SrcRepo _ ->
+                 n)
+        1
+        t.pkg_generic.sections
+    in
+      ()
+  in
+
     begin 
       match t.deb_dev with 
         | Some (deb_dev, deb_runtime) ->
@@ -114,7 +199,21 @@ OPT: @OCamlStdlibDir@/$findlib_name/*.cmxa")
                            else
                              (interpolate 
                                 "OPT: @OCamlStdlibDir@/$findlib_name/*.a"))
-                          chn)
+                          chn;
+
+                        begin
+                          match t.deb_doc, docdir t with 
+                            | None, Some fn ->
+                                output_content 
+                                  (FilePath.make_relative "/" fn)
+                                  chn;
+
+                                mk_doc_bases deb_dev fn
+                            | _, _ ->
+                                ()
+                        end;
+
+                     )
                      roots);
               
               dh_with_fn deb_runtime "install.in"
@@ -141,10 +240,22 @@ OPT: @OCamlStdlibDir@/$findlib_name/*.cmxa")
     begin
       match t.deb_doc with 
         | Some deb_pkg ->
-            mk_ocamldoc deb_pkg;
+            begin
+              mk_ocamldoc deb_pkg;
 
-            (* TODO *)
-            ()
+              match docdir t with 
+                | Some docdir -> 
+                    begin
+                      dh_with_fn deb_pkg "install"
+                        (output_content 
+                           (FilePath.make_relative "/" docdir));
+
+                      mk_doc_bases deb_pkg docdir 
+                    end
+
+                | None ->
+                    ()
+            end
 
         | None ->
             begin
diff --git a/src/Rules.ml b/src/Rules.ml
index ea01f2d..52d7c13 100644
--- a/src/Rules.ml
+++ b/src/Rules.ml
@@ -17,6 +17,14 @@ let create t =
            *)
           "tmp"
   in
+
+  let docdir = 
+    match docdir t with 
+      | Some fn ->
+          " --docdir '"^fn^"'"
+      | None ->
+          ""
+  in
     debian_with_fn "rules"
       (output_content 
          (interpolate "\
@@ -38,7 +46,7 @@ export OCAMLFIND_DESTDIR
 
 .PHONY: override_dh_auto_configure
 override_dh_auto_configure:
-	ocaml setup.ml -configure --prefix /usr --destdir '\$(DESTDIR)' 
+	ocaml setup.ml -configure --prefix /usr --destdir '\$(DESTDIR)'$docdir
 
 .PHONY: override_dh_auto_build
 override_dh_auto_build:

-- 
oasis2debian project



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