You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
101 lines
3.1 KiB
101 lines
3.1 KiB
#!/bin/bash
|
|
|
|
# tag.sh - script to automate the checkpointing and packaging process
|
|
# Copyright (C) 2020 wowario
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
# install jq (brew install jq | apt-get install jq)
|
|
# for mac, intall gnu sed with: brew install gnu-sed
|
|
# and echo 'export PATH="/usr/local/opt/gnu-sed/libexec/gnubin:$PATH"' >> ~/.bashrc
|
|
# run wownerod --detach and sync up before running script
|
|
|
|
# set parameter as version
|
|
version=$1
|
|
|
|
# error out if version not set
|
|
if [ $# -eq 0 ]; then
|
|
echo "include version as a parameter (./tag.sh 0.8.0.2)"
|
|
exit 1
|
|
fi
|
|
|
|
# OS check
|
|
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
|
|
wowdir=/home/ubuntu/wownero
|
|
platform=Linux_v
|
|
usrdir=/home/ubuntu
|
|
wowdir=/home/ubuntu/wownero
|
|
release=release-static-linux-x86_64
|
|
elif [[ "$OSTYPE" == "darwin"* ]]; then
|
|
platform=macOS_v
|
|
usrdir=/Users/administrator
|
|
wowdir=/Users/administrator/gits/wownero
|
|
release=release-static-mac-x86_64
|
|
else
|
|
echo "Unknown OS"
|
|
fi
|
|
|
|
# echo version to tag
|
|
echo "Building tagged version: wownero_$platform$version"
|
|
|
|
# logging
|
|
exec > >(tee -i $usrdir/logs/tag.log)
|
|
exec 2>&1
|
|
|
|
# update repo
|
|
echo "Updating repo"
|
|
cd $wowdir
|
|
rm -rf build
|
|
git checkout .
|
|
git fetch --all
|
|
git pull
|
|
|
|
# checkpoint
|
|
cd $usrdir/utilities/
|
|
./wownerod status
|
|
echo "Checkpointing"
|
|
height=$(curl -s http://127.0.0.1:34568/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"get_info"}' -H 'Content-Type: application/json' | jq -r '.result.height')
|
|
echo "Starting height: $height"
|
|
declare -i value
|
|
value=$height-60
|
|
echo "Roll back 60 blocks. New height: $value"
|
|
sha1=$(sha256sum $wowdir/src/blocks/checkpoints.dat | awk '{print $1}')
|
|
echo "Old SHA-256: $sha1"
|
|
rm -rf $wowdir/src/blocks/checkpoints.dat
|
|
./wownero-blockchain-export --blocksdat --block-stop $value --output-file $wowdir/src/blocks/checkpoints.dat &
|
|
sleep 20s
|
|
sha2=$(sha256sum $wowdir/src/blocks/checkpoints.dat | awk '{print $1}')
|
|
echo "New SHA-256: $sha2"
|
|
cd $wowdir/src/cryptonote_core/
|
|
sed -i "s/$sha1/$sha2/g" blockchain.cpp
|
|
cd $wowdir
|
|
git status
|
|
git diff
|
|
|
|
# build Wownero
|
|
echo "Building Wownero"
|
|
USE_SINGLE_BUILDDIR=1 make -j3 $release > /dev/null 2>&1
|
|
|
|
# archive binaries
|
|
echo "taring the binaries"
|
|
cd $wowdir/build/release/bin
|
|
tar -cvjSf wownero_$platform$version.tar.bz2 *
|
|
sha256sum $wowdir/build/release/bin/wownero_$platform$version.tar.bz2
|
|
|
|
# copy archive file to release folder
|
|
echo -e "\e[42mmoving tar file to release folder"
|
|
mv $wowdir/build/release/bin/wownero_$platform$version.tar.bz2 $usrdir/release/wownero_$platform$version.tar.bz2
|
|
sha256sum $usrdir/release/wownero_$platform$version.tar.bz2
|
|
echo "done!"
|