Subject: [bug#56080] [PATCH 4/4] gnu: bap: Update to 2.5.0-alpha.

From: Julien Lepiller <[email-masked]>
Date: Sun, 19 Jun 2022 09:51:50 +0200

* gnu/packages/ocaml.scm (bap): Update to 2.5.0-alpha.
---
 gnu/packages/ocaml.scm | 104 ++++++++++++++++++++++-------------------
 1 file changed, 55 insertions(+), 49 deletions(-)

diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm
index 59a883b400..06fee0ed59 100644
--- a/gnu/packages/ocaml.scm
+++ b/gnu/packages/ocaml.scm
@@ -4074,7 +4074,7 @@ (define-public ocaml-ppx-bap
 (define-public bap
   (package
     (name "bap")
-    (version "2.0.0")
+    (version "2.5.0-alpha")
     (home-page "https://github.com/BinaryAnalysisPlatform/bap")
     (source (origin
               (method git-fetch)
@@ -4084,58 +4084,64 @@ (define-public bap
               (file-name (git-file-name name version))
               (sha256
                (base32
-                "0lb9xkfp67wjjqr75p6krivmjra7l5673236v9ny4gp0xi0755bk"))))
+                "1fw9pp0xnssc08qqfkcafffap4f46hw7zmk80gif5yc4nazga8w5"))))
    (build-system ocaml-build-system)
-   (native-inputs
-    `(("ocaml-oasis" ,(package-with-ocaml4.07 ocaml-oasis))
-      ("clang" ,clang-3.8)
-      ("ocaml-ounit" ,(package-with-ocaml4.07 ocaml-ounit))))
-   (propagated-inputs
-    `(("camlzip" ,(package-with-ocaml4.07 camlzip))
-      ("ocaml-bitstring" ,(package-with-ocaml4.07 ocaml-bitstring))
-      ("ocaml-cmdliner" ,(package-with-ocaml4.07 ocaml-cmdliner))
-      ("ocaml-core-kernel" ,ocaml4.07-core-kernel)
-      ("ocaml-ezjsonm" ,(package-with-ocaml4.07 ocaml-ezjsonm))
-      ("ocaml-fileutils" ,(package-with-ocaml4.07 ocaml-fileutils))
-      ("ocaml-frontc" ,(package-with-ocaml4.07 ocaml-frontc))
-      ("ocaml-graph" ,(package-with-ocaml4.07 ocaml-graph))
-      ("ocaml-ocurl" ,(package-with-ocaml4.07 ocaml-ocurl))
-      ("ocaml-piqi" ,(package-with-ocaml4.07 ocaml-piqi))
-      ("ocaml-ppx-jane" ,ocaml4.07-ppx-jane)
-      ("ocaml-utop" ,ocaml4.07-utop)
-      ("ocaml-uuidm" ,(package-with-ocaml4.07 ocaml-uuidm))
-      ("ocaml-uri" ,ocaml4.07-uri)
-      ("ocaml-zarith" ,(package-with-ocaml4.07 ocaml-zarith))))
-   (inputs
-    (list gmp llvm-3.8 ncurses))
    (arguments
-    `(#:use-make? #t
+    (list
+      #:use-make? #t
       #:phases
-      (modify-phases %standard-phases
-        (add-before 'configure 'fix-ncurses
-          (lambda _
-            (substitute* "oasis/llvm"
-              (("-lcurses") "-lncurses"))
-            #t))
-        (replace 'configure
-          (lambda* (#:key outputs inputs #:allow-other-keys)
-            ;; add write for user, to prevent a failure in the install phase
-            (for-each
-              (lambda (file)
-                (let ((stat (stat file)))
-                  (chmod file (+ #o200 (stat:mode stat)))))
-              (find-files "." "."))
-            (invoke "./configure" "--prefix"
-                    (assoc-ref outputs "out")
-                    "--libdir"
-                    (string-append
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'fix-ncurses
+            (lambda _
+              (substitute* "oasis/llvm"
+                (("-lcurses") "-lncurses"))
+              #t))
+          (replace 'configure
+            (lambda* (#:key outputs inputs #:allow-other-keys)
+              (for-each make-file-writable (find-files "." "."))
+              ;; Package name changed
+              (substitute* "oasis/elf-loader"
+                (("bitstring.ppx") "ppx_bitstring"))
+              ;; We don't have a monolithic llvm
+              (substitute* "oasis/llvm.setup.ml.in"
+                (("llvm_static = \"true\"") "true"))
+              (invoke "./configure" "--prefix"
                       (assoc-ref outputs "out")
-                      "/lib/ocaml/site-lib")
-                    "--with-llvm-version=3.8"
-                    "--with-llvm-config=llvm-config"
-                    "--enable-everything"))))
-       #:ocaml ,ocaml-4.07
-       #:findlib ,ocaml4.07-findlib))
+                      "--libdir"
+                      (string-append
+                        (assoc-ref outputs "out")
+                        "/lib/ocaml/site-lib")
+                      (string-append "--with-llvm-version=" #$(package-version llvm))
+                      "--with-llvm-config=llvm-config"
+                      "--disable-ghidra"
+                      "--disable-llvm-static"
+                      "--enable-llvm"
+                      "--enable-everything"))))))
+   (native-inputs (list clang ocaml-oasis ocaml-ounit))
+   (propagated-inputs
+     (list
+       camlzip
+       ocaml-bitstring
+       ocaml-cmdliner
+       ocaml-core-kernel
+       ocaml-ezjsonm
+       ocaml-fileutils
+       ocaml-frontc
+       ocaml-graph
+       ocaml-linenoise
+       ocaml-ocurl
+       ocaml-piqi
+       ocaml-ppx-bap
+       ocaml-ppx-bitstring
+       ocaml-re
+       ocaml-uri
+       ocaml-utop
+       ocaml-uuidm
+       ocaml-yojson
+       ocaml-z3
+       ocaml-zarith))
+   (inputs
+    (list gmp llvm ncurses))
    (synopsis "Binary Analysis Platform")
    (description "Binary Analysis Platform is a framework for writing program
 analysis tools, that target binary files.  The framework consists of a plethora
-- 
2.36.1