mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 13:07:58 -05:00
added a pmconflict_t structure to handle file conflicts
This commit is contained in:
parent
c432d52506
commit
325e3b6b98
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* alpm.c
|
* alpm.c
|
||||||
*
|
*
|
||||||
* Copyright (c) 2002 by Judd Vinet <jvinet@zeroflux.org>
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,6 +43,7 @@
|
|||||||
#include "db.h"
|
#include "db.h"
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
|
#include "conflict.h"
|
||||||
#include "backup.h"
|
#include "backup.h"
|
||||||
#include "add.h"
|
#include "add.h"
|
||||||
#include "remove.h"
|
#include "remove.h"
|
||||||
@ -415,6 +416,7 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
|
|||||||
if(pkg->origin == PKG_FROM_CACHE) {
|
if(pkg->origin == PKG_FROM_CACHE) {
|
||||||
switch(parm) {
|
switch(parm) {
|
||||||
/* Desc entry */
|
/* Desc entry */
|
||||||
|
/* not needed: the cache is loaded with DESC by default
|
||||||
case PM_PKG_NAME:
|
case PM_PKG_NAME:
|
||||||
case PM_PKG_VERSION:
|
case PM_PKG_VERSION:
|
||||||
case PM_PKG_DESC:
|
case PM_PKG_DESC:
|
||||||
@ -433,7 +435,7 @@ void *alpm_pkg_getinfo(pmpkg_t *pkg, unsigned char parm)
|
|||||||
snprintf(target, PKG_FULLNAME_LEN, "%s-%s", pkg->name, pkg->version);
|
snprintf(target, PKG_FULLNAME_LEN, "%s-%s", pkg->name, pkg->version);
|
||||||
db_read(pkg->data, target, INFRQ_DESC, pkg);
|
db_read(pkg->data, target, INFRQ_DESC, pkg);
|
||||||
}
|
}
|
||||||
break;
|
break;*/
|
||||||
/* Depends entry */
|
/* Depends entry */
|
||||||
/* not needed: the cache is loaded with DEPENDS by default
|
/* not needed: the cache is loaded with DEPENDS by default
|
||||||
case PM_PKG_DEPENDS:
|
case PM_PKG_DEPENDS:
|
||||||
@ -806,6 +808,37 @@ void *alpm_dep_getinfo(pmdepmissing_t *miss, unsigned char parm)
|
|||||||
}
|
}
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/** @defgroup alpm_dep File Conflicts Functions
|
||||||
|
* @brief Functions to get informations about a libalpm file conflict
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Get informations about a file conflict.
|
||||||
|
* @param db conflict pointer
|
||||||
|
* @param parm name of the info to get
|
||||||
|
* @return a void* on success (the value), NULL on error
|
||||||
|
*/
|
||||||
|
void *alpm_conflict_getinfo(pmconflict_t *conflict, unsigned char parm)
|
||||||
|
{
|
||||||
|
void *data;
|
||||||
|
|
||||||
|
/* Sanity checks */
|
||||||
|
ASSERT(conflict != NULL, return(NULL));
|
||||||
|
|
||||||
|
switch(parm) {
|
||||||
|
case PM_CONFLICT_TARGET: data = conflict->target; break;
|
||||||
|
case PM_CONFLICT_TYPE: data = (void *)(int)conflict->type; break;
|
||||||
|
case PM_CONFLICT_FILE: data = conflict->file; break;
|
||||||
|
case PM_CONFLICT_CTARGET: data = conflict->ctarget; break;
|
||||||
|
default:
|
||||||
|
data = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return(data);
|
||||||
|
}
|
||||||
|
/** @} */
|
||||||
|
|
||||||
/** @defgroup alpm_log Logging Functions
|
/** @defgroup alpm_log Logging Functions
|
||||||
* @brief Functions to log using libalpm
|
* @brief Functions to log using libalpm
|
||||||
* @{
|
* @{
|
||||||
|
@ -49,6 +49,7 @@ typedef struct __pmgrp_t PM_GRP;
|
|||||||
typedef struct __pmsyncpkg_t PM_SYNCPKG;
|
typedef struct __pmsyncpkg_t PM_SYNCPKG;
|
||||||
typedef struct __pmtrans_t PM_TRANS;
|
typedef struct __pmtrans_t PM_TRANS;
|
||||||
typedef struct __pmdepmissing_t PM_DEPMISS;
|
typedef struct __pmdepmissing_t PM_DEPMISS;
|
||||||
|
typedef struct __pmconflict_t PM_CONFLICT;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Library
|
* Library
|
||||||
@ -268,7 +269,7 @@ int alpm_trans_commit(PM_LIST **data);
|
|||||||
int alpm_trans_release(void);
|
int alpm_trans_release(void);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dependencies
|
* Dependencies and conflicts
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -293,6 +294,24 @@ enum {
|
|||||||
|
|
||||||
void *alpm_dep_getinfo(PM_DEPMISS *miss, unsigned char parm);
|
void *alpm_dep_getinfo(PM_DEPMISS *miss, unsigned char parm);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* File conflicts
|
||||||
|
*/
|
||||||
|
|
||||||
|
enum {
|
||||||
|
PM_CONFLICT_TYPE_TARGET = 1,
|
||||||
|
PM_CONFLICT_TYPE_FILE
|
||||||
|
};
|
||||||
|
/* Info parameters */
|
||||||
|
enum {
|
||||||
|
PM_CONFLICT_TARGET = 1,
|
||||||
|
PM_CONFLICT_TYPE,
|
||||||
|
PM_CONFLICT_FILE,
|
||||||
|
PM_CONFLICT_CTARGET
|
||||||
|
};
|
||||||
|
|
||||||
|
void *alpm_conflict_getinfo(PM_CONFLICT *conflict, unsigned char parm);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Helpers
|
* Helpers
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include "deps.h"
|
#include "deps.h"
|
||||||
#include "conflict.h"
|
#include "conflict.h"
|
||||||
|
|
||||||
/* Returns a PMList* of missing_t pointers.
|
/* Returns a PMList* of pmdepmissing_t pointers.
|
||||||
*
|
*
|
||||||
* conflicts are always name only
|
* conflicts are always name only
|
||||||
*/
|
*/
|
||||||
@ -194,18 +194,20 @@ PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip
|
|||||||
if(strcmp(p1->name, p2->name)) {
|
if(strcmp(p1->name, p2->name)) {
|
||||||
for(k = p1->files; k; k = k->next) {
|
for(k = p1->files; k; k = k->next) {
|
||||||
filestr = k->data;
|
filestr = k->data;
|
||||||
if(!strcmp(filestr, "._install") || !strcmp(filestr, ".INSTALL")) {
|
if(filestr[strlen(filestr)-1] == '/') {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if(rindex(filestr, '/') == filestr+strlen(filestr)-1) {
|
|
||||||
/* this filename has a trailing '/', so it's a directory -- skip it. */
|
/* this filename has a trailing '/', so it's a directory -- skip it. */
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if(!strcmp(filestr, "._install") || !strcmp(filestr, ".INSTALL")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(pm_list_is_strin(filestr, p2->files)) {
|
if(pm_list_is_strin(filestr, p2->files)) {
|
||||||
MALLOC(str, 512);
|
pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
|
||||||
snprintf(str, 512, "%s: exists in \"%s\" (target) and \"%s\" (target)",
|
conflict->type = PM_CONFLICT_TYPE_TARGET;
|
||||||
filestr, p1->name, p2->name);
|
STRNCPY(conflict->target, p1->name, PKG_NAME_LEN);
|
||||||
conflicts = pm_list_add(conflicts, str);
|
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
|
||||||
|
STRNCPY(conflict->ctarget, p2->name, PKG_NAME_LEN);
|
||||||
|
conflicts = pm_list_add(conflicts, conflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -297,9 +299,12 @@ PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip
|
|||||||
}
|
}
|
||||||
donecheck:
|
donecheck:
|
||||||
if(!ok) {
|
if(!ok) {
|
||||||
MALLOC(str, 512);
|
pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
|
||||||
snprintf(str, 512, "%s: %s: exists in filesystem", p->name, path);
|
conflict->type = PM_CONFLICT_TYPE_FILE;
|
||||||
conflicts = pm_list_add(conflicts, str);
|
STRNCPY(conflict->target, p->name, PKG_NAME_LEN);
|
||||||
|
STRNCPY(conflict->file, filestr, CONFLICT_FILE_LEN);
|
||||||
|
conflict->ctarget[0] = 0;
|
||||||
|
conflicts = pm_list_add(conflicts, conflict);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,15 @@
|
|||||||
|
|
||||||
#include "db.h"
|
#include "db.h"
|
||||||
|
|
||||||
|
#define CONFLICT_FILE_LEN 512
|
||||||
|
|
||||||
|
typedef struct __pmconflict_t {
|
||||||
|
char target[PKG_NAME_LEN];
|
||||||
|
unsigned char type;
|
||||||
|
char file[CONFLICT_FILE_LEN];
|
||||||
|
char ctarget[PKG_NAME_LEN];
|
||||||
|
} pmconflict_t;
|
||||||
|
|
||||||
PMList *checkconflicts(pmdb_t *db, PMList *packages);
|
PMList *checkconflicts(pmdb_t *db, PMList *packages);
|
||||||
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list);
|
PMList *db_find_conflicts(pmdb_t *db, PMList *targets, char *root, PMList **skip_list);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user