Skip to content

Commit

Permalink
Merge pull request #128 from kloptops/main
Browse files Browse the repository at this point in the history
Updates!
  • Loading branch information
kloptops committed Apr 25, 2024
2 parents c540405 + 7869f72 commit 9fff62b
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 53 deletions.
2 changes: 1 addition & 1 deletion PortMaster/harbourmaster
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def do_device_info(hm, argv):

for cfw_name in device_data['cfw']:
info = {'name': cfw_name.lower(), 'version': 'N/A', 'device': device_data['device']}
harbourmaster.expand_info(info)
harbourmaster.expand_info(info, use_old_cpu_info=True)

website_data[device_name][cfw_name] = info

Expand Down
6 changes: 6 additions & 0 deletions PortMaster/mod_Batocera.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ if [[ "$PORT_32BIT" == "Y" ]]; then
export SPA_PLUGIN_DIR="/usr/lib32/spa-0.2"
export PIPEWIRE_MODULE_DIR="/usr/lib32/pipewire-0.3/"
fi

# Use for Godot 2
GODOT2_OPTS="-r ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} -f"

# Use for Godot 3+
GODOT_OPTS="--resolution ${DISPLAY_WIDTH}x${DISPLAY_HEIGHT} -f"
31 changes: 21 additions & 10 deletions PortMaster/muos/control.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ export PATH="/opt/python/bin:$controlfolder/muos:$controlfolder/muos:$PATH"
export LD_LIBRARY_PATH="/opt/python/lib:$LD_LIBRARY_PATH"
ESUDO=""
ESUDOKILL="-1" # for 351Elec and EmuELEC use "-1" (numeric one) or "-k"
export SDL_GAMECONTROLLERCONFIG_FILE="/usr/lib/gamecontrollerdb.txt"
if [ -d "/usr/lib32/" ]; then
export SDL_GAMECONTROLLERCONFIG_FILE="/usr/lib32/gamecontrollerdb.txt"
else
export SDL_GAMECONTROLLERCONFIG_FILE="/usr/lib/gamecontrollerdb.txt"
fi
# export SDL_GAMECONTROLLERCONFIG=$(grep "Deeplay" "/usr/lib/gamecontrollerdb.txt")

get_controls() {
Expand All @@ -23,17 +27,24 @@ get_controls() {
cat /dev/zero > /dev/fb0 2>/dev/null
}

# CRUSH KILL DESTROY
if [ -f "$controlfolder/gptokeyb.armhf" ]; then
mv "$controlfolder/gptokeyb.armhf" "$controlfolder/gptokeyb"
fi
# HACKY MC HACK FACE
if [ ! -d /lib32/ ]; then
# CRUSH KILL DESTROY
if [ -f "$controlfolder/gptokeyb.armhf" ]; then
mv "$controlfolder/gptokeyb.armhf" "$controlfolder/gptokeyb"
fi

if [ -f "$controlfolder/gptokeyb2.armhf" ]; then
mv "$controlfolder/gptokeyb2.armhf" "$controlfolder/gptokeyb2"
fi
if [ -f "$controlfolder/gptokeyb2.armhf" ]; then
mv "$controlfolder/gptokeyb2.armhf" "$controlfolder/gptokeyb2"
fi

if [ -f "$controlfolder/xdelta3.armhf" ]; then
mv "$controlfolder/xdelta3.armhf" "$controlfolder/xdelta3"
if [ -f "$controlfolder/xdelta3.armhf" ]; then
mv "$controlfolder/xdelta3.armhf" "$controlfolder/xdelta3"
fi
else
if [ -f "$controlfolder/muos/mount" ]; then
rm -f "$controlfolder/muos/mount"
fi
fi

if [ -f "$controlfolder/cwtbe_flag" ]; then
Expand Down
2 changes: 1 addition & 1 deletion PortMaster/pylibs/harbourmaster/hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def cpu_info_v2(info):
info["capabilities"].append("x86")
info['primary_arch'] = "x86"

if subprocess.getoutput('uname -i').strip() == 'x86_64':
if subprocess.getoutput('uname -m').strip() == 'x86_64':
info["capabilities"].append("x86_64")
info['primary_arch'] = "x86_64"

Expand Down
24 changes: 19 additions & 5 deletions PortMaster/pylibs/harbourmaster/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class PlatformBase():
'genre': 'genre',
}

XML_PATH_FIX = ['path', 'image']

BLANK_GAMELIST_XML = """<?xml version='1.0' encoding='utf-8'?>\n<gameList />\n"""

def __init__(self, hm):
Expand Down Expand Up @@ -122,6 +124,8 @@ def gamelist_add(self, gameinfo_file):
if not gameinfo_file.is_file():
return

FIX_PATH = self.hm.ports_dir != self.hm.scripts_dir

with self.gamelist_backup() as gamelist_xml:
if gamelist_xml is None:
return
Expand All @@ -148,7 +152,15 @@ def gamelist_add(self, gameinfo_file):
if gamelist_element is None:
gamelist_element = ET.SubElement(gamelist_update, self.XML_ELEMENT_MAP[child.tag])

gamelist_element.text = child.text
if FIX_PATH and child.tag in self.XML_PATH_FIX:
new_path = child.text.strip()
if new_path.startswith('./'):
new_path = new_path[2:]

gamelist_element.text = str(self.hm.ports_dir / new_path)

else:
gamelist_element.text = child.text

if hasattr(ET, 'indent'):
ET.indent(gamelist_root, space=" ", level=0)
Expand Down Expand Up @@ -374,7 +386,7 @@ class PlatformEmuELEC(PlatformGCD_PortMaster, PlatformBase):
ES_NAME = 'emustation'

def gamelist_file(self):
return self.hm.ports_dir / 'gamelist.xml'
return self.hm.scripts_dir / 'gamelist.xml'


class PlatformRetroDECK(PlatformBase):
Expand Down Expand Up @@ -637,7 +649,8 @@ def add_port_script(self, port_script):
PORT_CONFIG_JSON
.replace("{{PORTTITLE}}", port_script.stem)
.replace("{{PORTNAME}}", new_port_dir.name.lower())
.replace("{{PORTSCRIPT}}", str(port_script)))
## A-PEH ESC-A-PEH
.replace("{{PORTSCRIPT}}", str(port_script).replace(' ', '\\\\ ')))

def remove_port_script(self, port_script):
ROM_SCRIPT_DIR = Path("/mnt/SDCARD/Roms/PORTS")
Expand Down Expand Up @@ -777,7 +790,8 @@ def gamelist_add(self, gameinfo_file):
PORT_CONFIG_JSON
.replace("{{PORTTITLE}}", port_title)
.replace("{{PORTNAME}}", new_port_dir.name.lower())
.replace("{{PORTSCRIPT}}", str(port_script_file)))
## A-PEH ESC-A-PEH
.replace("{{PORTSCRIPT}}", str(port_script_file).replace(' ', '\\\\ ')))

if image_file is not None:
target_file = new_port_dir / ("icon-pre" + image_file.suffix)
Expand All @@ -789,7 +803,7 @@ class PlatformTesting(PlatformBase):
WANT_XBOX_FIX = False

def gamelist_file(self):
return self.hm.ports_dir / 'gamelist.xml'
return self.hm.scripts_dir / 'gamelist.xml'


HM_PLATFORMS = {
Expand Down
33 changes: 18 additions & 15 deletions PortMaster/retrodeck/PortMaster.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/bin/bash

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

controlfolder="$XDG_DATA_HOME/PortMaster"

if [ -d "${HOME}/.var/app/net.retrodeck.retrodeck/config/retrodeck/" ]; then
mkdir -p $controlfolder
cp retrodeck/control.txt $controlfolder
Expand All @@ -25,9 +29,9 @@ fi

## Autoinstallation Code
# This will automatically install zips found within the PortMaster/autoinstall directory using harbourmaster
AUTOINSTALL=$(find "${toolsfolderloc}/PortMaster/autoinstall" -type f \( -name "*.zip" -o -name "*.squashfs" \))
AUTOINSTALL=$(find "$controlfolder/autoinstall" -type f \( -name "*.zip" -o -name "*.squashfs" \))
if [ -n "$AUTOINSTALL" ]; then
source "PortMasterDialog.txt"
source "$controlfolder/PortMasterDialog.txt"

GW=$(PortMasterIPCheck)
PortMasterDialogInit "no-check"
Expand All @@ -37,44 +41,46 @@ if [ -n "$AUTOINSTALL" ]; then
PortMasterDialog "message" "Auto-installation"

# Install the latest runtimes.zip
if [ -f "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip" ]; then
if [ -f "$controlfolder/autoinstall/runtimes.zip" ]; then
PortMasterDialog "message" "- Installing runtimes.zip, this could take a minute or two."
unzip -o "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip" -d "${toolsfolderloc}/PortMaster/libs"
rm -f "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip"
$ESUDO unzip -o "$controlfolder/autoinstall/runtimes.zip" -d "$controlfolder/libs"
$ESUDO rm -f "$controlfolder/autoinstall/runtimes.zip"
PortMasterDialog "message" "- SUCCESS: runtimes.zip"
fi

for file_name in "${toolsfolderloc}/PortMaster/autoinstall"/*.squashfs
for file_name in "$controlfolder/autoinstall"/*.squashfs
do
mv -f "$file_name" "${toolsfolderloc}/PortMaster/libs"
$ESUDO mv -f "$file_name" "$controlfolder/libs"
PortMasterDialog "message" "- SUCCESS: $(basename $file_name)"
done

for file_name in "${toolsfolderloc}/PortMaster/autoinstall"/*.zip
for file_name in "$controlfolder/autoinstall"/*.zip
do
if [[ "$(basename $file_name)" == "PortMaster.zip" ]]; then
continue
fi

if [[ $(PortMasterDialogResult "install" "$file_name") == "OKAY" ]]; then
rm -f "$file_name"
$ESUDO rm -f "$file_name"
PortMasterDialog "message" "- SUCCESS: $(basename $file_name)"
else
PortMasterDialog "message" "- FAILURE: $(basename $file_name)"
fi
done

if [ -f "${toolsfolderloc}/PortMaster/autoinstall/PortMaster.zip" ]; then
file_name="${toolsfolderloc}/PortMaster/autoinstall/PortMaster.zip"
if [ -f "$controlfolder/autoinstall/PortMaster.zip" ]; then
file_name="$controlfolder/autoinstall/PortMaster.zip"

if [[ $(PortMasterDialogResult "install" "$file_name") == "OKAY" ]]; then
rm -f "$file_name"
$ESUDO rm -f "$file_name"
PortMasterDialog "message" "- SUCCESS: $(basename $file_name)"
else
PortMasterDialog "message" "- FAILURE: $(basename $file_name)"
fi
fi

touch "$controlfolder/.muos-refresh"

PortMasterDialog "messages_end"
if [ -z "$GW" ]; then
PortMasterDialogMessageBox "Finished running autoinstall.\n\nNo internet connection present so exiting."
Expand All @@ -97,9 +103,6 @@ while true; do
rm -f "${controlfolder}/.pugwash-reboot"
done

ps -f es-de
es-de

unset LD_LIBRARY_PATH
unset SDL_GAMECONTROLLERCONFIG

Expand Down
88 changes: 68 additions & 20 deletions PortMaster/trimui/update.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,77 @@
#!/bin/ash
#!/bin/bash

NEW_DATA_DIR="/mnt/SDCARD/Data/ports"
LASTPWD="$PWD"
cd /mnt/SDCARD/

OLD_SCRIPT_DIR="/mnt/SDCARD/Roms/PORTS"
if [ -d "/mnt/SDCARD/ports" ]; then
OLD_DATA_DIR="/mnt/SDCARD/ports"
else
OLD_DATA_DIR="/mnt/SDCARD/Ports"
if [ -d "Data/ports" ]; then
exit 0
fi

if [ ! -d "$NEW_DATA_DIR" ]; then
mkdir -p "$NEW_DATA_DIR"
# Function to get the name of a directory with its original case sensitivity
directory_name() {
local dir="$1"
local parent_dir=$(dirname "$dir")
local original_dir=$(basename "$dir")
local found_dir=$(find "$parent_dir" -maxdepth 1 -iname "$original_dir" -type d)

echo "Moving $OLD_DATA_DIR to $NEW_DATA_DIR"
for file in "$OLD_DATA_DIR"/*; do
mv -v "$file" "$NEW_DATA_DIR"
done
if [ -n "$found_dir" ]; then
echo "$found_dir"
else
echo "$original_dir"
fi
}

echo "Moving $OLD_SCRIPT_DIR to $NEW_DATA_DIR"
for file in "$OLD_SCRIPT_DIR"/*.sh; do
cp -v "$file" "$NEW_DATA_DIR"
done
# Function to check if a directory exists, ignoring case sensitivity
directory_exists() {
local dir="$1"
local parent_dir=$(dirname "$dir")
local original_name=$(basename "$dir")
local found
found=$(find "$parent_dir" -maxdepth 1 -iname "$original_name" -type d)
[ -n "$found" ]
}

if directory_exists "Data" && [ ! "$(directory_name "Data")" = "Data" ]; then
# FUCK THIS SHIT
mv_directory="$(directory_name "Data")"
echo "Moving $mv_directory to portmaster_migration_backup" | tee -a "System/portmaster_migration.log"
mkdir -p "portmaster_migration_backup"
mv -v "$mv_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log"
fi

if directory_exists "Data/ports" && [ ! "$(directory_name "Data/ports")" = "Data/ports" ]; then
# Or this
mv_directory="$(directory_name "Data/ports")"
echo "Moving $mv_directory to portmaster_migration_backup" | tee -a "System/portmaster_migration.log"
mkdir -p "portmaster_migration_backup"
mv -v "$mv_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log"
fi

if [ -d "/mnt/SDCARD/ports" ]; then
rm -fR /mnt/SDCARD/ports
mkdir -p /mnt/SDCARD/Ports
# Okay this should be safe...
if ! mkdir -p "Data/ports"; then
# WELL FUCK.
echo "Error: Failed to create Data/ports directory." | tee -a "System/portmaster_migration.log"
cd "$LASTPWD"
exit 1
fi

# Move scripts and directories to Data/ports
mv -v Roms/PORTS/*.sh Data/ports | tee -a "System/portmaster_migration.log"

if directory_exists "ports"; then
ports_directory="$(directory_name "ports")"
mv -v "$ports_directory"/* "Data/ports" | tee -a "System/portmaster_migration.log"

if [ ! -z "$(ls -A ports)" ]; then
# If not empty, backup the directory, recreate Ports/ directory
mkdir -p "portmaster_migration_backup"
mv -v "$ports_directory" "portmaster_migration_backup/" | tee -a "System/portmaster_migration.log"
else
rm -fRv "$ports_directory" | tee -a "System/portmaster_migration.log"
fi
fi

# Okay we made it to the end...
mkdir -v "Ports" | tee -a "System/portmaster_migration.log"

cd "$LASTPWD"
2 changes: 1 addition & 1 deletion tools/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: MIT
#

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

if [ -d "/opt/system/Tools/" ]; then
controlfolder="/opt/system/Tools"
Expand Down

0 comments on commit 9fff62b

Please sign in to comment.