install dependencies
This commit is contained in:
@@ -3,6 +3,8 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import tarfile
|
import tarfile
|
||||||
|
import configparser
|
||||||
|
import shutil
|
||||||
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.progress import SpinnerColumn
|
from rich.progress import SpinnerColumn
|
||||||
@@ -12,10 +14,12 @@ from util import check_ground_libs_path, check_sudo
|
|||||||
console = Console()
|
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
|
retries_left = args.max_retries
|
||||||
|
|
||||||
with console.status("Downloading tarball...", spinner="bouncingBall", spinner_style="blue") as status:
|
with console.status("Downloading tarball...", spinner="bouncingBall", spinner_style="blue") as status:
|
||||||
|
console.print(f"Installing {package_name} [d]({version})[/]")
|
||||||
|
|
||||||
while retries_left > 0:
|
while retries_left > 0:
|
||||||
# grab the tar ball
|
# grab the tar ball
|
||||||
response = requests.get(f"https://chookspace.com/api/packages/ground/generic/{package_name}/{version}/mineral.tar")
|
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...")
|
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
|
# 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
|
symlink_path = os.path.join(extract_dir, f"{package_name}.so") # the path where the symlink is
|
||||||
if not os.path.isfile(symlink_path):
|
if not os.path.isfile(symlink_path):
|
||||||
os.symlink(os.path.join(extract_dir, package_name, "main.so"), 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):
|
def install(args):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user