From 77a7a4480467fb5342f039fa7d3508c8bf1fdb02 Mon Sep 17 00:00:00 2001 From: SpookyDervish Date: Mon, 19 Jan 2026 21:06:25 +1100 Subject: [PATCH] install dependencies --- src/install.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/install.py b/src/install.py index dbdcafe..0183dd8 100644 --- a/src/install.py +++ b/src/install.py @@ -3,6 +3,8 @@ import os import sys import tempfile import tarfile +import configparser +import shutil from rich.console import Console from rich.progress import SpinnerColumn @@ -12,10 +14,12 @@ from util import check_ground_libs_path, check_sudo console = Console() -def install_package(package_name, version, args): +def install_package(package_name, version, args, is_dependency: bool = False): retries_left = args.max_retries with console.status("Downloading tarball...", spinner="bouncingBall", spinner_style="blue") as status: + console.print(f"Installing {package_name} [d]({version})[/]") + while retries_left > 0: # grab the tar ball response = requests.get(f"https://chookspace.com/api/packages/ground/generic/{package_name}/{version}/mineral.tar") @@ -65,12 +69,32 @@ def install_package(package_name, version, args): console.status("Finishing up...") + package_folder = os.path.join(extract_dir, f"{package_name}/") + + if not os.path.isfile(os.path.join(package_folder, "mineral.ini")): + console.print(f"[b red]digpkg: failed to install {package_name}: the mineral doesn't have a mineral.ini file, please contact the maintainer because they've set up the mineral incorrectly.") + console.print("[d]Cleaning up failed install...[/]") + shutil.rmtree(os.path.join(extract_dir, package_name)) + sys.exit(1) + + config_parser = configparser.ConfigParser() + config_parser.read(os.path.join(package_folder, "mineral.ini")) + dependencies = config_parser["dependencies"] + # create a symlink from the main.so file to the ground libs folder so ground can find it symlink_path = os.path.join(extract_dir, f"{package_name}.so") # the path where the symlink is if not os.path.isfile(symlink_path): os.symlink(os.path.join(extract_dir, package_name, "main.so"), symlink_path) - console.print("[:white_check_mark:] Done!") + if is_dependency: + console.print(f"[d][:white_check_mark:] Done installing dependency: {package_name}[/]") + + for dependency, dependency_version in dependencies.items(): + install_package(dependency, dependency_version, args, True) + + if not is_dependency: + console.print(f"\n[b green][:white_check_mark:] Installed {package_name}![/]") + def install(args):