From f98a088e1cb585344c3199ce868472e826dced8e Mon Sep 17 00:00:00 2001 From: linj Date: Fri, 23 Feb 2024 13:59:44 +0800 Subject: [PATCH] make pkg --- Makefile | 7 +++++- genconfig.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) create mode 100755 genconfig.sh diff --git a/Makefile b/Makefile index 60821713c..e733ad4f8 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ BUILD_FLAGS := -ldflags '-X "github.com/assetcloud/plugin/version.GitCommit=$(Gi MKPATH=$(abspath $(lastword $(MAKEFILE_LIST))) MKDIR=$(dir $(MKPATH)) proj := "build" -.PHONY: default dep all build release cli linter race test fmt vet bench msan coverage coverhtml docker docker-compose protobuf clean help autotest +.PHONY: default dep all build release cli linter race test fmt vet bench msan coverage coverhtml docker docker-compose protobuf clean help autotest pkg default: depends build @@ -37,6 +37,11 @@ build_ci: depends ## Build the binary file for CI @cp chain.toml build/ @cp chain.para.toml build/ci/paracross/ +pkg: + rm assetchain-qbft assetchain-qbft.tgz -rf + mkdir assetchain-qbft + cp build/chain build/chain-cli chain.para.toml genconfig.sh assetchain-qbft + tar zcfv assetchain-qbft.tgz assetchain-qbft PLATFORM_LIST = \ darwin-amd64 \ diff --git a/genconfig.sh b/genconfig.sh new file mode 100755 index 000000000..65d25f971 --- /dev/null +++ b/genconfig.sh @@ -0,0 +1,64 @@ +#!/bin/bash + +set -x +config="chain.para.toml" + +function genConfig() { + echo -e "start auto modify config" + + peerArray=$1 + num=$2 + + validatorNodes="" + seeds="" + for((i=0;i<$num;i++)); + do + validatorNodes=${validatorNodes},\""${peerArray[$i]}:33001"\" + seeds=${seeds},"\"${peerArray[$i]}:13801\"" + done + validatorNodes=$(echo $validatorNodes|sed '/^,/s///g') + seeds=$(echo $seeds|sed '/^,/s///g') + + sed -i "s/^validatorNodes=.*/validatorNodes=[${validatorNodes}]/g" ${config} + sed -i "s/^seeds=.*/seeds=[${seeds}]/g" ${config} + for((i=0;i<$num;i++)); + do + rm -rf ${peerArray[$i]} + mkdir -p ${peerArray[$i]} + cp ${config} ${peerArray[$i]}/${config} + done + +} + +function prepareChainPkg() { + echo -e "start prepare chain33 files" + + peerArray=$1 + num=$2 + + ./chain-cli qbft gen_file -n $num -t bls + + for((i=0;i<$num;i++)); + do + cp priv_validator_$i.json ${peerArray[$i]}/priv_validator.json + cp genesis_file.json ${peerArray[$i]}/genesis.json + cp chain ${peerArray[$i]}/chain + cp chain-cli ${peerArray[$i]}/chain-cli + done + +} + +function main() { + peers=$1 + + peerArray=(${peers//,/ }) + + peerNum=${#peerArray[*]} + + genConfig $peerArray $peerNum + + prepareChainPkg $peerArray $peerNum +} + +main $1 +