mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 09:21:53 -05:00
* Bug fix for makepkg dependency testing. This requires that we
expose alpm_splitdep and alpm_depcmp as public symbols * Removed a duplicate strtrim for question responses
This commit is contained in:
parent
1a9e6015c7
commit
166ffc4f9e
@ -375,6 +375,9 @@ typedef enum _pmdeptype_t {
|
|||||||
PM_DEP_TYPE_CONFLICT
|
PM_DEP_TYPE_CONFLICT
|
||||||
} pmdeptype_t;
|
} pmdeptype_t;
|
||||||
|
|
||||||
|
pmdepend_t *alpm_splitdep(const char *depstring);
|
||||||
|
int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
|
||||||
|
|
||||||
const char *alpm_dep_get_target(pmdepmissing_t *miss);
|
const char *alpm_dep_get_target(pmdepmissing_t *miss);
|
||||||
pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
|
pmdeptype_t alpm_dep_get_type(pmdepmissing_t *miss);
|
||||||
pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
|
pmdepmod_t alpm_dep_get_mod(pmdepmissing_t *miss);
|
||||||
|
@ -142,7 +142,7 @@ alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode)
|
|||||||
pmpkg_t *p = i->data;
|
pmpkg_t *p = i->data;
|
||||||
_alpm_log(PM_LOG_DEBUG, " sorting %s", alpm_pkg_get_name(p));
|
_alpm_log(PM_LOG_DEBUG, " sorting %s", alpm_pkg_get_name(p));
|
||||||
for(j = alpm_pkg_get_depends(p); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(p); j; j = j->next) {
|
||||||
pmdepend_t *depend = _alpm_splitdep(j->data);
|
pmdepend_t *depend = alpm_splitdep(j->data);
|
||||||
pmpkg_t *q = NULL;
|
pmpkg_t *q = NULL;
|
||||||
if(depend == NULL) {
|
if(depend == NULL) {
|
||||||
continue;
|
continue;
|
||||||
@ -244,20 +244,20 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
}
|
}
|
||||||
for(k = alpm_pkg_get_depends(p); k; k = k->next) {
|
for(k = alpm_pkg_get_depends(p); k; k = k->next) {
|
||||||
/* don't break any existing dependencies (possible provides) */
|
/* don't break any existing dependencies (possible provides) */
|
||||||
pmdepend_t *depend = _alpm_splitdep(k->data);
|
pmdepend_t *depend = alpm_splitdep(k->data);
|
||||||
if(depend == NULL) {
|
if(depend == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if oldpkg satisfied this dep, and newpkg doesn't */
|
/* if oldpkg satisfied this dep, and newpkg doesn't */
|
||||||
if(_alpm_depcmp(oldpkg, depend) && !_alpm_depcmp(newpkg, depend)) {
|
if(alpm_depcmp(oldpkg, depend) && !alpm_depcmp(newpkg, depend)) {
|
||||||
/* we've found a dep that was removed... see if any other package
|
/* we've found a dep that was removed... see if any other package
|
||||||
* still contains/provides the dep */
|
* still contains/provides the dep */
|
||||||
int satisfied = 0;
|
int satisfied = 0;
|
||||||
for(l = packages; l; l = l->next) {
|
for(l = packages; l; l = l->next) {
|
||||||
pmpkg_t *pkg = l->data;
|
pmpkg_t *pkg = l->data;
|
||||||
|
|
||||||
if(_alpm_depcmp(pkg, depend)) {
|
if(alpm_depcmp(pkg, depend)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' has moved from '%s' to '%s'"),
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' has moved from '%s' to '%s'"),
|
||||||
depend->name, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg));
|
depend->name, alpm_pkg_get_name(oldpkg), alpm_pkg_get_name(pkg));
|
||||||
satisfied = 1;
|
satisfied = 1;
|
||||||
@ -276,7 +276,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(_alpm_depcmp(pkg, depend)) {
|
if(alpm_depcmp(pkg, depend)) {
|
||||||
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' satisfied by installed package '%s'"),
|
_alpm_log(PM_LOG_DEBUG, _("checkdeps: dependency '%s' satisfied by installed package '%s'"),
|
||||||
depend->name, alpm_pkg_get_name(pkg));
|
depend->name, alpm_pkg_get_name(pkg));
|
||||||
satisfied = 1;
|
satisfied = 1;
|
||||||
@ -313,7 +313,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
|
|
||||||
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(tp); j; j = j->next) {
|
||||||
/* split into name/version pairs */
|
/* split into name/version pairs */
|
||||||
pmdepend_t *depend = _alpm_splitdep((char*)j->data);
|
pmdepend_t *depend = alpm_splitdep((char*)j->data);
|
||||||
if(depend == NULL) {
|
if(depend == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
/* check database for literal packages */
|
/* check database for literal packages */
|
||||||
for(k = _alpm_db_get_pkgcache(db); k && !found; k = k->next) {
|
for(k = _alpm_db_get_pkgcache(db); k && !found; k = k->next) {
|
||||||
pmpkg_t *p = (pmpkg_t *)k->data;
|
pmpkg_t *p = (pmpkg_t *)k->data;
|
||||||
found = _alpm_depcmp(p, depend);
|
found = alpm_depcmp(p, depend);
|
||||||
}
|
}
|
||||||
/* check database for provides matches */
|
/* check database for provides matches */
|
||||||
if(!found) {
|
if(!found) {
|
||||||
@ -345,14 +345,14 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
found = _alpm_depcmp(p, depend);
|
found = alpm_depcmp(p, depend);
|
||||||
}
|
}
|
||||||
FREELISTPTR(k);
|
FREELISTPTR(k);
|
||||||
}
|
}
|
||||||
/* check other targets */
|
/* check other targets */
|
||||||
for(k = packages; k && !found; k = k->next) {
|
for(k = packages; k && !found; k = k->next) {
|
||||||
pmpkg_t *p = k->data;
|
pmpkg_t *p = k->data;
|
||||||
found = _alpm_depcmp(p, depend);
|
found = alpm_depcmp(p, depend);
|
||||||
}
|
}
|
||||||
/* else if still not found... */
|
/* else if still not found... */
|
||||||
if(!found) {
|
if(!found) {
|
||||||
@ -424,7 +424,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
|||||||
return(baddeps);
|
return(baddeps);
|
||||||
}
|
}
|
||||||
|
|
||||||
pmdepend_t *_alpm_splitdep(const char *depstring)
|
pmdepend_t *alpm_splitdep(const char *depstring)
|
||||||
{
|
{
|
||||||
pmdepend_t *depend;
|
pmdepend_t *depend;
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
@ -517,7 +517,7 @@ alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs)
|
|||||||
for(i = targs; i; i = i->next) {
|
for(i = targs; i; i = i->next) {
|
||||||
pmpkg_t *pkg = i->data;
|
pmpkg_t *pkg = i->data;
|
||||||
for(j = alpm_pkg_get_depends(pkg); j; j = j->next) {
|
for(j = alpm_pkg_get_depends(pkg); j; j = j->next) {
|
||||||
pmdepend_t *depend = _alpm_splitdep(j->data);
|
pmdepend_t *depend = alpm_splitdep(j->data);
|
||||||
pmpkg_t *deppkg;
|
pmpkg_t *deppkg;
|
||||||
if(depend == NULL) {
|
if(depend == NULL) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -49,7 +49,6 @@ int _alpm_depmiss_isin(pmdepmissing_t *needle, alpm_list_t *haystack);
|
|||||||
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode);
|
alpm_list_t *_alpm_sortbydeps(alpm_list_t *targets, pmtranstype_t mode);
|
||||||
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
||||||
alpm_list_t *packages);
|
alpm_list_t *packages);
|
||||||
pmdepend_t *_alpm_splitdep(const char *depstring);
|
|
||||||
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
|
alpm_list_t *_alpm_removedeps(pmdb_t *db, alpm_list_t *targs);
|
||||||
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||||
alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
|
alpm_list_t *list, alpm_list_t *trail, pmtrans_t *trans,
|
||||||
|
@ -552,7 +552,7 @@ void _alpm_pkg_update_requiredby(pmpkg_t *pkg)
|
|||||||
if(!j->data) {
|
if(!j->data) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
dep = _alpm_splitdep(j->data);
|
dep = alpm_splitdep(j->data);
|
||||||
if(dep == NULL) {
|
if(dep == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ int _alpm_trans_update_depends(pmtrans_t *trans, pmpkg_t *pkg)
|
|||||||
|
|
||||||
localdb = alpm_option_get_localdb();
|
localdb = alpm_option_get_localdb();
|
||||||
for(i = depends; i; i = i->next) {
|
for(i = depends; i; i = i->next) {
|
||||||
pmdepend_t* dep = _alpm_splitdep(i->data);
|
pmdepend_t* dep = alpm_splitdep(i->data);
|
||||||
if(dep == NULL) {
|
if(dep == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ int _alpm_versioncmp(const char *a, const char *b)
|
|||||||
return(*one ? 1 : -1);
|
return(*one ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
|
int alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
|
||||||
{
|
{
|
||||||
int equal = 0;
|
int equal = 0;
|
||||||
|
|
||||||
|
@ -26,10 +26,8 @@
|
|||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
#include "package.h"
|
#include "package.h"
|
||||||
|
|
||||||
int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep);
|
|
||||||
int _alpm_versioncmp(const char *a, const char *b);
|
int _alpm_versioncmp(const char *a, const char *b);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _ALPM_VERSIONCMP_H */
|
#endif /* _ALPM_VERSIONCMP_H */
|
||||||
|
|
||||||
/* vim: set ts=2 sw=2 noet: */
|
/* vim: set ts=2 sw=2 noet: */
|
||||||
|
@ -38,35 +38,54 @@
|
|||||||
|
|
||||||
extern config_t *config;
|
extern config_t *config;
|
||||||
|
|
||||||
|
int chk_package(const char *pkgname, pmdepend_t *dep)
|
||||||
|
{
|
||||||
|
pmpkg_t *pkg;
|
||||||
|
pkg = alpm_db_get_pkg(alpm_option_get_localdb(), pkgname);
|
||||||
|
|
||||||
|
if(!pkg || !alpm_depcmp(pkg, dep)) {
|
||||||
|
return(1);
|
||||||
|
}
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
int pacman_deptest(alpm_list_t *targets)
|
int pacman_deptest(alpm_list_t *targets)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
pmdb_t *local;
|
alpm_list_t *i;
|
||||||
pmpkg_t *pkg;
|
|
||||||
alpm_list_t *i, *provides;
|
|
||||||
|
|
||||||
if(targets == NULL) {
|
if(targets == NULL) {
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
local = alpm_option_get_localdb();
|
|
||||||
|
|
||||||
for(i = targets; i; i = alpm_list_next(i)) {
|
for(i = targets; i; i = alpm_list_next(i)) {
|
||||||
const char *pkgname;
|
int found = 0;
|
||||||
|
pmdepend_t *dep;
|
||||||
pkgname = alpm_list_getdata(i);
|
const char *target;
|
||||||
/* find this package in the local DB */
|
alpm_list_t *j, *provides;
|
||||||
pkg = alpm_db_get_pkg(local, pkgname);
|
|
||||||
|
|
||||||
if(!pkg) {
|
target = alpm_list_getdata(i);
|
||||||
|
dep = alpm_splitdep(target);
|
||||||
|
|
||||||
|
if(chk_package(target, dep) == 0) {
|
||||||
|
found = 1;
|
||||||
|
} else {
|
||||||
/* not found, can we find anything that provides this in the local DB? */
|
/* not found, can we find anything that provides this in the local DB? */
|
||||||
provides = alpm_db_whatprovides(local, pkgname);
|
provides = alpm_db_whatprovides(alpm_option_get_localdb(), target);
|
||||||
if(!provides) {
|
for(j = provides; j; j = alpm_list_next(j)) {
|
||||||
/* nope, must be missing */
|
const char *provide;
|
||||||
MSG(NL, _("requires: %s"), pkgname);
|
provide = alpm_list_getdata(j);
|
||||||
retval = 1;
|
|
||||||
|
if(chk_package(provide, dep) == 0) {
|
||||||
|
found = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!found) {
|
||||||
|
MSG(NL, _("requires: %s"), target);
|
||||||
|
retval = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
@ -184,19 +184,6 @@ int yesno(char *fmt, ...)
|
|||||||
pm_fprintf(stderr, NL, str); \
|
pm_fprintf(stderr, NL, str); \
|
||||||
|
|
||||||
if(fgets(response, 32, stdin)) {
|
if(fgets(response, 32, stdin)) {
|
||||||
/* trim whitespace and newlines */
|
|
||||||
char *pch = response;
|
|
||||||
while(isspace(*pch)) {
|
|
||||||
pch++;
|
|
||||||
}
|
|
||||||
if(pch != response) {
|
|
||||||
memmove(response, pch, strlen(pch) + 1);
|
|
||||||
}
|
|
||||||
pch = response + strlen(response) - 1;
|
|
||||||
while(isspace(*pch)) {
|
|
||||||
pch--;
|
|
||||||
}
|
|
||||||
*++pch = 0;
|
|
||||||
if(strlen(response) != 0) {
|
if(strlen(response) != 0) {
|
||||||
strtrim(response);
|
strtrim(response);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user