From 53c3d1cf2a77580dcac65829d8a1ecd0606de4aa Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Thu, 6 Feb 2014 19:22:10 +0000 Subject: [PATCH] Some additional debian build stuff fixed for alethzero rename. CMake install executables with make install. --- CMakeLists.txt | 2 +- alethzero/CMakeLists.txt | 1 + debian/control | 4 ++-- debian/rules | 4 +--- eth/CMakeLists.txt | 3 +++ libethereum/PeerNetwork.cpp | 36 ++++++++++++++++++++++++++---------- 6 files changed, 34 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5dd4c0928..be0b668d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ project(ethereum) -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 2.8.9) set(CMAKE_AUTOMOC ON) diff --git a/alethzero/CMakeLists.txt b/alethzero/CMakeLists.txt index 7e50a171c..f94896671 100644 --- a/alethzero/CMakeLists.txt +++ b/alethzero/CMakeLists.txt @@ -14,3 +14,4 @@ qt5_wrap_ui(ui_Main.h Main.ui) qt5_use_modules(alethzero Widgets Network ) target_link_libraries(alethzero ethereum) +install( TARGETS alethzero RUNTIME DESTINATION bin ) diff --git a/debian/control b/debian/control index a37384015..a54315c18 100644 --- a/debian/control +++ b/debian/control @@ -22,8 +22,8 @@ Depends: libethereum (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}, Description: The future of computational social contracts. Dev Files. A long description of libethereum. Dev Files. -Package: alephzero +Package: alethzero Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends}, libethereum (= ${binary:Version}), qtbase5 Description: The Qt-based Ethereum GUI. - A long description of alephzero. + A long description of alethzero. diff --git a/debian/rules b/debian/rules index 3202a570b..5ffe813ee 100755 --- a/debian/rules +++ b/debian/rules @@ -22,11 +22,9 @@ export DH_OPTIONS override_dh_auto_configure: cmake -DCMAKE_INSTALL_PREFIX=$(CURDIR)/debian/libethereum-dev/usr . - cd alephzero && qmake alephzero.pro INCLUDEPATH=$(CURDIR) QMAKE_LIBDIR=$(CURDIR)/libethereum override_dh_auto_build: $(MAKE) -j8 - cd alephzero && $(MAKE) -j8 override_dh_auto_install: $(MAKE) install @@ -34,5 +32,5 @@ override_dh_auto_install: mkdir -p $(CURDIR)/debian/libethereum/usr mv $(CURDIR)/debian/libethereum-dev/usr/lib $(CURDIR)/debian/libethereum/usr/lib mkdir -p $(CURDIR)/debian/alephzero/usr/bin - install -m 755 -s alephzero/alephzero $(CURDIR)/debian/alephzero/usr/bin + mv $(CURDIR)/debian/libethereum-dev/usr/bin/alethzero $(CURDIR)/debian/alethzero/usr/lib diff --git a/eth/CMakeLists.txt b/eth/CMakeLists.txt index 0676b34fe..9f082595b 100644 --- a/eth/CMakeLists.txt +++ b/eth/CMakeLists.txt @@ -17,3 +17,6 @@ target_link_libraries(eth gmp) target_link_libraries(eth boost_system) target_link_libraries(eth boost_filesystem) target_link_libraries(eth ${CMAKE_THREAD_LIBS_INIT}) + +install( TARGETS eth RUNTIME DESTINATION bin ) + diff --git a/libethereum/PeerNetwork.cpp b/libethereum/PeerNetwork.cpp index eed687caa..1148caf91 100644 --- a/libethereum/PeerNetwork.cpp +++ b/libethereum/PeerNetwork.cpp @@ -606,8 +606,10 @@ struct UPnP string externalIP() { char addr[16]; - UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, addr); - return addr; + if (!UPNP_GetExternalIPAddress(urls.controlURL, data.first.servicetype, addr)) + return addr; + else + return "0.0.0.0"; } int addRedirect(char const* addr, int port) @@ -695,7 +697,7 @@ struct UPnP class NoNetworking: public std::exception {}; -PeerServer::PeerServer(std::string const& _clientVersion, BlockChain const& _ch, uint _networkId, short _port, NodeMode _m, string const& _publicAddress): +PeerServer::PeerServer(std::string const& _clientVersion, BlockChain const& _ch, uint _networkId, short _port, NodeMode _m, string const& _publicAddress, bool _upnp): m_clientVersion(_clientVersion), m_mode(_m), m_listenPort(_port), @@ -705,7 +707,7 @@ PeerServer::PeerServer(std::string const& _clientVersion, BlockChain const& _ch, m_requiredNetworkId(_networkId) { populateAddresses(); - determinePublic(_publicAddress); + determinePublic(_publicAddress, _upnp); ensureAccepting(); if (m_verbosity) cout << "Mode: " << (_m == NodeMode::PeerServer ? "PeerServer" : "Full") << endl; @@ -732,12 +734,14 @@ PeerServer::~PeerServer() delete m_upnp; } -void PeerServer::determinePublic(string const& _publicAddress) +void PeerServer::determinePublic(string const& _publicAddress, bool _upnp) { - m_upnp = new UPnP; - if (m_upnp->isValid() && m_peerAddresses.size()) + if (_upnp) + m_upnp = new UPnP; + + bi::tcp::resolver r(m_ioService); + if (m_upnp && m_upnp->isValid() && m_peerAddresses.size()) { - bi::tcp::resolver r(m_ioService); cout << "external addr: " << m_upnp->externalIP() << endl; int p = m_upnp->addRedirect(m_peerAddresses[0].to_string().c_str(), m_listenPort); if (!p) @@ -747,15 +751,27 @@ void PeerServer::determinePublic(string const& _publicAddress) p = m_listenPort; } - if (m_upnp->externalIP() == string("0.0.0.0") && _publicAddress.empty()) + auto eip = m_upnp->externalIP(); + if (eip == string("0.0.0.0") && _publicAddress.empty()) m_public = bi::tcp::endpoint(bi::address(), p); else { - auto it = r.resolve({_publicAddress.empty() ? m_upnp->externalIP() : _publicAddress, toString(p)}); + auto it = r.resolve({_publicAddress.empty() ? eip : _publicAddress, toString(p)}); m_public = it->endpoint(); m_addresses.push_back(m_public.address().to_v4()); } } + else + { + // No UPnP - fallback on given public address or, if empty, the assumed peer address. + if (_publicAddress.size()) + m_public = r.resolve({_publicAddress, toString(m_listenPort)})->endpoint(); + else if (m_peerAddresses.size()) + m_public = r.resolve({m_peerAddresses[0].to_string(), toString(m_listenPort)})->endpoint(); + else + m_public = bi::tcp::endpoint(bi::address(), m_listenPort); + m_addresses.push_back(m_public.address().to_v4()); + } /* int er; UPNPDev* dlist = upnpDiscover(250, 0, 0, 0, 0, &er); for (UPNPDev* d = dlist; d; d = dlist->pNext)