Skip to content

Commit

Permalink
Split patchscript (patching vs updating)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeletre committed Dec 6, 2024
1 parent 0165e36 commit 46cbb8f
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 45 deletions.
9 changes: 8 additions & 1 deletion ports/riskofrain/Risk of Rain (2013).sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ export PATCHER_GAME="$(basename "${0%.*}")" # This gets the current script filen
export PATCHER_TIME="1 to 2 minutes"

# Exports
export LD_LIBRARY_PATH="/usr/lib:/usr/lib32:/$GAMEDIR/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="/usr/lib:/usr/lib32:/$GAMEDIR/libs.armhf:$LD_LIBRARY_PATH"
export PATH="$PATH:$GAMEDIR/tools"

# If previous installation (671b20f)
# remove patchlog.txt so that Patcher
# will update properly
[[ -f "$GAMEDIR/game.apk" ]] && rm "$GAMEDIR/patchlog.txt" \
&& export PATCHER_FILE="$GAMEDIR/tools/updatescript" \
&& export PATCHER_TIME="less than a minute"

# Check if patchlog.txt to skip patching
if [ ! -f patchlog.txt ]; then
if [ -f "$controlfolder/utils/patcher.txt" ]; then
Expand Down
Empty file modified ports/riskofrain/riskofrain/gmloadernext.armhf
100644 → 100755
Empty file.
17 changes: 17 additions & 0 deletions ports/riskofrain/riskofrain/lib/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# What are those?

Those are native Android libraries meant to be loaded into the guest environment,
and the come from a [prebuilt AOSP image provided by google](https://ci.android.com/builds/branches/aosp-main/grid).

# What are these files for then?

They provide a similar-to-android implementation to all of the supported libraries,
allowing us to make less guesswork, and provide more accurate renditions of a lot
of those functionalities, specially for libc++ where a lot of guesswork was done
in the past.

OpenAL, OpenGL and libc.so are provided from the host (via thunking where needed) or
via reimplementations.

You still need a suitable GameMaker Android title/runner. You can source those from
either [freeware Android APKs](https://itch.io) or finding a [suitable runner](https://gamemaker.io/account/runtimes) for hacking.
File renamed without changes.
47 changes: 3 additions & 44 deletions ports/riskofrain/riskofrain/tools/patchscript
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,6 @@ DATA_WIN_MD5="d32c0d93bfc23b242fe7fca90f1d07ef"

# -------------------- BEGIN FUNCTIONS --------------------

update_install_671b20f()
{
# Update from previous install (git commit 671b20f)
files_to_move=(
"Prefs.ini"
"Save.ini"
"game.droid"
"options.ini"
)

for file in "${files_to_move[@]}"; do
echo "Moving $file"
mv "$file" "$GAMEDIR/gamedata/"
[[ ! $? -eq 0 ]] && echo "Cannot move $file" && return 1 # CRITICAL
done

echo "Renaming game.apk"
mv "$GAMEDIR/game.apk" "$GAMEDIR/riskofrain.port"
[[ ! $? -eq 0 ]] && echo "Cannot rename game.apk" && return 1 # CRITICAL

files_to_delete=(
"gmloadernext"
)

for file in "${files_to_delete[@]}"; do
echo "Deleting $file"
rm "$file"
done

return 0

}

cleanup_files()
{
# Delete unnecessary files
Expand Down Expand Up @@ -151,17 +118,9 @@ patch_game()

# --------------------- END FUNCTIONS ---------------------

# If previous installation (671b20f) is detected update and exit
# (no need to install the game again)
if [[ -f "$GAMEDIR/game.apk" ]]; then
update_install_671b20f
[[ ! $? -eq 0 ]] && echo "Cannot update game" \
&& echo "Patching process failed!" && exit 1 \
|| echo "Game updated" && echo "Patching process done!" && exit 0
fi

# Install the game
patch_game && install_conf && pack_assets && cleanup_files
[[ ! $? -eq 0 ]] && echo "Cannot install the game" \
&& echo "Patching process failed!" && exit 1 \
|| echo "Patching process done!" && exit 0
&& echo "Patching process failed!" && exit 1

echo "Patching process done!" && exit 0
76 changes: 76 additions & 0 deletions ports/riskofrain/riskofrain/tools/updatescript
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
#!/bin/bash

#
# Risk of Rain update script
# Author: kotzebuedog
# Version: 1.0
# Update 671b20f
#

XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share}

if [ -d "/opt/system/Tools/PortMaster/" ]; then
controlfolder="/opt/system/Tools/PortMaster"
elif [ -d "/opt/tools/PortMaster/" ]; then
controlfolder="/opt/tools/PortMaster"
elif [ -d "$XDG_DATA_HOME/PortMaster/" ]; then
controlfolder="$XDG_DATA_HOME/PortMaster"
else
controlfolder="/roms/ports/PortMaster"
fi

source $controlfolder/control.txt

# Set GAMEDIR to the current directory and set logfile
export GAMEDIR="$PWD"
LOGFILE="$GAMEDIR/patchlog.txt"

# Redirect output and error to the log file
exec > >(tee -a "$LOGFILE") 2>&1
echo "GAMEDIR is set to: $GAMEDIR"

# -------------------- BEGIN FUNCTIONS --------------------

update_install_671b20f()
{
# Update from previous install (git commit 671b20f)
files_to_move=(
"Prefs.ini"
"Save.ini"
"game.droid"
"options.ini"
)

for file in "${files_to_move[@]}"; do
echo "Moving $file"
mv "$file" "$GAMEDIR/gamedata/"
[[ ! $? -eq 0 ]] && echo "Cannot move $file" && return 1 # CRITICAL
done

echo "Renaming game.apk"
mv "$GAMEDIR/game.apk" "$GAMEDIR/riskofrain.port"
[[ ! $? -eq 0 ]] && echo "Cannot rename game.apk" && return 1 # CRITICAL

files_to_delete=(
"gmloadernext"
"lib/libcrypto.so.1.1"
"lib/libzip.so.5"
"lib/arm64-v8a"
)

for file in "${files_to_delete[@]}"; do
echo "Deleting $file"
rm -rf "$file"
done

return 0

}

# --------------------- END FUNCTIONS ---------------------

update_install_671b20f
[[ ! $? -eq 0 ]] && echo "Cannot update game" \
&& echo "Patching process failed!" && exit 1

echo "Game updated" && echo "Patching process done!" && exit 0

0 comments on commit 46cbb8f

Please sign in to comment.