提交 0d951d80 编写于 作者: J Jonathan Giszczak 提交者: Jonathan Giszczak

Be proper UNIX citizens in expected directory hierarchy.

Support independent data and config directories in eosiod.
Start successfully on first launch whether installed or just built.
Honor EOSIO_ROOT environment variable in eosiod.
Regularize whitespace in eosiod main.cpp.
Remove cruft and fix typo in top level CMakeLists.txt.
Add support for CMake v3.6 packaging features, and emulate in older
versions.
Update skeleton contract if it changes, and install it in an eosio
directory.
Add an eosio user and group in .deb package and set appropriate
permissions.
Regularize whitespace in various CMakeLists.txt.
Add libmongoc dependency to Debian package if built with mongo support.
Add self-registration to template plugin.
Remove last reference to steemd in CMakeLists.txt.
上级 9356951b
......@@ -7,8 +7,9 @@ enable_testing()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libraries/fc/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
INCLUDE( VersionMacros )
INCLUDE( SetupTargetMacros )
include( VersionMacros )
include( SetupTargetMacros )
include( InstallDirectoryPermissions )
set( BLOCKCHAIN_NAME "Eos" )
set( CMAKE_CXX_STANDARD 14 )
......@@ -17,8 +18,8 @@ set(VERSION_MAJOR 3)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
set( CLI_CLIENT_EXECUTABLE_NAME eos_client )
set( GUI_CLIENT_EXECUTABLE_NAME eos )
set( CLI_CLIENT_EXECUTABLE_NAME eosioc )
set( GUI_CLIENT_EXECUTABLE_NAME eosio )
set( CUSTOM_URL_SCHEME "gcs" )
set( INSTALLER_APP_ID "68ad7005-8eee-49c9-95ce-9eed97e5b347" )
......@@ -114,12 +115,6 @@ if( WIN32 )
else( WIN32 ) # Apple AND Linux
find_library(READLINE_LIBRARIES NAMES readline)
find_path(READLINE_INCLUDE_DIR readline/readline.h)
#if(NOT READLINE_INCLUDE_DIR OR NOT READLINE_LIBRARIES)
# MESSAGE(FATAL_ERROR "Could not find lib readline.")
#endif()
if( APPLE )
# Apple Specific Options Here
message( STATUS "Configuring Eos on OS X" )
......@@ -165,7 +160,6 @@ if(ENABLE_COVERAGE_TESTING)
endif()
include(wasm)
include(installer)
add_subdirectory( externals )
add_subdirectory( contracts )
......@@ -175,8 +169,13 @@ add_subdirectory( programs )
add_subdirectory( scripts )
add_subdirectory( tests )
add_subdirectory( tools )
add_subdirectory( debian )
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/genesis.json ${CMAKE_CURRENT_BINARY_DIR}/genesis.json COPYONLY)
install(FILES genesis.json DESTINATION etc/eosio/node_00)
install_directory_permissions(DIRECTORY etc/eosio)
install_directory_permissions(DIRECTORY etc/eosio/node_00)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/genesis.json ${CMAKE_CURRENT_BINARY_DIR}/etc/eosio/node_00/genesis.json COPYONLY)
include(installer)
include(doxygen)
# Fix directory permissions after installation of header files (primarily).
macro(install_directory_permissions)
cmake_parse_arguments(ARG "" "DIRECTORY" "" ${ARGN})
set(dir ${ARG_DIRECTORY})
install(DIRECTORY DESTINATION ${dir}
DIRECTORY_PERMISSIONS OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
endmacro(install_directory_permissions)
include(InstallRequiredSystemLibraries)
install_directory_permissions( DIRECTORY usr/include/eosio )
set(CPACK_PACKAGE_CONTACT "support@block.one")
set(CPACK_OUTPUT_FILE_PREFIX ${CMAKE_BINARY_DIR}/packages)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install)
......@@ -11,8 +13,8 @@ set(CPACK_PACKAGE_VERSION_MAJOR "${VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_PACKAGE_DESCRIPTION "A client for the EOS.IO network")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A client for the EOS.IO network")
set(CPACK_PACKAGE_DESCRIPTION "Software for the EOS.IO network")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Software for the EOS.IO network")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_INSTALL_DIRECTORY "EOS.IO ${CPACK_PACKAGE_VERSION}")
......@@ -28,9 +30,20 @@ elseif(APPLE)
set(CPACK_GENERATOR "DragNDrop")
else()
# Linux gets a .tgz
SET(CPACK_GENERATOR "TGZ;DEB")
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1)
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_RELEASE 0)
set(CPACK_PACKAGING_INSTALL_PREFIX /)
if(CMAKE_VERSION VERSION_GREATER 3.6.0) # Buggy in 3.5, behaves like VERSION_GREATER_EQUAL
set(CPACK_DEBIAN_FILE_NAME "DEB-DEFAULT")
else()
string(TOLOWER ${CPACK_PACKAGE_NAME} CPACK_DEBIAN_PACKAGE_NAME)
execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(CPACK_PACKAGE_FILE_NAME ${CPACK_DEBIAN_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}-${CPACK_DEBIAN_PACKAGE_RELEASE}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE})
endif()
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY TRUE)
set(CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION TRUE)
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://github.com/EOSIO/eos")
endif()
include(CPack)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst" PARENT_SCOPE)
#!/bin/sh
# postinst script for eosio
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
set -e
PACKAGE="eosio"
USER="eosio"
GROUP=${USER}
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
# * <old-postinst> `abort-upgrade' <new version>
# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
# <new-version>
# * <postinst> `abort-remove'
# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
# <failed-install-package> <version> `removing'
# <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package
# source debconf library
. /usr/share/debconf/confmodule
case "$1" in
configure)
getent passwd ${USER} > /dev/null 2>&1
if [ $? -ne 0 ]; then
adduser --no-create-home --group --system ${USER}
fi
chown ${USER}:${GROUP} /var/log/${PACKAGE}
chown ${USER}:${GROUP} /var/lib/${PACKAGE}
chown ${USER}:${GROUP} /etc/${PACKAGE}
chown ${USER}:${GROUP} /etc/${PACKAGE}/node_00
chown ${USER} /usr/bin/eosiod
chmod u+s /usr/bin/eosiod
;;
abort-upgrade|abort-remove|abort-deconfigure)
exit 0
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
exit 0
......@@ -10,9 +10,9 @@ add_library( abi_generator
abi_generator.cpp
${HEADERS} )
target_include_directories( abi_generator
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${LLVM_INCLUDE_DIRS}" )
target_include_directories(abi_generator
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include"
"${LLVM_INCLUDE_DIRS}")
target_link_libraries(abi_generator eosio_chain
clangRewrite
......
Subproject commit ef2b0c8d64f770d80ce537ec04d0de4bdc4d3585
Subproject commit 26477ee10fee7272559e47539317d8141d6439b5
Subproject commit 664fdd9e79263a894794f96959612ec2d1d013d0
Subproject commit ab35dd17dc7e763aef207e4c6e3f02f6a9ad6b46
......@@ -11,3 +11,6 @@ add_subdirectory(wallet_api_plugin)
add_subdirectory(txn_test_gen_plugin)
add_subdirectory(faucet_testnet_plugin)
add_subdirectory(mongo_db_plugin)
# Forward variables to top level so packaging picks them up
set(CPACK_DEBIAN_PACKAGE_DEPENDS ${CPACK_DEBIAN_PACKAGE_DEPENDS} PARENT_SCOPE)
file(GLOB HEADERS "include/eosio/account_history_api_plugin/*.hpp")
file( GLOB HEADERS "include/eosio/account_history_api_plugin/*.hpp" )
add_library( account_history_api_plugin
account_history_api_plugin.cpp
${HEADERS} )
......
......@@ -60,7 +60,7 @@ chain_plugin::~chain_plugin(){}
void chain_plugin::set_program_options(options_description& cli, options_description& cfg)
{
cfg.add_options()
("genesis-json", bpo::value<boost::filesystem::path>(), "File to read Genesis State from")
("genesis-json", bpo::value<bfs::path>()->default_value("genesis.json"), "File to read Genesis State from")
("genesis-timestamp", bpo::value<string>(), "override the initial timestamp in the Genesis State file")
("block-log-dir", bpo::value<bfs::path>()->default_value("blocks"),
"the location of the block log (absolute path or relative to application data dir)")
......@@ -93,7 +93,11 @@ void chain_plugin::plugin_initialize(const variables_map& options) {
ilog("initializing chain plugin");
if(options.count("genesis-json")) {
my->genesis_file = options.at("genesis-json").as<bfs::path>();
auto genesis = options.at("genesis-json").as<bfs::path>();
if(genesis.is_relative())
my->genesis_file = app().config_dir() / genesis;
else
my->genesis_file = genesis;
}
if(options.count("genesis-timestamp")) {
string tstr = options.at("genesis-timestamp").as<string>();
......
......@@ -63,6 +63,8 @@ if(BUILD_MONGO_DB_PLUGIN)
PUBLIC chain_plugin eosio_chain appbase
${EOS_LIBMONGOCXX} ${EOS_LIBBSONCXX}
)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libmongoc-1.0-0 (>= 1.3)" PARENT_SCOPE)
else()
message("mongo_db_plugin not selected and will be omitted.")
endif()
......@@ -4,4 +4,4 @@ add_library( net_plugin
${HEADERS} )
target_link_libraries( net_plugin chain_plugin producer_plugin appbase fc )
target_include_directories( net_plugin PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" )
target_include_directories( net_plugin PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include )
......@@ -5,6 +5,7 @@
#include <eosio/template_plugin/template_plugin.hpp>
namespace eosio {
static appbase::abstract_plugin& _template_plugin = app().register_plugin<template_plugin>();
class template_plugin_impl {
public:
......
......@@ -15,7 +15,7 @@ target_link_libraries( debug_node
install( TARGETS
debug_node
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
......@@ -22,7 +22,7 @@ target_link_libraries(eosio-abigen abi_generator)
install( TARGETS
eosio-abigen
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
......@@ -20,9 +20,9 @@ add_custom_command(TARGET eosio-applesedemo POST_BUILD
install( TARGETS
eosio-applesedemo
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
endif(APPLE)
......@@ -34,7 +34,7 @@ target_link_libraries(eosio-launcher
install( TARGETS
eosio-launcher
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
......@@ -38,7 +38,7 @@ target_link_libraries( eosioc
install( TARGETS
eosioc
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
......@@ -58,7 +58,27 @@ endif()
install( TARGETS
eosiod
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
install(DIRECTORY DESTINATION var/log/eosio
DIRECTORY_PERMISSIONS OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_WRITE
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
install(DIRECTORY DESTINATION var/lib/eosio
DIRECTORY_PERMISSIONS OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_WRITE
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
......@@ -12,6 +12,7 @@
#include <fc/log/appender.hpp>
#include <fc/exception/exception.hpp>
#include <boost/dll/runtime_symbol_info.hpp>
#include <boost/exception/diagnostic_information.hpp>
#include "config.hpp"
......@@ -27,62 +28,87 @@ namespace detail {
void configure_logging(const bfs::path& config_path)
{
try {
try {
fc::configure_logging(config_path);
} catch (...) {
elog("Error reloading logging.json");
throw;
}
} catch (const fc::exception& e) {
elog("${e}", ("e",e.to_detail_string()));
} catch (const boost::exception& e) {
elog("${e}", ("e",boost::diagnostic_information(e)));
} catch (const std::exception& e) {
elog("${e}", ("e",e.what()));
} catch (...) {
// empty
}
try {
try {
fc::configure_logging(config_path);
} catch (...) {
elog("Error reloading logging.json");
throw;
}
} catch (const fc::exception& e) {
elog("${e}", ("e",e.to_detail_string()));
} catch (const boost::exception& e) {
elog("${e}", ("e",boost::diagnostic_information(e)));
} catch (const std::exception& e) {
elog("${e}", ("e",e.what()));
} catch (...) {
// empty
}
}
} // namespace detail
void logging_conf_loop()
{
std::shared_ptr<boost::asio::signal_set> sighup_set(new boost::asio::signal_set(app().get_io_service(), SIGHUP));
sighup_set->async_wait([sighup_set](const boost::system::error_code& err, int /*num*/) {
if(!err)
{
ilog("Received HUP. Reloading logging configuration.");
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
::detail::configure_logging(config_path);
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
logging_conf_loop();
}
});
std::shared_ptr<boost::asio::signal_set> sighup_set(new boost::asio::signal_set(app().get_io_service(), SIGHUP));
sighup_set->async_wait([sighup_set](const boost::system::error_code& err, int /*num*/) {
if(!err)
{
ilog("Received HUP. Reloading logging configuration.");
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
::detail::configure_logging(config_path);
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
logging_conf_loop();
}
});
}
void initialize_logging()
{
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
fc::configure_logging(config_path); // intentionally allowing exceptions to escape
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
auto config_path = app().get_logging_conf();
if(fc::exists(config_path))
fc::configure_logging(config_path); // intentionally allowing exceptions to escape
for(auto iter : fc::get_appender_map())
iter.second->initialize(app().get_io_service());
logging_conf_loop();
}
logging_conf_loop();
bfs::path determine_root_directory()
{
bfs::path root;
char* path = std::getenv("EOSIO_ROOT");
if(path != nullptr)
root = bfs::path(path);
else {
bfs::path p = boost::dll::program_location();
while(p != p.root_directory()) {
p = p.parent_path();
if(exists(p / "etc")) {
root = p;
break;
}
}
if(p == p.root_directory())
root = p;
}
return root;
}
int main(int argc, char** argv)
{
try {
app().set_version(eosio::eosiod::config::version);
bfs::path root = determine_root_directory();
app().set_default_data_dir(root / "var/lib/eosio/node_00");
app().set_default_config_dir(root / "etc/eosio/node_00");
if(!app().initialize<chain_plugin, http_plugin, net_plugin>(argc, argv))
return -1;
initialize_logging();
ilog("eosiod version ${ver}", ("ver", eosio::eosiod::config::itoh(static_cast<uint32_t>(app().version()))));
ilog("eosio root is ${root}", ("root", root.string()));
app().startup();
app().exec();
} catch (const fc::exception& e) {
......
......@@ -18,7 +18,7 @@ target_link_libraries( eosiowd
install( TARGETS
eosiowd
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION usr/bin
LIBRARY DESTINATION usr/lib
ARCHIVE DESTINATION usr/lib
)
configure_file( eosiocpp.in eosiocpp @ONLY)
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eosiocpp DESTINATION bin/ PERMISSIONS WORLD_EXECUTE OWNER_EXECUTE GROUP_EXECUTE WORLD_READ GROUP_READ OWNER_READ )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/eosiocpp DESTINATION usr/bin
PERMISSIONS OWNER_READ
OWNER_WRITE
OWNER_EXECUTE
GROUP_READ
GROUP_EXECUTE
WORLD_READ
WORLD_EXECUTE
)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册