Subject: [bug#31531] [PATCH 2/3] gnu: monero: Update to 0.12.0.0.

From: Theodoros Foradis <[email-masked]>
Date: Sat, 19 May 2018 21:54:36 +0300

* gnu/packages/patches/monero-fix-version.patch: New file.
* gnu/local.mk: Add it.
* gnu/packages/finance.scm: Update to 0.12.0.0.
[source]: Add patch.
[inputs]: Add zeromq, cppzmq, libsodium.
[arguments]: Change build-type to "release".
Add argument on unit-tests phase.
Substitute system* with invoke.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/finance.scm                      | 29 ++++++++++++++++++---------
 gnu/packages/patches/monero-fix-version.patch | 16 +++++++++++++++
 3 files changed, 36 insertions(+), 10 deletions(-)
 create mode 100644 gnu/packages/patches/monero-fix-version.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index fbdb30989..e9e1fe9f4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -924,6 +924,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch		\
   %D%/packages/patches/mpc123-initialize-ao.patch		\
   %D%/packages/patches/module-init-tools-moduledir.patch	\
+  %D%/packages/patches/monero-fix-version.patch			\
   %D%/packages/patches/mongodb-support-unknown-linux-distributions.patch	\
   %D%/packages/patches/mozjs17-aarch64-support.patch		\
   %D%/packages/patches/mozjs24-aarch64-support.patch		\
diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index c93f64193..9f18d79ac 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -4,7 +4,7 @@
 ;;; Copyright © 2016 Alex Griffin <[email-masked]>
 ;;; Copyright © 2016 Hartmut Goebel <[email-masked]>
 ;;; Copyright © 2017 Carlo Zancanaro <[email-masked]>
-;;; Copyright © 2017 Theodoros Foradis <[email-masked]>
+;;; Copyright © 2017,2018 Theodoros Foradis <[email-masked]>
 ;;; Copyright © 2017 Vasile Dumitrascu <[email-masked]>
 ;;; Copyright © 2017 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2018 Eric Bavier <[email-masked]>
@@ -36,6 +36,7 @@
   #:use-module (gnu packages base)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages crypto)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
   #:use-module (gnu packages dns)
@@ -48,6 +49,7 @@
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages multiprecision)
+  #:use-module (gnu packages networking)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
@@ -328,7 +330,7 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
   ;; the system's dynamically linked library.
   (package
     (name "monero")
-    (version "0.11.1.0")
+    (version "0.12.0.0")
     (source
      (origin
        (method url-fetch)
@@ -344,9 +346,11 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
             '("external/miniupnpc" "external/rapidjson"
               "external/unbound"))
            #t))
+       ;; Patch should be upstream by next update. TODO: Delete it.
+       (patches (search-patches "monero-fix-version.patch"))
        (sha256
         (base32
-         "16shd834025jyzy68h3gag1sz8vbk875hy4j97hrki8pacz8vd5m"))))
+         "1ywgvkpd9jx9hagh9q84ay8lxq4ymdbxjhdaxg29dqir1a8070sy"))))
     (build-system cmake-build-system)
     (native-inputs
      `(("doxygen" ,doxygen)
@@ -356,7 +360,10 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
     (inputs
      `(("bind" ,isc-bind)
        ("boost" ,boost)
+       ("zeromq" ,zeromq)
+       ("cppzmq" ,cppzmq)
        ("expat" ,expat)
+       ("libsodium" ,libsodium)
        ("libunwind" ,libunwind)
        ("lmdb" ,lmdb)
        ("miniupnpc" ,miniupnpc)
@@ -365,6 +372,7 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
        ("unbound" ,unbound)))
     (arguments
      `(#:out-of-source? #t
+       #:build-type "release"
        #:configure-flags '("-DBUILD_TESTS=ON"
                            ,@(if (string=? "aarch64-linux" (%current-system))
                                  '("-DARCH=armv8-a")
@@ -392,9 +400,8 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
              #t))
          (replace 'check
            (lambda _
-             (zero?
-              (system* "make" "ARGS=-E 'unit_tests|libwallet_api_tests'"
-                       "test"))))
+             (invoke "make" "ARGS=-E 'unit_tests|libwallet_api_tests'"
+                     "test")))
          ;; The excluded unit tests need network access
          (add-after 'check 'unit-tests
            (lambda _
@@ -407,10 +414,12 @@ other machines/servers.  Electrum does not download the Bitcoin blockchain.")
                        "DNSResolver.DNSSECFailure"
                        "DNSResolver.GetTXTRecord")
                      ":")))
-               (zero?
-                (system* "tests/unit_tests/unit_tests"
-                         (string-append "--gtest_filter=-"
-                                        excluded-unit-tests))))))
+               (invoke "tests/unit_tests/unit_tests"
+                       (string-append "--gtest_filter=-"
+                                      excluded-unit-tests)
+                       ;; Fix for data dir should be upstream by next update.
+                       ;; TODO: Delete next command line argument.
+                       (string-append "--data-dir=tests/data")))))
          (add-after 'install 'install-blockchain-import-export
            (lambda* (#:key outputs #:allow-other-keys)
              (let* ((out (assoc-ref outputs "out"))
diff --git a/gnu/packages/patches/monero-fix-version.patch b/gnu/packages/patches/monero-fix-version.patch
new file mode 100644
index 000000000..694e0aaf9
--- /dev/null
+++ b/gnu/packages/patches/monero-fix-version.patch
@@ -0,0 +1,16 @@
+Fixes error during configure.
+Will be upstream in monero-0.12.1.0.
+
+diff --git a/cmake/Version.cmake b/cmake/Version.cmake
+index 439c4c5..3677e80 100644
+--- a/cmake/Version.cmake
++++ b/cmake/Version.cmake
+@@ -28,7 +28,7 @@
+ 
+ function (write_static_version_header hash)
+   set(VERSIONTAG "${hash}")
+-  configure_file("src/version.cpp.in" "version.cpp")
++  configure_file("${CMAKE_SOURCE_DIR}/src/version.cpp.in" "${CMAKE_BINARY_DIR}/version.cpp")
+ endfunction ()
+ 
+ find_package(Git QUIET)
-- 
2.16.2