Remove duplicated get_upgrades function, use sysupgrade instead.
The alpm_get_upgrades was exactly the same as find_replacements + _alpm_sync_sysupgrade, except that it automatically made the eventual replacements, without asking the user : Replace %s with %s/%s? [Y/n] The replace question, asked in find_replacements. can now be skipped by using a NULL trans argument, so that we get the same behavior as with alpm_get_upgrades. So alpm_db_get_upgrades() can now be replaced by alpm_sync_sysupgrade(db_local, syncdbs). Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
3e9c590480
commit
83fa6aa289
6 changed files with 144 additions and 244 deletions
|
@ -174,8 +174,6 @@ pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
|
||||||
alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
|
alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
|
||||||
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
|
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
|
||||||
|
|
||||||
alpm_list_t *alpm_db_get_upgrades(void);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Packages
|
* Packages
|
||||||
*/
|
*/
|
||||||
|
@ -252,6 +250,8 @@ typedef enum _pmsynctype_t {
|
||||||
pmsynctype_t alpm_sync_get_type(const pmsyncpkg_t *sync);
|
pmsynctype_t alpm_sync_get_type(const pmsyncpkg_t *sync);
|
||||||
pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync);
|
pmpkg_t *alpm_sync_get_pkg(const pmsyncpkg_t *sync);
|
||||||
void *alpm_sync_get_data(const pmsyncpkg_t *sync);
|
void *alpm_sync_get_data(const pmsyncpkg_t *sync);
|
||||||
|
int alpm_sync_sysupgrade(pmdb_t *db_local,
|
||||||
|
alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Transactions
|
* Transactions
|
||||||
|
|
144
lib/libalpm/db.c
144
lib/libalpm/db.c
|
@ -47,8 +47,6 @@
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "alpm.h"
|
#include "alpm.h"
|
||||||
|
|
||||||
#include "sync.h" /* alpm_db_get_upgrades() */
|
|
||||||
|
|
||||||
/** \addtogroup alpm_databases Database Functions
|
/** \addtogroup alpm_databases Database Functions
|
||||||
* @brief Functions to query and manipulate the database of libalpm
|
* @brief Functions to query and manipulate the database of libalpm
|
||||||
* @{
|
* @{
|
||||||
|
@ -436,148 +434,6 @@ alpm_list_t SYMEXPORT *alpm_db_search(pmdb_t *db, const alpm_list_t* needles)
|
||||||
return(_alpm_db_search(db, needles));
|
return(_alpm_db_search(db, needles));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This function is mostly the same as sync.c find_replacements and sysupgrade
|
|
||||||
* functions, and we should be able to combine them - this is an interim
|
|
||||||
* solution made for -Qu operation */
|
|
||||||
/** Get a list of upgradable packages on the current system
|
|
||||||
* @return a pmsyncpkg_t list of packages that are out of date
|
|
||||||
*/
|
|
||||||
alpm_list_t SYMEXPORT *alpm_db_get_upgrades(void)
|
|
||||||
{
|
|
||||||
alpm_list_t *syncpkgs = NULL;
|
|
||||||
const alpm_list_t *i, *j, *k, *m;
|
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
|
||||||
|
|
||||||
/* TODO holy nested loops, Batman! */
|
|
||||||
/* check for "recommended" package replacements */
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking for package replacements\n");
|
|
||||||
for(i = handle->dbs_sync; i; i = i->next) {
|
|
||||||
for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) {
|
|
||||||
pmpkg_t *spkg = j->data;
|
|
||||||
|
|
||||||
for(k = alpm_pkg_get_replaces(spkg); k; k = k->next) {
|
|
||||||
|
|
||||||
for(m = _alpm_db_get_pkgcache(handle->db_local); m; m = m->next) {
|
|
||||||
pmpkg_t *lpkg = m->data;
|
|
||||||
|
|
||||||
if(strcmp(k->data, alpm_pkg_get_name(lpkg)) == 0) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking replacement '%s' for package '%s'\n",
|
|
||||||
(char *)k->data, alpm_pkg_get_name(spkg));
|
|
||||||
if(_alpm_pkg_should_ignore(spkg) || _alpm_pkg_should_ignore(lpkg)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)\n"),
|
|
||||||
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
|
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
|
||||||
} else {
|
|
||||||
/* assume all replaces=() packages are accepted */
|
|
||||||
pmsyncpkg_t *sync = NULL;
|
|
||||||
pmpkg_t *dummy = _alpm_pkg_new(alpm_pkg_get_name(lpkg), NULL);
|
|
||||||
if(dummy == NULL) {
|
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
pmsyncpkg_t *syncpkg;
|
|
||||||
syncpkg = _alpm_sync_find(syncpkgs, alpm_pkg_get_name(spkg));
|
|
||||||
|
|
||||||
if(syncpkg) {
|
|
||||||
/* found it -- just append to the replaces list */
|
|
||||||
sync->data = alpm_list_add(sync->data, dummy);
|
|
||||||
} else {
|
|
||||||
/* none found -- enter pkg into the final sync list */
|
|
||||||
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
|
|
||||||
if(sync == NULL) {
|
|
||||||
_alpm_pkg_free(dummy);
|
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sync->data = alpm_list_add(NULL, dummy);
|
|
||||||
syncpkgs = alpm_list_add(syncpkgs, sync);
|
|
||||||
}
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s-%s elected for upgrade (to be replaced by %s-%s)\n",
|
|
||||||
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
|
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now do normal upgrades */
|
|
||||||
for(i = _alpm_db_get_pkgcache(handle->db_local); i; i = i->next) {
|
|
||||||
int replace=0;
|
|
||||||
pmpkg_t *local = i->data;
|
|
||||||
pmpkg_t *spkg = NULL;
|
|
||||||
pmsyncpkg_t *sync;
|
|
||||||
|
|
||||||
for(j = handle->dbs_sync; !spkg && j; j = j->next) {
|
|
||||||
spkg = _alpm_db_get_pkgfromcache(j->data, alpm_pkg_get_name(local));
|
|
||||||
}
|
|
||||||
if(spkg == NULL) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db -- skipping\n",
|
|
||||||
alpm_pkg_get_name(local));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* we don't care about a to-be-replaced package's newer version */
|
|
||||||
for(j = syncpkgs; j && !replace; j=j->next) {
|
|
||||||
sync = j->data;
|
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
|
||||||
if(_alpm_pkg_find(alpm_pkg_get_name(spkg), sync->data)) {
|
|
||||||
replace=1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(replace) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "'%s' is already elected for removal -- skipping\n",
|
|
||||||
alpm_pkg_get_name(local));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(alpm_pkg_compare_versions(local, spkg)) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s elected for upgrade (%s => %s)\n",
|
|
||||||
alpm_pkg_get_name(local), alpm_pkg_get_version(local),
|
|
||||||
alpm_pkg_get_version(spkg));
|
|
||||||
|
|
||||||
pmsyncpkg_t *syncpkg;
|
|
||||||
syncpkg = _alpm_sync_find(syncpkgs, alpm_pkg_get_name(local));
|
|
||||||
|
|
||||||
if(!syncpkg) {
|
|
||||||
/* If package is in the ignorepkg list, skip it */
|
|
||||||
if(_alpm_pkg_should_ignore(spkg)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pmpkg_t *dummy = _alpm_pkg_new(alpm_pkg_get_name(local),
|
|
||||||
alpm_pkg_get_version(local));
|
|
||||||
if(dummy == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
|
|
||||||
if(sync == NULL) {
|
|
||||||
_alpm_pkg_free(dummy);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
syncpkgs = alpm_list_add(syncpkgs, sync);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return(syncpkgs);
|
|
||||||
error:
|
|
||||||
if(syncpkgs) {
|
|
||||||
alpm_list_t *tmp;
|
|
||||||
for(tmp = syncpkgs; tmp; tmp = alpm_list_next(tmp)) {
|
|
||||||
if(tmp->data) {
|
|
||||||
_alpm_sync_free(tmp->data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
alpm_list_free(syncpkgs);
|
|
||||||
}
|
|
||||||
return(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
pmdb_t *_alpm_db_new(const char *dbpath, const char *treename)
|
pmdb_t *_alpm_db_new(const char *dbpath, const char *treename)
|
||||||
|
|
|
@ -87,16 +87,33 @@ void _alpm_sync_free(pmsyncpkg_t *sync)
|
||||||
FREE(sync);
|
FREE(sync);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void synclist_free(alpm_list_t *syncpkgs)
|
||||||
|
{
|
||||||
|
if(syncpkgs) {
|
||||||
|
alpm_list_t *tmp;
|
||||||
|
for(tmp = syncpkgs; tmp; tmp = alpm_list_next(tmp)) {
|
||||||
|
if(tmp->data) {
|
||||||
|
_alpm_sync_free(tmp->data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
alpm_list_free(syncpkgs);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* Find recommended replacements for packages during a sync.
|
/* Find recommended replacements for packages during a sync.
|
||||||
* (refactored from _alpm_sync_prepare)
|
|
||||||
*/
|
*/
|
||||||
static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
|
static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
|
||||||
alpm_list_t *dbs_sync)
|
alpm_list_t *dbs_sync, alpm_list_t **syncpkgs)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j, *k; /* wow */
|
alpm_list_t *i, *j, *k; /* wow */
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
|
if(syncpkgs == NULL) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
/* check for "recommended" package replacements */
|
/* check for "recommended" package replacements */
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking for package replacements\n");
|
_alpm_log(PM_LOG_DEBUG, "checking for package replacements\n");
|
||||||
for(i = dbs_sync; i; i = i->next) {
|
for(i = dbs_sync; i; i = i->next) {
|
||||||
|
@ -123,121 +140,141 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
||||||
} else {
|
} else {
|
||||||
/* get confirmation for the replacement */
|
/* get confirmation for the replacement */
|
||||||
int doreplace = 0;
|
if(trans) {
|
||||||
QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
|
int doreplace = 0;
|
||||||
|
QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, db->treename, &doreplace);
|
||||||
if(doreplace) {
|
if(!doreplace) {
|
||||||
/* if confirmed, add this to the 'final' list, designating 'lpkg' as
|
continue;
|
||||||
* the package to replace.
|
|
||||||
*/
|
|
||||||
pmsyncpkg_t *sync;
|
|
||||||
pmpkg_t *dummy = _alpm_pkg_new(alpm_pkg_get_name(lpkg), NULL);
|
|
||||||
if(dummy == NULL) {
|
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
}
|
||||||
/* check if spkg->name is already in the packages list. */
|
|
||||||
sync = _alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg));
|
|
||||||
if(sync) {
|
|
||||||
/* found it -- just append to the replaces list */
|
|
||||||
sync->data = alpm_list_add(sync->data, dummy);
|
|
||||||
} else {
|
|
||||||
/* none found -- enter pkg into the final sync list */
|
|
||||||
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
|
|
||||||
if(sync == NULL) {
|
|
||||||
_alpm_pkg_free(dummy);
|
|
||||||
pm_errno = PM_ERR_MEMORY;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sync->data = alpm_list_add(NULL, dummy);
|
|
||||||
trans->packages = alpm_list_add(trans->packages, sync);
|
|
||||||
}
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s-%s elected for upgrade (to be replaced by %s-%s)\n",
|
|
||||||
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
|
|
||||||
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* if confirmed, add this to the 'final' list, designating 'lpkg' as
|
||||||
|
* the package to replace.
|
||||||
|
*/
|
||||||
|
pmsyncpkg_t *sync;
|
||||||
|
pmpkg_t *dummy = _alpm_pkg_new(alpm_pkg_get_name(lpkg), NULL);
|
||||||
|
if(dummy == NULL) {
|
||||||
|
pm_errno = PM_ERR_MEMORY;
|
||||||
|
synclist_free(*syncpkgs);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
/* check if spkg->name is already in the packages list. */
|
||||||
|
sync = _alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg));
|
||||||
|
if(sync) {
|
||||||
|
/* found it -- just append to the replaces list */
|
||||||
|
sync->data = alpm_list_add(sync->data, dummy);
|
||||||
|
} else {
|
||||||
|
/* none found -- enter pkg into the final sync list */
|
||||||
|
sync = _alpm_sync_new(PM_SYNC_TYPE_REPLACE, spkg, NULL);
|
||||||
|
if(sync == NULL) {
|
||||||
|
_alpm_pkg_free(dummy);
|
||||||
|
pm_errno = PM_ERR_MEMORY;
|
||||||
|
synclist_free(*syncpkgs);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
sync->data = alpm_list_add(NULL, dummy);
|
||||||
|
*syncpkgs = alpm_list_add(*syncpkgs, sync);
|
||||||
|
}
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "%s-%s elected for upgrade (to be replaced by %s-%s)\n",
|
||||||
|
alpm_pkg_get_name(lpkg), alpm_pkg_get_version(lpkg),
|
||||||
|
alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
error:
|
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO reimplement this in terms of alpm_get_upgrades */
|
/** Get a list of upgradable packages on the current system
|
||||||
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync)
|
* 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)
|
||||||
{
|
{
|
||||||
alpm_list_t *i, *j;
|
alpm_list_t *i, *j;
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
|
if(syncpkgs == NULL) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
/* check for "recommended" package replacements */
|
/* check for "recommended" package replacements */
|
||||||
if(find_replacements(trans, db_local, dbs_sync) == 0) {
|
if(find_replacements(trans, db_local, dbs_sync, syncpkgs)) {
|
||||||
/* match installed packages with the sync dbs and compare versions */
|
return(-1);
|
||||||
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
|
}
|
||||||
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
|
||||||
int replace=0;
|
|
||||||
pmpkg_t *local = i->data;
|
|
||||||
pmpkg_t *spkg = NULL;
|
|
||||||
pmsyncpkg_t *sync;
|
|
||||||
|
|
||||||
for(j = dbs_sync; !spkg && j; j = j->next) {
|
/* match installed packages with the sync dbs and compare versions */
|
||||||
spkg = _alpm_db_get_pkgfromcache(j->data, alpm_pkg_get_name(local));
|
_alpm_log(PM_LOG_DEBUG, "checking for package upgrades\n");
|
||||||
}
|
for(i = _alpm_db_get_pkgcache(db_local); i; i = i->next) {
|
||||||
if(spkg == NULL) {
|
int replace = 0;
|
||||||
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db -- skipping\n",
|
pmpkg_t *local = i->data;
|
||||||
alpm_pkg_get_name(local));
|
pmpkg_t *spkg = NULL;
|
||||||
continue;
|
pmsyncpkg_t *sync;
|
||||||
}
|
|
||||||
|
|
||||||
/* we don't care about a to-be-replaced package's newer version */
|
for(j = dbs_sync; !spkg && j; j = j->next) {
|
||||||
for(j = trans->packages; j && !replace; j=j->next) {
|
spkg = _alpm_db_get_pkgfromcache(j->data, alpm_pkg_get_name(local));
|
||||||
sync = j->data;
|
}
|
||||||
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
if(spkg == NULL) {
|
||||||
if(_alpm_pkg_find(alpm_pkg_get_name(spkg), sync->data)) {
|
_alpm_log(PM_LOG_DEBUG, "'%s' not found in sync db -- skipping\n",
|
||||||
replace=1;
|
alpm_pkg_get_name(local));
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(replace) {
|
|
||||||
_alpm_log(PM_LOG_DEBUG, "'%s' is already elected for removal -- skipping\n",
|
|
||||||
alpm_pkg_get_name(local));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* compare versions and see if we need to upgrade */
|
/* we don't care about a to-be-replaced package's newer version */
|
||||||
if(alpm_pkg_compare_versions(local, spkg)) {
|
for(j = *syncpkgs; j && !replace; j=j->next) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "%s elected for upgrade (%s => %s)\n",
|
sync = j->data;
|
||||||
alpm_pkg_get_name(local), alpm_pkg_get_version(local),
|
if(sync->type == PM_SYNC_TYPE_REPLACE) {
|
||||||
alpm_pkg_get_version(spkg));
|
if(_alpm_pkg_find(alpm_pkg_get_name(spkg), sync->data)) {
|
||||||
if(!_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) {
|
replace = 1;
|
||||||
/* If package is in the ignorepkg list, skip it */
|
|
||||||
if(_alpm_pkg_should_ignore(spkg)) {
|
|
||||||
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"),
|
|
||||||
alpm_pkg_get_name(local), alpm_pkg_get_version(local),
|
|
||||||
alpm_pkg_get_version(spkg));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
pmpkg_t *tmp = _alpm_pkg_dup(local);
|
|
||||||
if(tmp == NULL) {
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, tmp);
|
|
||||||
if(sync == NULL) {
|
|
||||||
_alpm_pkg_free(tmp);
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
trans->packages = alpm_list_add(trans->packages, sync);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(replace) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "'%s' is already elected for removal -- skipping\n",
|
||||||
|
alpm_pkg_get_name(local));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return(0);
|
/* compare versions and see if we need to upgrade */
|
||||||
|
if(alpm_pkg_compare_versions(local, spkg)) {
|
||||||
|
_alpm_log(PM_LOG_DEBUG, "%s elected for upgrade (%s => %s)\n",
|
||||||
|
alpm_pkg_get_name(local), alpm_pkg_get_version(local),
|
||||||
|
alpm_pkg_get_version(spkg));
|
||||||
|
if(!_alpm_sync_find(*syncpkgs, alpm_pkg_get_name(spkg))) {
|
||||||
|
/* If package is in the ignorepkg list, skip it */
|
||||||
|
if(_alpm_pkg_should_ignore(spkg)) {
|
||||||
|
_alpm_log(PM_LOG_WARNING, _("%s: ignoring package upgrade (%s => %s)\n"),
|
||||||
|
alpm_pkg_get_name(local), alpm_pkg_get_version(local),
|
||||||
|
alpm_pkg_get_version(spkg));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pmpkg_t *tmp = _alpm_pkg_dup(local);
|
||||||
|
if(tmp == NULL) {
|
||||||
|
pm_errno = PM_ERR_MEMORY;
|
||||||
|
synclist_free(*syncpkgs);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, tmp);
|
||||||
|
if(sync == NULL) {
|
||||||
|
_alpm_pkg_free(tmp);
|
||||||
|
pm_errno = PM_ERR_MEMORY;
|
||||||
|
synclist_free(*syncpkgs);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
*syncpkgs = alpm_list_add(*syncpkgs, sync);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
error:
|
|
||||||
/* if we're here, it's an error */
|
return(0);
|
||||||
return(-1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name)
|
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name)
|
||||||
|
|
|
@ -35,7 +35,9 @@ struct __pmsyncpkg_t {
|
||||||
pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data);
|
pmsyncpkg_t *_alpm_sync_new(int type, pmpkg_t *spkg, void *data);
|
||||||
void _alpm_sync_free(pmsyncpkg_t *data);
|
void _alpm_sync_free(pmsyncpkg_t *data);
|
||||||
|
|
||||||
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync);
|
int _alpm_sync_sysupgrade(pmtrans_t *trans,
|
||||||
|
pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **syncpkgs);
|
||||||
|
|
||||||
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, char *name);
|
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);
|
int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync, alpm_list_t **data);
|
||||||
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data);
|
int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data);
|
||||||
|
|
|
@ -298,7 +298,8 @@ int _alpm_trans_sysupgrade(pmtrans_t *trans)
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||||
|
|
||||||
return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync));
|
return(_alpm_sync_sysupgrade(trans, handle->db_local, handle->dbs_sync,
|
||||||
|
&(trans->packages)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Add a target to the transaction.
|
/** Add a target to the transaction.
|
||||||
|
|
|
@ -213,10 +213,14 @@ static int query_group(alpm_list_t *targets)
|
||||||
|
|
||||||
static int query_upgrades(void)
|
static int query_upgrades(void)
|
||||||
{
|
{
|
||||||
alpm_list_t *syncpkgs;
|
alpm_list_t *syncpkgs = NULL;
|
||||||
printf(_("Checking for package upgrades... \n"));
|
printf(_("Checking for package upgrades... \n"));
|
||||||
|
|
||||||
if((syncpkgs = alpm_db_get_upgrades()) != NULL) {
|
alpm_list_t *syncdbs = alpm_option_get_syncdbs();
|
||||||
|
if(alpm_sync_sysupgrade(db_local, syncdbs, &syncpkgs) == -1) {
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
if(syncpkgs) {
|
||||||
display_targets(syncpkgs, db_local);
|
display_targets(syncpkgs, db_local);
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue