From 1e12d78efe730fcf35bc949d70c8db04e5917945 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 12 Mar 2020 22:19:29 +0100 Subject: [PATCH] Implement app update --- usr/bin/spoc-app | 4 ++-- usr/lib/python3.8/spoc/app.py | 19 +++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/usr/bin/spoc-app b/usr/bin/spoc-app index 4e1ac8f..adb5624 100644 --- a/usr/bin/spoc-app +++ b/usr/bin/spoc-app @@ -42,11 +42,11 @@ def install(app_name): @locked(LOCK_FILE, print_lock) def update(app_name): - App(app_name).update() + App(app_name, False).update() @locked(LOCK_FILE, print_lock) def uninstall(app_name): - App(app_name).uninstall() + App(app_name, False).uninstall() def start(app_name): App(app_name).start() diff --git a/usr/lib/python3.8/spoc/app.py b/usr/lib/python3.8/spoc/app.py index 880506c..174b359 100644 --- a/usr/lib/python3.8/spoc/app.py +++ b/usr/lib/python3.8/spoc/app.py @@ -87,11 +87,26 @@ class App: repo_local.register_app(self.name, self.get_definition()) def update(self): - raise NotImplementedError() + # Load the local repo data here instead set_definition() to avoid fully defining containers which may not exist already + definition = repo_local.get_app(self.name) + # Remove containers + for container in definition['containers']: + Container(container, False).destroy() + # Load online definition + definition = repo_online.get_app(self.name) + self.version = definition['version'] + self.meta = definition['meta'] + # Build containers + for container,container_defintion in definition['containers'].items(): + self.create_container(container, container_defintion) + # Run update script and re-register the app + self.run_script('update') + repo_local.register_app(self.name, self.get_definition()) def uninstall(self): - definition = repo_local.get_app(self.name) self.run_script('uninstall') + # Load the local repo data here instead set_definition() to avoid fully defining containers which may not exist already + definition = repo_local.get_app(self.name) # Remove containers for container in definition['containers']: Container(container, False).destroy()