refactor: update dependency management
Signed-off-by: Dominik Willner <th33xitus@gmail.com>
This commit is contained in:
@@ -74,6 +74,7 @@ def install_klipper() -> None:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
if not kl_im.instances:
|
if not kl_im.instances:
|
||||||
|
check_install_dependencies(["git"])
|
||||||
setup_klipper_prerequesites()
|
setup_klipper_prerequesites()
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
|
|||||||
@@ -260,10 +260,11 @@ def handle_disruptive_system_packages() -> None:
|
|||||||
try:
|
try:
|
||||||
cmd_sysctl_service(service, "mask")
|
cmd_sysctl_service(service, "mask")
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
|
# todo: replace with Logger.print_dialog
|
||||||
warn_msg = textwrap.dedent(
|
warn_msg = textwrap.dedent(
|
||||||
f"""
|
f"""
|
||||||
KIAUH was unable to mask the {service} system service.
|
KIAUH was unable to mask the {service} system service.
|
||||||
Please fix the problem manually. Otherwise, this may have
|
Please fix the problem manually. Otherwise, this may have
|
||||||
undesirable effects on the operation of Klipper.
|
undesirable effects on the operation of Klipper.
|
||||||
"""
|
"""
|
||||||
)[1:]
|
)[1:]
|
||||||
|
|||||||
@@ -52,14 +52,17 @@ def install_klipperscreen() -> None:
|
|||||||
mr_im = InstanceManager(Moonraker)
|
mr_im = InstanceManager(Moonraker)
|
||||||
mr_instances = mr_im.instances
|
mr_instances = mr_im.instances
|
||||||
if not mr_instances:
|
if not mr_instances:
|
||||||
warn_msg = [
|
Logger.print_dialog(
|
||||||
"Moonraker not found! KlipperScreen will not properly work "
|
DialogType.WARNING,
|
||||||
"without a working Moonraker installation.",
|
[
|
||||||
"\n\n",
|
"Moonraker not found! KlipperScreen will not properly work "
|
||||||
"KlipperScreens update manager configuration for Moonraker "
|
"without a working Moonraker installation.",
|
||||||
"will not be added to any moonraker.conf.",
|
"\n\n",
|
||||||
]
|
"KlipperScreens update manager configuration for Moonraker "
|
||||||
Logger.print_dialog(DialogType.WARNING, warn_msg)
|
"will not be added to any moonraker.conf.",
|
||||||
|
],
|
||||||
|
end="",
|
||||||
|
)
|
||||||
if not get_confirm(
|
if not get_confirm(
|
||||||
"Continue KlipperScreen installation?",
|
"Continue KlipperScreen installation?",
|
||||||
default_choice=False,
|
default_choice=False,
|
||||||
@@ -67,7 +70,7 @@ def install_klipperscreen() -> None:
|
|||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
package_list = ["wget", "curl", "unzip", "dfu-util"]
|
package_list = ["git", "wget", "curl", "unzip", "dfu-util"]
|
||||||
check_install_dependencies(package_list)
|
check_install_dependencies(package_list)
|
||||||
|
|
||||||
git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR)
|
git_clone_wrapper(KLIPPERSCREEN_REPO, KLIPPERSCREEN_DIR)
|
||||||
@@ -80,7 +83,8 @@ def install_klipperscreen() -> None:
|
|||||||
mr_im.restart_all_instance()
|
mr_im.restart_all_instance()
|
||||||
else:
|
else:
|
||||||
Logger.print_info(
|
Logger.print_info(
|
||||||
"Moonraker is not installed! Cannot add KlipperScreen to update manager!"
|
"Moonraker is not installed! Cannot add "
|
||||||
|
"KlipperScreen to update manager!"
|
||||||
)
|
)
|
||||||
Logger.print_ok("KlipperScreen successfully installed!")
|
Logger.print_ok("KlipperScreen successfully installed!")
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
|
|||||||
@@ -52,13 +52,16 @@ def install_mobileraker() -> None:
|
|||||||
mr_im = InstanceManager(Moonraker)
|
mr_im = InstanceManager(Moonraker)
|
||||||
mr_instances = mr_im.instances
|
mr_instances = mr_im.instances
|
||||||
if not mr_instances:
|
if not mr_instances:
|
||||||
warn_msg = [
|
Logger.print_dialog(
|
||||||
"Moonraker not found! Mobileraker's companion will not properly work "
|
DialogType.WARNING,
|
||||||
"without a working Moonraker installation.",
|
[
|
||||||
"Mobileraker's companion's update manager configuration for Moonraker "
|
"Moonraker not found! Mobileraker's companion will not properly work "
|
||||||
"will not be added to any moonraker.conf.",
|
"without a working Moonraker installation.",
|
||||||
]
|
"Mobileraker's companion's update manager configuration for Moonraker "
|
||||||
Logger.print_dialog(DialogType.WARNING, warn_msg)
|
"will not be added to any moonraker.conf.",
|
||||||
|
],
|
||||||
|
end="",
|
||||||
|
)
|
||||||
if not get_confirm(
|
if not get_confirm(
|
||||||
"Continue Mobileraker's companion installation?",
|
"Continue Mobileraker's companion installation?",
|
||||||
default_choice=False,
|
default_choice=False,
|
||||||
@@ -66,7 +69,7 @@ def install_mobileraker() -> None:
|
|||||||
):
|
):
|
||||||
return
|
return
|
||||||
|
|
||||||
package_list = ["wget", "curl", "unzip", "dfu-util"]
|
package_list = ["git", "wget", "curl", "unzip", "dfu-util"]
|
||||||
check_install_dependencies(package_list)
|
check_install_dependencies(package_list)
|
||||||
|
|
||||||
git_clone_wrapper(MOBILERAKER_REPO, MOBILERAKER_DIR)
|
git_clone_wrapper(MOBILERAKER_REPO, MOBILERAKER_DIR)
|
||||||
@@ -79,7 +82,8 @@ def install_mobileraker() -> None:
|
|||||||
mr_im.restart_all_instance()
|
mr_im.restart_all_instance()
|
||||||
else:
|
else:
|
||||||
Logger.print_info(
|
Logger.print_info(
|
||||||
"Moonraker is not installed! Cannot add Mobileraker's companion to update manager!"
|
"Moonraker is not installed! Cannot add Mobileraker's "
|
||||||
|
"companion to update manager!"
|
||||||
)
|
)
|
||||||
Logger.print_ok("Mobileraker's companion successfully installed!")
|
Logger.print_ok("Mobileraker's companion successfully installed!")
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
# #
|
# #
|
||||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||||
# ======================================================================= #
|
# ======================================================================= #
|
||||||
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -86,32 +86,40 @@ def install_moonraker() -> None:
|
|||||||
instance_names.append(klipper_instances[index].suffix)
|
instance_names.append(klipper_instances[index].suffix)
|
||||||
|
|
||||||
create_example_cfg = get_confirm("Create example moonraker.conf?")
|
create_example_cfg = get_confirm("Create example moonraker.conf?")
|
||||||
setup_moonraker_prerequesites()
|
|
||||||
install_moonraker_polkit()
|
|
||||||
|
|
||||||
used_ports_map = {
|
try:
|
||||||
instance.suffix: instance.port for instance in moonraker_instances
|
check_install_dependencies(["git"])
|
||||||
}
|
setup_moonraker_prerequesites()
|
||||||
for name in instance_names:
|
install_moonraker_polkit()
|
||||||
current_instance = Moonraker(suffix=name)
|
|
||||||
|
|
||||||
mr_im.current_instance = current_instance
|
used_ports_map = {
|
||||||
mr_im.create_instance()
|
instance.suffix: instance.port for instance in moonraker_instances
|
||||||
mr_im.enable_instance()
|
}
|
||||||
|
for name in instance_names:
|
||||||
|
current_instance = Moonraker(suffix=name)
|
||||||
|
|
||||||
if create_example_cfg:
|
mr_im.current_instance = current_instance
|
||||||
# if a webclient and/or it's config is installed, patch its update section to the config
|
mr_im.create_instance()
|
||||||
clients = get_existing_clients()
|
mr_im.enable_instance()
|
||||||
create_example_moonraker_conf(current_instance, used_ports_map, clients)
|
|
||||||
|
|
||||||
mr_im.start_instance()
|
if create_example_cfg:
|
||||||
|
# if a webclient and/or it's config is installed, patch
|
||||||
|
# its update section to the config
|
||||||
|
clients = get_existing_clients()
|
||||||
|
create_example_moonraker_conf(current_instance, used_ports_map, clients)
|
||||||
|
|
||||||
mr_im.reload_daemon()
|
mr_im.start_instance()
|
||||||
|
|
||||||
# if mainsail is installed, and we installed
|
mr_im.reload_daemon()
|
||||||
# multiple moonraker instances, we enable mainsails remote mode
|
|
||||||
if MainsailData().client_dir.exists() and len(mr_im.instances) > 1:
|
# if mainsail is installed, and we installed
|
||||||
enable_mainsail_remotemode()
|
# multiple moonraker instances, we enable mainsails remote mode
|
||||||
|
if MainsailData().client_dir.exists() and len(mr_im.instances) > 1:
|
||||||
|
enable_mainsail_remotemode()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
Logger.print_error(f"Error while installing Moonraker: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
def check_moonraker_install_requirements() -> bool:
|
def check_moonraker_install_requirements() -> bool:
|
||||||
@@ -140,9 +148,19 @@ def setup_moonraker_prerequesites() -> None:
|
|||||||
|
|
||||||
|
|
||||||
def install_moonraker_packages(moonraker_dir: Path) -> None:
|
def install_moonraker_packages(moonraker_dir: Path) -> None:
|
||||||
script = moonraker_dir.joinpath("scripts/install-moonraker.sh")
|
install_script = moonraker_dir.joinpath("scripts/install-moonraker.sh")
|
||||||
packages = parse_packages_from_file(script)
|
deps_json = MOONRAKER_DIR.joinpath("scripts/system-dependencies.json")
|
||||||
check_install_dependencies(packages)
|
moonraker_deps = []
|
||||||
|
|
||||||
|
if deps_json.exists():
|
||||||
|
moonraker_deps = json.load(deps_json).get("debian", [])
|
||||||
|
elif install_script.exists():
|
||||||
|
moonraker_deps = parse_packages_from_file(install_script)
|
||||||
|
|
||||||
|
if not moonraker_deps:
|
||||||
|
raise ValueError("Error reading Moonraker dependencies!")
|
||||||
|
|
||||||
|
check_install_dependencies(moonraker_deps)
|
||||||
|
|
||||||
|
|
||||||
def install_moonraker_polkit() -> None:
|
def install_moonraker_polkit() -> None:
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ def install_client(client: BaseWebClient) -> None:
|
|||||||
)
|
)
|
||||||
valid_port = is_valid_port(port, ports_in_use)
|
valid_port = is_valid_port(port, ports_in_use)
|
||||||
|
|
||||||
check_install_dependencies(["nginx"])
|
check_install_dependencies(["nginx", "unzip"])
|
||||||
|
|
||||||
try:
|
try:
|
||||||
download_client(client)
|
download_client(client)
|
||||||
|
|||||||
Reference in New Issue
Block a user