diff --git a/PortMaster/PortMaster.sh b/PortMaster/PortMaster.sh index 9edd44d..998ac01 100755 --- a/PortMaster/PortMaster.sh +++ b/PortMaster/PortMaster.sh @@ -29,6 +29,87 @@ echo "Starting PortMaster." > $CUR_TTY $ESUDO chmod -R +x . +if [[ -e "/storage/.config/.OS_ARCH" ]] || [ "${OS_NAME}" == "JELOS" ] || [ "${OS_NAME}" == "UnofficialOS" ]; then + toolsfolderloc="/storage/roms/ports" +else + isitthera=$($GREP "title=" "/usr/share/plymouth/themes/text.plymouth") + if [[ $isitthera == *"TheRA"* ]]; then + if [ -d "/opt/tools/PortMaster/" ]; then + toolsfolderloc="/opt/tools" + else + toolsfolderloc="/roms/ports" + fi + else + if [ -d "/opt/system/Tools/PortMaster/" ]; then + toolsfolderloc="/opt/system/Tools" + else + toolsfolderloc="/roms/ports" + fi + fi +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" \)) +if [ -n "$AUTOINSTALL" ]; then + source "PortMasterDialog.txt" + + GW=$(PortMasterIPCheck) + PortMasterDialogInit "no-check" + + PortMasterDialog "messages_begin" + + PortMasterDialog "message" "Auto-installation" + + # Install the latest runtimes.zip + if [ -f "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip" ]; then + $ESUDO unzip -o "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip" -d "${toolsfolderloc}/PortMaster/libs" + $ESUDO rm -f "${toolsfolderloc}/PortMaster/autoinstall/runtimes.zip" + PortMasterDialog "message" "- SUCCESS: runtimes.zip" + fi + + for file_name in "${toolsfolderloc}/PortMaster/autoinstall"/*.squashfs + do + $ESUDO mv -f "$file_name" "${toolsfolderloc}/PortMaster/libs" + PortMasterDialog "message" "- SUCCESS: $(basename $file_name)" + done + + for file_name in "${toolsfolderloc}/PortMaster/autoinstall"/*.zip + do + if [[ "$(basename $file_name)" == "PortMaster.zip" ]]; then + continue + fi + + if [[ $(PortMasterDialogResult "install" "$file_name") == "OKAY" ]]; then + $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 [[ $(PortMasterDialogResult "install" "$file_name") == "OKAY" ]]; then + $ESUDO rm -f "$file_name" + PortMasterDialog "message" "- SUCCESS: $(basename $file_name)" + else + PortMasterDialog "message" "- FAILURE: $(basename $file_name)" + fi + fi + + PortMasterDialog "messages_end" + if [ -z "$GW" ]; then + PortMasterDialogMessageBox "Finished running autoinstall.\n\nNo internet connection present so exiting." + PortMasterDialogExit + exit 0 + else + PortMasterDialogMessageBox "Finished running autoinstall." + PortMasterDialogExit + fi +fi + export PYSDL2_DLL_PATH="/usr/lib" $ESUDO rm -f "${controlfolder}/.pugwash-reboot" while true; do diff --git a/PortMaster/pugwash b/PortMaster/pugwash index 8093a91..60e05ae 100755 --- a/PortMaster/pugwash +++ b/PortMaster/pugwash @@ -1,7 +1,7 @@ #!/usr/bin/env python3 ## -- BEGIN PORTMASTER INFO -- -PORTMASTER_VERSION = '8.4.19' +PORTMASTER_VERSION = '8.4.20' PORTMASTER_RELEASE_CHANNEL = 'beta' ## -- END PORTMASTER INFO -- @@ -609,6 +609,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): self.callback_messages = [] self.callback_progress = None self.callback_amount = 0 + self.message_box_disable = False self.message_box_depth = 0 self.message_box_scene = None self.was_cancelled = False @@ -1062,6 +1063,12 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): if cancel_text is None: cancel_text = _("Cancel") + if self.message_box_disable: + if want_cancel: + return False + + return True + ## This fixes a bug :D self.events.handle_events() @@ -1139,6 +1146,20 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): finally: self.messages_end(internal=True) + @contextlib.contextmanager + def disable_messagebox(self): + """ + Disables displaying the messagebox, should be used in conjunction with enable_cancellable(False) + """ + old_message_state = self.message_box_disable + try: + self.message_box_disable = True + + yield + + finally: + self.message_box_disable = old_message_state + ## Scene code. def scene_list(self): return [ @@ -1544,6 +1565,22 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): result = self.hm.check_runtime(args[0]) fifo_config['done-file'].write_text(result and "FAIL" or "OKAY") + def fifo_install(self, fifo_config, args): + if self.hm is None: + logger.debug("port install requested with no harbourmaster.") + fifo_config['done-file'].write_text("FAIL") + return + + if len(args) == 0: + fifo_config['done-file'].write_text("FAIL") + return + + with self.enable_messages(): + with self.enable_cancellable(False): + with self.disable_messagebox(): + result = self.hm.install_port(args[0]) + fifo_config['done-file'].write_text(result and "FAIL" or "OKAY") + fifo_commands = { 'register_set_info': fifo_reg_set_info, 'register_clear_info': fifo_reg_clear_info, @@ -1561,6 +1598,7 @@ class PortMasterGUI(pySDL2gui.GUI, harbourmaster.Callback): 'message_box': fifo_message_box, 'check_runtime': fifo_check_runtime, + 'install': fifo_install, } def do_fifo_control(self, config, argv): diff --git a/PortMaster/pylibs/pugscene.py b/PortMaster/pylibs/pugscene.py index d76c346..071b16e 100644 --- a/PortMaster/pylibs/pugscene.py +++ b/PortMaster/pylibs/pugscene.py @@ -1441,6 +1441,7 @@ def update_filters(self): DISPLAY_ORDER = [ 'sort', + 'clear-filters', 'attr', 'genres', 'porters', @@ -1469,6 +1470,14 @@ def update_filters(self): if selected_option == hm_sort_order: selected_offset = len(self.tags['filter_list'].options) - 1 + elif display_order == 'clear-filters': + if len(self.selected_genres) > 0: + if add_blank: + self.tags['filter_list'].add_option(None, "") + + add_blank = True + self.tags['filter_list'].add_option('clear-filters', [" ", _("Clear Filters"), " "]) + elif display_order == 'genres': for hm_genre in sorted(harbourmaster.HM_GENRES, key=lambda genre: (sort_order.get(genre, 0), filter_translation.get(genre, genre))): if hm_genre in self.locked_genres: @@ -1576,7 +1585,10 @@ def do_update(self, events): self.button_activate() return True - if selected_filter in self.selected_genres: + if selected_filter == 'clear-filters': + self.selected_genres.clear() + + elif selected_filter in self.selected_genres: self.selected_genres.remove(selected_filter) else: