From 77b06090f69264bcc93911664bea2810cd4571ba Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 24 Nov 2021 22:22:30 +0000 Subject: cleaned a few things up --- src/verbs/install.py | 60 +++++++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'src/verbs/install.py') diff --git a/src/verbs/install.py b/src/verbs/install.py index 0531110..6c8c9fd 100644 --- a/src/verbs/install.py +++ b/src/verbs/install.py @@ -174,28 +174,38 @@ def find_all_dependencies(package_names, options, config): while len(to_check) > 0: util.loading_bar(len(all_deps), len(all_deps) + len(to_check), "Resolving dependencies...") dep = to_check.pop() - - dep_checksum, dep_sources, dep_repo = find_package(dep, config["repos"], config["dir"]["packages"], config["sources"]) - if dep_checksum is not None: - info = retrieve_package_info( - dep_sources, dep_checksum, dep, config, - verbose=options["v"], skip_verification=options["u"] - ) - - if len(info) > 0: - if not dep in all_deps: - all_deps.append(dep) - deps = resolve_dependencies(info) - for dep in deps: - if not dep in all_deps: - if is_installed(dep, config, options["r"]): - if options["v"]: print(colors.YELLOW + f"Package {dep} has already been installed") - else: - to_check.append(dep) - elif options["v"]: - util.print_reset(colors.CLEAR_LINE + colors.RED + f"Failed to retrieve info for {dep}") + + # probably better way to implement this obligatory wildcard + # 100% sure there is a better way of doing this than installing all packages from a repo + # maybe some sort of package grouping (or empty package with deps on all needed) + if dep[-2:] == "/*": + repo = dep[:-2] + repo_dir = os.path.join(config["dir"]["packages"], repo) + files = os.listdir(repo_dir) + return files else: - if options["v"]: util.print_reset(colors.CLEAR_LINE + colors.RED + f"Failed to find package {dep}") + dep_checksum, dep_sources, dep_repo = find_package(dep, config["repos"], config["dir"]["packages"], config["sources"]) + + if dep_checksum is not None: + info = retrieve_package_info( + dep_sources, dep_checksum, dep, config, + verbose=options["v"], skip_verification=options["u"] + ) + + if len(info) > 0: + if not dep in all_deps: + all_deps.append(dep) + deps = resolve_dependencies(info) + for dep in deps: + if not dep in all_deps: + if is_installed(dep, config, options["r"]): + if options["v"]: print(colors.YELLOW + f"Package {dep} has already been installed") + else: + to_check.append(dep) + elif options["v"]: + util.print_reset(colors.CLEAR_LINE + colors.RED + f"Failed to retrieve info for {dep}") + else: + if options["v"]: util.print_reset(colors.CLEAR_LINE + colors.RED + f"Failed to find package {dep}") if len(all_deps) > 0: util.loading_bar(len(all_deps), len(all_deps) + len(to_check), "Resolved dependencies") @@ -270,6 +280,7 @@ def install(args, options, config): if len(to_install) > 0: + print(colors.CLEAR_LINE + colors.RESET, end="") print(colors.BLUE + "The following packages will be installed:") print(end="\t") for d in to_install: @@ -278,6 +289,7 @@ def install(args, options, config): if util.ask_confirmation(colors.BLUE + "Continue?", no_confirm=options["y"]): + downloaded = [] for package in to_install: checksum, sources, repo = find_package(package, config["repos"], config["dir"]["packages"], config["sources"]) @@ -291,10 +303,14 @@ def install(args, options, config): info, package, config, verbose=v, skip_verification=unsafe) + downloaded.append(package, package_path, info, + repo, sources[source], key + ) install_package(package, package_path, info, repo, sources[source], key, config, root=options["r"]) - print(colors.BG_CYAN + colors.LIGHT_BLACK + f"Installed {package}" + colors.RESET) + util.fill_line(f"Installed {package}", colors.BG_CYAN + colors.LIGHT_BLACK, end="\n") + else: print(colors.RED + "Action cancelled by user") else: -- cgit v1.2.1