FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 06-07-2011, 09:36 PM
Dan McGee
 
Default Require handle for alpm_checkconflicts()

Signed-off-by: Dan McGee <dan@archlinux.org>
---
lib/libalpm/alpm.h | 2 +-
lib/libalpm/conflict.c | 20 ++++++++++++--------
lib/libalpm/conflict.h | 2 +-
lib/libalpm/sync.c | 2 +-
src/util/testdb.c | 2 +-
5 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 44f2ba1..270418e 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -912,7 +912,7 @@ const char *alpm_miss_get_target(const pmdepmissing_t *miss);
pmdepend_t *alpm_miss_get_dep(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_package2(pmconflict_t *conflict);
diff --git a/lib/libalpm/conflict.c b/lib/libalpm/conflict.c
index 8921470..28f8cc6 100644
--- a/lib/libalpm/conflict.c
+++ b/lib/libalpm/conflict.c
@@ -160,7 +160,7 @@ static void check_conflict(alpm_list_t *list1, alpm_list_t *list2,
}

/* 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;

@@ -197,11 +197,13 @@ alpm_list_t *_alpm_outerconflicts(pmdb_t *db, alpm_list_t *packages)

/** Check the package conflicts in a database
*
+ * @param handle the context handle
* @param pkglist the list of packages to check
* @return an alpm_list_t of pmconflict_t
*/
-alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_list_t *pkglist) {
- return _alpm_innerconflicts(pkglist);
+alpm_list_t SYMEXPORT *alpm_checkconflicts(pmhandle_t *handle,
+ alpm_list_t *pkglist) {
+ return _alpm_innerconflicts(handle, pkglist);
}

static const int DIFFERENCE = 0;
@@ -297,7 +299,8 @@ void _alpm_fileconflict_free(pmfileconflict_t *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 stat sbuf;
@@ -305,7 +308,7 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
char abspath[PATH_MAX];
DIR *dir;

- snprintf(abspath, PATH_MAX, "%s%s", pkg->handle->root, dirpath);
+ snprintf(abspath, PATH_MAX, "%s%s", root, dirpath);
dir = opendir(abspath);
if(dir == NULL) {
return 1;
@@ -317,12 +320,12 @@ static int dir_belongsto_pkg(char *dirpath, pmpkg_t *pkg)
continue;
}
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) {
continue;
}
if(S_ISDIR(sbuf.st_mode)) {
- if(dir_belongsto_pkg(path, pkg)) {
+ if(dir_belongsto_pkg(root, path, pkg)) {
continue;
} else {
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),di r)) {
_alpm_log(PM_LOG_DEBUG, "check if all files in %s belongs to %s
",
dir, dbpkg->name);
- resolved_conflict = dir_belongsto_pkg(filestr, dbpkg);
+ resolved_conflict = dir_belongsto_pkg(handle->root, filestr, dbpkg);
}
free(dir);
}
@@ -561,4 +564,5 @@ const char SYMEXPORT *alpm_fileconflict_get_ctarget(pmfileconflict_t *conflict)

return conflict->ctarget;
}
+
/* vim: set ts=2 sw=2 noet: */
diff --git a/lib/libalpm/conflict.h b/lib/libalpm/conflict.h
index d00314d..2101170 100644
--- a/lib/libalpm/conflict.h
+++ b/lib/libalpm/conflict.h
@@ -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_dup(const 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_db_find_fileconflicts(pmhandle_t *handle,
alpm_list_t *upgrade, alpm_list_t *remove);
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 1882888..518e853 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -398,7 +398,7 @@ int _alpm_sync_prepare(pmhandle_t *handle, alpm_list_t **data)

/* 1. check for conflicts in the target list */
_alpm_log(PM_LOG_DEBUG, "check targets vs targets
");
- deps = _alpm_innerconflicts(trans->add);
+ deps = _alpm_innerconflicts(handle, trans->add);

for(i = deps; i; i = i->next) {
pmconflict_t *conflict = i->data;
diff --git a/src/util/testdb.c b/src/util/testdb.c
index 620328e..839a9cf 100644
--- a/src/util/testdb.c
+++ b/src/util/testdb.c
@@ -117,7 +117,7 @@ static int checkconflicts(alpm_list_t *pkglist)
alpm_list_t *data, *i;
int ret = 0;
/* check conflicts */
- data = alpm_checkconflicts(pkglist);
+ data = alpm_checkconflicts(handle, pkglist);
for(i = data; i; i = i->next) {
pmconflict_t *conflict = alpm_list_getdata(i);
printf("%s conflicts with %s
", alpm_conflict_get_package1(conflict),
--
1.7.5.2
 

Thread Tools




All times are GMT. The time now is 03:38 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org