Browse Source

read web version of release.txt before downloading

resolves #330
master
poikilos 5 years ago
committed by Jacob Gustafson
parent
commit
9484944ab9
  1. 22
      webapp/install-mts.sh
  2. 46
      webapp/reset-minetest-install-source.sh
  3. 39
      webapp/versionize.sh

22
webapp/install-mts.sh

@ -15,6 +15,27 @@ $1
END
exit 1
}
customWarn() {
cat <<END
WARNING:
$1
END
echo -en "\a" > /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

46
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 <<END
WARNING:
$1
END
echo -en "\a" > /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 <https://unix.stackexchange.com/questions/174037/extracting-the-second-word-from-a-string-variable>
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

39
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 <<END
WARNING:
$1
END
echo -en "\a" > /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
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 $src_path/release.txt"
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'"

Loading…
Cancel
Save