Subject: [bug#35150] [PATCH 8/9] gnu: Add ocaml-dose3.

From: Julien Lepiller <[email-masked]>
Date: Thu, 4 Apr 2019 21:16:37 +0200

* gnu/packages/ocaml.scm (ocaml-dose3): New variable.
* gnu/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch:
New file.
* gnu/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch: New file.
* gnu/packages/patches/ocaml-dose3-dont-make-printconf.patch: New file.
* gnu/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                  |   4 +
 gnu/packages/ocaml.scm                        |  52 +++++++
 ...ependency-to-dose3.common-in-META.in.patch |  25 ++++
 .../ocaml-dose3-Fix-for-ocaml-4.06.patch      |  52 +++++++
 .../ocaml-dose3-Install-mli-cmx-etc.patch     | 133 ++++++++++++++++++
 .../ocaml-dose3-dont-make-printconf.patch     |   9 ++
 6 files changed, 275 insertions(+)
 create mode 100644 gnu/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch
 create mode 100644 gnu/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch
 create mode 100644 gnu/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch
 create mode 100644 gnu/packages/patches/ocaml-dose3-dont-make-printconf.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index f9fd5d8fbc..858c13d8d7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1103,6 +1103,10 @@ dist_patch_DATA =						\
   %D%/packages/patches/ocaml-CVE-2015-8869.patch		\
   %D%/packages/patches/ocaml-Add-a-.file-directive.patch	\
   %D%/packages/patches/ocaml-enable-ocamldoc-reproducibility.patch	\
+  %D%/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch	\
+  %D%/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch	\
+  %D%/packages/patches/ocaml-dose3-dont-make-printconf.patch	\
+  %D%/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch	\
   %D%/packages/patches/omake-fix-non-determinism.patch	\
   %D%/packages/patches/ola-readdir-r.patch			\
   %D%/packages/patches/openbabel-fix-crash-on-nwchem-output.patch	\
diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 04d5a84d1a..0613bc29c6 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -57,6 +57,7 @@
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tex)
@@ -391,6 +392,57 @@ underlying solvers like Cplex, Gurobi, Lpsolver, Glpk, CbC, SCIP or WBO.")
                ;; With static-linking exception
                license:lgpl2.1+))))
 
+(define-public ocaml-dose3
+  (package
+    (name "ocaml-dose3")
+    (version "5.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri "https://gforge.inria.fr/frs/download.php/file/36063/dose3-5.0.1.tar.gz")
+              (sha256
+               (base32
+                "00yvyfm4j423zqndvgc1ycnmiffaa2l9ab40cyg23pf51qmzk2jm"))
+              (patches
+               (search-patches
+                "ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch"
+                "ocaml-dose3-Fix-for-ocaml-4.06.patch"
+                "ocaml-dose3-dont-make-printconf.patch"
+                "ocaml-dose3-Install-mli-cmx-etc.patch"))))
+    (build-system ocaml-build-system)
+    (arguments
+     `(#:configure-flags
+       (list (string-append "SHELL="
+                            (assoc-ref %build-inputs "bash")
+                            "/bin/sh"))
+       #:make-flags
+       (list (string-append "LIBDIR="
+                            (assoc-ref %outputs "out")
+                            "/lib/ocaml/site-lib"))))
+    (propagated-inputs
+      `(("ocaml-graph" ,ocaml-graph)
+        ("ocaml-cudf" ,ocaml-cudf)
+        ("ocaml-extlib" ,ocaml-extlib)
+        ("ocaml-re" ,ocaml-re)))
+    (native-inputs
+      `(("perl" ,perl)
+        ("python" ,python-2) ; for a test script
+        ("python2-pyyaml" ,python2-pyyaml) ; for a test script
+        ("ocaml-extlib" ,ocaml-extlib)
+        ("ocamlbuild" ,ocamlbuild)
+        ("ocaml-cppo" ,ocaml-cppo)))
+    (home-page "http://www.mancoosi.org/software/")
+    (synopsis "Package distribution management framework")
+    (description "Dose3 is a framework made of several OCaml libraries for
+managing distribution packages and their dependencies.  Though not tied to
+any particular distribution, dose3 constitutes a pool of libraries which
+enable analyzing packages coming from various distributions.  Besides basic
+functionalities for querying and setting package properties, dose3 also
+implements algorithms for solving more complex problems such as monitoring
+package evolutions, correct and complete dependency resolution and
+repository-wide uninstallability checks.")
+    ;; with static-linking exception
+    (license license:lgpl2.1+)))
+
 (define-public ocaml-opam-file-format
   (package
     (name "ocaml-opam-file-format")
diff --git a/gnu/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch b/gnu/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch
new file mode 100644
index 0000000000..d2cc44c784
--- /dev/null
+++ b/gnu/packages/patches/ocaml-dose3-Add-unix-as-dependency-to-dose3.common-in-META.in.patch
@@ -0,0 +1,25 @@
+From b94cf24739818e5aff397e0a83b19ea32dc81f42 Mon Sep 17 00:00:00 2001
+From: Louis Gesbert <[email-masked]>
+Date: Tue, 6 Feb 2018 10:15:45 +0100
+Subject: [PATCH 3/3] Add "unix" as dependency to dose3.common in META.in
+
+---
+ META.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/META.in b/META.in
+index aa2cd8d..0f9d337 100644
+--- a/META.in
++++ b/META.in
+@@ -8,7 +8,7 @@ package "common" (
+ version = "@PACKAGE_VERSION@"
+ archive(byte) = "common.cma"
+ archive(native) = "common.cmxa"
+-requires = "extlib, re.pcre, cudf, @ZIP@, @BZ2@"
++requires = "extlib, re.pcre, cudf, unix, @ZIP@, @BZ2@"
+ )
+ 
+ package "algo" (
+-- 
+2.11.0
+
diff --git a/gnu/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch b/gnu/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch
new file mode 100644
index 0000000000..2c344af821
--- /dev/null
+++ b/gnu/packages/patches/ocaml-dose3-Fix-for-ocaml-4.06.patch
@@ -0,0 +1,52 @@
+From aeca7656f499d7f4595319858f242276920e31bb Mon Sep 17 00:00:00 2001
+From: Louis Gesbert <[email-masked]>
+Date: Sat, 2 Dec 2017 12:51:01 +0100
+Subject: [PATCH] Fix for ocaml 4.06
+
+---
+ common/criteria_lexer.mll | 8 ++++----
+ common/util.ml            | 2 +-
+ 2 files changed, 5 insertions(+), 5 deletions(-)
+
+diff --git a/common/criteria_lexer.mll b/common/criteria_lexer.mll
+index 71f9178..fc4eae3 100644
+--- a/common/criteria_lexer.mll
++++ b/common/criteria_lexer.mll
+@@ -18,7 +18,7 @@
+     let c = Lexing.lexeme_char lexbuf 2 in (* the delimiter can be any character *)
+     (* find the terminating delimiter *)
+     let endpos =
+-      try String.index_from lexbuf.lex_buffer (lexbuf.lex_start_pos + 3) c with
++      try Bytes.index_from lexbuf.lex_buffer (lexbuf.lex_start_pos + 3) c with
+       |Invalid_argument _ ->
+           raise (Format822.Syntax_error (
+             Format822.error lexbuf "String too short"))
+@@ -27,9 +27,9 @@
+             Format822.error lexbuf (Printf.sprintf "cannot find: %c" c)))
+     in
+     let len = endpos - (lexbuf.lex_start_pos + 3) in
+-    let s = String.sub lexbuf.lex_buffer (lexbuf.lex_start_pos + 3) len in
+-    lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_start_pos + ((String.length s)+4);
+-    s
++    let s = Bytes.sub lexbuf.lex_buffer (lexbuf.lex_start_pos + 3) len in
++    lexbuf.Lexing.lex_curr_pos <- lexbuf.Lexing.lex_start_pos + ((Bytes.length s)+4);
++    Bytes.to_string s
+ 
+ }
+ 
+diff --git a/common/util.ml b/common/util.ml
+index 598f266..36ca3d1 100644
+--- a/common/util.ml
++++ b/common/util.ml
+@@ -87,7 +87,7 @@ module MakeMessages(X : sig val label : string end) = struct
+   let clean label =
+     try 
+       let s = Filename.chop_extension (Filename.basename label) in
+-      String.capitalize s
++      String.capitalize_ascii s
+     with Invalid_argument _ -> label
+ 
+   let create ?(enabled=false) label =
+-- 
+2.11.0
+
diff --git a/gnu/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch b/gnu/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch
new file mode 100644
index 0000000000..41494e7b3c
--- /dev/null
+++ b/gnu/packages/patches/ocaml-dose3-Install-mli-cmx-etc.patch
@@ -0,0 +1,133 @@
+From b5314c20d8e3caf62fe0dc96ad937a2950158b23 Mon Sep 17 00:00:00 2001
+From: Louis Gesbert <[email-masked]>
+Date: Thu, 2 Mar 2017 12:19:56 +0100
+Subject: [PATCH] Install mli, cmx, etc.
+
+---
+ Makefile | 26 +++++++++++++-------------
+ 1 file changed, 13 insertions(+), 13 deletions(-)
+
+diff --git a/Makefile b/Makefile
+index 09464ff..5044d7f 100644
+--- a/Makefile
++++ b/Makefile
+@@ -56,7 +56,7 @@ $(DOSELIBS)/cudf.%:
+ 	@for i in _build/cudf/cudf.*; do \
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -67,7 +67,7 @@ $(DOSELIBS)/common.%: common/*.ml common/*.mli
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -78,7 +78,7 @@ $(DOSELIBS)/versioning.%: versioning/*.ml versioning/*.mli
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -88,7 +88,7 @@ $(DOSELIBS)/algo.%: algo/*.ml algo/*.mli $(DOSELIBS)/common.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -98,7 +98,7 @@ $(DOSELIBS)/debian.%: deb/*.ml deb/*.mli $(DOSELIBS)/pef.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -108,7 +108,7 @@ $(DOSELIBS)/opam.%: opam/*.ml opam/*.mli $(DOSELIBS)/pef.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -118,7 +118,7 @@ $(DOSELIBS)/npm.%: npm/*.ml npm/*.mli $(DOSELIBS)/versioning.% $(DOSELIBS)/pef.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -128,7 +128,7 @@ $(DOSELIBS)/rpm.%: rpm/*.ml $(DOSELIBS)/algo.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -138,7 +138,7 @@ $(DOSELIBS)/pef.%: pef/*.ml pef/*.mli
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -148,7 +148,7 @@ $(DOSELIBS)/csw.%: opencsw/*.ml $(DOSELIBS)/versioning.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
++	  rm -f $(DOSELIBS)/*.mlpack ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -158,7 +158,7 @@ $(DOSELIBS)/doseparse.%: $(DOSELIBS)/pef.% $(DOSELIBS)/debian.%
+ 	  if [ -e $$i ]; then \
+ 	  cp $$i $(DOSELIBS) ; \
+ 		rm $$i ;\
+-	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx $(DOSELIBS)/*.ml ; \
++	  rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.ml ; \
+ 	  fi ; \
+ 	done
+ 
+@@ -168,7 +168,7 @@ $(DOSELIBS)/doseparseNoRpm.%: $(DOSELIBS)/pef.% $(DOSELIBS)/debian.%
+ 	  if [ -e $$i ]; then \
+ 			cp $$i $(DOSELIBS) ;\
+ 			rm $$i ;\
+-			rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ;\
++			rm -f $(DOSELIBS)/*.mlpack ;\
+ 	  fi ; \
+ 	done
+ 
+@@ -223,7 +223,7 @@ INSTALL_STUFF_ = META
+ INSTALL_STUFF_ += $(wildcard _build/doselibs/*.cma _build/doselibs/*.cmi)
+ INSTALL_STUFF_ += $(wildcard _build/doselibs/*.cmxa _build/doselibs/*.cmxs)
+ INSTALL_STUFF_ += $(wildcard _build/doselibs/*.a)
+-#INSTALL_STUFF_ += $(wildcard _build/*/*.mli)
++INSTALL_STUFF_ += $(wildcard _build/doselibs/*.mli) $(wildcard _build/doselibs/*.cmti) $(wildcard _build/doselibs/*.cmx)
+ INSTALL_STUFF_ += $(wildcard _build/rpm/*.so)
+ 
+ exclude_cudf = $(wildcard _build/doselibs/*cudf* _build/cudf/*)
+-- 
+2.11.0
+
diff --git a/gnu/packages/patches/ocaml-dose3-dont-make-printconf.patch b/gnu/packages/patches/ocaml-dose3-dont-make-printconf.patch
new file mode 100644
index 0000000000..84b6a3b81b
--- /dev/null
+++ b/gnu/packages/patches/ocaml-dose3-dont-make-printconf.patch
@@ -0,0 +1,9 @@
+--- a/configure
++++ b/configure
+@@ -6552,6 +6552,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+ $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+ fi
+-
+-
+-make printconf
-- 
2.21.0