summaryrefslogtreecommitdiff
path: root/src/verbs/update.py
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-01-16 01:59:07 +0000
committerdavidovski <david@davidovski.xyz>2022-01-16 01:59:07 +0000
commit83f2427f0d9378eb25c894648873738dea6a97a4 (patch)
tree9aea5ab584e96a7f02caf143d475c71d0475fca2 /src/verbs/update.py
parent169c42b7c4d9311030f027528e4b13307e1c4688 (diff)
merged updating and syncing
Diffstat (limited to 'src/verbs/update.py')
-rw-r--r--src/verbs/update.py37
1 files changed, 7 insertions, 30 deletions
diff --git a/src/verbs/update.py b/src/verbs/update.py
index 6fe89f6..5b7a49f 100644
--- a/src/verbs/update.py
+++ b/src/verbs/update.py
@@ -3,46 +3,23 @@ import util
import colors
import time
-from verbs.install import find_package, install_multiple
+from verbs.install import find_package, install
from verbs.sync import sync
VERSION_COMPARED = "CHECKSUM"
-def get_installed_versions(config, root="/"):
- packages = {}
-
+def get_installed_list(config, root="/"):
installed_dir = util.add_path(root, config["dir"]["installed"])
if os.path.exists(installed_dir):
files = os.listdir(installed_dir)
- for package in files:
- with open(util.add_path(installed_dir, package, "info")) as file:
- for line in file:
- if line.startswith(VERSION_COMPARED):
- packages[package] = line.strip().split("=")[-1]
+ return files
+ return []
- return packages
-def get_available_version(package_name, config, root="/"):
- repos = config["repos"]
- packages_dir = config["dir"]["packages"]
- sources = config["sources"]
- checksum, found_sources, requested_repo, size, files = find_package(package_name, repos, packages_dir, sources)
- return checksum
-
def update(args, options, config):
if not options["l"]:
sync(args, options, config)
- v = options["v"]
-
- updates = [package for package,checksum in get_installed_versions(config, options["r"]).items() if not checksum == get_available_version(package, config, options["r"])]
-
- if len(args) > 0:
- updates = [update for update in updates if update in args]
-
- if len(updates) > 0:
- install_multiple(updates, args, options, config, terminology=("update", "updated", "updating"))
- else:
- print(colors.LIGHT_RED + "Nothing to do")
-
-
+ packages = [package for package in get_installed_list(config, options["r"]) if len(args) == 0 or package in args]
+ options["l"] = True
+ install(packages, options, config)