From 3a90bade7634e6a416edf083a36172de3fe57ab2 Mon Sep 17 00:00:00 2001 From: poikilos <7557867+poikilos@users.noreply.github.com> Date: Thu, 7 May 2020 20:04:54 -0400 Subject: [PATCH] Migrate installers to minetestenv-in-place.rc resolves #390 resolves #382 resolves #339 --- changelog.md | 21 ++ install-mts.sh | 521 ++++++------------------------ minetestenv-in-place.rc | 644 +++++++++++++++++++++++++++++++++---- update-minetest-linux64.sh | 361 ++++++--------------- versionize.sh | 35 +- 5 files changed, 796 insertions(+), 786 deletions(-) diff --git a/changelog.md b/changelog.md index aadb4c7..b38d95d 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,27 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +## [git] - 2020-05-07 +### Changed +- Make both `install-minetest-linux64.sh` and + `install-mts.sh` use `minetestenv-in-place.rc` +- Test and fix `minetestenv-in-place.rc`. +- Rename variables. + + +## [git] - 2020-05-07 +### Added +- bash script library (`minetestenv-in-place.rc`) + +### Changed +- Move most shared functionality to `minetestenv-in-place.sh`. +- Rename variables. + +### Removed +- sponge mod (since coderblocks now has one) + + + ## [git] - 2020-03-29 ### Added - Add "Linux Server Install or Upgrade" section to diff --git a/install-mts.sh b/install-mts.sh index e34b3b1..4fe01fa 100755 --- a/install-mts.sh +++ b/install-mts.sh @@ -1,153 +1,71 @@ #!/bin/bash +clear me=`basename "$0"` echo echo echo -echo "Starting install..." -MY_NAME="install-mts.sh" -EM_CONFIG_PATH="$HOME/.config/EnlivenMinetest" -date - -customExit() { - errorCode=1 - if [ ! -z "$2" ]; then - errorCode="$2" - fi - 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_shortcut(){ - enable_clear_icon_cache=false - - _SRC_SHORTCUT_PATH=$1 - _DST_SHORTCUT_NAME=$2 - # _CAPTION is optional (original "Name" is kept if not specified) - _EXEC=$3 - _WORKING_DIR=$4 - _ICON=$5 - _CAPTION=$6 - dest_icons=$HOME/.local/share/applications - dest_icon=$dest_icons/$_DST_SHORTCUT_NAME - if [ ! -d "$dest_icons" ]; then - mdkir -p "$dest_icons" || customExit "mkdir -p \"$dest_icons\" failed." - fi - # if [ -f "$dest_icon" ]; then - # comment since never fixes broken icon anyway - # TODO: fixed bad cache even if icon was rewritten properly after written improperly - # * not tried yet: - # * rm $HOME/.kde/share/config/kdeglobals - # enable_clear_icon_cache=true - # fi - echo "Writing icon '$dest_icon'..." - if [ ! -z "$_ICON" ]; then - cat "$_SRC_SHORTCUT_PATH" | grep -v Icon | grep -v Path | grep -v Exec > "$dest_icon" - else - cat "$_SRC_SHORTCUT_PATH" | grep -v Path | grep -v Exec > "$dest_icon" - fi - # Icon must be an absolute path (other variables use $HOME in - # desktop file above), so exclude it above and rewrite it below: - echo "Path=$dest_programs/minetest/bin" >> "$dest_icon" - if [ ! -z "$_ICON" ]; then - echo "Icon=$_ICON" >> "$dest_icon" +scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc +if [ -f "$EM_CONFIG_PATH/scripting.rc" ]; then + echo "* [$MT_ENV_RUP_NAME] using $scripting_rc_path..." + source $scripting_rc_path +fi +if [ -z "$REPO_PATH" ]; then + REPO_PATH="$HOME/git/EnlivenMinetest" +fi +MT_BASH_RC_NAME="minetestenv-in-place.rc" +CURRENT_MT_SCRIPTS_DIR="$HOME/.local/bin" +MT_BASH_RC_PATH="$CURRENT_MT_SCRIPTS_DIR/$MT_BASH_RC_NAME" +TRY_CURRENT_MT_SCRIPTS_DIR="$REPO_PATH" +TRY_MT_BASH_RC_PATH="$TRY_CURRENT_MT_SCRIPTS_DIR/$MT_BASH_RC_NAME" +if [ -f "$TRY_MT_BASH_RC_PATH" ]; then + CURRENT_MT_SCRIPTS_DIR="$TRY_CURRENT_MT_SCRIPTS_DIR" + MT_BASH_RC_PATH="$TRY_MT_BASH_RC_PATH" +#fi +#if [ ! -f "$MT_BASH_RC_PATH" ]; then +else + if [ ! -d "$CURRENT_MT_SCRIPTS_DIR" ]; then + mkdir -p "$CURRENT_MT_SCRIPTS_DIR" fi - echo "Exec=$_EXEC" >> "$dest_icon" - if [ "@$enable_clear_icon_cache" = "@true" ]; then - if [ -f "`command -v gnome-shell`" ]; then - echo "Refreshing Gnome icons..." - gnome-shell --replace & disown - sleep 10 - fi - if [ -f "$HOME/.cache/icon-cache.kcache" ]; then - echo "clearing $HOME/.cache/icon-cache.kcache..." - rm $HOME/.cache/icon-cache.kcache - fi - if [ -f "`command -v kquitapp5`" ]; then - echo "Refreshing KDE icons..." - if [ "`command -v kstart5`" ]; then - kquitapp5 plasmashell && kstart5 plasmashell - else - kquitapp5 plasmashell && kstart plasmashell - fi - sleep 15 - fi - if [ -f "`command -v xfce4-panel`" ]; then - echo "Refreshing Xfce icons..." - xfce4-panel -r && xfwm4 --replace - sleep 5 - fi - if [ -f "`command -v lxpanelctl`" ]; then - echo "Refreshing LXDE icons..." - lxpanelctl restart && openbox --restart - sleep 5 - fi + MT_BASH_RC_URL=https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/$MT_BASH_RC_NAME + curl $MT_BASH_RC_URL -o "$MT_BASH_RC_PATH" + if [ $? -ne 0 ]; then + echo + echo "ERROR: Downloading $MT_BASH_RC_URL to $MT_BASH_RC_PATH failed." + echo + sleep 10 + exit 1 fi -} +fi +if [ ! -f "$MT_BASH_RC_PATH" ]; then + echo + echo "$MT_BASH_RC_PATH is not present." + echo + sleep 10 + exit 1 +fi +source $MT_BASH_RC_PATH # ^ same as install-minetest-linux64.sh -install_git_mod_here(){ - git_url="$1" - mod_name="$2" - if [ -z "$git_url" ]; then - customExit "install_git_mod_here requires a URL." - fi - if [ -z "$mod_name" ]; then - customExit "install_git_mod_here requires a mod name as the second parameter." - fi - if [ ! -d "$mod_name" ]; then - git clone "$git_url" "$mod_name" - else - cd "$mod_name" || customExit "(install_git_mod_here) 'cd \"$mod_name\"' failed in '`pwd`'" - echo "* updating '`pwd`' from git..." - git pull || echo "WARNING: (install_git_mod_here) 'git pull' failed in '`pwd`'" - cd .. || customExit "(install_git_mod_here) 'cd ..' failed in '`pwd`'" - fi -} +INSTALL_MTS_NAME="install-mts.sh" + +echo "* starting install from source..." +date + enable_server=true dest_programs="$HOME" #NOTE: $HOME is still used further down, for $HOME/.* and $HOME/i_am_dedicated_minetest_server flag file (which can be empty) #TODO: change $HOME/i_am_dedicated_minetest_server to $HOME/.config/EnlivenMinetest/i_am_dedicated_minetest_server or rc file -extracted_name="linux-minetest-kit" -extracted_path="$EM_CONFIG_PATH/$extracted_name" -cd "$EM_CONFIG_PATH" || customExit "[$MY_NAME] cd \"$EM_CONFIG_PATH\" failed." -flag_dir_rel="$extracted_name/mtsrc" -code_flag_dir_path="$extracted_path/mtsrc" +EXTRACTED_SRC_NAME="linux-minetest-kit" +# EM_CONFIG_PATH is from "minetestenv-in-place.rc". +EXTRACTED_SRC_PATH="$EM_CONFIG_PATH/$EXTRACTED_SRC_NAME" +cd "$EM_CONFIG_PATH" || customExit "[$INSTALL_MTS_NAME] cd \"$EM_CONFIG_PATH\" failed." +flag_dir_rel="$EXTRACTED_SRC_NAME/mtsrc" +code_flag_dir_path="$EXTRACTED_SRC_PATH/mtsrc" if [ -z "$CUSTOM_SCRIPTS_PATH" ]; then CUSTOM_SCRIPTS_PATH="$HOME" fi MT_POST_INSTALL_SCRIPT_1=archive-minetestserver-debug.sh -scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc +# scripting_rc_path is set in minetestenv-in-place.rc if [ -z "$MT_POST_INSTALL_SCRIPT_2" ]; then MT_POST_INSTALL_SCRIPT_2="mts.sh" if [ -f "$CUSTOM_SCRIPTS_PATH/mts-CenterOfTheSun.sh" ]; then @@ -170,20 +88,7 @@ if [ -z "$ENABLE_CLIENT" ]; then ENABLE_CLIENT=false fi - - -if [ -f "$EM_CONFIG_PATH/scripting.rc" ]; then - echo "Using $scripting_rc_path..." - source $scripting_rc_path - # may contain any variables above, plus: - # * enable_run_after_compile: if true, then run the server, such as - # ~/mts-CenterOfTheSun.sh -else - echo "* skipping $scripting_rc_path (not present)" - echo " (can contain settings such as enable_run_after_compile=true)" -fi - -pushd "$extracted_path" || customExit "pushd \"$extracted_path\" failed in \"`pwd`\"" +#pushd "$EXTRACTED_SRC_PATH" || customExit "pushd \"$EXTRACTED_SRC_PATH\" failed in \"`pwd`\"" extra_options="" for var in "$@" @@ -192,8 +97,10 @@ do ENABLE_CLIENT=true elif [ "@$var" = "@--clean" ]; then enable_clean=true + echo "* --clean is deprecated." elif [ "@$var" = "@--noclean" ]; then enable_clean=false + echo "* --noclean is deprecated." else customExit "Invalid argument: $var" fi @@ -203,11 +110,12 @@ if [ -z "$enable_clean" ]; then enable_clean=true fi -echo "enable_clean=\"$enable_clean\"..." +# echo "enable_clean=\"$enable_clean\"..." + # flag_icon="$HOME/Desktop/org.minetest.minetest.desktop" -good_src_mts="$extracted_path/minetest/bin/minetestserver" -good_src_mt="$extracted_path/minetest/bin/minetest" +good_src_mts="$EXTRACTED_SRC_PATH/minetest/bin/minetestserver" +good_src_mt="$EXTRACTED_SRC_PATH/minetest/bin/minetest" this_src_flag_path="$good_src_mts" good_dst_mts="$dest_programs/minetest/bin/minetestserver" good_dst_mt="$dest_programs/minetest/bin/minetest" @@ -274,13 +182,13 @@ END fi start=`date +%s` - cd "$extracted_path" || customExit "cd \"$extracted_path\" failed." + cd "$EXTRACTED_SRC_PATH" || customExit "cd \"$EXTRACTED_SRC_PATH\" failed." if [ -f "mtcompile-program.pl" ]; then # perl mtcompile-program.pl build >& program.log echo "Compiling via perl (this may take a while--output redirected to `pwd`/program.log)..." perl mtcompile-program.pl build --server $extra_options >& program.log else - # NOTE: no pl in $extracted_name, assuming bash: + # NOTE: no pl in $EXTRACTED_SRC_NAME, assuming bash: if [ -f mtcompile-program.sh ]; then echo "Compiling via bash (this may take a while--output redirected to `pwd`/program.log)..." bash -e mtcompile-program.sh build --server $extra_options >& program.log @@ -288,7 +196,7 @@ END echo echo "ERROR: Install cannot finish since there is no" echo " mtcompile-program.pl nor mtcompile-program.pl" - echo " in the extracted $extracted_name directory." + echo " in the extracted $EXTRACTED_SRC_NAME directory." echo echo fi @@ -296,12 +204,12 @@ END end=`date +%s` compile_time=$((end-start)) echo "Compiling the program finished in $compile_time seconds." - cp $extracted_path/release.txt $extracted_path/minetest/ || customWarn "Cannot copy $extracted_path/release.txt to $extracted_path/minetest/" + cp $EXTRACTED_SRC_PATH/release.txt $EXTRACTED_SRC_PATH/minetest/ || customWarn "Cannot copy $EXTRACTED_SRC_PATH/release.txt to $EXTRACTED_SRC_PATH/minetest/" else - echo "* using existing $extracted_path/minetest..." + echo "* using existing $EXTRACTED_SRC_PATH/minetest..." fi if [ ! -f "$this_src_flag_path" ]; then - customExit "The build did not complete since '$this_src_flag_path' is missing. Maybe you didn't compile the libraries. Running reset-minetest-install-source.sh should do that automatically, but you can also do: cd $extracted_path && ./mtcompile-libraries.sh build" + customExit "The build did not complete since '$this_src_flag_path' is missing. Maybe you didn't compile the libraries. Running reset-minetest-install-source.sh should do that automatically, but you can also do: cd $EXTRACTED_SRC_PATH && ./mtcompile-libraries.sh build" fi if [ -f "$this_dst_flag_path" ]; then mv -f "$this_dst_flag_path" "$this_dst_flag_path.bak" @@ -309,283 +217,37 @@ fi if [ -f "$this_dst_flag_path" ]; then customExit "Install is incomplete because it can't move '$this_dst_flag_path'." fi -if [ ! -d "$extracted_path/minetest" ]; then - customExit "Install is incomplete because \"$extracted_path/minetest\" is missing." -fi -virtual_dest="$dest_programs/minetest" -link_target=`readlink $virtual_dest` -# install_dest="/tank/local/owner/minetest" -install_dest="$virtual_dest" -dest_official_game="$dest_programs/minetest/games/Bucket_Game" -dest_enliven="$dest_programs/minetest/games/ENLIVEN" -skins_dst="$dest_enliven/mods/codercore/coderskins/textures" -skins_bak="$HOME/Backup/ENLIVEN/mods/codercore/coderskins/textures" -official_game_mod_list="coderbuild codercore coderedit coderfood codermobs decorpack mtmachines" -dest_enliven_mods="$dest_enliven/mods" -if [ "@$enable_clean" = "@true" ]; then - echo "* cleaning destination..." - if [ -d "$dest_official_game" ]; then - echo " - erasing '$dest_official_game'..." - rm -Rf "$dest_official_game" - fi - if [ -d "$dest_enliven" ]; then - if [ -d "$skins_dst" ]; then - echo " - Backing up '$skins_dst' to '$skins_bak'..." - if [ ! -d "$skins_bak" ]; then - mkdir -p "$skins_bak" || customExit "* cannot create $skins_bak" - fi - rsync -rt "$skins_dst/" "$skins_bak" - fi - for var in $official_game_mod_list - do - if [ -d "$dest_enliven_mods/$var" ]; then - echo " - erasing '$dest_enliven_mods/$var'..." - rm -Rf "$dest_enliven_mods/$var" || customExit "rm -Rf \"$dest_enliven_mods/$var\" failed" - # See rsync further down for installation of each of these - else - echo " - already clean: no '$dest_enliven_mods/$var'..." - fi - done - fi +if [ ! -d "$EXTRACTED_SRC_PATH/minetest" ]; then + customExit "Install is incomplete because \"$EXTRACTED_SRC_PATH/minetest\" is missing." fi -enliven_warning="" -if [ -d "$dest_enliven_mods" ]; then - pushd "$dest_enliven_mods" || customExit "'pushd \"$dest_enliven_mods\"' failed." - install_git_mod_here https://github.com/BenjieFiftysix/sponge.git sponge - install_git_mod_here https://github.com/poikilos/metatools.git metatools - install_git_mod_here https://github.com/MinetestForFun/fishing.git fishing - install_git_mod_here https://github.com/minetest-mods/throwing.git throwing - install_git_mod_here https://github.com/minetest-mods/ccompass.git ccompass - install_git_mod_here https://github.com/minetest-mods/throwing_arrows.git throwing_arrows - popd || customExit "'popd' failed." -else - enliven_warning="$enliven_warning* WARNING: Installing ENLIVEN mods was skipped since '$dest_enliven_mods' does not exist." -fi -if [ ! -z "$link_target" ]; then - install_dest="$link_target" - echo "* detected that $virtual_dest is a symlink to $link_target" - echo " (redirecting rsync to prevent symlink to dir conversion: installing to $install_dest" - echo " and recreating symlink '$virtual_dest' pointing to '$install_dest')..." - rsync -rt "$extracted_path/minetest/" "$install_dest" || customExit "Cannot rsync files from installer data $extracted_path/minetest/ to $install_dest" - if [ ! -d "$dest_programs/minetest" ]; then - echo "* creating link to $install_dest directory as $dest_programs/minetest..." - ln -s "$install_dest" "$dest_programs/minetest" - fi -else - echo "Installing \"$extracted_path/minetest\" directory to \"$dest_programs\"..." - rsync -rt --info=progress2 $extracted_path/minetest/ $install_dest || customExit "Cannot rsync files from installer data $extracted_path/minetest/ to $install_dest" -fi -if [ ! -f "$this_dst_flag_path" ]; then - customExit "ERROR: not complete--couldn't install binary as '$this_dst_flag_path'" -fi -dst_game_flag_dir_path="$dest_official_game" -if [ ! -d "$dst_game_flag_dir_path" ]; then - customExit "ERROR: missing $dst_game_flag_dir_path" -fi -if [ ! -d "$dest_programs/minetest/games/ENLIVEN" ]; then - echo "Copying $dst_game_flag_dir_path to $dest_programs/minetest/games/ENLIVEN..." - cp -R "$dst_game_flag_dir_path" "$dest_programs/minetest/games/ENLIVEN" - echo "name = ENLIVEN" > "$dest_programs/minetest/games/ENLIVEN/game.conf" -else - - for mod_name in $official_game_mod_list - do - echo " - updating $mod_name from '$dst_game_flag_dir_path/mods/$mod_name' to '$dest_programs/minetest/games/ENLIVEN/mods'..." - rsync -rt --delete "$dst_game_flag_dir_path/mods/$mod_name" "$dest_programs/minetest/games/ENLIVEN/mods" - done - # cp -f "$dst_game_flag_dir_path/mods/LICENSE" "$dest_programs/minetest/games/ENLIVEN/mods/LICENSE" - if [ -d "$skins_bak" ]; then - echo " - restoring skins from '$skins_bak'..." - rsync -rt "$skins_bak/" "$skins_dst" - fi -fi -popd - -# pushd .. # go from EnlivenMinetest/webapp to EnlivenMinetest -# PATCHES_DIR_NAME="patches" -if [ -z "$REPO_PATH" ]; then - REPO_PATH="$HOME/git/EnlivenMinetest" -fi -PATCHES_PATH="$REPO_PATH/patches" -if [ -d "$PATCHES_PATH" ]; then - # pushd "$REPO_PATH" - -src="$PATCHES_PATH/subgame/menu" -dst="$dest_programs/minetest/games/ENLIVEN/menu" -echo "updating '$dst' from '$src/'..." -rsync -rt "$src/" "$dst" - -src="$PATCHES_PATH/Bucket_Game-patched" -dst="$dest_programs/minetest/games/ENLIVEN" -echo "updating '$dst' from '$src/'..." -rsync -rt "$src/" "$dst" -if [ -d "$dst/mods/coderfood/food_basic/etc" ]; then - rm -Rf "$dst/mods/coderfood/food_basic/etc" -fi - -minetest_conf_dest="$dest_programs/minetest/minetest.conf" -game_minetest_conf_dest="$dest_programs/minetest/games/ENLIVEN/minetest.conf" - -# Bucket_Game doesn't come with a minetest.conf, only minetest.conf.example* files -# if [ ! -f "$dest_programs/minetest/minetest.Bucket_Game-example.conf" ]; then -# cp -f "$$minetest_conf_dest" "$dest_programs/minetest/minetest.Bucket_Game-example.conf" -# fi - -client_example_dest="$dest_programs/minetest/minetest.ENLIVEN.client-example.conf" - -echo "Installing minetest.ENLIVEN.*-example.conf files..." -cp -f "$PATCHES_PATH/subgame/minetest.LAN-client-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.LAN-client-example.conf" || customExit "Cannot copy minetest.ENLIVEN.LAN-client-example.conf" -cp -f "$PATCHES_PATH/subgame/minetest.server-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.server-example.conf" || customExit "Cannot copy minetest.ENLIVEN.server-example.conf" -cp -f "$PATCHES_PATH/subgame/minetest.client-example.conf" "$dest_programs/minetest/minetest.ENLIVEN.client-example.conf" || customExit "Cannot copy minetest.ENLIVEN.client-example.conf" - -echo "Writing '$game_minetest_conf_dest'..." -cp -f "$PATCHES_PATH/subgame/minetest.conf" "$game_minetest_conf_dest" - -# client conf writing only ever happens once, unless you manually delete $minetest_conf_dest: -if [ ! -f "$minetest_conf_dest" ]; then - # if [ -f "$minetest_conf_dest" ]; then - # echo "Backing up minetest.conf..." - # if [ ! -f "$minetest_conf_dest.1st" ]; then - # cp -f "$minetest_conf_dest" "$minetest_conf_dest.1st" - # else - # cp -f "$minetest_conf_dest" "$minetest_conf_dest.bak" - # fi - # fi - echo "Writing minetest.conf (client region)..." - cp -f "$PATCHES_PATH/subgame/minetest.client-example.conf" "$minetest_conf_dest" || customExit "Cannot copy minetest.client-example.conf to $minetest_conf_dest" - echo "Appending example settings (server region) to '$minetest_conf_dest'..." - cat "$PATCHES_PATH/subgame/minetest.server-example.conf" >> "$minetest_conf_dest" || customExit "Cannot append minetest.server-example.conf" -else - echo "$minetest_conf_dest exists (remove it if you want the installer to write an example version)" -fi - - -if [ -f "$minetest_conf_dest" ]; then - cat << END -NOTE: minetest.org releases allow you to put a world.conf file in your - world, so that is the file you should edit manually in your world - --this installer overwrites $minetest_conf_dest and - worlds/CenterOfTheSun settings (the author Poikilos' world). - Continue to place server settings such as announce in - $minetest_conf_dest. - Leave $game_minetest_conf_dest intact, as it defines the game. - If you have suggestions for changes or configurability, please use the - issue tracker at . - -END -fi - - -world_override_src="overrides/CenterOfTheSun/minetest/worlds/CenterOfTheSun" -world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" -world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" -try_world_override_dst="$HOME/minetest/worlds/CenterOfTheSun" -if [ -d "$try_world_override_dst" ]; then - world_override_dst="$try_world_override_dst" -fi -world_conf_src="$world_override_src/world.conf" -world_conf_dst="$world_override_dst/world.conf" -world_mt_src="$world_override_src/world.mt" -world_mt_dst="$world_override_dst/world.mt" -override_more="overrides/CenterOfTheSun/games/ENLIVEN" -appends="overrides/CenterOfTheSun/append" -minetest_conf_append="$appends/minetest.conf" -if [ -d "$world_override_dst" ]; then - echo "You have the CenterOfTheSun world. Listing any changes..." - if [ -f "$world_conf_src" ]; then - if [ -f "$world_conf_dst" ]; then - echo " * overwrite $world_conf_dst with $world_conf_src" - else - echo " * add the world.conf from $world_conf_src" - fi - cp -f "$world_conf_src" "$world_conf_dst" - fi - if [ -f "$minetest_conf_append" ]; then - cat "$minetest_conf_append" >> "$minetest_conf_dest" - fi -fi - - - - -if [ "@$ENABLE_CLIENT" = "@true" ]; then - #params: _SRC_SHORTCUT_PATH, _DST_SHORTCUT_NAME, _EXEC, _WORKING_DIR, _ICON, _CAPTION: - SHORTCUT_PATH="$PATCHES_PATH/deploy-patched/misc/org.minetest.minetest.desktop" - EXEC_PATH="$dest_programs/minetest/bin/minetest" - WORKING_DIR_PATH="$dest_programs/minetest/bin" - MT_ICON="$dest_programs/minetest/misc/minetest-xorg-icon-128.png" - install_shortcut "$SHORTCUT_PATH" "org.minetest.minetest.desktop" "$EXEC_PATH" "$WORKING_DIR_PATH" "$MT_ICON" "Final Minetest" -fi - -if [ -f $dest_programs/minetest/games/ENLIVEN/mods/codermobs/codermobs/animal_materials.lua ]; then - if [ -d $PATCHES_PATH/mods-stopgap/animal_materials_legacy ]; then - echo "* installing animal_materials_legacy (only needed for worlds created with old versions of Bucket_Game)" - rsync -rt $PATCHES_PATH/mods-stopgap/animal_materials_legacy $dest_programs/minetest/games/ENLIVEN/mods/ - else - echo "* MISSING $PATCHES_PATH/mods-stopgap/animal_materials" - fi -else - echo "* SKIPPING a stopgap mod since no animal_materials" -fi - -if [ -f $dest_programs/minetest/games/ENLIVEN/mods/codermobs/codermobs/elk.lua ]; then - if [ -d $PATCHES_PATH/mods-stopgap/elk_legacy ]; then - echo "* installing elk_legacy (only needed for worlds created with old versions of Bucket_Game)" - rsync -rt $PATCHES_PATH/mods-stopgap/elk_legacy $dest_programs/minetest/games/ENLIVEN/mods/ - else - echo "* MISSING $PATCHES_PATH/mods-stopgap/elk_legacy" - fi -else - echo "* SKIPPING a stopgap mod since no elk.lua" -fi - -if [ -d "$dest_programs/minetest/games/ENLIVEN/mods/coderbuild/nftools" ]; then - if [ -d $PATCHES_PATH/mods-stopgap/nftools_legacy ]; then - echo "* installing nftools_legacy (only needed for worlds created with old versions of Bucket_Game)" - rsync -rt $PATCHES_PATH/mods-stopgap/nftools_legacy $dest_programs/minetest/games/ENLIVEN/mods/ - else - echo "* MISSING $PATCHES_PATH/mods-stopgap/nftools_legacy" - fi -else - echo "* SKIPPING a stopgap mod since no nftools" -fi - -# popd -else - cat < $settings_dump -pushd linux-minetest-kit/minetest/games -if [ ! -f "$settings_dump" ]; then - echo "Creating $settings_dump..." - grep -r Bucket_Game -e "setting_get" > $settings_dump - grep -r Bucket_Game -e "minetest.settings:get" >> $settings_dump -else - echo "* $settings_dump was already created" -fi -if [ ! -f "$settings_types_list" ]; then - echo "Creating $settings_types_list..." - find Bucket_Game -name "settingtypes.txt" > $settings_types_list -else - echo "* $settings_types_list was already created" -fi -popd echo "* finished compiling." -if [ -f "$extracted_path/release.txt" ]; then - versionLine=`cat $extracted_path/release.txt | grep Release` - echo " - version: $versionLine" -fi +INSTALL_PATH="$HOME/minetest" +echo "* installing Minetest..." +if [ -z "$EM_TMP" ]; then + customWarn "EM_TMP was not set." + EM_TMP="/tmp/EnlivenMintest" +fi +tmp_mt_copy=$EM_TMP/minetest +if [ -d "$tmp_mt_copy" ]; then + echo "* removing old $tmp_mt_copy..." + rm -Rf "$tmp_mt_copy" || customExit "rm -Rf \"$tmp_mt_copy\" failed." +fi +old_release_line= +old_release_version= +detect_installed_mt_version "1st" "bak" +echo "* making temporary copy at $tmp_mt_copy..." +cp -R "$EXTRACTED_SRC_PATH/minetest" "$tmp_mt_copy" +detect_mt_version_at "$tmp_mt_copy" +installOrUpgradeMinetest "$tmp_mt_copy" "$INSTALL_PATH" +echo " - old:$old_release_version; new:$new_release_version" +echo "* installing ENLIVEN..." +installOrUpgradeENLIVEN "$INSTALL_PATH" +echo "* analyzing settings..." +analyzeGameSettings $EXTRACTED_SRC_PATH/minetest/games/Bucket_Game + if [ "@$enable_run_after_compile" = "@true" ]; then echo "Trying to run minetest or other custom post-install script" echo "(enable_run_after_compile is true in '$scripting_rc_path')." @@ -609,7 +271,7 @@ ERROR: enable_run_after_compile is true, but '$scripting_rc_path' END fi - popd + #popd else cat < /dev/tty0 # beep (You must specify a tty path if not in console mode) - echo "Press Ctrl+C to cancel..." + #echo "Press Ctrl+C to cancel..." sleep 1 - echo -en "\a" > /dev/tty0 + #echo -en "\a" > /dev/tty0 echo "3..." sleep 1 - echo -en "\a" > /dev/tty0 + #echo -en "\a" > /dev/tty0 echo "2..." sleep 1 - echo -en "\a" > /dev/tty0 + #echo -en "\a" > /dev/tty0 echo "1..." sleep 1 } @@ -80,7 +119,7 @@ install_shortcut(){ fi # Icon must be an absolute path (other variables use $HOME in # desktop file above), so exclude it above and rewrite it below: - echo "Path=$dest_programs/minetest/bin" >> "$dest_icon" + echo "Path=$_WORKING_DIR" >> "$dest_icon" if [ ! -z "$_CAPTION" ]; then echo "Name=$_CAPTION" >> "$dest_icon" fi @@ -128,16 +167,16 @@ install_mt_in_place_shortcut(){ # valid Minetest ".desktop" file. # You must either set INSTALL_PATH or the second parameter to a # valid installed minetest directory (containing bin). - if [ ! -f "$SHORTCUT_PATH" ]; then + #if [ ! -f "$SHORTCUT_PATH" ]; then if [ ! -z "$1" ]; then SHORTCUT_PATH="$1" fi - fi - if [ ! -d "$INSTALL_PATH" ]; then + #fi + #if [ ! -d "$INSTALL_PATH" ]; then if [ ! -z "$2" ]; then INSTALL_PATH="$2" fi - fi + #fi if [ ! -f "$SHORTCUT_PATH" ]; then echo "* WARNING: The SHORTCUT_PATH $SHORTCUT_PATH does not exist." elif [ ! -d "$INSTALL_PATH" ]; then @@ -165,16 +204,17 @@ upgradeAndMerge(){ # 1. UPGRADE_TYPE: a minetest subdirectory such as "worlds" # 2. INSTALL_PATH: a valid installed copy of minetest # 3. OLD_VERSION_PATH: a valid old installed copy of minetest - # 4. (optional) "inplace" to copy instead of move and to only affect - # OLD_VERSION_PATH such as for: + # 4. (optional) "inplace" to copy instead of "move" and to only + # affect OLD_VERSION_PATH such as for: # upgradeAndMerge "mods" "$INSTALL_PATH/games/Bucket_Game" "$INSTALL_PATH/games/ENLIVEN" "inplace" if [ ! -z "$1" ]; then # worlds, games, or something else UPGRADE_TYPE="$1" fi + upgrades_base_path="$INSTALL_PATH" if [ ! -z "$2" ]; then # ~/minetest or - INSTALL_PATH="$2" + upgrades_base_path="$2" fi if [ ! -z "$3" ]; then OLD_VERSION_PATH="$3" @@ -183,43 +223,65 @@ upgradeAndMerge(){ if [ ! -z "$4" ]; then UPGRADE_MODE="$4" fi - if [ ! -d "$INSTALL_PATH/$UPGRADE_TYPE" ]; then - customExit "* WARNING: The $UPGRADE_TYPE upgrade will be skipped since the UPGRADE_TYPE directory \"$UPGRADE_TYPE\" is not present in the INSTALL_PATH \"$INSTALL_PATH\"." + if [ ! -d "$upgrades_base_path/$UPGRADE_TYPE" ]; then + customExit "* WARNING: The $UPGRADE_TYPE upgrade will be skipped since the UPGRADE_TYPE directory \"$UPGRADE_TYPE\" is not present in the upgrades_base_path \"$upgrades_base_path\"." else - echo "* upgrading $UPGRADE_TYPE" - for SUB_PATH in `find $INSTALL_PATH/$UPGRADE_TYPE -maxdepth 1` + #echo "* upgrading $UPGRADE_TYPE" + for SUB_PATH in `find $upgrades_base_path/$UPGRADE_TYPE -maxdepth 1` do SUB_NAME="`basename $SUB_PATH`" - if [ "$SUB_PATH" = "$INSTALL_PATH/$UPGRADE_TYPE" ]; then - echo " * examining $SUB_PATH..." + if [ "$SUB_PATH" = "$upgrades_base_path/$UPGRADE_TYPE" ]; then + echo " * upgrading $SUB_PATH..." elif [ -d "$SUB_PATH" ]; then - echo " * upgrading $SUB_NAME..." + if [ "@$QUIET" != "@true" ]; then + echo " * upgrading $SUB_NAME..." + fi if [ -d "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" ]; then # Remove the old version (the one to upgrade and # keep if $UPGRADE_MODE is not move, otherwise the - # one to upgrade and later move to INSTALL_PATH!) + # one to upgrade and later move to upgrades_base_path!) rm -Rf "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "* rm -Rf \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" failed." if [ "@$UPGRADE_MODE" = "@move" ]; then - mv "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "mv \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\"" + #if [ "@$QUIET" != "@true" ]; then + # echo " - moving $SUB_PATH..." + #fi + mv "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "mv \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" failed for the SUB_PATH directory on the destination" else - cp -R "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "cp -R \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\"" + cp -R "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "cp -R \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" failed for the SUB_PATH directory on the destination" + fi + else + if [ "@$UPGRADE_MODE" = "@move" ]; then + #echo " - moving $SUB_PATH..." + if [ ! -d "$OLD_VERSION_PATH/$UPGRADE_TYPE" ]; then + mkdir -p "$OLD_VERSION_PATH/$UPGRADE_TYPE" + fi + mv "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "mv \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" for the SUB_PATH directory that is not on the destination." + # ^ so that rmdir doesn't fail below. fi fi else - echo " * upgrading $SUB_NAME..." + if [ "@$QUIET" != "@true" ]; then + echo " * upgrading $SUB_NAME..." + fi if [ "@$UPGRADE_MODE" = "@move" ]; then - mv -f "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "mv \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\"" + #if [ "@$QUIET" != "@true" ]; then + # echo " - moving $SUB_PATH..." + #fi + if [ ! -d "$OLD_VERSION_PATH/$UPGRADE_TYPE" ]; then + mkdir -p "$OLD_VERSION_PATH/$UPGRADE_TYPE" || customExit "mkdir -p \"$OLD_VERSION_PATH/$UPGRADE_TYPE\" failed for the SUB_PATH file on the destination." + fi + mv -f "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "mv \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" failed for the SUB_PATH file on the destination" else - cp -f "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "cp \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\"" + cp -f "$SUB_PATH" "$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME" || customExit "cp \"$SUB_PATH\" \"$OLD_VERSION_PATH/$UPGRADE_TYPE/$SUB_NAME\" failed for the SUB_PATH file on the destination" fi fi done if [ "@$UPGRADE_MODE" = "@move" ]; then - rmdir "$INSTALL_PATH/$UPGRADE_TYPE" || customExit "rmdir \"$INSTALL_PATH/$UPGRADE_TYPE\" failed." - mv "$OLD_VERSION_PATH/$UPGRADE_TYPE" "$INSTALL_PATH/" || customExit "mv \"$OLD_VERSION_PATH/$UPGRADE_TYPE\" \"$INSTALL_PATH/\"" - echo " * $OLD_VERSION_PATH/$UPGRADE_TYPE is now upgraded and moved to \"$INSTALL_PATH/$UPGRADE_TYPE\"." - else - echo " * $OLD_VERSION_PATH is now upgraded in place (\"$INSTALL_PATH/$UPGRADE_TYPE\" was left untouched as expected)." + rmdir "$upgrades_base_path/$UPGRADE_TYPE" || customExit "rmdir \"$upgrades_base_path/$UPGRADE_TYPE\" failed while upgrading \"$OLD_VERSION_PATH\"." + mv "$OLD_VERSION_PATH/$UPGRADE_TYPE" "$upgrades_base_path/" || customExit "mv \"$OLD_VERSION_PATH/$UPGRADE_TYPE\" \"$upgrades_base_path/\"" + # echo " * $OLD_VERSION_PATH/$UPGRADE_TYPE is now upgraded and moved to \"$upgrades_base_path/$UPGRADE_TYPE\"." + #else + #echo " * $OLD_VERSION_PATH has been upgraded in place (\"$upgrades_base_path/$UPGRADE_TYPE\" remains untouched)." fi fi } @@ -262,9 +324,12 @@ installOrUpgradeMinetest(){ # You must set the following variables or sequential parameters: # 1. NEW_VERSION_PATH # 2. INSTALL_PATH - # 3. VERSIONED_MT_PATH (a path that does not yet exist but will - # store the old version temporarily until user data is moved - # to the new version and other data is deleted) + # 3. (optional) VERSIONED_MT_PATH (a path that does not yet exist + # but will store the old version temporarily until user data is + # moved to the new version and other data is deleted). + # If not set, it will become $INSTALL_PATH.$new_release_version + # ($new_release_version must be present, and is set above by + # this rc file). if [ ! -z "$1" ]; then NEW_VERSION_PATH="$1" fi @@ -273,10 +338,54 @@ installOrUpgradeMinetest(){ fi if [ ! -z "$3" ]; then VERSIONED_MT_PATH="$3" + else + if [ -z "$old_release_version" ]; then + customExit "old_release_version was not detected. This should never happen (it should at least be 1st or bak or something)." + fi + if [ -z "$INSTALL_PATH" ]; then + customExit "INSTALL_PATH was not detected. This should never happen." + fi + VERSIONED_MT_PATH="$INSTALL_PATH.$old_release_version" + echo " * [installOrUpgradeMinetest] using $VERSIONED_MT_PATH for remnants" + fi + install_dest="$INSTALL_PATH" + # ^ make a separate variable since it will change if a symlink + if [ -z "$this_dst_flag_path" ]; then + this_dst_flag_path="$INSTALL_PATH/bin/minetest" + fi + + #rsync -rt --info=progress2 "$EXTRACTED_SRC_PATH/minetest/" "$install_dest" || customExit "Cannot rsync files from installer data $EXTRACTED_SRC_PATH/minetest/ to $install_dest" + if [ -z "$new_release_version" ]; then + customExit "You must call detect_mt_version_at such as 'detect_mt_version_at \"$NEW_VERSION_PATH\"' before running installOrUpgradeMinetest." + fi + #echo "Checking $new_release_version..." + if [ "@$new_release_version" = "@new" ]; then + customWarn "The new version wasn't detected properly (using \"new\")" + else + echo " - installing or upgrading using version $new_release_version..." fi + if [ -d "$NEW_VERSION_PATH" ]; then - # cd "$HOME" || customExit "cd \"$HOME\" failed." - if [ -d "$INSTALL_PATH" ]; then + virtual_dest="$install_dest" + link_target=`readlink $virtual_dest` + # install_dest="/tank/local/owner/minetest" + #install_dest="$virtual_dest" + ENABLE_RELINK=false + if [ ! -z "$link_target" ]; then + ENABLE_RELINK=true + if [ ! -d "$link_target" ]; then + customExit "The link \"$virtual_dest\" points to a directory that does not exist: \"$link_target\"" + fi + install_dest="$link_target" + echo "* detected that $virtual_dest is a symlink to $link_target" + echo " (redirecting rsync to prevent symlink to dir conversion: installing to $install_dest" + echo " and recreating symlink '$virtual_dest' pointing to '$install_dest')..." + else + echo "Installing \"$EXTRACTED_SRC_PATH/minetest\" directory as \"$install_dest\"..." + fi + + + if [ -d "$install_dest" ]; then if [ -z "$VERSIONED_MT_PATH" ]; then customExit "You must specify the VERSIONED_MT_PATH (such as \"$HOME/minetest.bak\" or another unused directory) to retain and merge the old version's user data since the old version exists." fi @@ -290,71 +399,119 @@ installOrUpgradeMinetest(){ if [ ! -f "`command -v find`" ]; then customExit "Install cannot continue because the find command is not present." fi - mv "$INSTALL_PATH" "$VERSIONED_MT_PATH" - mv "$NEW_VERSION_PATH" "$INSTALL_PATH" + mv "$install_dest" "$VERSIONED_MT_PATH" + mv "$NEW_VERSION_PATH" "$install_dest" - moveIfExists "$VERSIONED_MT_PATH/client/serverlist/favoriteservers.txt" "$NEW_VERSION_PATH/client/serverlist/favoriteservers.txt" + #moveIfExists "$VERSIONED_MT_PATH/client/serverlist/favoriteservers.txt" "$install_dest/client/serverlist/favoriteservers.txt" + moveIfExists "$VERSIONED_MT_PATH/client/serverlist/favoriteservers.txt" "$install_dest/client/serverlist/favoriteservers.txt" if [ -d "$VERSIONED_MT_PATH/client/serverlist" ]; then rmdir --ignore-fail-on-non-empty "$VERSIONED_MT_PATH/client/serverlist" fi - upgradeAndMerge "client" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "clientmods" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "games" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "worlds" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "mods" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "textures" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - upgradeAndMerge "media" "$INSTALL_PATH/cache" "$VERSIONED_MT_PATH/cache" + upgradeAndMerge "client" "$install_dest" "$VERSIONED_MT_PATH" + upgradeAndMerge "clientmods" "$install_dest" "$VERSIONED_MT_PATH" + upgradeAndMerge "games" "$install_dest" "$VERSIONED_MT_PATH" + upgradeAndMerge "worlds" "$install_dest" "$VERSIONED_MT_PATH" + upgradeAndMerge "mods" "$install_dest" "$VERSIONED_MT_PATH" + PREV_QUIET="$QUIET" + QUIET=true + upgradeAndMerge "textures" "$install_dest" "$VERSIONED_MT_PATH" + upgradeAndMerge "media" "$install_dest/cache" "$VERSIONED_MT_PATH/cache" deleteIfExists "$VERSIONED_MT_PATH/media" + QUIET="$PREV_QUIET" deleteIfExists "$VERSIONED_MT_PATH/minetest.conf.example" deleteIfExists "$VERSIONED_MT_PATH/minetest.conf.example.extra" deleteIfExists "$VERSIONED_MT_PATH/bin/minetest" deleteIfExists "$VERSIONED_MT_PATH/bin/minetestserver" + deleteIfExists "$VERSIONED_MT_PATH/bin/minetest.bak" deleteIfExists "$VERSIONED_MT_PATH/bin/minetest.bin" + deleteIfExists "$VERSIONED_MT_PATH/bin/minetestserver.bak" deleteIfExists "$VERSIONED_MT_PATH/bin/minetestserver.bin" + deleteIfExists "$VERSIONED_MT_PATH/bin/debug.txt" rmdir --ignore-fail-on-non-empty "$VERSIONED_MT_PATH/bin" - # upgradeAndMerge "util" "$INSTALL_PATH" "$VERSIONED_MT_PATH" + # upgradeAndMerge "util" "$install_dest" "$VERSIONED_MT_PATH" # ^ texture packs - upgradeAndMerge "clientmods" "$INSTALL_PATH" "$VERSIONED_MT_PATH" - moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.client-example.conf" "$INSTALL_PATH/minetest.ENLIVEN.client-example.conf" - moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.LAN-client-example.conf" "$INSTALL_PATH/minetest.ENLIVEN.LAN-client-example.conf" - moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.server-example.conf" "$INSTALL_PATH/minetest.ENLIVEN.server-example.conf" - moveIfExists "$VERSIONED_MT_PATH/minetest.conf" "$INSTALL_PATH/minetest.conf" - moveIfExists "$VERSIONED_MT_PATH/arrowkeys.txt" "$INSTALL_PATH/arrowkeys.txt" - moveIfExists "$VERSIONED_MT_PATH/.saved_passwords" "$INSTALL_PATH/.saved_passwords" - if [ -d "$INSTALL_PATH/games/ENLIVEN" ]; then - if [ -d "$INSTALL_PATH/games/Bucket_Game" ]; then - echo "* upgrading $INSTALL_PATH/games/ENLIVEN components using $INSTALL_PATH/games/Bucket_Game..." - upgradeAndMerge "mods" "$INSTALL_PATH/games/Bucket_Game" "$INSTALL_PATH/games/ENLIVEN" "inplace" - else - echo "* WARNING: Upgrading ENLIVEN is not possible since $INSTALL_PATH/games/Bucket_Game is not present." - fi - fi + upgradeAndMerge "clientmods" "$install_dest" "$VERSIONED_MT_PATH" + moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.client-example.conf" "$install_dest/minetest.ENLIVEN.client-example.conf" + moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.LAN-client-example.conf" "$install_dest/minetest.ENLIVEN.LAN-client-example.conf" + moveIfExistsOrDeleteIfOnDest "$VERSIONED_MT_PATH/minetest.ENLIVEN.server-example.conf" "$install_dest/minetest.ENLIVEN.server-example.conf" + moveIfExists "$VERSIONED_MT_PATH/minetest.conf" "$install_dest/minetest.conf" + moveIfExists "$VERSIONED_MT_PATH/arrowkeys.txt" "$install_dest/arrowkeys.txt" + moveIfExists "$VERSIONED_MT_PATH/.saved_passwords" "$install_dest/.saved_passwords" OLD_BIN_PATH="$VERSIONED_MT_PATH/bin" - NEW_BIN_PATH="$NEW_VERSION_PATH/bin" + NEW_BIN_PATH="$install_dest/bin" # See if ls ${OLD_BIN_PATH}/*.png &>/dev/null then + echo " * moving png screenshots..." mv ${OLD_BIN_PATH}/*.png ${NEW_BIN_PATH}/ + else + echo " * You have no png files in ${OLD_BIN_PATH}." fi if ls ${OLD_BIN_PATH}/*.jpg &>/dev/null then + echo " * moving jpg screenshots..." mv ${OLD_BIN_PATH}/*.jpg ${NEW_BIN_PATH}/ + else + echo " * You have no jpg files in ${OLD_BIN_PATH}." fi deleteIfExists "$VERSIONED_MT_PATH/builtin" + rmdir --ignore-fail-on-non-empty "$VERSIONED_MT_PATH/cache" deleteIfExists "$VERSIONED_MT_PATH/doc" deleteIfExists "$VERSIONED_MT_PATH/fonts" deleteIfExists "$VERSIONED_MT_PATH/locale" deleteIfExists "$VERSIONED_MT_PATH/misc" deleteIfExists "$VERSIONED_MT_PATH/po" + deleteIfExists "$VERSIONED_MT_PATH/solib" deleteIfExists "$VERSIONED_MT_PATH/sounds" deleteIfExists "$VERSIONED_MT_PATH/util" + deleteIfExists "$VERSIONED_MT_PATH/LICENSE.txt" + deleteIfExists "$VERSIONED_MT_PATH/release.txt" + deleteIfExists "$VERSIONED_MT_PATH/readme.txt" + rmdir --ignore-fail-on-non-empty "$VERSIONED_MT_PATH/bin" + rmdir --ignore-fail-on-non-empty "$VERSIONED_MT_PATH" else - mv "$NEW_VERSION_PATH" "$INSTALL_PATH" + mv "$NEW_VERSION_PATH" "$install_dest" + fi + + if [ "@$ENABLE_RELINK" = "@true" ]; then + if [ ! -d "$dest_programs/minetest" ]; then + echo "* removing old symlink $virtual_dest..." + rm "$virtual_dest" || customExit "Removing the old symlink failed: rm \"$virtual_dest\"." + echo "* creating new symlink to $install_dest directory as $virtual_dest..." + ln -s "$install_dest" "$virtual_dest" + fi + fi + + if [ ! -f "$this_dst_flag_path" ]; then + customExit "ERROR: not complete--couldn't install binary as '$this_dst_flag_path'" fi - # curl https://downloads.minetest.org/release.txt -o "$INSTALL_PATH/release.txt" + # curl https://downloads.minetest.org/release.txt -o "$install_dest/release.txt" else customExit "There is no minetest directory $NEW_VERSION_PATH." fi + if [ "@$new_release_version" != "@new" ]; then + echo "Release $new_release_version" > "$install_dest/release.txt" + echo " * wrote \"`cat $install_dest/release.txt`\" to \"$install_dest/release.txt\"." + fi +} + +install_git_mod_here(){ + git_url="$1" + mod_name="$2" + if [ -z "$git_url" ]; then + customExit "install_git_mod_here requires a URL." + fi + if [ -z "$mod_name" ]; then + customExit "install_git_mod_here requires a mod name as the second parameter." + fi + if [ ! -d "$mod_name" ]; then + git clone "$git_url" "$mod_name" + else + cd "$mod_name" || customExit "(install_git_mod_here) 'cd \"$mod_name\"' failed in '`pwd`'" + echo "* updating '`pwd`' from git..." + git pull || echo "WARNING: (install_git_mod_here) 'git pull' failed in '`pwd`'" + cd .. || customExit "(install_git_mod_here) 'cd ..' failed in '`pwd`'" + fi } show_os_release(){ @@ -366,3 +523,362 @@ show_os_release(){ #fi fi } + +addEnlivenMinetestPatches(){ + # REPO_PATH is determined above. + if [ ! -z "$1" ]; then + install_dest="$1" + fi + if [ -z "$REPO_PATH" ]; then + customExit "[$addEnlivenMinetestPatches] The REPO_PATH is not set." + fi + if [ ! -d "$REPO_PATH" ]; then + customExit "[$addEnlivenMinetestPatches] The REPO_PATH does not exist: \"$REPO_PATH\"" + fi + if [ -z "$PATCHES_PATH" ]; then + PATCHES_PATH="$REPO_PATH/patches" + fi + if [ ! -d "$PATCHES_PATH" ]; then + customExit "The PATCHES_PATH does not exist: \"$PATCHES_PATH\"" + fi + if [ ! -d "$install_dest" ]; then + customExit "The install_dest does not exist: \"$install_dest\"" + fi + src_menu="$PATCHES_PATH/subgame/menu" + dst_menu="$install_dest/games/ENLIVEN/menu" + echo "updating '$dst_menu' from '$src_menu/'..." + if [ -f "`command -v rsync`" ]; then + rsync -rt "$src_menu/" "$dst_menu" + else + echo "* WARNING: rsync is missing, so patching ENLIVEN/menu from \"$src_menu\" is being skipped." + cp -f "$src_menu/header.png" "$dst_menu/" + cp -f "$src_menu/menu.png" "$dst_menu/" + fi + echo "name = ENLIVEN" > "$install_dest/games/ENLIVEN/game.conf" + src_game="$PATCHES_PATH/Bucket_Game-patched" + dst_game="$install_dest/games/ENLIVEN" + echo "updating '$dst_game' from '$src_game/'..." + if [ -f "`command -v rsync`" ]; then + rsync -rt "$src_game/" "$dst_game" + else + echo "* WARNING: rsync is missing, so patching ENLIVEN from \"$src_game\" is being skipped." + fi + if [ -d "$dst_game/mods/coderfood/food_basic/etc" ]; then + rm -Rf "$dst_game/mods/coderfood/food_basic/etc" + fi + + minetest_conf_dest="$install_dest/minetest.conf" + game_minetest_conf_dest="$install_dest/games/ENLIVEN/minetest.conf" + + # Bucket_Game doesn't come with a minetest.conf, only minetest.conf.example* files + # if [ ! -f "$install_dest/minetest.Bucket_Game-example.conf" ]; then + # cp -f "$$minetest_conf_dest" "$install_dest/minetest.Bucket_Game-example.conf" + # fi + + client_example_dest="$install_dest/minetest.ENLIVEN.client-example.conf" + + echo "Installing minetest.ENLIVEN.*-example.conf files..." + cp -f "$PATCHES_PATH/subgame/minetest.LAN-client-example.conf" "$install_dest/minetest.ENLIVEN.LAN-client-example.conf" || customExit "Cannot copy minetest.ENLIVEN.LAN-client-example.conf" + cp -f "$PATCHES_PATH/subgame/minetest.server-example.conf" "$install_dest/minetest.ENLIVEN.server-example.conf" || customExit "Cannot copy minetest.ENLIVEN.server-example.conf" + cp -f "$PATCHES_PATH/subgame/minetest.client-example.conf" "$install_dest/minetest.ENLIVEN.client-example.conf" || customExit "Cannot copy minetest.ENLIVEN.client-example.conf" + + echo "Writing '$game_minetest_conf_dest'..." + cp -f "$PATCHES_PATH/subgame/minetest.conf" "$game_minetest_conf_dest" + + # client conf writing only ever happens once, unless you manually delete $minetest_conf_dest: + if [ ! -f "$minetest_conf_dest" ]; then + # if [ -f "$minetest_conf_dest" ]; then + # echo "Backing up minetest.conf..." + # if [ ! -f "$minetest_conf_dest.1st" ]; then + # cp -f "$minetest_conf_dest" "$minetest_conf_dest.1st" + # else + # cp -f "$minetest_conf_dest" "$minetest_conf_dest.bak" + # fi + # fi + echo "Writing minetest.conf (client region)..." + cp -f "$PATCHES_PATH/subgame/minetest.client-example.conf" "$minetest_conf_dest" || customExit "Cannot copy minetest.client-example.conf to $minetest_conf_dest" + echo "Appending example settings (server region) to '$minetest_conf_dest'..." + cat "$PATCHES_PATH/subgame/minetest.server-example.conf" >> "$minetest_conf_dest" || customExit "Cannot append minetest.server-example.conf" + else + echo "$minetest_conf_dest exists (remove it if you want the installer to write an example version)" + fi + + + if [ -f "$minetest_conf_dest" ]; then + cat << END +NOTE: minetest.org releases allow you to put a world.conf file in your + world, so that is the file you should edit manually in your world + --this installer overwrites $minetest_conf_dest and + worlds/CenterOfTheSun settings (the author Poikilos' world). + Continue to place server settings such as announce in + $minetest_conf_dest. + Leave $game_minetest_conf_dest intact, as it defines the game. + If you have suggestions for changes or configurability, please use the + issue tracker at . + +END + fi + + + world_override_src="$REPO_PATH/overrides/CenterOfTheSun/minetest/worlds/CenterOfTheSun" + world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" + world_override_dst="$HOME/.minetest/worlds/CenterOfTheSun" + try_world_override_dst="$HOME/minetest/worlds/CenterOfTheSun" + if [ -d "$try_world_override_dst" ]; then + world_override_dst="$try_world_override_dst" + fi + world_conf_src="$world_override_src/world.conf" + world_conf_dst="$world_override_dst/world.conf" + world_mt_src="$world_override_src/world.mt" + world_mt_dst="$world_override_dst/world.mt" + override_more="$REPO_PATH/overrides/CenterOfTheSun/games/ENLIVEN" + appends="$REPO_PATH/overrides/CenterOfTheSun/append" + minetest_conf_append="$appends/minetest.conf" + if [ -d "$world_override_dst" ]; then + echo "You have the CenterOfTheSun world. Listing any changes..." + if [ -f "$world_conf_src" ]; then + if [ -f "$world_conf_dst" ]; then + echo " * overwrite $world_conf_dst with $world_conf_src" + else + echo " * add the world.conf from $world_conf_src" + fi + cp -f "$world_conf_src" "$world_conf_dst" + fi + if [ -z "`grep 'region overrides/CenterOfTheSun/append' $minetest_conf_dest`" ]; then + if [ -f "$minetest_conf_append" ]; then + cat "$minetest_conf_append" >> "$minetest_conf_dest" + fi + fi + fi + + if [ "@$ENABLE_CLIENT" = "@true" ]; then + #params: _SRC_SHORTCUT_PATH, _DST_SHORTCUT_NAME, _EXEC, _WORKING_DIR, _ICON, _CAPTION: + SHORTCUT_PATH="$PATCHES_PATH/deploy-patched/misc/org.minetest.minetest.desktop" + EXEC_PATH="$install_dest/bin/minetest" + WORKING_DIR_PATH="$install_dest/bin" + MT_ICON="$install_dest/misc/minetest-xorg-icon-128.png" + install_shortcut "$SHORTCUT_PATH" "org.minetest.minetest.desktop" "$EXEC_PATH" "$WORKING_DIR_PATH" "$MT_ICON" "Final Minetest" + fi + + if [ -f "`command -v rsync`" ]; then + if [ -f $install_dest/games/ENLIVEN/mods/codermobs/codermobs/animal_materials.lua ]; then + if [ -d $PATCHES_PATH/mods-stopgap/animal_materials_legacy ]; then + echo "* installing animal_materials_legacy (only needed for worlds created with old versions of Bucket_Game)" + rsync -rt $PATCHES_PATH/mods-stopgap/animal_materials_legacy $install_dest/games/ENLIVEN/mods/ + else + echo "* MISSING $PATCHES_PATH/mods-stopgap/animal_materials" + fi + else + echo "* SKIPPING a stopgap mod since no animal_materials" + fi + + if [ -f $install_dest/games/ENLIVEN/mods/codermobs/codermobs/elk.lua ]; then + if [ -d $PATCHES_PATH/mods-stopgap/elk_legacy ]; then + echo "* installing elk_legacy (only needed for worlds created with old versions of Bucket_Game)" + rsync -rt $PATCHES_PATH/mods-stopgap/elk_legacy $install_dest/games/ENLIVEN/mods/ + else + echo "* MISSING $PATCHES_PATH/mods-stopgap/elk_legacy" + fi + else + echo "* SKIPPING a stopgap mod since no elk.lua" + fi + + if [ -d "$install_dest/games/ENLIVEN/mods/coderbuild/nftools" ]; then + if [ -d $PATCHES_PATH/mods-stopgap/nftools_legacy ]; then + echo "* installing nftools_legacy (only needed for worlds created with old versions of Bucket_Game)" + rsync -rt $PATCHES_PATH/mods-stopgap/nftools_legacy $install_dest/games/ENLIVEN/mods/ + else + echo "* MISSING $PATCHES_PATH/mods-stopgap/nftools_legacy" + fi + else + echo "* SKIPPING a stopgap mod since no nftools" + fi + else + echo "* WARNING: rsync is missing, so adding mods from \"$PATCHES_PATH/mods-stopgap\" to ENLIVEN/mods is being skipped." + fi +} + +analyzeGameSettings() { + if [ ! -z "$1" ]; then + THIS_GAME_PATH=$1 + fi + if [ ! -d "$THIS_GAME_PATH" ]; then + customExit " [$MT_ENV_RUP_NAME: analyzeGameSettings] THIS_GAME_PATH \"$THIS_GAME_PATH\" is not present." + fi + this_dumps_name="`basename $THIS_GAME_PATH`" + this_dumps_path="$EM_CACHE_PATH/$this_dumps_name" + if [ ! -d "$this_dumps_path" ]; then + mkdir -p "$this_dumps_path" + fi + settings_dump="$this_dumps_path/settings-dump.txt" + settings_types_list="$this_dumps_path/settingtypes-list.txt" + if [ ! -f "$settings_dump" ]; then + echo " - Creating $settings_dump..." + grep -r "$THIS_GAME_PATH" -e "setting_get" > $settings_dump + grep -r "$THIS_GAME_PATH" -e "minetest.settings:get" >> $settings_dump + else + echo " - $settings_dump was already created" + fi + if [ ! -f "$settings_types_list" ]; then + echo " - creating $settings_types_list..." + find "$THIS_GAME_PATH" -name "settingtypes.txt" > $settings_types_list + else + echo " - $settings_types_list was already created" + fi +} + +installOrUpgradeENLIVEN() { + PREV_DIR="`pwd`" + # REPO_PATH is detected above. + if [ -z "$REPO_PATH" ]; then + customExit "[installOrUpgradeENLIVEN] The REPO_PATH is not set." + fi + if [ ! -d "$REPO_PATH" ]; then + customExit "[installOrUpgradeENLIVEN] The REPO_PATH does not exist: \"$REPO_PATH\"" + fi + if [ ! -z "$1" ]; then + install_dest="$1" + fi + if [ ! -d "$install_dest" ]; then + customExit "[installOrUpgradeENLIVEN] The install_dest is missing: \"$install_dest\"" + fi + dest_official_game="$install_dest/games/Bucket_Game" + dest_enliven="$install_dest/games/ENLIVEN" + if [ ! -d "$dest_official_game" ]; then + customExit "[installOrUpgradeENLIVEN] \"$dest_official_game\" is missing." + fi + if [ ! -d "$dest_enliven" ]; then + echo "Copying $dest_official_game to $dest_enliven..." + cp -R "$dest_official_game" "$dest_enliven" + else + if [ -d "$dest_enliven" ]; then + if [ -d "$dest_official_game" ]; then + echo "* upgrading $dest_enliven components using $dest_official_game..." + upgradeAndMerge "mods" "$dest_official_game" "$dest_enliven" "inplace" + else + echo "* WARNING: Upgrading ENLIVEN is not possible since $dest_official_game is not present." + fi + fi + fi + dest_enliven_mods="$dest_enliven/mods" + enliven_warning="" + if [ -d "$dest_enliven_mods" ]; then + cd "$dest_enliven_mods" || customExit "[installOrUpgradeENLIVEN] 'cd \"$dest_enliven_mods\"' failed." + # install_git_mod_here https://github.com/BenjieFiftysix/sponge.git sponge + install_git_mod_here https://github.com/poikilos/metatools.git metatools + install_git_mod_here https://github.com/MinetestForFun/fishing.git fishing + install_git_mod_here https://github.com/minetest-mods/throwing.git throwing + install_git_mod_here https://github.com/minetest-mods/ccompass.git ccompass + install_git_mod_here https://github.com/minetest-mods/throwing_arrows.git throwing_arrows + else + enliven_warning="$enliven_warning* WARNING: Installing ENLIVEN mods was skipped since '$dest_enliven_mods' does not exist." + fi + cd "$PREV_DIR" + # PATCHES_DIR_NAME="patches" + PATCHES_PATH="$REPO_PATH/patches" + if [ -d "$PATCHES_PATH" ]; then + #pushd "$REPO_PATH" + addEnlivenMinetestPatches "$install_dest" + #popd + else + 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_shortcut(){ - enable_clear_icon_cache=false - - _SRC_SHORTCUT_PATH=$1 - if [ ! -f "$_SRC_SHORTCUT_PATH" ]; then - customExit "\"$_SRC_SHORTCUT_PATH\" is missing." - fi - _DST_SHORTCUT_NAME=$2 - # _CAPTION is optional (original "Name" is kept if not specified) - _EXEC=$3 - _WORKING_DIR=$4 - _ICON=$5 - _CAPTION=$6 - dest_icons=$HOME/.local/share/applications - dest_icon=$dest_icons/$_DST_SHORTCUT_NAME - if [ ! -d "$dest_icons" ]; then - mdkir -p "$dest_icons" || customExit "mkdir -p \"$dest_icons\" failed." - fi - # if [ -f "$dest_icon" ]; then - # comment since never fixes broken icon anyway - # TODO: fixed bad cache even if icon was rewritten properly after written improperly - # * not tried yet: - # * rm $HOME/.kde/share/config/kdeglobals - # enable_clear_icon_cache=true - # fi - echo "* writing icon '$dest_icon'..." - if [ ! -z "$_ICON" ]; then - if [ ! -z "$_CAPTION" ]; then - cat "$_SRC_SHORTCUT_PATH" | grep -v "^Icon=" | grep -v "^Path=" | grep -v "^Exec=" | grep -v "^Name=" > "$dest_icon" - else - cat "$_SRC_SHORTCUT_PATH" | grep -v "^Icon=" | grep -v "^Path=" | grep -v "^Exec=" > "$dest_icon" - fi - else - if [ ! -z "$_CAPTION" ]; then - cat "$_SRC_SHORTCUT_PATH" | grep -v "^Path=" | grep -v "^Exec=" | grep -v "^Name=" > "$dest_icon" - else - cat "$_SRC_SHORTCUT_PATH" | grep -v "^Path=" | grep -v "^Exec=" > "$dest_icon" - fi - fi - # Icon must be an absolute path (other variables use $HOME in - # desktop file above), so exclude it above and rewrite it below: - echo "Path=$dest_programs/minetest/bin" >> "$dest_icon" - if [ ! -z "$_CAPTION" ]; then - echo "Name=$_CAPTION" >> "$dest_icon" - fi - if [ ! -z "$_ICON" ]; then - echo "Icon=$_ICON" >> "$dest_icon" - fi - echo "Exec=$_EXEC" >> "$dest_icon" - if [ -d "$HOME/Desktop" ]; then - cp -f "$dest_icon" "$HOME/Desktop/$_DST_SHORTCUT_NAME" - fi - if [ "@$enable_clear_icon_cache" = "@true" ]; then - if [ -f "`command -v gnome-shell`" ]; then - echo "Refreshing Gnome icons..." - gnome-shell --replace & disown - sleep 10 - fi - if [ -f "$HOME/.cache/icon-cache.kcache" ]; then - echo "clearing $HOME/.cache/icon-cache.kcache..." - rm $HOME/.cache/icon-cache.kcache - fi - if [ -f "`command -v kquitapp5`" ]; then - echo "Refreshing KDE icons..." - if [ "`command -v kstart5`" ]; then - kquitapp5 plasmashell && kstart5 plasmashell - else - kquitapp5 plasmashell && kstart plasmashell - fi - sleep 15 - fi - if [ -f "`command -v xfce4-panel`" ]; then - echo "Refreshing Xfce icons..." - xfce4-panel -r && xfwm4 --replace - sleep 5 - fi - if [ -f "`command -v lxpanelctl`" ]; then - echo "Refreshing LXDE icons..." - lxpanelctl restart && openbox --restart - sleep 5 - fi +scripting_rc_path=~/.config/EnlivenMinetest/scripting.rc +if [ -f "$EM_CONFIG_PATH/scripting.rc" ]; then + echo "* [$MT_ENV_RUP_NAME] using $scripting_rc_path..." + source $scripting_rc_path +fi +if [ -z "$REPO_PATH" ]; then + REPO_PATH="$HOME/git/EnlivenMinetest" +fi +MT_BASH_RC_NAME="minetestenv-in-place.rc" +CURRENT_MT_SCRIPTS_DIR="$HOME/.local/bin" +MT_BASH_RC_PATH="$CURRENT_MT_SCRIPTS_DIR/$MT_BASH_RC_NAME" +TRY_CURRENT_MT_SCRIPTS_DIR="$REPO_PATH" +TRY_MT_BASH_RC_PATH="$TRY_CURRENT_MT_SCRIPTS_DIR/$MT_BASH_RC_NAME" +if [ -f "$TRY_MT_BASH_RC_PATH" ]; then + CURRENT_MT_SCRIPTS_DIR="$TRY_CURRENT_MT_SCRIPTS_DIR" + MT_BASH_RC_PATH="$TRY_MT_BASH_RC_PATH" +#fi +#if [ ! -f "$MT_BASH_RC_PATH" ]; then +else + if [ ! -d "$CURRENT_MT_SCRIPTS_DIR" ]; then + mkdir -p "$CURRENT_MT_SCRIPTS_DIR" fi -} -# ^ same as install-minetest-linux64.sh -get_os_release(){ - if [ -f "/etc/os-release" ]; then - #if [ -z "$NAME" ]; then - source /etc/os-release + MT_BASH_RC_URL=https://raw.githubusercontent.com/poikilos/EnlivenMinetest/master/$MT_BASH_RC_NAME + curl $MT_BASH_RC_URL -o "$MT_BASH_RC_PATH" + if [ $? -ne 0 ]; then echo - echo "Your operating system is $NAME $VERSION" - #fi - fi -} -install_my_shortcut(){ - #requires SHORTCUT_PATH to already be set to a valid Minetest ".desktop" file. - EXEC_PATH="$INSTALL_PATH/bin/minetest" - if [ ! -f "$EXEC_PATH" ]; then - echo "* WARNING: The Minetest executable is not present: \"$EXEC_PATH\"" - fi - WORKING_DIR_PATH="$INSTALL_PATH/bin" - if [ ! -d "$WORKING_DIR_PATH" ]; then - echo "* WARNING: The Minetest working directory is not present: \"$WORKING_DIR_PATH\"" - fi - MT_ICON="$INSTALL_PATH/misc/minetest-xorg-icon-128.png" - if [ ! -f "$MT_ICON" ]; then - echo "* WARNING: The Minetest icon is not present: \"$MT_ICON\"" + echo "ERROR: Downloading $MT_BASH_RC_URL to $MT_BASH_RC_PATH failed." + echo + sleep 10 + exit 1 fi - install_shortcut "$SHORTCUT_PATH" "org.minetest.minetest.desktop" "$EXEC_PATH" "$WORKING_DIR_PATH" "$MT_ICON" "Final Minetest" - get_os_release -} +fi +if [ ! -f "$MT_BASH_RC_PATH" ]; then + echo + echo "$MT_BASH_RC_PATH is not present." + echo + sleep 10 + exit 1 +fi +source $MT_BASH_RC_PATH +# ^ same as install-mts.sh +#INSTALL_SCRIPT_NAME="update-minetest-linux64.sh" + +echo "* starting download..." +date + +if [ -z "$INSTALL_MODE" ]; then + INSTALL_MODE="move" +fi DL_NAME=minetest-linux64.zip +RELEASE_ARC_URL="https://downloads.minetest.org/$DL_NAME" DL_PATH=$HOME/Downloads/$DL_NAME EXTRACTED_NAME=minetest-linux64 if [ -z "$INSTALL_PATH" ]; then @@ -170,11 +67,8 @@ if [ -f "$TRY_ORG_PATH" ]; then SHORTCUT_PATH="$TRY_ORG_PATH" fi -if [ -z "$MY_TMP" ]; then - MY_TMP=/tmp/minetest-webinstall -fi -mkdir -p "$MY_TMP" -EXTRACTED_PATH="$MY_TMP/$EXTRACTED_NAME" +mkdir -p "$EM_TMP" +EXTRACTED_PATH="$EM_TMP/$EXTRACTED_NAME" if [ -d "$EXTRACTED_PATH" ]; then rm -Rf "$EXTRACTED_PATH" || customExit "Deleting the old $EXTRACTED_PATH failed." fi @@ -210,54 +104,50 @@ do fi done +if [ ! -f "`command -v unzip`" ]; then + cat </dev/null 1>&2 +cd "$EM_TMP" || customExit "cd \"$EM_TMP\" failed." -upgradeAndMerge(){ - UPGRADE_TYPE="$1" - if [ ! -d "$INSTALL_PATH/$UPGRADE_TYPE" ]; then - customExit "* WARNING: $UPGRADE_TYPE upgrade is skipped since $INSTALL_PATH/$UPGRADE_TYPE is not present." - else - echo "* upgrading $UPGRADE_TYPE" - for UPGRADE_PATH in `find $INSTALL_PATH/$UPGRADE_TYPE -maxdepth 1` - do - UPGRADE_NAME="`basename $UPGRADE_PATH`" - if [ "$UPGRADE_PATH" = "$INSTALL_PATH/$UPGRADE_TYPE" ]; then - echo " * examining $UPGRADE_PATH..." - elif [ -d "$UPGRADE_PATH" ]; then - echo " * upgrading $UPGRADE_NAME..." - if [ -d "$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME" ]; then - rm -Rf "$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME" || customExit "* rm -Rf \"$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME\" failed." - mv "$UPGRADE_PATH" "$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME" || customExit "mv \"$UPGRADE_PATH\" \"$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME\"" - fi - else - echo " * upgrading $UPGRADE_NAME..." - mv -f "$UPGRADE_PATH" "$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME" || customExit "mv \"$UPGRADE_PATH\" \"$INSTALL_PATH.$old_version/$UPGRADE_TYPE/$UPGRADE_NAME\"" - fi - done - rmdir "$INSTALL_PATH/$UPGRADE_TYPE" || customExit "rmdir \"$INSTALL_PATH/$UPGRADE_TYPE\" failed." - mv "$INSTALL_PATH.$old_version/$UPGRADE_TYPE" "$INSTALL_PATH/" || customExit "mv \"$INSTALL_PATH.$old_version/$UPGRADE_TYPE\" \"$INSTALL_PATH/\"" - fi -} +killall minetest 2>/dev/null 1>&2 -if [ -d "$MY_TMP/$EXTRACTED_NAME" ]; then - rm -Rf "$MY_TMP/$EXTRACTED_NAME" || customExit "* removing the old \"$MY_TMP/$EXTRACTED_NAME\" failed." +if [ -d "$EM_TMP/$EXTRACTED_NAME" ]; then + rm -Rf "$EM_TMP/$EXTRACTED_NAME" || customExit "* removing the old \"$EM_TMP/$EXTRACTED_NAME\" failed." fi -unzip "$DL_PATH" || customExit "Extracting $DL_PATH failed." +unzip "$DL_PATH" > /dev/null || customExit "Extracting $DL_PATH failed." -if [ -d "$EXTRACTED_PATH" ]; then - # cd "$HOME" || customExit "cd \"$HOME\" failed." - if [ -d "$INSTALL_PATH" ]; then - if [ -d "$INSTALL_PATH.$old_version" ]; then - customExit "You already have an old copy of \"$INSTALL_PATH.$old_version\". You must rename it or backup your world and other data then remove it before proceeding." - fi - if [ ! -f "`command -v basename`" ]; then - customExit "Install cannot continue because the basename command is not present." - fi - if [ ! -f "`command -v find`" ]; then - customExit "Install cannot continue because the find command is not present." - fi - mv "$INSTALL_PATH" "$INSTALL_PATH.$old_version" - mv "$EXTRACTED_PATH" "$INSTALL_PATH" - upgradeAndMerge "games" - upgradeAndMerge "worlds" - upgradeAndMerge "mods" - if [ -f "$INSTALL_PATH.$old_version/minetest.conf" ]; then - mv "$INSTALL_PATH.$old_version/minetest.conf" "$INSTALL_PATH/minetest.conf" - fi - else - mv "$EXTRACTED_PATH" "$INSTALL_PATH" - fi - # curl https://downloads.minetest.org/release.txt -o "$INSTALL_PATH/release.txt" -else - customExit "Extracting \"$DL_PATH\" did not result in $EXTRACTED_PATH." -fi -echo "Installing Final Minetest $version to $INSTALL_PATH is complete." +UNUSED_MT_PATH="$INSTALL_PATH.$old_release_version" +installOrUpgradeMinetest "$EXTRACTED_PATH" "$INSTALL_PATH" "$UNUSED_MT_PATH" +echo "Installing Final Minetest $new_release_version to $INSTALL_PATH is complete." +echo " - old:$old_release_version; new:$new_release_version" +echo "* installing ENLIVEN..." +installOrUpgradeENLIVEN "$INSTALL_PATH" +install_mt_in_place_shortcut "$SHORTCUT_PATH" "$INSTALL_PATH" echo diff --git a/versionize.sh b/versionize.sh index 24fa873..7acad8f 100755 --- a/versionize.sh +++ b/versionize.sh @@ -1,9 +1,8 @@ #!/bin/bash echo echo "Collecting version..." -MY_NAME="versionize.sh" EM_CONFIG_PATH=$HOME/.config/EnlivenMinetest -cd "$EM_CONFIG_PATH" || customExit "[$MY_NAME] cd \"$EM_CONFIG_PATH\" failed." +cd "$EM_CONFIG_PATH" || customExit "[versionize.sh] cd \"$EM_CONFIG_PATH\" failed." if [ -z "$original_src_path" ]; then original_src_path="$1" fi @@ -99,30 +98,16 @@ elif [ -d "$try_path" ]; then else customExit "$try_path is not a file or directory." fi -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." - customExit "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 $release_txt_path`" -version="${release_line##* }" # get second word -version_len=${#version} -if [ "$version_len" -ne "6" ]; then - customExit "Unexpected version scheme (not 6 characters): '$version' near '$release_line' in file $release_txt_path" -fi + +detect_mt_version_at "$src_path/minetest" +# ^ DOES exit if no 6-digit version is detected when no 3rd param +# is provided. + echo "src_name=$src_name" echo "src_path=$src_path" -echo "version=$version" -# dest_path="$versions_path/$src_name-$version" -dest_path="$versions_path/linux-minetest-kit-$version" +echo "new_release_version=$new_release_version" +# dest_path="$versions_path/$src_name-$new_release_version" +dest_path="$versions_path/linux-minetest-kit-$new_release_version" echo "dest_path=$dest_path" if [ ! -z "$src_archive" ]; then @@ -133,7 +118,7 @@ if [ ! -z "$src_archive" ]; then filename=$(basename -- "$src_archive") extension="${filename##*.}" filename="${filename%.*}" - dst_archive="$versions_path/$filename-$version.$extension" + dst_archive="$versions_path/$filename-$new_release_version.$extension" if [ -f "$dst_archive" ]; then customWarn "This will overwrite '$dst_archive' with '$src_archive'." fi