Require handle for alpm_checkconflicts()

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2011-06-07 13:53:53 -05:00
parent d76341297a
commit 70a86c14f4
5 changed files with 16 additions and 12 deletions

View file

@ -914,7 +914,7 @@ const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss); pmdepend_t *alpm_miss_get_dep(pmdepmissing_t *miss);
const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss); const char *alpm_miss_get_causingpkg(const pmdepmissing_t *miss);
alpm_list_t *alpm_checkconflicts(alpm_list_t *pkglist); alpm_list_t *alpm_checkconflicts(pmhandle_t *handle, alpm_list_t *pkglist);
const char *alpm_conflict_get_package1(pmconflict_t *conflict); const char *alpm_conflict_get_package1(pmconflict_t *conflict);
const char *alpm_conflict_get_package2(pmconflict_t *conflict); const char *alpm_conflict_get_package2(pmconflict_t *conflict);

View file

@ -160,7 +160,7 @@ static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
} }
/* Check for inter-conflicts */ /* Check for inter-conflicts */
alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages) alpm_list_t *_alpm_innerconflicts(pmhandle_t *handle, alpm_list_t *packages)
{ {
alpm_list_t *baddeps = NULL; alpm_list_t *baddeps = NULL;
@ -197,11 +197,13 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)
/** Check the package conflicts in a database /** Check the package conflicts in a database
* *
* @param handle the context handle
* @param pkglist the list of packages to check * @param pkglist the list of packages to check
* @return an alpm_list_t of pmconflict_t * @return an alpm_list_t of pmconflict_t
*/ */
alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) { alpm_list_t SYMEXPORT *alpm_checkconflicts(pmhandle_t *handle,
return _alpm_innerconflicts(pkglist); alpm_list_t *pkglist) {
return _alpm_innerconflicts(handle, pkglist);
} }
static const int DIFFERENCE = 0; static const int DIFFERENCE = 0;
@ -297,7 +299,8 @@ void _alpm_fileconflict_free(pmfileconflict_t *conflict)
FREE(conflict); FREE(conflict);
} }
static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg) static int dir_belongsto_pkg(const char *root, const char *dirpath,
pmpkg_t *pkg)
{ {
struct dirent *ent = NULL; struct dirent *ent = NULL;
struct stat sbuf; struct stat sbuf;
@ -305,7 +308,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
char abspath[PATH_MAX]; char abspath[PATH_MAX];
DIR *dir; DIR *dir;
snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, dirpath); snprintf(abspath, PATH_MAX, "%s%s", root, dirpath);
dir = opendir(abspath); dir = opendir(abspath);
if(dir == NULL) { if(dir == NULL) {
return 1; return 1;
@ -317,12 +320,12 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
continue; continue;
} }
snprintf(path, PATH_MAX, "%s/%s", dirpath, name); snprintf(path, PATH_MAX, "%s/%s", dirpath, name);
snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, path); snprintf(abspath, PATH_MAX, "%s%s", root, path);
if(stat(abspath, &sbuf) != 0) { if(stat(abspath, &sbuf) != 0) {
continue; continue;
} }
if(S_ISDIR(sbuf.st_mode)) { if(S_ISDIR(sbuf.st_mode)) {
if(dir_belongsto_pkg(path, pkg)) { if(dir_belongsto_pkg(root, path, pkg)) {
continue; continue;
} else { } else {
closedir(dir); closedir(dir);
@ -474,7 +477,7 @@ alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
if(alpm_list_find_str(alpm_pkg_get_files(dbpkg),dir)) { if(alpm_list_find_str(alpm_pkg_get_files(dbpkg),dir)) {
_alpm_log(PM_LOG_DEBUG, "check if all files in %s belongs to %s\n", _alpm_log(PM_LOG_DEBUG, "check if all files in %s belongs to %s\n",
dir, dbpkg->name); dir, dbpkg->name);
resolved_conflict = dir_belongsto_pkg(filestr, dbpkg); resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
} }
free(dir); free(dir);
} }
@ -561,4 +564,5 @@ const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict)
return conflict->ctarget; return conflict->ctarget;
} }
/* vim: set ts=2 sw=2 noet: */ /* vim: set ts=2 sw=2 noet: */

View file

@ -40,7 +40,7 @@ struct __pmfileconflict_t {
pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, const char *reason); pmconflict_t *_alpm_conflict_new(const char *package1, const char *package2, const char *reason);
pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict); pmconflict_t *_alpm_conflict_dup(const pmconflict_t *conflict);
void _alpm_conflict_free(pmconflict_t *conflict); void _alpm_conflict_free(pmconflict_t *conflict);
alpm_list_t *_alpm_innerconflicts(alpm_list_t *packages); alpm_list_t *_alpm_innerconflicts(pmhandle_t *handle, alpm_list_t *packages);
alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages); alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages);
alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle, alpm_list_t *_alpm_db_find_fileconflicts(pmhandle_t *handle,
alpm_list_t *upgrade, alpm_list_t *remove); alpm_list_t *upgrade, alpm_list_t *remove);

View file

@ -398,7 +398,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)
/* 1. check for conflicts in the target list */ /* 1. check for conflicts in the target list */
_alpm_log(PM_LOG_DEBUG, "check targets vs targets\n"); _alpm_log(PM_LOG_DEBUG, "check targets vs targets\n");
deps = _alpm_innerconflicts(trans->add); deps = _alpm_innerconflicts(handle, trans->add);
for(i = deps; i; i = i->next) { for(i = deps; i; i = i->next) {
pmconflict_t *conflict = i->data; pmconflict_t *conflict = i->data;

View file

@ -117,7 +117,7 @@ static int checkconflicts(alpm_list_t *pkglist)
alpm_list_t *data, *i; alpm_list_t *data, *i;
int ret = 0; int ret = 0;
/* check conflicts */ /* check conflicts */
data = alpm_checkconflicts(pkglist); data = alpm_checkconflicts(handle, pkglist);
for(i = data; i; i = i->next) { for(i = data; i; i = i->next) {
pmconflict_t *conflict = alpm_list_getdata(i); pmconflict_t *conflict = alpm_list_getdata(i);
printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict), printf("%s conflicts with %s\n", alpm_conflict_get_package1(conflict),