Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #6003 from EOSIO/feature/bin_rel
Browse files Browse the repository at this point in the history
Binary Releases
  • Loading branch information
b1bart committed Oct 16, 2018
2 parents 920a49b + b3ef2b6 commit 22e45ae
Show file tree
Hide file tree
Showing 14 changed files with 275 additions and 10 deletions.
20 changes: 17 additions & 3 deletions CMakeLists.txt
Expand Up @@ -186,6 +186,7 @@ if(ENABLE_COVERAGE_TESTING)
find_program( GENHTML_PATH NAMES genhtml)
endif()

include(utils)
add_subdirectory( externals )

if ("${CORE_SYMBOL_NAME}" STREQUAL "")
Expand All @@ -207,7 +208,6 @@ endif()
message( STATUS "Using '${EOSIO_ROOT_KEY}' as public key for 'eosio' account" )

include(wasm)

add_subdirectory( libraries )
add_subdirectory( contracts )
add_subdirectory( plugins )
Expand Down Expand Up @@ -238,6 +238,21 @@ install(FILES ${CMAKE_BINARY_DIR}/modules/eosio-config.cmake DESTINATION ${CMAKE
configure_file(${CMAKE_SOURCE_DIR}/CMakeModules/EosioTester.cmake.in ${CMAKE_BINARY_DIR}/modules/EosioTester.cmake @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/modules/EosioTester.cmake DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR}/cmake/eosio)

configure_file(${CMAKE_SOURCE_DIR}/LICENSE
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/wabt/LICENSE
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.wabt COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/softfloat/COPYING.txt
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.softfloat COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/wasm-jit/LICENSE
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.wavm COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/fc/secp256k1/upstream/COPYING
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.secp256k1 COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/libraries/fc/src/network/LICENSE.go
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.go COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/externals/binaryen/LICENSE
${CMAKE_BINARY_DIR}/licenses/eosio/LICENSE.binaryen COPYONLY)

install(FILES LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/)
install(FILES libraries/wabt/LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.wabt)
install(FILES libraries/softfloat/COPYING.txt DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.softfloat)
Expand All @@ -246,6 +261,5 @@ install(FILES libraries/fc/secp256k1/upstream/COPYING DESTINATION ${CMAKE_INSTAL
install(FILES externals/binaryen/LICENSE DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ RENAME LICENSE.binaryen)
install(FILES libraries/fc/src/network/LICENSE.go DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/licenses/eosio/ )

include(installer)

include(package)
include(doxygen)
11 changes: 11 additions & 0 deletions CMakeModules/package.cmake
@@ -0,0 +1,11 @@
set(VENDOR "block.one")
set(PROJECT_NAME "eosio")
set(DESC "Software for the EOS.IO network")
set(URL "https://github.com/eosio/eos")
set(EMAIL "support@block.one")

configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_package.sh.in ${CMAKE_BINARY_DIR}/packages/generate_package.sh @ONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_bottle.sh ${CMAKE_BINARY_DIR}/packages/generate_bottle.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_deb.sh ${CMAKE_BINARY_DIR}/packages/generate_deb.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_rpm.sh ${CMAKE_BINARY_DIR}/packages/generate_rpm.sh COPYONLY)
configure_file(${CMAKE_SOURCE_DIR}/scripts/generate_tarball.sh ${CMAKE_BINARY_DIR}/packages/generate_tarball.sh COPYONLY)
4 changes: 4 additions & 0 deletions CMakeModules/utils.cmake
@@ -0,0 +1,4 @@
macro( copy_bin file )
add_custom_command( TARGET ${file} POST_BUILD COMMAND mkdir -p ${CMAKE_BINARY_DIR}/bin )
add_custom_command( TARGET ${file} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${file} ${CMAKE_BINARY_DIR}/bin/ )
endmacro( copy_bin )
5 changes: 4 additions & 1 deletion plugins/chain_plugin/chain_plugin.cpp
Expand Up @@ -1650,6 +1650,9 @@ read_only::get_account_results read_only::get_account( const get_account_params&

auto core_symbol = extract_core_symbol();

if (params.expected_core_symbol.valid())
core_symbol = *(params.expected_core_symbol);

const auto* t_id = d.find<chain::table_id_object, chain::by_code_scope_table>(boost::make_tuple( token_code, params.account_name, N(accounts) ));
if( t_id != nullptr ) {
const auto &idx = d.get_index<key_value_index, by_scope_primary>();
Expand Down Expand Up @@ -1783,7 +1786,7 @@ namespace detail {
}

chain::symbol read_only::extract_core_symbol()const {
symbol core_symbol; // Default to CORE_SYMBOL if the appropriate data structure cannot be found in the system contract table data
symbol core_symbol(0);

// The following code makes assumptions about the contract deployed on eosio account (i.e. the system contract) and how it stores its data.
const auto& d = db.db();
Expand Down
Expand Up @@ -36,6 +36,7 @@ namespace eosio {
using fc::optional;
using boost::container::flat_set;
using chain::asset;
using chain::symbol;
using chain::authority;
using chain::account_name;
using chain::action_name;
Expand Down Expand Up @@ -137,7 +138,8 @@ class read_only {
};

struct get_account_params {
name account_name;
name account_name;
optional<symbol> expected_core_symbol;
};
get_account_results get_account( const get_account_params& params )const;

Expand Down Expand Up @@ -697,7 +699,7 @@ FC_REFLECT( eosio::chain_apis::read_only::get_account_results,
FC_REFLECT( eosio::chain_apis::read_only::get_code_results, (account_name)(code_hash)(wast)(wasm)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_hash_results, (account_name)(code_hash) )
FC_REFLECT( eosio::chain_apis::read_only::get_abi_results, (account_name)(abi) )
FC_REFLECT( eosio::chain_apis::read_only::get_account_params, (account_name) )
FC_REFLECT( eosio::chain_apis::read_only::get_account_params, (account_name)(expected_core_symbol) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_params, (account_name)(code_as_wasm) )
FC_REFLECT( eosio::chain_apis::read_only::get_code_hash_params, (account_name) )
FC_REFLECT( eosio::chain_apis::read_only::get_abi_params, (account_name) )
Expand Down
2 changes: 2 additions & 0 deletions programs/cleos/CMakeLists.txt
Expand Up @@ -36,7 +36,9 @@ target_include_directories(${CLI_CLIENT_EXECUTABLE_NAME} PUBLIC ${Intl_INCLUDE_D

target_link_libraries( ${CLI_CLIENT_EXECUTABLE_NAME}
PRIVATE appbase chain_api_plugin producer_plugin chain_plugin http_plugin eosio_chain fc ${CMAKE_DL_LIBS} ${PLATFORM_SPECIFIC_LIBS} ${Intl_LIBRARIES} )


copy_bin( ${CLI_CLIENT_EXECUTABLE_NAME} )
install( TARGETS
${CLI_CLIENT_EXECUTABLE_NAME}

Expand Down
16 changes: 12 additions & 4 deletions programs/cleos/main.cpp
Expand Up @@ -1466,10 +1466,16 @@ struct canceldelay_subcommand {
}
};

void get_account( const string& accountName, bool json_format ) {
auto json = call(get_account_func, fc::mutable_variant_object("account_name", accountName));
auto res = json.as<eosio::chain_apis::read_only::get_account_results>();
void get_account( const string& accountName, const string& coresym, bool json_format ) {
fc::variant json;
if (coresym.empty()) {
json = call(get_account_func, fc::mutable_variant_object("account_name", accountName));
}
else {
json = call(get_account_func, fc::mutable_variant_object("account_name", accountName)("expected_core_symbol", symbol::from_string(coresym)));
}

auto res = json.as<eosio::chain_apis::read_only::get_account_results>();
if (!json_format) {
asset staked;
asset unstaking;
Expand Down Expand Up @@ -1912,11 +1918,13 @@ int main( int argc, char** argv ) {

// get account
string accountName;
string coresym;
bool print_json;
auto getAccount = get->add_subcommand("account", localized("Retrieve an account from the blockchain"), false);
getAccount->add_option("name", accountName, localized("The name of the account to retrieve"))->required();
getAccount->add_option("core-symbol", coresym, localized("The expected core symbol of the chain you are querying"));
getAccount->add_flag("--json,-j", print_json, localized("Output in JSON format") );
getAccount->set_callback([&]() { get_account(accountName, print_json); });
getAccount->set_callback([&]() { get_account(accountName, coresym, print_json); });

// get code
string codeFilename;
Expand Down
1 change: 1 addition & 0 deletions programs/keosd/CMakeLists.txt
Expand Up @@ -20,6 +20,7 @@ target_include_directories(${KEY_STORE_EXECUTABLE_NAME} PUBLIC ${CMAKE_CURRENT_B

mas_sign(${KEY_STORE_EXECUTABLE_NAME})

copy_bin( ${KEY_STORE_EXECUTABLE_NAME} )
install( TARGETS
${KEY_STORE_EXECUTABLE_NAME}

Expand Down
1 change: 1 addition & 0 deletions programs/nodeos/CMakeLists.txt
Expand Up @@ -72,6 +72,7 @@ endif()

include(additionalPlugins)

copy_bin( ${NODE_EXECUTABLE_NAME} )
install( TARGETS
${NODE_EXECUTABLE_NAME}

Expand Down
62 changes: 62 additions & 0 deletions scripts/generate_bottle.sh
@@ -0,0 +1,62 @@
#! /bin/bash

VERS=`sw_vers -productVersion | awk '/10\.13\..*/{print $0}'`
if [[ -z "$VERS" ]];
then
VERS=`sw_vers -productVersion | awk '/10\.14\..*/{print $0}'`
if [[ -z "$VERS" ]];
then
echo "Error, unsupported OS X version"
exit -1
fi
MAC_VERSION="mojave"
else
MAC_VERSION="high_sierra"
fi

NAME="${PROJECT}-${VERSION}.${MAC_VERSION}.bottle.tar.gz"

mkdir -p ${PROJECT}/${VERSION}/opt/eosio/lib/cmake

PREFIX="${PROJECT}/${VERSION}"
SPREFIX="\/usr\/local"
SUBPREFIX="opt/${PROJECT}"
SSUBPREFIX="opt\/${PROJECT}"

export PREFIX
export SPREFIX
export SUBPREFIX
export SSUBPREFIX

bash generate_tarball.sh ${NAME}

hash=`openssl dgst -sha256 ${NAME} | awk 'NF>1{print $NF}'`

echo "class Eosio < Formula
homepage \"${URL}\"
revision 0
url \"https://github.com/eosio/eos/archive/v${VERSION}.tar.gz\"
version \"${VERSION}\"
option :universal
depends_on \"gmp\"
depends_on \"gettext\"
depends_on \"openssl\"
depends_on \"gmp\"
depends_on :xcode
depends_on :macos => :high_sierra
depends_on :arch => :intel
bottle do
root_url \"https://github.com/eosio/eos/releases/download/v${VERSION}\"
sha256 \"${hash}\" => :${MAC_VERSION}
end
def install
raise \"Error, only supporting binary packages at this time\"
end
end
__END__" &> eosio.rb

rm -r ${PROJECT}
34 changes: 34 additions & 0 deletions scripts/generate_deb.sh
@@ -0,0 +1,34 @@
#! /bin/bash

NAME="${PROJECT}-${VERSION}.x86_64"
PREFIX="usr"
SPREFIX=${PREFIX}
SUBPREFIX="opt/${PROJECT}/${VERSION}"
SSUBPREFIX="opt\/${PROJECT}\/${VERSION}"

DEPS_STR=""
for dep in "${DEPS[@]}"; do
DEPS_STR="${DEPS_STR} Depends: ${dep}"
done
mkdir -p ${PROJECT}/DEBIAN
echo "Package: ${PROJECT}
Version: ${VERSION}
Section: devel
Priority: optional
Depends: libbz2-dev (>= 1.0), libssl-dev (>= 1.0), libgmp3-dev, build-essential, libicu-dev, zlib1g-dev
Architecture: amd64
Homepage: ${URL}
Maintainer: ${EMAIL}
Description: ${DESC}" &> ${PROJECT}/DEBIAN/control

export PREFIX
export SUBPREFIX
export SPREFIX
export SSUBPREFIX

bash generate_tarball.sh ${NAME}.tar.gz

tar -xvzf ${NAME}.tar.gz -C ${PROJECT}
dpkg-deb --build ${PROJECT}
mv ${PROJECT}.deb ${NAME}.deb
rm -r ${PROJECT}
35 changes: 35 additions & 0 deletions scripts/generate_package.sh.in
@@ -0,0 +1,35 @@
#! /bin/bash

VARIANT=$1

VERSION="@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@"

BUILD_DIR="@CMAKE_BINARY_DIR@"

VENDOR="@VENDOR@"
PROJECT="@PROJECT_NAME@"
DESC="@DESC@"
URL="@URL@"
EMAIL="@EMAIL@"

export BUILD_DIR
export VERSION
export VENDOR
export PROJECT
export DESC
export URL
export EMAIL

mkdir tmp

if [[ ${VARIANT} == "brew" ]]; then
bash generate_bottle.sh
elif [[ ${VARIANT} == "deb" ]]; then
bash generate_deb.sh
elif [[ ${VARIANT} == "rpm" ]]; then
bash generate_rpm.sh
else
echo "Error, unknown package type. Use either ['brew', 'deb', 'rpm']."
exit -1
fi
rm -r tmp
44 changes: 44 additions & 0 deletions scripts/generate_rpm.sh
@@ -0,0 +1,44 @@
#! /bin/bash

NAME="${PROJECT}-${VERSION}.x86_64"
PREFIX="usr"
SPREFIX=${PREFIX}
SUBPREFIX="opt/${PROJECT}/${VERSION}"
SSUBPREFIX="opt\/${PROJECT}\/${VERSION}"

export PREFIX
export SUBPREFIX
export SPREFIX
export SSUBPREFIX

bash generate_tarball.sh ${NAME}.tar.gz

RPMBUILD=`realpath ~/rpmbuild/BUILDROOT/${NAME}-0.x86_64`
mkdir -p ${RPMBUILD}
FILES=$(tar -xvzf ${NAME}.tar.gz -C ${RPMBUILD})
PFILES=""
for f in ${FILES[@]}; do
if [ -f ${RPMBUILD}/${f} ]; then
PFILES="${PFILES}/${f}\n"
fi
done
echo -e ${PFILES} &> ~/rpmbuild/BUILD/filenames.txt

mkdir -p ${PROJECT}
echo -e "Name: ${PROJECT}
Version: ${VERSION}.x86_64
License: MIT
Vendor: ${VENDOR}
Source: ${URL}
Requires: openssl-devel.x86_64, gmp-devel.x86_64, libstdc++-devel.x86_64, bzip2.x86_64, bzip2-devel.x86_64, mongodb.x86_64, mongodb-server.x86_64
URL: ${URL}
Packager: ${VENDOR} <${EMAIL}>
Summary: ${DESC}
Release: 0
%description
${DESC}
%files -f filenames.txt" &> ${PROJECT}.spec

rpmbuild -bb ${PROJECT}.spec
mv ~/rpmbuild/RPMS/x86_64 ./
rm -r ${PROJECT} ~/rpmbuild/BUILD/filenames.txt ${PROJECT}.spec
44 changes: 44 additions & 0 deletions scripts/generate_tarball.sh
@@ -0,0 +1,44 @@
#! /bin/bash

NAME=$1
EOS_PREFIX=${PREFIX}/${SUBPREFIX}
mkdir -p ${PREFIX}/bin/
#mkdir -p ${PREFIX}/lib/cmake/${PROJECT}
mkdir -p ${EOS_PREFIX}/bin
mkdir -p ${EOS_PREFIX}/licenses/eosio
#mkdir -p ${EOS_PREFIX}/include
#mkdir -p ${EOS_PREFIX}/lib/cmake/${PROJECT}
#mkdir -p ${EOS_PREFIX}/cmake
#mkdir -p ${EOS_PREFIX}/scripts

# install binaries
cp -R ${BUILD_DIR}/bin/* ${EOS_PREFIX}/bin

# install licenses
cp -R ${BUILD_DIR}/licenses/eosio/* ${EOS_PREFIX}/licenses

# install libraries
#cp -R ${BUILD_DIR}/lib/* ${EOS_PREFIX}/lib

# install cmake modules
#sed "s/_PREFIX_/\/${SPREFIX}/g" ${BUILD_DIR}/modules/EosioTesterPackage.cmake &> ${EOS_PREFIX}/lib/cmake/${PROJECT}/EosioTester.cmake
#sed "s/_PREFIX_/\/${SPREFIX}\/${SSUBPREFIX}/g" ${BUILD_DIR}/modules/${PROJECT}-config.cmake.package &> ${EOS_PREFIX}/lib/cmake/${PROJECT}/${PROJECT}-config.cmake

# install includes
#cp -R ${BUILD_DIR}/include/* ${EOS_PREFIX}/include

# make symlinks
#pushd ${PREFIX}/lib/cmake/${PROJECT} &> /dev/null
#ln -sf ../../../${SUBPREFIX}/lib/cmake/${PROJECT}/${PROJECT}-config.cmake ${PROJECT}-config.cmake
#ln -sf ../../../${SUBPREFIX}/lib/cmake/${PROJECT}/EosioTester.cmake EosioTester.cmake
#popd &> /dev/null

pushd ${PREFIX}/bin &> /dev/null
for f in `ls ${BUILD_DIR}/bin/`; do
bn=$(basename $f)
ln -sf ../${SUBPREFIX}/bin/$bn $bn
done
popd &> /dev/null

tar -cvzf $NAME ./${PREFIX}/*
rm -r ${PREFIX}

0 comments on commit 22e45ae

Please sign in to comment.