From 4bd34cd1f5c032e57c0847100426a00645f00dff Mon Sep 17 00:00:00 2001 From: William Douglas Date: Tue, 30 Jul 2013 13:55:12 -0700 Subject: [PATCH] Ensure only new updates are installed The previously get_uninstalled_updates would look only at updates which had been installed by the system updater and would then add updates that didn't need to be applied because the current system was installed from a later image than the earlier updates. This patch adds a check for said invalid updates as well as creates a folder for the zypper rpm cache of the update when needed. Signed-off-by: William Douglas --- swup.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/swup.py b/swup.py index f61f052..cf270b1 100755 --- a/swup.py +++ b/swup.py @@ -21,6 +21,7 @@ import re update_repo="http://www.planux.com/updates" update_cache="/var/cache/updatemanager" +zypp_cache="/var/cache/zypp" # zypper return values that are acceptable when running the patch command patch_okay_codes = [0, 102, 103] @@ -287,6 +288,16 @@ def list_updates(): def get_uninstalled_updates(updates): uninstalled = copy.deepcopy(updates) + to_install = [] + to_install_fixed = [] + if os.path.isdir("%s/install/" % update_cache): + to_install = os.listdir("%s/install/" % update_cache) + for i in to_install: + to_install_fixed.append(re.sub('^[0-9]*-', '', i)) + for i in uninstalled.keys(): + if i not in to_install_fixed: + uninstalled.pop(i) + if os.path.isdir("%s/installed/" % update_cache): update_ids = sorted(uninstalled.keys(), reverse=True) installed = sorted(os.listdir("%s/installed/" % update_cache), reverse=True) @@ -377,6 +388,8 @@ def run_action(options): updates = parse_updates() uninstalled_updates = get_uninstalled_updates(updates) for u in uninstalled_updates.values(): + if not os.path.exists("%s/packages/%s/rpms" % (zypp_cache, u['id'])): + os.makedirs("%s/packages/%s/rpms" % (zypp_cache, u['id'])) download_update(u) install_update(u) -- 2.7.4