index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | lib/libalpm/deps.c | 6 | ||||
-rw-r--r-- | lib/libalpm/sync.c | 45 | ||||
-rw-r--r-- | pactest/tests/sync1006.py | 14 | ||||
-rw-r--r-- | pactest/tests/sync1008.py (renamed from pactest/tests/sync1005.py) | 11 |
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 180c46bf..1eebca3e 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -570,7 +570,8 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, if(!sync) { continue; } - found = alpm_depcmp(sync, missdep) && !_alpm_pkg_find(alpm_pkg_get_name(sync), remove); + found = alpm_depcmp(sync, missdep) && !_alpm_pkg_find(alpm_pkg_get_name(sync), remove) + && !_alpm_pkg_find(alpm_pkg_get_name(sync), *list); if(!found) { continue; } @@ -592,7 +593,8 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg, continue; } found = alpm_depcmp(sync, missdep) && strcmp(sync->name, missdep->name) - && !_alpm_pkg_find(alpm_pkg_get_name(sync), remove); + && !_alpm_pkg_find(alpm_pkg_get_name(sync), remove) + && !_alpm_pkg_find(alpm_pkg_get_name(sync), *list); if(!found) { continue; } diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c index 9df59431..5b3087a3 100644 --- a/lib/libalpm/sync.c +++ b/lib/libalpm/sync.c @@ -128,6 +128,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local, pmsyncpkg_t *sync; /* 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)); if(sync) { /* found it -- just append to the removes list */ @@ -246,7 +247,7 @@ 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))) { - /* it is already there, done */ + /* avoid duplicated targets */ continue; } /* we can set any reason here, it will be overridden by add_commit */ @@ -317,6 +318,11 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy } } + if(_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { + FREE(targline); + RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1); + } + if(_alpm_pkg_should_ignore(spkg)) { int resp; QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, spkg, NULL, NULL, &resp); @@ -343,15 +349,13 @@ int _alpm_sync_addtarget(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sy } /* add the package to the transaction */ - if(!_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { - sync = _alpm_sync_new(PM_PKG_REASON_EXPLICIT, spkg, NULL); - if(sync == NULL) { - goto error; - } - _alpm_log(PM_LOG_DEBUG, "adding target '%s' to the transaction set\n", - alpm_pkg_get_name(spkg)); - trans->packages = alpm_list_add(trans->packages, sync); + sync = _alpm_sync_new(PM_PKG_REASON_EXPLICIT, spkg, NULL); + if(sync == NULL) { + goto error; } + _alpm_log(PM_LOG_DEBUG, "adding target '%s' to the transaction set\n", + alpm_pkg_get_name(spkg)); + trans->packages = alpm_list_add(trans->packages, sync); FREE(targline); return(0); @@ -399,6 +403,9 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync } if(!(trans->flags & PM_TRANS_FLAG_NODEPS)) { + /* store a pointer to the last original target so we can tell what was + * pulled by resolvedeps */ + alpm_list_t *pulled = alpm_list_last(list); /* Resolve targets dependencies */ EVENT(trans, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL); _alpm_log(PM_LOG_DEBUG, "resolving target's dependencies\n"); @@ -421,19 +428,16 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync } } - for(i = list; i; i = i->next) { - /* add the dependencies found by resolvedeps to the transaction set */ + for(i = pulled->next; i; i = i->next) { pmpkg_t *spkg = i->data; - if(!_alpm_sync_find(trans->packages, alpm_pkg_get_name(spkg))) { - pmsyncpkg_t *sync = _alpm_sync_new(PM_PKG_REASON_DEPEND, spkg, NULL); - if(sync == NULL) { - ret = -1; - goto cleanup; - } - trans->packages = alpm_list_add(trans->packages, sync); - _alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", - alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); + pmsyncpkg_t *sync = _alpm_sync_new(PM_PKG_REASON_DEPEND, spkg, NULL); + if(sync == NULL) { + ret = -1; + goto cleanup; } + trans->packages = alpm_list_add(trans->packages, sync); + _alpm_log(PM_LOG_DEBUG, "adding package %s-%s to the transaction targets\n", + alpm_pkg_get_name(spkg), alpm_pkg_get_version(spkg)); } /* re-order w.r.t. dependencies */ @@ -444,6 +448,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync pmsyncpkg_t *s = j->data; if(s->pkg == i->data) { newpkgs = alpm_list_add(newpkgs, s); + break; } } } diff --git a/pactest/tests/sync1006.py b/pactest/tests/sync1006.py deleted file mode 100644 index c331f42e..00000000 --- a/pactest/tests/sync1006.py +++ /dev/null @@ -1,14 +0,0 @@ -self.description = "Conflicting package names in sync repos (diff versions)" - -sp1 = pmpkg("pkg", "1.0-1") -sp1.provides = [ "provision1" ] -self.addpkg2db("sync1", sp1) - -sp2 = pmpkg("pkg", "2.0-1") -sp2.provides = [ "provision2" ] -self.addpkg2db("sync2", sp2) - -self.args = "-S provision1 provision2" - -self.addrule("PACMAN_RETCODE=1") -self.addrule("!PKG_EXIST=pkg") diff --git a/pactest/tests/sync1005.py b/pactest/tests/sync1008.py index 4fa82478..a6064597 100644 --- a/pactest/tests/sync1005.py +++ b/pactest/tests/sync1008.py @@ -1,14 +1,19 @@ self.description = "Conflicting package names in sync repos" -sp1 = pmpkg("pkg") +sp1 = pmpkg("cpkg", "1.0-1") sp1.provides = [ "provision1" ] self.addpkg2db("sync1", sp1) -sp2 = pmpkg("pkg") +sp2 = pmpkg("cpkg", "2.0-1") sp2.provides = [ "provision2" ] self.addpkg2db("sync2", sp2) -self.args = "-S provision1 provision2" +sp3 = pmpkg("pkg") +sp3.depends = [ "provision1" , "provision2" ] +self.addpkg2db("sync1", sp3) + +self.args = "-S pkg" self.addrule("PACMAN_RETCODE=1") self.addrule("!PKG_EXIST=pkg") +self.addrule("!PKG_EXIST=cpkg") |