1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

* Removed latest fix from TODO.autoconf

* Attempted fix for FS#6100 - "-Spd foo" failure
* Beginning of refactoring from Dan McGee <dpmcgee@gmail.com>
This commit is contained in:
Aaron Griffin 2006-12-29 17:04:58 +00:00
parent 5e2d757c34
commit 07c1309009
3 changed files with 110 additions and 103 deletions

View File

@ -1,12 +1,5 @@
TODO for autoconf/automake: TODO for autoconf/automake:
pacman's Makefile.am and configure.in
=====================================
- find out how can we prevent automake/autoconf to build pacman.static binary, if we
are configured using --disable-static flag. Now if builded with this option, then pacman.static
compile fails, because there will be no libalpm.a (just .so)
global global
====== ======

View File

@ -118,7 +118,10 @@ static int istoonew(pmpkg_t *pkg)
return((pkg->date + handle->upgradedelay) > t); return((pkg->date + handle->upgradedelay) > t);
} }
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_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, pmlist_t *dbs_sync)
{ {
pmlist_t *i, *j, *k; pmlist_t *i, *j, *k;
@ -178,83 +181,94 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync
} }
} }
} }
/* match installed packages with the sync dbs and compare versions */
_alpm_log(PM_LOG_FLOW1, _("checking for package upgrades"));
for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) {
int cmp;
int replace=0;
pmpkg_t *local = i->data;
pmpkg_t *spkg = NULL;
pmsyncpkg_t *sync;
for(j = dbs_sync; !spkg && j; j = j->next) {
spkg = _alpm_db_get_pkgfromcache(j->data, local->name);
}
if(spkg == NULL) {
_alpm_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name);
continue;
}
/* we don't care about a to-be-replaced package's newer version */
for(j = trans->packages; j && !replace; j=j->next) {
sync = j->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
if(_alpm_pkg_isin(spkg->name, sync->data)) {
replace=1;
}
}
}
if(replace) {
_alpm_log(PM_LOG_DEBUG, _("'%s' is already elected for removal -- skipping"),
local->name);
continue;
}
/* compare versions and see if we need to upgrade */
cmp = _alpm_versioncmp(local->version, spkg->version);
if(cmp > 0 && !spkg->force) {
/* local version is newer */
pmdb_t *db = spkg->data;
_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"),
local->name, local->version, db->treename, spkg->version);
} else if(cmp == 0) {
/* versions are identical */
} else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
} else if(istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
} else {
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"),
local->name, local->version, local->version, spkg->version);
if(!find_pkginsync(spkg->name, trans->packages)) {
pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version);
if(dummy == NULL) {
goto error;
}
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
if(sync == NULL) {
FREEPKG(dummy);
goto error;
}
trans->packages = _alpm_list_add(trans->packages, sync);
} else {
/* spkg->name is already in the packages list -- just ignore it */
}
}
}
return(0); return(0);
error: error:
return(-1); return(-1);
} }
int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync)
{
pmlist_t *i, *j;
/* check for "recommended" package replacements */
_alpm_log(PM_LOG_FLOW1, _("checking for package replacements"));
if( find_replacements(trans, db_local, dbs_sync) == 0 ) {
/* match installed packages with the sync dbs and compare versions */
_alpm_log(PM_LOG_FLOW1, _("checking for package upgrades"));
for(i = _alpm_db_get_pkgcache(db_local, INFRQ_NONE); i; i = i->next) {
int cmp;
int replace=0;
pmpkg_t *local = i->data;
pmpkg_t *spkg = NULL;
pmsyncpkg_t *sync;
for(j = dbs_sync; !spkg && j; j = j->next) {
spkg = _alpm_db_get_pkgfromcache(j->data, local->name);
}
if(spkg == NULL) {
_alpm_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name);
continue;
}
/* we don't care about a to-be-replaced package's newer version */
for(j = trans->packages; j && !replace; j=j->next) {
sync = j->data;
if(sync->type == PM_SYNC_TYPE_REPLACE) {
if(_alpm_pkg_isin(spkg->name, sync->data)) {
replace=1;
}
}
}
if(replace) {
_alpm_log(PM_LOG_DEBUG, _("'%s' is already elected for removal -- skipping"),
local->name);
continue;
}
/* compare versions and see if we need to upgrade */
cmp = _alpm_versioncmp(local->version, spkg->version);
if(cmp > 0 && !spkg->force) {
/* local version is newer */
pmdb_t *db = spkg->data;
_alpm_log(PM_LOG_WARNING, _("%s: local (%s) is newer than %s (%s)"),
local->name, local->version, db->treename, spkg->version);
} else if(cmp == 0) {
/* versions are identical */
} else if(_alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
/* package should be ignored (IgnorePkg) */
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
local->name, local->version, spkg->version);
} else if(istoonew(spkg)) {
/* package too new (UpgradeDelay) */
_alpm_log(PM_LOG_FLOW1, _("%s-%s: delaying upgrade of package (%s)"),
local->name, local->version, spkg->version);
/* check if spkg->name is already in the packages list. */
} else {
_alpm_log(PM_LOG_FLOW2, _("%s-%s elected for upgrade (%s => %s)"),
local->name, local->version, local->version, spkg->version);
if(!find_pkginsync(spkg->name, trans->packages)) {
pmpkg_t *dummy = _alpm_pkg_new(local->name, local->version);
if(dummy == NULL) {
goto error;
}
sync = _alpm_sync_new(PM_SYNC_TYPE_UPGRADE, spkg, dummy);
if(sync == NULL) {
FREEPKG(dummy);
goto error;
}
trans->packages = _alpm_list_add(trans->packages, sync);
} else {
/* spkg->name is already in the packages list -- just ignore it */
}
}
}
return(0);
}
/* if we're here, it's an error */
return(-1);
}
int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name) int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, pmlist_t *dbs_sync, char *name)
{ {
char targline[PKG_FULLNAME_LEN]; char targline[PKG_FULLNAME_LEN];

View File

@ -664,46 +664,46 @@ int pacman_sync(list_t *targets)
if(!confirm) { if(!confirm) {
goto cleanup; goto cleanup;
} }
}
/* Step 3: actually perform the installation /* Step 3: actually perform the installation
*/ */
if(alpm_trans_commit(&data) == -1) { if(alpm_trans_commit(&data) == -1) {
ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno)); ERR(NL, _("failed to commit transaction (%s)\n"), alpm_strerror(pm_errno));
switch(pm_errno) { switch(pm_errno) {
case PM_ERR_FILE_CONFLICTS: case PM_ERR_FILE_CONFLICTS:
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
pmconflict_t *conflict = alpm_list_getdata(lp); pmconflict_t *conflict = alpm_list_getdata(lp);
switch(alpm_conflict_get_type(conflict)) { switch(alpm_conflict_get_type(conflict)) {
case PM_CONFLICT_TYPE_TARGET: case PM_CONFLICT_TYPE_TARGET:
MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"), MSG(NL, _("%s%s exists in \"%s\" (target) and \"%s\" (target)"),
config->root, config->root,
alpm_conflict_get_file(conflict), alpm_conflict_get_file(conflict),
alpm_conflict_get_target(conflict), alpm_conflict_get_target(conflict),
alpm_conflict_get_ctarget(conflict)); alpm_conflict_get_ctarget(conflict));
break; break;
case PM_CONFLICT_TYPE_FILE: case PM_CONFLICT_TYPE_FILE:
MSG(NL, _("%s: %s%s exists in filesystem"), MSG(NL, _("%s: %s%s exists in filesystem"),
alpm_conflict_get_target(conflict), alpm_conflict_get_target(conflict),
config->root, config->root,
alpm_conflict_get_file(conflict)); alpm_conflict_get_file(conflict));
break; break;
} }
} }
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break; break;
case PM_ERR_PKG_CORRUPTED: case PM_ERR_PKG_CORRUPTED:
for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) { for(lp = alpm_list_first(data); lp; lp = alpm_list_next(lp)) {
MSG(NL, "%s", (char*)alpm_list_getdata(lp)); MSG(NL, "%s", (char*)alpm_list_getdata(lp));
} }
MSG(NL, _("\nerrors occurred, no packages were upgraded.\n")); MSG(NL, _("\nerrors occurred, no packages were upgraded.\n"));
break; break;
default: default:
break; break;
}
retval = 1;
goto cleanup;
} }
retval = 1; }/* else 'print uris' requested. We're done at this point */
goto cleanup;
}
/* Step 4: release transaction resources /* Step 4: release transaction resources
*/ */