Script: fix archive_protocol.sh
This commit is contained in:
parent
30def07aee
commit
7b59161591
@ -13,9 +13,11 @@ fi
|
|||||||
|
|
||||||
version=$1
|
version=$1
|
||||||
name=${2:-alpha}
|
name=${2:-alpha}
|
||||||
|
dir_name=${3:-$name}
|
||||||
|
lib_name=`echo $dir_name | tr -- _ -`
|
||||||
|
|
||||||
if [ -z "$version" ] ; then
|
if [ -z "$version" ] ; then
|
||||||
echo "Usage: $0 NNN [alpha|genesis|...]"
|
echo "Usage: $0 NNN alpha [proto_dir]"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -30,12 +32,15 @@ trap cleanup EXIT INT
|
|||||||
|
|
||||||
mkdir "$alpha_tmpdir"/src
|
mkdir "$alpha_tmpdir"/src
|
||||||
|
|
||||||
current_hash_alpha=`jq '.hash' < src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL | tr -d '"'`
|
current_hash_alpha=`jq '.hash' < src/proto_$dir_name/lib_protocol/src/TEZOS_PROTOCOL | tr -d '"'`
|
||||||
|
|
||||||
echo "Computing the protocol hash..."
|
echo "Computing the protocol hash..."
|
||||||
|
|
||||||
cp src/proto_${name}/lib_protocol/src/*.ml src/proto_${name}/lib_protocol/src/*.mli "$alpha_tmpdir"/src/
|
cp src/proto_${dir_name}/lib_protocol/src/*.ml src/proto_${dir_name}/lib_protocol/src/*.mli "$alpha_tmpdir"/src/
|
||||||
grep -v '"hash"' < src/proto_${name}/lib_protocol/src/TEZOS_PROTOCOL > "$alpha_tmpdir"/src/TEZOS_PROTOCOL
|
sed -i --follow-symlink \
|
||||||
|
-e 's/let version_value = "[^"]*"/let version_value = "'${name}'_'${version}'"/' \
|
||||||
|
"$alpha_tmpdir"/src/raw_context.ml
|
||||||
|
grep -v '"hash"' < src/proto_${dir_name}/lib_protocol/src/TEZOS_PROTOCOL > "$alpha_tmpdir"/src/TEZOS_PROTOCOL
|
||||||
long_hash=`./tezos-protocol-compiler -hash-only $alpha_tmpdir/tmp $alpha_tmpdir/src`
|
long_hash=`./tezos-protocol-compiler -hash-only $alpha_tmpdir/tmp $alpha_tmpdir/src`
|
||||||
short_hash=$(echo $long_hash | head -c 8)
|
short_hash=$(echo $long_hash | head -c 8)
|
||||||
|
|
||||||
@ -44,36 +49,55 @@ if [ -d "src/proto_${version}_${short_hash}" ] ; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git mv src/proto_${name}/ src/proto_${version}_${short_hash}
|
git mv src/proto_${dir_name}/ src/proto_${version}_${short_hash}
|
||||||
git commit -m "Archive_protocol: rename proto_${name} into proto_${version}_${short_hash}"
|
git commit -m "Archive_protocol: rename proto_${dir_name} into proto_${version}_${short_hash}"
|
||||||
|
|
||||||
sed -i --follow-symlink \
|
sed -i --follow-symlink \
|
||||||
-e s/_${name}/_${version}_${short_hash}/g \
|
-e s/_${dir_name}/_${version}_${short_hash}/g \
|
||||||
-e s/-${name}/-${version}-${short_hash}/g \
|
-e s/-${lib_name}/-${version}-${short_hash}/g \
|
||||||
$(find -name jbuild -or -name \*.opam)
|
$(find -name jbuild -or -name \*.opam)
|
||||||
|
|
||||||
|
if ls src/proto_000_*/lib_protocol/src/TEZOS_PROTOCOL | grep proto_000_ > /dev/null ; then
|
||||||
|
proto_genesis_dir="proto_000_`ls src | grep proto_000_ | cut -f3 -d_`"
|
||||||
|
else
|
||||||
|
proto_genesis_dir="proto_genesis"
|
||||||
|
fi
|
||||||
|
|
||||||
cd "src/proto_${version}_${short_hash}"
|
cd "src/proto_${version}_${short_hash}"
|
||||||
|
|
||||||
rename s/${name}/${version}-${short_hash}/ $(find -name \*.opam)
|
rename s/${lib_name}/${version}-${short_hash}/ $(find -name \*.opam)
|
||||||
rename s/_${name}/_${version}_${short_hash}/ $(find -name main_\*.ml -or -name main_\*.mli)
|
rename s/_${dir_name}/_${version}_${short_hash}/ $(find -name main_\*.ml -or -name main_\*.mli)
|
||||||
|
|
||||||
sed -i --follow-symlink \
|
sed -i --follow-symlink \
|
||||||
-e s/Tezos_protocol_${name}/Tezos_protocol_${version}_${short_hash}/ \
|
-e s/Tezos_protocol_${dir_name}/Tezos_protocol_${version}_${short_hash}/ \
|
||||||
$(find -name \*.ml -or -name \*.mli) \
|
$(find -name \*.ml -or -name \*.mli) \
|
||||||
../proto_genesis/lib_client/proto_alpha.ml \
|
../$proto_genesis_dir/lib_client/proto_alpha.ml \
|
||||||
../lib_shell/bench/helpers/proto_alpha.ml
|
../lib_shell/bench/helpers/proto_alpha.ml
|
||||||
|
|
||||||
sed -i --follow-symlink \
|
sed -i --follow-symlink \
|
||||||
-e 's/let version_value = "[^"]*"/let version_value = "${name}_'${version}'"/' lib_protocol/src/raw_context.ml
|
-e 's/let name = "[^"]*"/let name = "'${name}'_'${version}'"/' \
|
||||||
|
lib_client/proto_alpha.ml \
|
||||||
|
lib_protocol/test/helpers/proto_alpha.ml
|
||||||
|
|
||||||
|
sed -i --follow-symlink \
|
||||||
|
-e 's/let version_value = "[^"]*"/let version_value = "'${name}'_'${version}'"/' \
|
||||||
|
lib_protocol/src/raw_context.ml
|
||||||
|
|
||||||
sed -i --follow-symlink \
|
sed -i --follow-symlink \
|
||||||
-e 's/"hash": "[^"]*",/"hash": "'$long_hash'",/' \
|
-e 's/"hash": "[^"]*",/"hash": "'$long_hash'",/' \
|
||||||
lib_protocol/src/TEZOS_PROTOCOL
|
lib_protocol/src/TEZOS_PROTOCOL
|
||||||
|
|
||||||
|
if [ $proto_genesis_dir = "proto_genesis" ] ; then
|
||||||
|
sed -i --follow-symlink \
|
||||||
|
-e "s/-genesis/-000-Ps9mPmXa/" \
|
||||||
|
-e "s/_genesis/_000_Ps9mPmXa/" \
|
||||||
|
$(find lib_delegate/test -type f)
|
||||||
|
fi
|
||||||
|
|
||||||
cd ../..
|
cd ../..
|
||||||
|
|
||||||
sed -i --follow-symlink \
|
sed -i --follow-symlink \
|
||||||
-e "s/${name}/${version}-${short_hash}/" \
|
-e "s/${lib_name}/${version}-${short_hash}/" \
|
||||||
active_protocol_versions
|
active_protocol_versions
|
||||||
|
|
||||||
find src/bin_client docs -type f -exec sed "s/$current_hash_alpha/$long_hash/g" -i {} \;
|
find src/bin_client docs -type f -exec sed "s/$current_hash_alpha/$long_hash/g" -i {} \;
|
||||||
|
Loading…
Reference in New Issue
Block a user