[pacman-dev] [PATCH 1/3] add 4 pactests for -Sdd
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> --- test/pacman/tests/sync-sdd1.py | 18 ++++++++++++++++++ test/pacman/tests/sync-sdd2.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd3.py | 15 +++++++++++++++ test/pacman/tests/sync-sdd4.py | 17 +++++++++++++++++ 4 files changed, 65 insertions(+), 0 deletions(-) create mode 100644 test/pacman/tests/sync-sdd1.py create mode 100644 test/pacman/tests/sync-sdd2.py create mode 100644 test/pacman/tests/sync-sdd3.py create mode 100644 test/pacman/tests/sync-sdd4.py diff --git a/test/pacman/tests/sync-sdd1.py b/test/pacman/tests/sync-sdd1.py new file mode 100644 index 0000000..4438ef0 --- /dev/null +++ b/test/pacman/tests/sync-sdd1.py @@ -0,0 +1,18 @@ +self.description = "-Sdd: -Sdd works" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>1.0-1"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-Sdd %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("PKG_EXIST=pkg2") +self.addrule("PKG_DEPENDS=pkg1|provision>1.0-1") + +self.expectfailure = True diff --git a/test/pacman/tests/sync-sdd2.py b/test/pacman/tests/sync-sdd2.py new file mode 100644 index 0000000..5f1f847 --- /dev/null +++ b/test/pacman/tests/sync-sdd2.py @@ -0,0 +1,15 @@ +self.description = "-Sdd: -S fails" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-S %s" % p1.name + +self.addrule("PACMAN_RETCODE=1") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") diff --git a/test/pacman/tests/sync-sdd3.py b/test/pacman/tests/sync-sdd3.py new file mode 100644 index 0000000..68733af --- /dev/null +++ b/test/pacman/tests/sync-sdd3.py @@ -0,0 +1,15 @@ +self.description = "-Sdd: -Sd works but no deps" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["provision>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-Sd %s" % p1.name + +self.addrule("PACMAN_RETCODE=0") +self.addrule("PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") diff --git a/test/pacman/tests/sync-sdd4.py b/test/pacman/tests/sync-sdd4.py new file mode 100644 index 0000000..4cd4b54 --- /dev/null +++ b/test/pacman/tests/sync-sdd4.py @@ -0,0 +1,17 @@ +self.description = "-Sdd: provision does not exist" + +p1 = pmpkg("pkg1", "1.0-2") +p1.depends = ["invalid>=1.0-2"] +self.addpkg2db("sync", p1) + +p2 = pmpkg("pkg2", "1.0-2") +p2.provides = ["provision=1.0-1"] +self.addpkg2db("sync", p2) + +self.args = "-Sdd %s" % p1.name + +self.addrule("PACMAN_RETCODE=1") +self.addrule("!PKG_EXIST=pkg1") +self.addrule("!PKG_EXIST=pkg2") + +self.expectfailure = True -- 1.7.3.1
This flag allows to disable version checking in dependency resolving code. depcmp_tolerant respects the NODEPVERSION flag but we still keep the original strict depcmp. The idea is to reduce the impact of the NODEPVERSION flag by using it in fewer places. I replaced almost all depcmp calls by depcmp_tolerant in deps.c (except in the public find_satisfier used by deptest / pacman -T), but I kept depcmp in sync.c and conflict.c Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> --- lib/libalpm/alpm.h | 2 +- lib/libalpm/deps.c | 48 +++++++++++++++++++++++++++++++++++++----------- lib/libalpm/deps.h | 1 + 3 files changed, 39 insertions(+), 12 deletions(-) diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 237e235..1ddf809 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -272,7 +272,7 @@ typedef enum _pmtransflag_t { PM_TRANS_FLAG_NODEPS = 1, PM_TRANS_FLAG_FORCE = (1 << 1), PM_TRANS_FLAG_NOSAVE = (1 << 2), - /* (1 << 3) flag can go here */ + PM_TRANS_FLAG_NODEPVERSION = (1 << 3), PM_TRANS_FLAG_CASCADE = (1 << 4), PM_TRANS_FLAG_RECURSE = (1 << 5), PM_TRANS_FLAG_DBONLY = (1 << 6), diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index e6d04a3..71f1134 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -195,7 +195,7 @@ pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep) for(i = pkgs; i; i = alpm_list_next(i)) { pmpkg_t *pkg = i->data; - if(_alpm_depcmp(pkg, dep)) { + if(_alpm_depcmp_tolerant(pkg, dep)) { return(pkg); } } @@ -329,19 +329,26 @@ static int dep_vercmp(const char *version1, pmdepmod_t mod, return(equal); } -int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep) +/* nodepversion: skip version checking */ +static int _depcmp(pmpkg_t *pkg, pmdepend_t *dep, int nodepversion) { alpm_list_t *i; + int satisfy = 0; + int depmod; + const char *pkgname = alpm_pkg_get_name(pkg); + const char *pkgversion = alpm_pkg_get_version(pkg); ALPM_LOG_FUNC; - const char *pkgname = alpm_pkg_get_name(pkg); - const char *pkgversion = alpm_pkg_get_version(pkg); - int satisfy = 0; + if(nodepversion) { + depmod = PM_DEP_MOD_ANY; + } else { + depmod = dep->mod; + } /* check (pkg->name, pkg->version) */ satisfy = (strcmp(pkgname, dep->name) == 0 - && dep_vercmp(pkgversion, dep->mod, dep->version)); + && dep_vercmp(pkgversion, depmod, dep->version)); /* check provisions, format : "name=version" */ for(i = alpm_pkg_get_provides(pkg); i && !satisfy; i = i->next) { @@ -349,13 +356,13 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep) char *provver = strchr(provname, '='); if(provver == NULL) { /* no provision version */ - satisfy = (dep->mod == PM_DEP_MOD_ANY + satisfy = (depmod == PM_DEP_MOD_ANY && strcmp(provname, dep->name) == 0); } else { *provver = '\0'; provver += 1; satisfy = (strcmp(provname, dep->name) == 0 - && dep_vercmp(provver, dep->mod, dep->version)); + && dep_vercmp(provver, depmod, dep->version)); } free(provname); } @@ -363,6 +370,25 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep) return(satisfy); } +/* tolerant : respects NODEPVERSION flag */ +int _alpm_depcmp_tolerant(pmpkg_t *pkg, pmdepend_t *dep) +{ + int nodepversion = 0; + int flags = alpm_trans_get_flags(); + + if (flags != -1) { + nodepversion = flags & PM_TRANS_FLAG_NODEPVERSION; + } + + return(_depcmp(pkg, dep, nodepversion)); +} + +/* strict : ignores NODEPVERSION flag */ +int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep) +{ + return(_depcmp(pkg, dep, 0)); +} + pmdepend_t *_alpm_splitdep(const char *depstring) { pmdepend_t *depend; @@ -523,7 +549,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, /* 1. literals */ for(i = dbs; i; i = i->next) { pmpkg_t *pkg = _alpm_db_get_pkgfromcache(i->data, dep->name); - if(pkg && _alpm_depcmp(pkg, dep) && !_alpm_pkg_find(excluding, pkg->name)) { + if(pkg && _alpm_depcmp_tolerant(pkg, dep) && !_alpm_pkg_find(excluding, pkg->name)) { if(_alpm_pkg_should_ignore(pkg)) { int install = 0; if (prompt) { @@ -544,7 +570,7 @@ pmpkg_t *_alpm_resolvedep(pmdepend_t *dep, alpm_list_t *dbs, for(i = dbs; i; i = i->next) { for(j = _alpm_db_get_pkgcache(i->data); j; j = j->next) { pmpkg_t *pkg = j->data; - if(_alpm_depcmp(pkg, dep) && strcmp(pkg->name, dep->name) != 0 && + if(_alpm_depcmp_tolerant(pkg, dep) && strcmp(pkg->name, dep->name) != 0 && !_alpm_pkg_find(excluding, pkg->name)) { if(_alpm_pkg_should_ignore(pkg)) { int install = 0; @@ -670,7 +696,7 @@ int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2) { alpm_list_t *i; for(i = alpm_pkg_get_depends(pkg1); i; i = i->next) { - if(_alpm_depcmp(pkg2, i->data)) { + if(_alpm_depcmp_tolerant(pkg2, i->data)) { return(1); } } diff --git a/lib/libalpm/deps.h b/lib/libalpm/deps.h index 6fa763e..41e6846 100644 --- a/lib/libalpm/deps.h +++ b/lib/libalpm/deps.h @@ -56,6 +56,7 @@ int _alpm_dep_edge(pmpkg_t *pkg1, pmpkg_t *pkg2); pmdepend_t *_alpm_splitdep(const char *depstring); pmpkg_t *_alpm_find_dep_satisfier(alpm_list_t *pkgs, pmdepend_t *dep); int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep); +int _alpm_depcmp_tolerant(pmpkg_t *pkg, pmdepend_t *dep); #endif /* _ALPM_DEPS_H */ -- 1.7.3.1
From: Florian Pritz <bluewind@xssn.at> -dd ignores only the version of a dependency being checked, but not the package itself. Signed-off-by: Florian Pritz <bluewind@xssn.at> Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> --- doc/pacman.8.txt | 1 + src/pacman/pacman.c | 11 ++++++++++- test/pacman/tests/sync-sdd1.py | 2 -- test/pacman/tests/sync-sdd4.py | 2 -- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/doc/pacman.8.txt b/doc/pacman.8.txt index 2b47a88..735bff9 100644 --- a/doc/pacman.8.txt +++ b/doc/pacman.8.txt @@ -155,6 +155,7 @@ Transaction Options (apply to '-S', '-R' and '-U') Skips all dependency checks. Normally, pacman will always check a package's dependency fields to ensure that all dependencies are installed and there are no package conflicts in the system. + Specify this option twice to skip the version checking only. *-k, \--dbonly*:: Adds/Removes the database entry only, leaves all files in place. diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 7d51124..d83ec07 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -512,8 +512,17 @@ static int parsearg_query(int opt) /* options common to -S -R -U */ static int parsearg_trans(int opt) { + static int nodeps = 0; switch(opt) { - case 'd': config->flags |= PM_TRANS_FLAG_NODEPS; break; + case 'd': + nodeps++; + if(nodeps == 1) { + config->flags |= PM_TRANS_FLAG_NODEPS; + } else if(nodeps == 2) { + config->flags ^= PM_TRANS_FLAG_NODEPS; + config->flags |= PM_TRANS_FLAG_NODEPVERSION; + } + break; case 'k': config->flags |= PM_TRANS_FLAG_DBONLY; break; case OP_NOPROGRESSBAR: config->noprogressbar = 1; break; case OP_NOSCRIPTLET: config->flags |= PM_TRANS_FLAG_NOSCRIPTLET; break; diff --git a/test/pacman/tests/sync-sdd1.py b/test/pacman/tests/sync-sdd1.py index 4438ef0..c73d203 100644 --- a/test/pacman/tests/sync-sdd1.py +++ b/test/pacman/tests/sync-sdd1.py @@ -14,5 +14,3 @@ self.addrule("PKG_EXIST=pkg1") self.addrule("PKG_EXIST=pkg2") self.addrule("PKG_DEPENDS=pkg1|provision>1.0-1") - -self.expectfailure = True diff --git a/test/pacman/tests/sync-sdd4.py b/test/pacman/tests/sync-sdd4.py index 4cd4b54..c96c6df 100644 --- a/test/pacman/tests/sync-sdd4.py +++ b/test/pacman/tests/sync-sdd4.py @@ -13,5 +13,3 @@ self.addrule("PACMAN_RETCODE=1") self.addrule("!PKG_EXIST=pkg1") self.addrule("!PKG_EXIST=pkg2") - -self.expectfailure = True -- 1.7.3.1
participants (1)
-
Xavier Chantry