From 9484944ab9be3d59d598dd3cb477090932e36845 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Mon, 10 Feb 2020 17:28:18 -0500 Subject: [PATCH] read web version of release.txt before downloading resolves #330 --- webapp/install-mts.sh | 24 ++++++++++++- webapp/reset-minetest-install-source.sh | 46 +++++++++++++++++++++++++ webapp/versionize.sh | 45 ++++++++++++++++++++---- 3 files changed, 107 insertions(+), 8 deletions(-) diff --git a/webapp/install-mts.sh b/webapp/install-mts.sh index 2d82397..1e93661 100755 --- a/webapp/install-mts.sh +++ b/webapp/install-mts.sh @@ -15,6 +15,27 @@ $1 END exit 1 } +customWarn() { + cat < /dev/tty0 # beep (You must specify a tty path if not in console mode) + echo "Press Ctrl+C to cancel..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "3..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "2..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "1..." + sleep 1 +} install_git_mod_here(){ git_url="$1" @@ -162,6 +183,7 @@ END end=`date +%s` compile_time=$((end-start)) echo "Compiling the program finished in $compile_time seconds." + cp release.txt minetest/ | customWarn "Cannot copy `pwd`/release.txt to `pwd`/minetest/" else echo "* using existing minetest..." fi @@ -453,7 +475,7 @@ fi popd settings_dump="`pwd`/settings-dump.txt" settings_types_list="`pwd`/settingtypes-list.txt" -#grep -r `pwd`/linux-minetest-kit/minetest/games/Bucket_Game -e "setting_get" > $settings_dump +# grep -r `pwd`/linux-minetest-kit/minetest/games/Bucket_Game -e "setting_get" > $settings_dump pushd linux-minetest-kit/minetest/games if [ ! -f "$settings_dump" ]; then echo "Creating $settings_dump..." diff --git a/webapp/reset-minetest-install-source.sh b/webapp/reset-minetest-install-source.sh index 93e483e..cd2cb26 100755 --- a/webapp/reset-minetest-install-source.sh +++ b/webapp/reset-minetest-install-source.sh @@ -14,12 +14,58 @@ in_use_name=minetest # killall $in_use_name #fi url=https://downloads.minetest.org +release_txt_url=http://downloads.minetest.org/release.txt +customWarn() { + cat < /dev/tty0 # beep (You must specify a tty path if not in console mode) + echo "Press Ctrl+C to cancel..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "3..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "2..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "1..." + sleep 1 +} customDie () { echo "ERROR: Cannot continue since" echo "$1" exit 1 } +available_release_line=`curl http://downloads.minetest.org/release.txt | head -n 1` +# echo "Release data: $available_release_line" # "Release *" where * is YYMMDD +# See +available_version=$(echo $available_release_line | awk '{print $2}') +# OR: available_version="${available_release_line##* }" # get second word +if [ ${#available_version} -ne 6 ]; then + customDie "The available version is not recognized: $available_version" +fi +installed_release_line=`head -n 1 ~/minetest/release.txt` +installed_version=$(echo $installed_release_line | awk '{print $2}') +compiled_release_line=`head -n 1 ~/minetest/release.txt` +compiled_version=$(echo $compiled_release_line | awk '{print $2}') +echo "installed_version: $installed_version" +echo "compiled_version: $compiled_version" +echo "available_version: $available_version" +if [ "@$installed_version" = "@$available_version" ]; then + echo "You already have the latest version installed." + exit 1 +fi +if [ "@$compiled_version" -ne "@$installed_version" ]; then + echo "ERROR: You have not yet installed version $compiled_version which you already compiled (you have installed $installed_version)." + echo "You should run ./install-mts.sh instead (with --client option if you want more than minetestserver)" + exit 2 +fi enable_offline=false for var in "$@" do diff --git a/webapp/versionize.sh b/webapp/versionize.sh index d9d7ff3..0f04970 100755 --- a/webapp/versionize.sh +++ b/webapp/versionize.sh @@ -16,6 +16,27 @@ if [ -z "$original_src_path" ]; then echo "You must specify a zip file path OR directory path." exit 1 fi +customWarn() { + cat < /dev/tty0 # beep (You must specify a tty path if not in console mode) + echo "Press Ctrl+C to cancel..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "3..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "2..." + sleep 1 + echo -en "\a" > /dev/tty0 + echo "1..." + sleep 1 +} customDie() { echo echo "ERROR:" @@ -75,17 +96,24 @@ elif [ -d "$try_path" ]; then else customDie "$try_path is not a file or directory." fi -if [ ! -f "$src_path/release.txt" ]; then - echo - echo - echo "* '$src_path' remains$destroy_msg." - customDie "Missing $src_path/release.txt" +release_txt_path="$src_path/minetest/release.txt" +if [ ! -f "$release_txt_path" ]; then + try_release_txt_path="$src_path/release.txt" + if [ ! -f "$try_release_txt_path" ]; then + echo + echo + echo "* '$src_path' remains$destroy_msg." + customDie "Missing $release_txt_path (or $src_path/release.txt)" + else + echo "Missing $release_txt_path (usually copied from $try_release_txt_path by EnlivenMinetest compille script(s)); reverting to $try_release_txt_path" + release_txt_path="$try_release_txt_path" + fi fi -release_line="`head -n 1 $src_path/release.txt`" +release_line="`head -n 1 $release_txt_path`" version="${release_line##* }" # get second word version_len=${#version} if [ "$version_len" -ne "6" ]; then - customDie "Unexpected version scheme (not 6 characters): '$version'" + customDie "Unexpected version scheme (not 6 characters): '$version' near '$release_line' in file $release_txt_path" fi echo "src_name=$src_name" echo "src_path=$src_path" @@ -103,6 +131,9 @@ if [ ! -z "$src_archive" ]; then extension="${filename##*.}" filename="${filename%.*}" dst_archive="$versions_path/$filename-$version.$extension" + if [ -f "$dst_archive" ]; then + customWarn "This will overwrite '$dst_archive' with '$src_archive'." + fi if [ -f "$src_archive" ]; then mv "$src_archive" "$dst_archive" || customDie "Cannot mv '$src_archive' '$dst_archive'" echo "* moved archive to '$dst_archive'"