Added release scripts.

This commit is contained in:
Ravin Perera
2019-10-17 19:31:44 +05:30
parent fb236d44be
commit 172d41d191
7 changed files with 63 additions and 6 deletions

9
.gitignore vendored
View File

@@ -4,8 +4,9 @@
.*.sw?
.DS_Store
build/**
release/**
.vscode/**
Makefile
CMakeCache.txt
cmake_install.cmake
CMakeFiles/**
**/Makefile
**/CMakeCache.txt
**/cmake_install.cmake
**/CMakeFiles/**

51
release.sh Executable file
View File

@@ -0,0 +1,51 @@
#!/bin/bash
# Hot Pocket - create release package
if [ -z "$1" ]
then
echo "Release Version not specified."
exit 1
fi
RELVERSION="hp-${1}"
RELEASEDIR=./release/$RELVERSION
cmake . -DCMAKE_BUILD_TYPE=Release
make
rm -rf ./release
# Copy hpcore binary
mkdir -p $RELEASEDIR
cp build/hpcore $RELEASEDIR/hpcore
$RELEASEDIR/hpcore new $RELEASEDIR/echocontract
# Copy example client
mkdir $RELEASEDIR/hpclient
cp -r examples/hpclient/client.js $RELEASEDIR/hpclient
cp -r examples/hpclient/package.json $RELEASEDIR/hpclient
echo "npm install hpclient"
npm --prefix $RELEASEDIR/hpclient install > /dev/null 2>&1
# Copy example contract
CTRPATH=./bin/contract.js
CFGPATH=${RELEASEDIR}/echocontract/cfg/hp.cfg
CFGJSON=${RELEASEDIR}/echocontract/cfg/hp.json
mv $CFGPATH $CFGJSON
node -p "JSON.stringify({...require('${CFGJSON}'), binary:'/usr/bin/node', binargs:'${CTRPATH}' }, null, 2)" > $CFGPATH
rm $CFGJSON
mkdir -p $RELEASEDIR/echocontract/bin
cp -r examples/echocontract/contract.js $RELEASEDIR/echocontract/bin
cp -r examples/echocontract/package.json $RELEASEDIR/echocontract/bin
echo "npm install echocontract"
npm --prefix $RELEASEDIR/echocontract/bin install > /dev/null 2>&1
echo "Creating tarball"
tar -C ./release -czf ./release/$RELVERSION.tar.gz $RELVERSION
rm -r $RELEASEDIR
echo "Release tarball has been created at ./release/${RELVERSION}.tar.gz"
# Switch cmake back to Debug build mode
cmake . -DCMAKE_BUILD_TYPE=Debug
exit 0

View File

@@ -2,6 +2,7 @@
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <experimental/filesystem>
#include <unistd.h>
#include <sstream>
#include <fcntl.h>
@@ -96,7 +97,7 @@ int exec_contract(const ContractExecArgs &args)
close_unused_fds(false);
// Set the contract process working directory.
chdir(conf::ctx.contractDir.data());
std::experimental::filesystem::current_path(conf::ctx.contractDir);
// Write the contract input message from HotPocket to the stdin (0) of the contract process.
write_contract_args(args);
@@ -204,7 +205,11 @@ int write_contract_args(const ContractExecArgs &args)
close(stdinpipe[0]);
// Write the json message and close write fd.
write(stdinpipe[1], json.data(), json.size());
if (write(stdinpipe[1], json.data(), json.size()) == -1)
{
std::cerr << "Failed to write to stdin of contract process.\n";
return -1;
}
close(stdinpipe[1]);
return 0;