Subject: bug#35248: Monero fails to build and is outdated

From: swedebugia <[email-masked]>
Date: Tue, 23 Apr 2019 08:08:58 +0200

I tried upgrading and solving all the errors I ran into. See patch attached.

I got stuck with a bunch of these linker errors in the end (97%) after
having upgraded the monero-upnpc also:

ld:
main.cpp:(.text._ZN8nodetool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj[_ZN8no\
detool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj]+0x26a):
undefined reference to \
`FreeUPNPUrls'

ld:
main.cpp:(.text._ZN8nodetool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj[_ZN8no\
detool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj]+0x4b4):
undefined reference to \
`UPNP_DeletePortMapping'

ld:
main.cpp:(.text._ZN8nodetool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj[_ZN8no\
detool11node_serverIN10cryptonote29t_cryptonote_protocol_handlerINS1_4coreEEEE24delete_upnp_port_mappingEj]+0x4de):
undefined reference to \
`strupnperror'

collect2: error: ld returned 1 exit status

Does anyone have an idea how to solve this?

-- 
Cheers Swedebugia
From 970e9e82f243f105cba8482690326877e916499f Mon Sep 17 00:00:00 2001
From: swedebugia <[email-masked]>
Date: Tue, 23 Apr 2019 07:56:08 +0200
Subject: [PATCH] gnu: monero: Update to 14.0.2

* gnu/packages/finance.scm (monero): Update to 14.0.2.
* gnu/packages/finance.scm (monero)[source]: New snippet.
  [inputs]: Add hidapi.
* gnu/packages/patches/monero-use-system-miniupnpc.patch: Deleted.
* gnu/packages/upnp.scm(monero-miniupnpc): Update to 14.0.2.
---
 gnu/packages/finance.scm                      |  28 ++++-
 .../patches/monero-use-system-miniupnpc.patch | 111 ------------------
 gnu/packages/upnp.scm                         |   8 +-
 3 files changed, 29 insertions(+), 118 deletions(-)
 delete mode 100644 gnu/packages/patches/monero-use-system-miniupnpc.patch

diff --git a/gnu/packages/finance.scm b/gnu/packages/finance.scm
index bd30d466f..f629d59e7 100644
--- a/gnu/packages/finance.scm
+++ b/gnu/packages/finance.scm
@@ -11,6 +11,7 @@
 ;;; Copyright © 2018 Adriano Peluso <[email-masked]>
 ;;; Copyright © 2018, 2019 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2018 Arun Isaac <[email-masked]>
+;;; Copyright © 2019 swedebugia <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -424,7 +425,7 @@ other machines/servers.  Electroncash does not download the Bitcoin Cash blockch
   ;; the system's dynamically linked library.
   (package
     (name "monero")
-    (version "0.12.3.0")
+    (version "0.14.0.2")
     (source
      (origin
        (method git-fetch)
@@ -432,10 +433,29 @@ other machines/servers.  Electroncash does not download the Bitcoin Cash blockch
              (url "https://github.com/monero-project/monero")
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
-       (patches (search-patches "monero-use-system-miniupnpc.patch"))
        (sha256
         (base32
-         "14db9kgjm2ha93c2x5fjdw01xaqshn756qr3x2cnzyyjh7caz5qd"))))
+         "0n23axpng50ixk8s3r88c7kqcbvzs1f4avsg4i19klhy90qvn5lv"))
+       (modules '((guix build utils)))
+       (snippet
+        '(begin
+           ;; This makes sure we use and find our miniupnp
+           ;; Delete 2 empty folders
+           (for-each delete-file-recursively
+                     '("external/miniupnp" "external/unbound"))
+           ;; Don't default to the in-tree miniupnp
+           (chmod "external/CMakeLists.txt" #o644)
+           (substitute* "external/CMakeLists.txt"
+             (("message\\(STATUS \"Using in-tree miniupnpc\"\\)") "")
+             (("add_subdirectory\\(miniupnp/miniupnpc\\)") "")
+             (("set_property\\(TARGET libminiupnpc-static.*") "")
+             (("set\\(UPNP_LIBRARIES \"libminiupnpc-static\" PARENT_SCOPE\\)") ""))
+           ;; Fix paths to shared miniupnp
+           (substitute* "src/p2p/net_node.inl"
+             (("<miniupnp/miniupnpc/miniupnpc.h>") "\"miniupnpc/miniupnpc.h\"")
+             (("<miniupnp/miniupnpc/upnpcommands.h>") "\"miniupnpc/upnpcommands.h\"")
+             (("<miniupnp/miniupnpc/upnperrors.h>") "\"miniupnpc/upnperrors.h\""))
+           #t))))
     (build-system cmake-build-system)
     (native-inputs
      `(("doxygen" ,doxygen)
@@ -443,11 +463,13 @@ other machines/servers.  Electroncash does not download the Bitcoin Cash blockch
        ("graphviz" ,graphviz)
        ("pkg-config" ,pkg-config)))
     (inputs
+     ;; TODO add readline support
      `(("bind" ,isc-bind)
        ("boost" ,boost)
        ("zeromq" ,zeromq)
        ("cppzmq" ,cppzmq)
        ("expat" ,expat)
+       ("hidapi" ,hidapi)
        ("libsodium" ,libsodium)
        ("libunwind" ,libunwind)
        ("lmdb" ,lmdb)
diff --git a/gnu/packages/patches/monero-use-system-miniupnpc.patch b/gnu/packages/patches/monero-use-system-miniupnpc.patch
deleted file mode 100644
index 6bc825d12..000000000
--- a/gnu/packages/patches/monero-use-system-miniupnpc.patch
+++ /dev/null
@@ -1,111 +0,0 @@
-This reverts commit 1e20d705e7c64d2b17c031f345057d1e8850fafa, so that it's possible to use our own
-miniupnpc, instead of a git submodule.
----
- CMakeLists.txt          |  8 ++++++++
- external/CMakeLists.txt | 41 +++++++++++++++++++++++++++++++----------
- src/p2p/net_node.inl    | 13 ++++++++++---
- 3 files changed, 49 insertions(+), 13 deletions(-)
-
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index 3b93988e..ef948885 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -430,6 +430,14 @@ include_directories("${CMAKE_CURRENT_BINARY_DIR}/translations")
- 
- add_subdirectory(external)
- 
-+# Final setup for miniupnpc
-+if(UPNP_STATIC OR IOS)
-+  add_definitions("-DUPNP_STATIC")
-+else()
-+  add_definitions("-DUPNP_DYNAMIC")
-+  include_directories(${UPNP_INCLUDE})
-+endif()
-+
- # Final setup for libunbound
- include_directories(${UNBOUND_INCLUDE})
- link_directories(${UNBOUND_LIBRARY_DIRS})
-diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt
-index 1fc4d64c..b4f712ee 100644
---- a/external/CMakeLists.txt
-+++ b/external/CMakeLists.txt
-@@ -34,21 +34,42 @@
- # We always compile if we are building statically to reduce static dependency issues...
- # ...except for FreeBSD, because FreeBSD is a special case that doesn't play well with
- # others.
-+if(NOT IOS)
-+    find_package(Miniupnpc QUIET)
-+endif()
- 
--find_package(Miniupnpc REQUIRED)
-+# If we have the correct shared version and we're not building static, use it
-+if(STATIC OR IOS)
-+ set(USE_SHARED_MINIUPNPC false)
-+elseif(MINIUPNP_FOUND AND MINIUPNPC_VERSION_1_7_OR_HIGHER)
-+ set(USE_SHARED_MINIUPNPC true)
-+endif()
- 
--message(STATUS "Using in-tree miniupnpc")
-+if(USE_SHARED_MINIUPNPC)
-+  message(STATUS "Using shared miniupnpc found at ${MINIUPNP_INCLUDE_DIR}")
- 
--add_subdirectory(miniupnp/miniupnpc)
-+  set(UPNP_STATIC false PARENT_SCOPE)
-+  set(UPNP_INCLUDE ${MINIUPNP_INCLUDE_DIR} PARENT_SCOPE)
-+  set(UPNP_LIBRARIES ${MINIUPNP_LIBRARY} PARENT_SCOPE)
-+else()
-+  if(STATIC)
-+    message(STATUS "Using miniupnpc from local source tree for static build")
-+  else()
-+    message(STATUS "Using miniupnpc from local source tree (/external/miniupnp/miniupnpc)")
-+  endif()
- 
--set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
--if(MSVC)
--  set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
--elseif(NOT MSVC)
--  set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
--endif()
-+  add_subdirectory(miniupnp/miniupnpc)
-+
-+  set_property(TARGET libminiupnpc-static PROPERTY FOLDER "external")
-+  if(MSVC)
-+    set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -wd4244 -wd4267")
-+  elseif(NOT MSVC)
-+    set_property(TARGET libminiupnpc-static APPEND_STRING PROPERTY COMPILE_FLAGS " -Wno-undef -Wno-unused-result -Wno-unused-value")
-+  endif()
- 
--set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
-+  set(UPNP_STATIC true PARENT_SCOPE)
-+  set(UPNP_LIBRARIES "libminiupnpc-static" PARENT_SCOPE)
-+endif()
- 
- find_package(Unbound)
- 
-diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
-index 9b21705e..76340a22 100644
---- a/src/p2p/net_node.inl
-+++ b/src/p2p/net_node.inl
-@@ -49,9 +49,16 @@
- #include "storages/levin_abstract_invoke2.h"
- #include "cryptonote_core/cryptonote_core.h"
- 
--#include <miniupnp/miniupnpc/miniupnpc.h>
--#include <miniupnp/miniupnpc/upnpcommands.h>
--#include <miniupnp/miniupnpc/upnperrors.h>
-+// We have to look for miniupnpc headers in different places, dependent on if its compiled or external
-+#ifdef UPNP_STATIC
-+  #include <miniupnp/miniupnpc/miniupnpc.h>
-+  #include <miniupnp/miniupnpc/upnpcommands.h>
-+  #include <miniupnp/miniupnpc/upnperrors.h>
-+#else
-+  #include "miniupnpc.h"
-+  #include "upnpcommands.h"
-+  #include "upnperrors.h"
-+#endif
- 
- #undef MONERO_DEFAULT_LOG_CATEGORY
- #define MONERO_DEFAULT_LOG_CATEGORY "net.p2p"
--- 
-2.16.2
-
diff --git a/gnu/packages/upnp.scm b/gnu/packages/upnp.scm
index 3f3d80f57..2d3fb4ad5 100644
--- a/gnu/packages/upnp.scm
+++ b/gnu/packages/upnp.scm
@@ -84,12 +84,12 @@ over IRC, instant messaging, network games, and most server software.")
   ;; Monero-project has been maintaining its own version of the package since
   ;; release 0.12.2.0.  It includes security fixes not included in upstream
   ;; releases.
-  (let ((revision "0")
-        (commit "6a63f9954959119568fbc4af57d7b491b9428d87"))
+  (let ((revision "1")
+        (commit "27d34098a331e4468a02adf65108bf74cae39ed7"))
     (package
       (inherit miniupnpc)
       (name "miniupnpc-monero")
-      (version (string-append "2.1-monero-0.12.3.0-" revision "."
+      (version (string-append "2.1-monero-0.14.0.2-" revision "."
                               (string-take commit 7)))
       (source (origin
                 (method git-fetch)
@@ -98,7 +98,7 @@ over IRC, instant messaging, network games, and most server software.")
                       (commit commit)))
                 (sha256
                  (base32
-                  "0s67zcz978iapjlq30yy9dl8qda9xhrl3jdi5f99cnbglh5gy16a"))
+                  "1gwnxmkcwp1za4996ycwylawyysqwcmdcskk33hfripg4pd9nv97"))
                 (file-name (string-append name "-" version "-checkout"))
                 (modules '((guix build utils)))
                 (snippet
-- 
2.19.2