From 314b4462d2ef1264b50b6745c57072f9c7b9d14e Mon Sep 17 00:00:00 2001 From: Nagy Gabor Date: Fri, 24 Oct 2008 02:05:12 +0200 Subject: -Qu rework From now on -Qu is an "outdated package" filter on local database. (This is a behaviour change.) This patch fixes some memleaks and makes the code cleaner, for details see my comment on FS#7884. FS#11868 is implemented. Signed-off-by: Nagy Gabor Signed-off-by: Dan McGee --- src/pacman/pacman.c | 2 +- src/pacman/query.c | 28 ++++------------------------ 2 files changed, 5 insertions(+), 25 deletions(-) (limited to 'src/pacman') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index afe4ae44..a71381fa 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -113,7 +113,7 @@ static void usage(int op, const char * const myname) printf(_(" -p, --file query a package file instead of the database\n")); printf(_(" -s, --search search locally-installed packages for matching strings\n")); printf(_(" -t, --unrequired list all packages not required by any package\n")); - printf(_(" -u, --upgrades list all packages that can be upgraded\n")); + printf(_(" -u, --upgrades list all outdated packages\n")); printf(_(" -q, --quiet show less information for query and search\n")); } else if(op == PM_OP_SYNC) { printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg); diff --git a/src/pacman/query.c b/src/pacman/query.c index 676d0b36..0d48638f 100644 --- a/src/pacman/query.c +++ b/src/pacman/query.c @@ -251,24 +251,6 @@ static int query_group(alpm_list_t *targets) return ret; } -static int query_upgrades(void) -{ - alpm_list_t *syncpkgs = NULL; - printf(_("Checking for package upgrades... \n")); - - alpm_list_t *syncdbs = alpm_option_get_syncdbs(); - if(alpm_sync_sysupgrade(db_local, syncdbs, &syncpkgs) == -1) { - return(-1); - } - if(syncpkgs) { - display_synctargets(syncpkgs); - return(0); - } - - printf(_("no upgrades found.\n")); - return(1); -} - static int is_foreign(pmpkg_t *pkg) { const char *pkgname = alpm_pkg_get_name(pkg); @@ -320,6 +302,10 @@ static int filter(pmpkg_t *pkg) if(config->op_q_unrequired && !is_unrequired(pkg)) { return(0); } + /* check if this pkg is outdated */ + if(config->op_q_upgrade && (alpm_sync_newversion(pkg, alpm_option_get_syncdbs()) == NULL)) { + return(0); + } return(1); } @@ -361,12 +347,6 @@ int pacman_query(alpm_list_t *targets) return(ret); } - /* check for package upgrades */ - if(config->op_q_upgrade) { - ret = query_upgrades(); - return(ret); - } - /* looking for groups */ if(config->group) { ret = query_group(targets); -- cgit v1.2.3-70-g09d2