summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2008-05-31 15:06:30 +0200
committerDan McGee <dan@archlinux.org>2008-08-23 08:47:07 -0500
commit5b51dbb11e2087e1055be24b486502be806b5e13 (patch)
treea2938506c96ba529361a55d6f92d8a29724667f2 /lib/libalpm/package.c
parente760c4f4784c7e7b59717cd10c56dac04f175b73 (diff)
downloadpacman-5b51dbb11e2087e1055be24b486502be806b5e13.tar.xz
Cleanup of _alpm_pkg_compare_versions.
* Change the return values to be more informative. It was previously boolean, only indicating if a sync package was newer than a local package. Now it is a simple wrapper to vercmp, handling the force flag. * Remove the verbose output from _alpm_pkg_compare_versions. The "force" message is not so useful. The "package : local (v1) is newer than repo (v2)" message can be moved to -Su operation. For the -S operation, it is better to have something like : "downgrading package from v1 to v2" * Don't display the "up to date -- skipping" and "up to date -- reinstalling" messages, when the local version is newer than the sync one. * Fix the behavior of --needed option to not skip a target when the local version is newer, and clarify its description. * Add a new alpm_pkg_has_force function This allows us to access the pkg->force field like any other package fields. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/package.c')
-rw-r--r--lib/libalpm/package.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/lib/libalpm/package.c b/lib/libalpm/package.c
index 49238ea8..eaef688d 100644
--- a/lib/libalpm/package.c
+++ b/lib/libalpm/package.c
@@ -295,6 +295,20 @@ alpm_list_t SYMEXPORT *alpm_pkg_get_groups(pmpkg_t *pkg)
return pkg->groups;
}
+unsigned short SYMEXPORT alpm_pkg_has_force(pmpkg_t *pkg)
+{
+ ALPM_LOG_FUNC;
+
+ /* Sanity checks */
+ ASSERT(handle != NULL, return(-1));
+ ASSERT(pkg != NULL, return(-1));
+
+ if(pkg->origin == PKG_FROM_CACHE && !(pkg->infolevel & INFRQ_DESC)) {
+ _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
+ }
+ return pkg->force;
+}
+
alpm_list_t SYMEXPORT *alpm_pkg_get_depends(pmpkg_t *pkg)
{
ALPM_LOG_FUNC;
@@ -827,32 +841,18 @@ void _alpm_pkg_free(pmpkg_t *pkg)
FREE(pkg);
}
-/* Is pkgB an upgrade for pkgA ? */
-int _alpm_pkg_compare_versions(pmpkg_t *local_pkg, pmpkg_t *pkg)
+/* Is spkg an upgrade for locapkg? */
+int _alpm_pkg_compare_versions(pmpkg_t *spkg, pmpkg_t *localpkg)
{
int cmp = 0;
ALPM_LOG_FUNC;
- if(pkg->origin == PKG_FROM_CACHE) {
- /* ensure we have the /desc file, which contains the 'force' option */
- _alpm_db_read(pkg->origin_data.db, pkg, INFRQ_DESC);
- }
-
- /* compare versions and see if we need to upgrade */
- cmp = alpm_pkg_vercmp(alpm_pkg_get_version(pkg), alpm_pkg_get_version(local_pkg));
+ cmp = alpm_pkg_vercmp(alpm_pkg_get_version(spkg),
+ alpm_pkg_get_version(localpkg));
- if(cmp != 0 && pkg->force) {
+ if(cmp < 0 && alpm_pkg_has_force(spkg)) {
cmp = 1;
- _alpm_log(PM_LOG_WARNING, _("%s: forcing upgrade to version %s\n"),
- alpm_pkg_get_name(pkg), alpm_pkg_get_version(pkg));
- } else if(cmp < 0) {
- /* local version is newer */
- pmdb_t *db = pkg->origin_data.db;
- _alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)\n"),
- alpm_pkg_get_name(local_pkg), alpm_pkg_get_version(local_pkg),
- alpm_db_get_name(db), alpm_pkg_get_version(pkg));
- cmp = 0;
}
return(cmp);