Skip to content

Commit

Permalink
Added option to choose ports sdcard on muOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
kloptops committed Jun 9, 2024
1 parent db9ec8c commit e758291
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
8 changes: 5 additions & 3 deletions PortMaster/pylibs/harbourmaster/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@

################################################################################
## The following code is a simplification of the PortMaster toolsloc and whichsd code.
HM_DEFAULT_PORTS_DIR = Path("/roms/ports")
HM_DEFAULT_PORTS_DIR = Path("/roms/ports")
HM_DEFAULT_SCRIPTS_DIR = Path("/roms/ports")
HM_DEFAULT_TOOLS_DIR = Path("/roms/ports")
HM_DEFAULT_TOOLS_DIR = Path("/roms/ports")

if 'XDG_DATA_HOME' not in os.environ:
os.environ['XDG_DATA_HOME'] = str(Path().home() / '.local' / 'share')
Expand Down Expand Up @@ -62,7 +62,9 @@
HM_DEFAULT_PORTS_DIR = Path("/mnt/mmc/ports")
HM_DEFAULT_SCRIPTS_DIR = Path("/mnt/mmc/ROMS/Ports")

if '/mnt/sdcard' in subprocess.getoutput(['df']):
MUOS_MMC_TOGGLE = Path('/mnt/mmc/MUOS/PortMaster/config/muos_mmc_master_race.txt')

if not MUOS_MMC_TOGGLE.is_file() and '/mnt/sdcard' in subprocess.getoutput(['df']):
HM_DEFAULT_PORTS_DIR = Path("/mnt/sdcard/ports")
HM_DEFAULT_SCRIPTS_DIR = Path("/mnt/sdcard/ROMS/Ports")

Expand Down
41 changes: 41 additions & 0 deletions PortMaster/pylibs/pugscene.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
import gettext
import json
import os
import pathlib
import shutil
import subprocess

import sdl2
import sdl2.ext

import harbourmaster
import pySDL2gui

from pathlib import Path
from loguru import logger


Expand Down Expand Up @@ -557,6 +560,15 @@ def __init__(self, gui):
_("Ports Location: ") + (self.gui.hm.cfg_data.get('trimui-port-mode', 'roms') == 'roms' and _("Roms section") or _("Ports tab")),
description=_("Location where ports should be installed to."))

if self.gui.hm.device['name'] == 'muOS':
if '/mnt/sdcard' in subprocess.getoutput(['df']):
MUOS_MMC_TOGGLE = Path('/mnt/mmc/MUOS/PortMaster/config/muos_mmc_master_race.txt')

self.tags['option_list'].add_option(
'muos-port-mode-toggle',
_("Ports Location: ") + (MUOS_MMC_TOGGLE.is_file() and _("SD 1") or _("SD 2")),
description=_("Location where ports should be installed to."))

self.tags['option_list'].add_option(None, _("System"))

self.tags['option_list'].add_option(
Expand Down Expand Up @@ -844,6 +856,35 @@ def do_update(self, events):

self.gui.hm.platform.do_move_ports()

if selected_option == 'muos-port-mode-toggle':
if '/mnt/sdcard' in subprocess.getoutput(['df']):
MUOS_MMC_TOGGLE = Path('/mnt/mmc/MUOS/PortMaster/config/muos_mmc_master_race.txt')

language_map = {
True: _('SDCARD 1'),
False: _('SDCARD 2'),
}

if self.gui.message_box(
_("Are you sure you want to manage and install ports on {to_loc}?\n\nAlready installed ports will not be moved.\nPortMaster will restart for this to take effect.").format(
to_loc=language_map[(not MUOS_MMC_TOGGLE.is_file())]),
want_cancel=True):

self.gui.events.running = False

if MUOS_MMC_TOGGLE.is_file():
MUOS_MMC_TOGGLE.unlink()

else:
MUOS_MMC_TOGGLE.touch(0o644)

if not harbourmaster.HM_TESTING:
reboot_file = (harbourmaster.HM_TOOLS_DIR / "PortMaster" / ".pugwash-reboot")
if not reboot_file.is_file():
reboot_file.touch(0o644)

return True

if selected_option == 'runtime-manager':
self.gui.push_scene('runtime-manager', RuntimesScene(self.gui))
return True
Expand Down

0 comments on commit e758291

Please sign in to comment.