diff options
author | davidovski <david@davidovski.xyz> | 2022-01-07 22:49:36 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-01-07 22:49:36 +0000 |
commit | 522470e4c6af96f94083c4ba7ef2ff4488458f74 (patch) | |
tree | 7602a8cb740ae0b86ca5dced51325bf021fc1370 | |
parent | 990511332009d1e1947aa89867c3d9ecb22941ac (diff) |
moved install script to other repo
-rwxr-xr-x | install-system.sh | 85 | ||||
-rw-r--r-- | src/verbs/install.py | 155 | ||||
-rw-r--r-- | src/verbs/update.py | 16 |
3 files changed, 84 insertions, 172 deletions
diff --git a/install-system.sh b/install-system.sh deleted file mode 100755 index eeb7e9c..0000000 --- a/install-system.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/bash - -# This is just a temporary install script that will install xilinux into a folder -# recommended to run with root - -KEY="davidovski https://xi.davidovski.xyz/repo/xi.pub" - -XI_OPTS="-nyl" - -R=$1 - -[ $# -eq 0 ] && echo "Please specify where you would like to instal the system" && exit 1 - -if [ -e $R ]; then - printf "Remove existing system? [Y/n] " - read response - - if [ "$response" != "n" ]; then - rm -rf $R - echo "removed $R" - fi -fi - - -mkdir -p $R -mkdir -p $R/tmp -mkdir -p $R/dev -mkdir -p $R/sys -mkdir -p $R/run -mkdir -p $R/proc -mkdir -p $R/usr/bin -mkdir -p $R/usr/lib -mkdir -p $R/root - -cd $R -ln -s usr/bin bin -ln -s usr/bin sbin -ln -s usr/bin usr/sbin - -ln -s usr/lib lib -ln -s usr/lib lib64 -ln -s usr/lib usr/lib64 - -ln -s usr/local usr - -xi sync && -xi $XI_OPTS --root . install $(ls /var/lib/xipkg/packages/core) && -xi $XI_OPTS --root . keyimport $KEY && -# chroot into the system to install xipkg and any postinstall scripts -xi $XI_OPTS --root . install xipkg && - -cd ../.. && - -echo "base system installed next to do:" && -echo " xichroot into system" && -echo " set hostname at /etc/hostname" && -echo " configure DNS at /etc/resolv.conf" && -echo " xi sync" && -echo " install any additional packages" && -echo " compile and install kernel" && -echo " configure and install grub" && -echo " * hope that the system works!" && -echo "have fun!" && -exit 0; - -echo "something went wrong" -exit 0; - - -## leftover autoconfig scripts - -mkdir -p $R/var/lib/xipkg/ -cp -r /var/lib/xipkg/packages $R/var/lib/xipkg -cp -r /var/lib/xipkg/keychain $R/var/lib/xipkg - -# Autoconfiguring some things like network - -mkdir -p $R/etc -echo "xilinux" > $R/etc/hostname - -cat > $R/etc/resolv.conf << "EOF" -nameserver 80.80.80.80 -nameserver 80.80.81.81 -EOF - diff --git a/src/verbs/install.py b/src/verbs/install.py index 9832e2b..b2fdf51 100644 --- a/src/verbs/install.py +++ b/src/verbs/install.py @@ -301,7 +301,7 @@ def run_post_install(config, verbose=False, root="/"): def install_single(package, options, config, post_install=True, verbose=False, unsafe=False): - checksum, sources, repo = find_package(package, config["repos"], + checksum, sources, repo, size, files = find_package(package, config["repos"], config["dir"]["packages"], config["sources"]) info = retrieve_package_info( @@ -318,6 +318,85 @@ def install_single(package, options, config, post_install=True, verbose=False, u config, verbose=verbose, root=options["r"]) +def install_multiple(to_install, args, options, config, terminology=("install", "installed", "installing")): + v = options["v"] + unsafe = options["u"] + + length = 0 + total_files = 0 + infos = [] + for package in to_install: + util.loading_bar(len(infos), len(to_install), "Gathering package infos") + checksum, sources, repo, size, filecount = find_package(package, config["repos"], + config["dir"]["packages"], config["sources"]) + + if checksum != None: + info = retrieve_package_info( + sources, checksum, package, config, + verbose=v, skip_verification=unsafe + ) + + # TODO make package_size be written in package info or sync list instead + length += int(size) + total_files += int(filecount) + + infos.append( + (package, sources, repo, info) + ) + + divisor, unit = util.get_unit(length) + + util.loading_bar(len(infos), len(to_install), "Gathered package infos") + print(colors.RESET) + + if not options["y"]: + print(colors.BLUE + f"The following packages will be {terminology[1]}:") + print(end="\t") + for d in to_install: + print(colors.BLUE if d in args else colors.LIGHT_BLUE, d, end="") + print() + + print(colors.BLUE + "Total download size: " + colors.LIGHT_BLUE + str(round(length / divisor, 2)) + unit) + + if options["y"] or util.ask_confirmation(colors.BLUE + "Continue?"): + # TODO try catch over each package in each stage so that we can know if there are errors + + downloaded = 0 + pkg_files = [] + for package_info in infos: + (package, sources, repo, info) = package_info + + package_path, source, key, size = retrieve_package(sources, + info, package, config, + completed=downloaded, total_download=length, + verbose=v, skip_verification=unsafe) + + downloaded += size + + pkg_files.append( + (package, package_path, sources[source], key, repo, info) + ) + + util.loading_bar(int(length/divisor), int(length/divisor), "Downloaded packages", unit=unit) + print(colors.RESET) + + extracted = 0 + for f in pkg_files: + util.loading_bar(extracted, total_files, terminology[2].capitalize() + " files") + + (package, package_path, source, key, repo, info) = f + + files = install_package(package, package_path, info, + repo, source, key, True, + config, verbose=v, root=options["r"]) + extracted += len(files.split("\n")) + + util.loading_bar(extracted, total_files, terminology[1].capitalize() + " files") + print(colors.RESET) + else: + print(colors.RED + "Action cancelled by user") + + def install(args, options, config): if not options["l"]: sync(args, options, config) @@ -345,79 +424,7 @@ def install(args, options, config): print() if len(to_install) > 0: - length = 0 - total_files = 0 - infos = [] - for package in to_install: - util.loading_bar(len(infos), len(to_install), "Gathering package infos") - checksum, sources, repo, size, filecount = find_package(package, config["repos"], - config["dir"]["packages"], config["sources"]) - - if checksum != None: - info = retrieve_package_info( - sources, checksum, package, config, - verbose=v, skip_verification=unsafe - ) - - # TODO make package_size be written in package info or sync list instead - length += int(size) - total_files += int(filecount) - - infos.append( - (package, sources, repo, info) - ) - - divisor, unit = util.get_unit(length) - - util.loading_bar(len(infos), len(to_install), "Gathered package infos") - print(colors.RESET) - - if not options["y"]: - print(colors.BLUE + "The following packages will be installed:") - print(end="\t") - for d in to_install: - print(colors.BLUE if d in args else colors.LIGHT_BLUE, d, end="") - print() - - print(colors.BLUE + "Total download size: " + colors.LIGHT_BLUE + str(round(length / divisor, 2)) + unit) - - if options["y"] or util.ask_confirmation(colors.BLUE + "Continue?"): - # TODO try catch over each package in each stage so that we can know if there are errors - - downloaded = 0 - pkg_files = [] - for package_info in infos: - (package, sources, repo, info) = package_info - - package_path, source, key, size = retrieve_package(sources, - info, package, config, - completed=downloaded, total_download=length, - verbose=v, skip_verification=unsafe) - - downloaded += size - - pkg_files.append( - (package, package_path, sources[source], key, repo, info) - ) - - util.loading_bar(int(length/divisor), int(length/divisor), "Downloaded packages", unit=unit) - print(colors.RESET) - - extracted = 0 - for f in pkg_files: - util.loading_bar(extracted, total_files, "Installing files") - - (package, package_path, source, key, repo, info) = f - - files = install_package(package, package_path, info, - repo, source, key, True, - config, verbose=v, root=options["r"]) - extracted += len(files.split("\n")) - - util.loading_bar(extracted, total_files, "Installed files") - print(colors.RESET) - else: - print(colors.RED + "Action cancelled by user") + install_multiple(to_install, args, options, config) else: print(colors.LIGHT_RED + "Nothing to do") else: diff --git a/src/verbs/update.py b/src/verbs/update.py index 4348637..6fe89f6 100644 --- a/src/verbs/update.py +++ b/src/verbs/update.py @@ -3,7 +3,7 @@ import util import colors import time -from verbs.install import find_package, install_single +from verbs.install import find_package, install_multiple from verbs.sync import sync VERSION_COMPARED = "CHECKSUM" @@ -26,7 +26,7 @@ def get_available_version(package_name, config, root="/"): repos = config["repos"] packages_dir = config["dir"]["packages"] sources = config["sources"] - checksum, found_sources, requested_repo = find_package(package_name, repos, packages_dir, sources) + checksum, found_sources, requested_repo, size, files = find_package(package_name, repos, packages_dir, sources) return checksum def update(args, options, config): @@ -41,17 +41,7 @@ def update(args, options, config): updates = [update for update in updates if update in args] if len(updates) > 0: - print(colors.CLEAR_LINE + colors.RESET, end="") - print(colors.BLUE + "The following packages will be updated:") - print(end="\t") - for d in updates: - print(colors.BLUE if d in args else colors.LIGHT_BLUE, d, end="") - print() - - if util.ask_confirmation(colors.BLUE + "Continue?", no_confirm=options["y"]): - for package in updates: - install_single(package, options, config, verbose=v, post_install=False, unsafe=options["u"]) - util.fill_line(f"Updated {package}", colors.BG_CYAN + colors.LIGHT_BLACK, end="\n") + install_multiple(updates, args, options, config, terminology=("update", "updated", "updating")) else: print(colors.LIGHT_RED + "Nothing to do") |