From 3a488564753cee51832b6824128249a99eb4613b Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Thu, 25 Jun 2009 11:09:40 +0300 Subject: upgrade: add --available option That will make the upgrade prefer packages available in repositories. This is good if one want's to downgrade packages by removing an experimental repository. Or to force re-install of locally built vs. repository version when the package version are same, but checksum is different. Fixes #51. --- src/state.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'src/state.c') diff --git a/src/state.c b/src/state.c index 5d0c074..44649de 100644 --- a/src/state.c +++ b/src/state.c @@ -4,7 +4,7 @@ * Copyright (C) 2008 Timo Teräs * All rights reserved. * - * This program is free software; you can redistribute it and/or modify it + * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. See http://www.gnu.org/ for details. */ @@ -232,8 +232,25 @@ int apk_state_lock_dependency(struct apk_state *state, if (apk_pkg_get_state(c->pkgs[i]) == APK_PKG_INSTALLED) installed = pkg; - if (latest == NULL || - apk_pkg_version_compare(pkg, latest) == APK_VERSION_GREATER) + if (latest == NULL) { + latest = pkg; + continue; + } + + if (apk_flags & APK_PREFER_AVAILABLE) { + if (latest->repos != 0 && pkg->repos == 0) + continue; + + if (latest->repos == 0 && pkg->repos != 0) { + latest = pkg; + continue; + } + + /* Otherwise both are not available, or both are + * available and we just compare the versions then */ + } + + if (apk_pkg_version_compare(pkg, latest) == APK_VERSION_GREATER) latest = pkg; } -- cgit v1.2.3-60-g2f50