index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/alpm.h | 2 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 52 | ||||
-rw-r--r-- | lib/libalpm/sync.h | 3 | ||||
-rw-r--r-- | lib/libalpm/trans.c | 13 | ||||
-rw-r--r-- | lib/libalpm/trans.h | 1 | ||||
-rw-r--r-- | src/pacman/pacman.c | 2 | ||||
-rw-r--r-- | src/pacman/query.c | 28 |
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 6f46e1cf..80a04262 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -254,8 +254,6 @@ alpm_list_t *alpm_grp_get_pkgs(const pmgrp_t *grp); pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync); alpm_list_t *alpm_sync_get_removes(const pmsyncpkg_t *sync); pmpkg_t *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync); -int alpm_sync_sysupgrade(pmdb_t *db_local, - alpm_list_t *dbs_sync, alpm_list_t **syncpkgs); /* * Transactions diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 96ca6319..b458874d 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -77,17 +77,12 @@ void _alpm_sync_free(pmsyncpkg_t *sync) /* Find recommended replacements for packages during a sync. */ -static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, - alpm_list_t *dbs_sync, alpm_list_t **syncpkgs) +static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync) { alpm_list_t *i, *j, *k; /* wow */ ALPM_LOG_FUNC; - if(syncpkgs == NULL) { - return(-1); - } - /* check for "recommended" package replacements */ _alpm_log(PM_LOG_DEBUG, "checking for package replacements\n"); for(i = dbs_sync; i; i = i->next) { @@ -113,13 +108,10 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg), alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); } else { - /* get confirmation for the replacement */ - if(trans) { - int doreplace = 0; - QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace); - if(!doreplace) { - continue; - } + int doreplace = 0; + QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace); + if(!doreplace) { + continue; } /* if confirmed, add this to the 'final' list, designating 'lpkg' as @@ -129,7 +121,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, /* check if spkg->name is already in the packages list. */ /* TODO: same package name doesn't mean same package */ - sync = _alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg)); + sync = _alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg)); if(sync) { /* found it -- just append to the removes list */ sync->removes = alpm_list_add(sync->removes, lpkg); @@ -143,15 +135,12 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, sync = _alpm_sync_new(alpm_pkg_get_reason(lpkg), spkg, NULL); if(sync == NULL) { pm_errno = PM_ERR_MEMORY; - alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free); - alpm_list_free(*syncpkgs); - *syncpkgs = NULL; return(-1); } sync->removes = alpm_list_add(NULL, lpkg); _alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); - *syncpkgs = alpm_list_add(*syncpkgs, sync); + trans->packages = alpm_list_add(trans->packages, sync); } _alpm_log(PM_LOG_DEBUG, "%s-%s elected for removal (to be replaced by %s-%s)\n", alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg), @@ -199,33 +188,19 @@ pmpkg_t SYMEXPORT *alpm_sync_newversion(pmpkg_t *pkg, alpm_list_t *dbs_sync) return(NULL); } -/** Get a list of upgradable packages on the current system - * Adds out of date packages to *list. - * @arg list pointer to a list of pmsyncpkg_t. - */ -int SYMEXPORT alpm_sync_sysupgrade(pmdb_t *db_local, - alpm_list_t *dbs_sync, alpm_list_t **syncpkgs) -{ - return(_alpm_sync_sysupgrade(NULL, db_local, dbs_sync, syncpkgs)); -} - -int _alpm_sync_sysupgrade(pmtrans_t *trans, - pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs) +int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync) { alpm_list_t *i, *j, *replaced = NULL; ALPM_LOG_FUNC; - if(syncpkgs == NULL) { - return(-1); - } /* check for "recommended" package replacements */ - if(find_replacements(trans, db_local, dbs_sync, syncpkgs)) { + if(find_replacements(trans, db_local, dbs_sync)) { return(-1); } /* compute the to-be-replaced packages for efficiency */ - for(i = *syncpkgs; i; i = i->next) { + for(i = trans->packages; i; i = i->next) { pmsyncpkg_t *sync = i->data; for(j = sync->removes; j; j = j->next) { replaced = alpm_list_add(replaced, j->data); @@ -255,22 +230,19 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, } /* add the upgrade package to our pmsyncpkg_t list */ - if(_alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg))) { + if(_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { /* avoid duplicated targets */ continue; } /* we can set any reason here, it will be overridden by add_commit */ pmsyncpkg_t *sync = _alpm_sync_new(PM_PKG_REASON_EXPLICIT, spkg, NULL); if(sync == NULL) { - alpm_list_free_inner(*syncpkgs, (alpm_list_fn_free)_alpm_sync_free); - alpm_list_free(*syncpkgs); - *syncpkgs = NULL; alpm_list_free(replaced); return(-1); } _alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); - *syncpkgs = alpm_list_add(*syncpkgs, sync); + trans->packages = alpm_list_add(trans->packages, sync); } } diff --git a/lib/libalpm/sync.h b/lib/libalpm/sync.h index b71f0ef2..b6a4bbff 100644 --- a/lib/libalpm/sync.h +++ b/lib/libalpm/sync.h @@ -33,8 +33,7 @@ struct __pmsyncpkg_t { pmsyncpkg_t *_alpm_sync_new(pmpkgreason_t newreason, pmpkg_t *spkg, alpm_list_t *removes); void _alpm_sync_free(pmsyncpkg_t *data); -int _alpm_sync_sysupgrade(pmtrans_t *trans, - pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs); +int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync); int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name); int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data); diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c index 96ac1bc8..4b831193 100644 --- a/lib/libalpm/trans.c +++ b/lib/libalpm/trans.c @@ -100,7 +100,7 @@ int SYMEXPORT alpm_trans_sysupgrade() ASSERT(trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1)); ASSERT(trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1)); - return(_alpm_trans_sysupgrade(trans)); + return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync)); } /** Add a target to the transaction. @@ -271,17 +271,6 @@ int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags, return(0); } -int _alpm_trans_sysupgrade(pmtrans_t *trans) -{ - ALPM_LOG_FUNC; - - /* Sanity checks */ - ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1)); - - return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync, - &(trans->packages))); -} - /** Add a target to the transaction. * @param trans the current transaction * @param target the name of the target to add diff --git a/lib/libalpm/trans.h b/lib/libalpm/trans.h index d74c3e90..48996573 100644 --- a/lib/libalpm/trans.h +++ b/lib/libalpm/trans.h @@ -71,7 +71,6 @@ void _alpm_trans_free(pmtrans_t *trans); int _alpm_trans_init(pmtrans_t *trans, pmtranstype_t type, pmtransflag_t flags, alpm_trans_cb_event event, alpm_trans_cb_conv conv, alpm_trans_cb_progress progress); -int _alpm_trans_sysupgrade(pmtrans_t *trans); int _alpm_trans_addtarget(pmtrans_t *trans, char *target); int _alpm_trans_prepare(pmtrans_t *trans, alpm_list_t **data); int _alpm_trans_commit(pmtrans_t *trans, alpm_list_t **data); 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 <package> query a package file instead of the database\n")); printf(_(" -s, --search <regex> 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); |