2005-03-22 15:21:12 -05:00
|
|
|
/*
|
|
|
|
* conflict.c
|
2007-11-16 21:18:45 -05:00
|
|
|
*
|
2016-01-02 22:48:43 -05:00
|
|
|
* Copyright (c) 2006-2016 Pacman Development Team <pacman-dev@archlinux.org>
|
2009-07-01 03:08:33 -04:00
|
|
|
* Copyright (c) 2002-2006 by Judd Vinet <jvinet@zeroflux.org>
|
2006-10-15 15:31:03 -04:00
|
|
|
* Copyright (c) 2005 by Aurelien Foret <orelien@chez.com>
|
|
|
|
* Copyright (c) 2006 by David Kimpe <dnaku@frugalware.org>
|
|
|
|
* Copyright (c) 2006 by Miklos Vajna <vmiklos@frugalware.org>
|
2006-10-15 20:05:10 -04:00
|
|
|
* Copyright (c) 2006 by Christian Hamar <krics@linuxforum.hu>
|
2007-11-16 21:18:45 -05:00
|
|
|
*
|
2005-03-22 15:21:12 -05:00
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2007-12-10 23:55:22 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2005-03-22 15:21:12 -05:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
2006-11-22 04:03:41 -05:00
|
|
|
#include <stdio.h>
|
2005-03-22 15:21:12 -05:00
|
|
|
#include <string.h>
|
2006-03-02 14:04:40 -05:00
|
|
|
#include <limits.h>
|
2005-03-22 15:21:12 -05:00
|
|
|
#include <sys/stat.h>
|
2009-07-17 09:48:57 -04:00
|
|
|
#include <dirent.h>
|
2007-03-05 17:13:33 -05:00
|
|
|
|
|
|
|
/* libalpm */
|
|
|
|
#include "conflict.h"
|
2007-01-19 04:28:44 -05:00
|
|
|
#include "alpm_list.h"
|
2011-06-16 14:16:49 -04:00
|
|
|
#include "alpm.h"
|
2007-03-05 17:13:33 -05:00
|
|
|
#include "handle.h"
|
2006-11-20 04:10:23 -05:00
|
|
|
#include "trans.h"
|
2005-03-22 15:21:12 -05:00
|
|
|
#include "util.h"
|
2006-01-15 10:55:16 -05:00
|
|
|
#include "log.h"
|
|
|
|
#include "deps.h"
|
2012-07-12 16:29:59 -04:00
|
|
|
#include "filelist.h"
|
2005-03-22 15:21:12 -05:00
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Creates a new conflict.
|
|
|
|
*/
|
2011-08-09 00:25:45 -04:00
|
|
|
static alpm_conflict_t *conflict_new(alpm_pkg_t *pkg1, alpm_pkg_t *pkg2,
|
2011-08-09 02:00:16 -04:00
|
|
|
alpm_depend_t *reason)
|
2007-11-18 08:25:43 -05:00
|
|
|
{
|
2011-06-28 00:33:55 -04:00
|
|
|
alpm_conflict_t *conflict;
|
2007-11-18 08:25:43 -05:00
|
|
|
|
2014-12-23 20:55:49 -05:00
|
|
|
CALLOC(conflict, 1, sizeof(alpm_conflict_t), return NULL);
|
2007-11-18 08:25:43 -05:00
|
|
|
|
2011-08-09 00:25:45 -04:00
|
|
|
conflict->package1_hash = pkg1->name_hash;
|
|
|
|
conflict->package2_hash = pkg2->name_hash;
|
2014-12-23 19:54:28 -05:00
|
|
|
STRDUP(conflict->package1, pkg1->name, goto error);
|
|
|
|
STRDUP(conflict->package2, pkg2->name, goto error);
|
2011-08-09 02:00:16 -04:00
|
|
|
conflict->reason = reason;
|
2007-11-18 08:25:43 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return conflict;
|
2014-12-23 19:54:28 -05:00
|
|
|
|
|
|
|
error:
|
|
|
|
alpm_conflict_free(conflict);
|
|
|
|
return NULL;
|
2007-11-18 08:25:43 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Free a conflict and its members.
|
|
|
|
*/
|
2014-02-03 12:09:18 -05:00
|
|
|
void SYMEXPORT alpm_conflict_free(alpm_conflict_t *conflict)
|
2008-01-11 01:01:58 -05:00
|
|
|
{
|
2015-10-25 07:39:27 -04:00
|
|
|
ASSERT(conflict != NULL, return);
|
2008-01-11 01:01:58 -05:00
|
|
|
FREE(conflict->package2);
|
|
|
|
FREE(conflict->package1);
|
|
|
|
FREE(conflict);
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Creates a copy of a conflict.
|
|
|
|
*/
|
2011-06-28 00:33:55 -04:00
|
|
|
alpm_conflict_t *_alpm_conflict_dup(const alpm_conflict_t *conflict)
|
2008-01-25 15:31:20 -05:00
|
|
|
{
|
2011-06-28 00:33:55 -04:00
|
|
|
alpm_conflict_t *newconflict;
|
2011-06-28 18:46:04 -04:00
|
|
|
CALLOC(newconflict, 1, sizeof(alpm_conflict_t), return NULL);
|
2008-01-25 15:31:20 -05:00
|
|
|
|
2011-08-09 00:25:45 -04:00
|
|
|
newconflict->package1_hash = conflict->package1_hash;
|
|
|
|
newconflict->package2_hash = conflict->package2_hash;
|
2014-12-22 02:39:47 -05:00
|
|
|
STRDUP(newconflict->package1, conflict->package1, goto error);
|
|
|
|
STRDUP(newconflict->package2, conflict->package2, goto error);
|
2011-08-09 02:00:16 -04:00
|
|
|
newconflict->reason = conflict->reason;
|
2008-01-25 15:31:20 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return newconflict;
|
2014-12-22 02:39:47 -05:00
|
|
|
|
|
|
|
error:
|
|
|
|
alpm_conflict_free(newconflict);
|
|
|
|
return NULL;
|
2008-01-25 15:31:20 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Searches for a conflict in a list.
|
|
|
|
*
|
|
|
|
* @param needle conflict to search for
|
|
|
|
* @param haystack list of conflicts to search
|
|
|
|
*
|
|
|
|
* @return 1 if needle is in haystack, 0 otherwise
|
|
|
|
*/
|
2011-06-28 00:33:55 -04:00
|
|
|
static int conflict_isin(alpm_conflict_t *needle, alpm_list_t *haystack)
|
2007-11-18 08:25:43 -05:00
|
|
|
{
|
|
|
|
alpm_list_t *i;
|
|
|
|
for(i = haystack; i; i = i->next) {
|
2011-06-28 00:33:55 -04:00
|
|
|
alpm_conflict_t *conflict = i->data;
|
2011-08-09 00:25:45 -04:00
|
|
|
if(needle->package1_hash == conflict->package1_hash
|
|
|
|
&& needle->package2_hash == conflict->package2_hash
|
|
|
|
&& strcmp(needle->package1, conflict->package1) == 0
|
|
|
|
&& strcmp(needle->package2, conflict->package2) == 0) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2007-11-18 08:25:43 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return 0;
|
2007-11-18 08:25:43 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Adds the pkg1/pkg2 conflict to the baddeps list.
|
|
|
|
*
|
2011-06-07 17:13:58 -04:00
|
|
|
* @param handle the context handle
|
|
|
|
* @param baddeps list to add conflict to
|
2007-07-19 19:22:45 -04:00
|
|
|
* @param pkg1 first package
|
|
|
|
* @param pkg2 package causing conflict
|
2011-06-07 17:13:58 -04:00
|
|
|
* @param reason reason for this conflict
|
2013-01-19 15:21:36 -05:00
|
|
|
*
|
|
|
|
* @return 0 on success, -1 on error
|
2007-07-19 19:22:45 -04:00
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
static int add_conflict(alpm_handle_t *handle, alpm_list_t **baddeps,
|
2011-08-09 02:00:16 -04:00
|
|
|
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, alpm_depend_t *reason)
|
2007-03-03 03:13:59 -05:00
|
|
|
{
|
2011-06-28 00:33:55 -04:00
|
|
|
alpm_conflict_t *conflict = conflict_new(pkg1, pkg2, reason);
|
2011-06-07 17:06:16 -04:00
|
|
|
if(!conflict) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if(!conflict_isin(conflict, *baddeps)) {
|
2011-08-09 02:00:16 -04:00
|
|
|
char *conflict_str = alpm_dep_compute_string(reason);
|
2007-11-18 08:25:43 -05:00
|
|
|
*baddeps = alpm_list_add(*baddeps, conflict);
|
2011-08-09 02:00:16 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "package %s conflicts with %s (by %s)\n",
|
|
|
|
pkg1->name, pkg2->name, conflict_str);
|
|
|
|
free(conflict_str);
|
2007-07-19 19:22:45 -04:00
|
|
|
} else {
|
2014-02-03 12:09:18 -05:00
|
|
|
alpm_conflict_free(conflict);
|
2007-03-03 03:13:59 -05:00
|
|
|
}
|
2011-06-07 17:06:16 -04:00
|
|
|
return 0;
|
2007-03-03 03:13:59 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Check if packages from list1 conflict with packages from list2.
|
|
|
|
*
|
|
|
|
* @details This looks at the conflicts fields of all packages from list1, and
|
|
|
|
* sees if they match packages from list2. If a conflict (pkg1, pkg2) is found,
|
|
|
|
* it is added to the baddeps list in this order if order >= 0, or reverse
|
|
|
|
* order (pkg2,pkg1) otherwise.
|
2007-07-19 19:22:45 -04:00
|
|
|
*
|
2011-06-07 17:13:58 -04:00
|
|
|
* @param handle the context handle
|
2007-07-19 19:22:45 -04:00
|
|
|
* @param list1 first list of packages
|
|
|
|
* @param list2 second list of packages
|
2011-06-07 17:13:58 -04:00
|
|
|
* @param baddeps list to store conflicts
|
2007-07-19 19:22:45 -04:00
|
|
|
* @param order if >= 0 the conflict order is preserved, if < 0 it's reversed
|
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
static void check_conflict(alpm_handle_t *handle,
|
2011-06-07 17:13:58 -04:00
|
|
|
alpm_list_t *list1, alpm_list_t *list2,
|
2013-01-03 16:48:52 -05:00
|
|
|
alpm_list_t **baddeps, int order)
|
|
|
|
{
|
2011-06-07 17:13:58 -04:00
|
|
|
alpm_list_t *i;
|
2007-03-03 03:13:59 -05:00
|
|
|
|
2007-07-19 19:22:45 -04:00
|
|
|
if(!baddeps) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
for(i = list1; i; i = i->next) {
|
2011-06-28 09:26:39 -04:00
|
|
|
alpm_pkg_t *pkg1 = i->data;
|
2011-06-07 17:13:58 -04:00
|
|
|
alpm_list_t *j;
|
2007-03-03 03:13:59 -05:00
|
|
|
|
2007-07-19 19:22:45 -04:00
|
|
|
for(j = alpm_pkg_get_conflicts(pkg1); j; j = j->next) {
|
2011-08-09 02:00:16 -04:00
|
|
|
alpm_depend_t *conflict = j->data;
|
2011-06-07 17:13:58 -04:00
|
|
|
alpm_list_t *k;
|
2007-03-03 03:13:59 -05:00
|
|
|
|
2007-07-19 19:22:45 -04:00
|
|
|
for(k = list2; k; k = k->next) {
|
2011-06-28 09:26:39 -04:00
|
|
|
alpm_pkg_t *pkg2 = k->data;
|
2007-07-19 19:22:45 -04:00
|
|
|
|
2011-08-09 00:25:45 -04:00
|
|
|
if(pkg1->name_hash == pkg2->name_hash
|
|
|
|
&& strcmp(pkg1->name, pkg2->name) == 0) {
|
2007-07-19 19:22:45 -04:00
|
|
|
/* skip the package we're currently processing */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-08-09 02:00:16 -04:00
|
|
|
if(_alpm_depcmp(pkg2, conflict)) {
|
2007-07-19 19:22:45 -04:00
|
|
|
if(order >= 0) {
|
2011-08-09 00:25:45 -04:00
|
|
|
add_conflict(handle, baddeps, pkg1, pkg2, conflict);
|
2007-07-19 19:22:45 -04:00
|
|
|
} else {
|
2011-08-09 00:25:45 -04:00
|
|
|
add_conflict(handle, baddeps, pkg2, pkg1, conflict);
|
2007-07-19 19:22:45 -04:00
|
|
|
}
|
|
|
|
}
|
2006-02-21 18:55:59 -05:00
|
|
|
}
|
2007-03-03 03:13:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Check for inter-conflicts in a list of packages.
|
|
|
|
*
|
|
|
|
* @param handle the context handle
|
|
|
|
* @param packages list of packages to check
|
|
|
|
*
|
|
|
|
* @return list of conflicts
|
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
alpm_list_t *_alpm_innerconflicts(alpm_handle_t *handle, alpm_list_t *packages)
|
2007-11-20 03:57:38 -05:00
|
|
|
{
|
|
|
|
alpm_list_t *baddeps = NULL;
|
|
|
|
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "check targets vs targets\n");
|
2011-06-07 17:13:58 -04:00
|
|
|
check_conflict(handle, packages, packages, &baddeps, 0);
|
2007-11-20 03:57:38 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return baddeps;
|
2007-11-20 03:57:38 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Returns a list of conflicts between a db and a list of packages.
|
|
|
|
*/
|
2011-06-28 00:11:43 -04:00
|
|
|
alpm_list_t *_alpm_outerconflicts(alpm_db_t *db, alpm_list_t *packages)
|
2007-03-03 03:13:59 -05:00
|
|
|
{
|
2007-07-19 19:22:45 -04:00
|
|
|
alpm_list_t *baddeps = NULL;
|
2007-03-03 03:13:59 -05:00
|
|
|
|
|
|
|
if(db == NULL) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return NULL;
|
2007-03-03 03:13:59 -05:00
|
|
|
}
|
|
|
|
|
2011-02-25 09:22:09 -05:00
|
|
|
alpm_list_t *dblist = alpm_list_diff(_alpm_db_get_pkgcache(db),
|
2011-01-24 20:49:34 -05:00
|
|
|
packages, _alpm_pkg_cmp);
|
2007-03-03 03:13:59 -05:00
|
|
|
|
2007-11-20 03:57:38 -05:00
|
|
|
/* two checks to be done here for conflicts */
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(db->handle, ALPM_LOG_DEBUG, "check targets vs db\n");
|
2011-06-07 17:13:58 -04:00
|
|
|
check_conflict(db->handle, packages, dblist, &baddeps, 1);
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(db->handle, ALPM_LOG_DEBUG, "check db vs targets\n");
|
2011-06-07 17:13:58 -04:00
|
|
|
check_conflict(db->handle, dblist, packages, &baddeps, -1);
|
2006-01-15 10:55:16 -05:00
|
|
|
|
2007-08-04 11:11:03 -04:00
|
|
|
alpm_list_free(dblist);
|
2011-03-20 20:45:57 -04:00
|
|
|
return baddeps;
|
2006-01-15 10:55:16 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Check the package conflicts in a database
|
2007-12-09 08:49:34 -05:00
|
|
|
*
|
2011-06-07 14:53:53 -04:00
|
|
|
* @param handle the context handle
|
2008-08-17 13:30:36 -04:00
|
|
|
* @param pkglist the list of packages to check
|
2013-01-19 15:21:36 -05:00
|
|
|
*
|
2011-06-28 00:33:55 -04:00
|
|
|
* @return an alpm_list_t of alpm_conflict_t
|
2007-12-09 08:49:34 -05:00
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
alpm_list_t SYMEXPORT *alpm_checkconflicts(alpm_handle_t *handle,
|
2011-06-07 17:13:58 -04:00
|
|
|
alpm_list_t *pkglist)
|
|
|
|
{
|
2011-06-14 11:01:08 -04:00
|
|
|
CHECK_HANDLE(handle, return NULL);
|
2011-06-07 14:53:53 -04:00
|
|
|
return _alpm_innerconflicts(handle, pkglist);
|
2007-11-20 03:57:38 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Creates and adds a file conflict to a conflict list.
|
|
|
|
*
|
|
|
|
* @param handle the context handle
|
|
|
|
* @param conflicts the list of conflicts to append to
|
|
|
|
* @param filestr the conflicting file path
|
|
|
|
* @param pkg1 package that wishes to install the file
|
|
|
|
* @param pkg2 package that currently owns the file, or NULL if unowned
|
|
|
|
*
|
|
|
|
* @return the updated conflict list
|
2007-02-13 23:52:17 -05:00
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
static alpm_list_t *add_fileconflict(alpm_handle_t *handle,
|
2011-09-26 18:31:34 -04:00
|
|
|
alpm_list_t *conflicts, const char *filestr,
|
|
|
|
alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
|
2007-02-13 23:52:17 -05:00
|
|
|
{
|
2011-06-28 00:35:17 -04:00
|
|
|
alpm_fileconflict_t *conflict;
|
2014-12-23 20:55:49 -05:00
|
|
|
CALLOC(conflict, 1, sizeof(alpm_fileconflict_t), goto error);
|
2007-10-29 02:00:52 -04:00
|
|
|
|
2011-09-26 18:31:34 -04:00
|
|
|
STRDUP(conflict->target, pkg1->name, goto error);
|
2011-06-14 10:30:46 -04:00
|
|
|
STRDUP(conflict->file, filestr, goto error);
|
2011-09-26 18:31:34 -04:00
|
|
|
if(pkg2) {
|
|
|
|
conflict->type = ALPM_FILECONFLICT_TARGET;
|
|
|
|
STRDUP(conflict->ctarget, pkg2->name, goto error);
|
2007-02-18 22:18:59 -05:00
|
|
|
} else {
|
2011-09-26 18:31:34 -04:00
|
|
|
conflict->type = ALPM_FILECONFLICT_FILESYSTEM;
|
2011-06-14 10:30:46 -04:00
|
|
|
STRDUP(conflict->ctarget, "", goto error);
|
2007-02-18 22:18:59 -05:00
|
|
|
}
|
|
|
|
|
2007-02-13 23:52:17 -05:00
|
|
|
conflicts = alpm_list_add(conflicts, conflict);
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "found file conflict %s, packages %s and %s\n",
|
2011-09-26 18:31:34 -04:00
|
|
|
filestr, pkg1->name, pkg2 ? pkg2->name : "(filesystem)");
|
2007-02-13 23:52:17 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return conflicts;
|
2011-06-14 10:30:46 -04:00
|
|
|
|
|
|
|
error:
|
2014-12-23 19:48:57 -05:00
|
|
|
alpm_fileconflict_free(conflict);
|
2011-07-01 12:01:39 -04:00
|
|
|
RET_ERR(handle, ALPM_ERR_MEMORY, conflicts);
|
2007-02-13 23:52:17 -05:00
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Frees a conflict and its members.
|
|
|
|
*/
|
2014-02-03 12:09:18 -05:00
|
|
|
void SYMEXPORT alpm_fileconflict_free(alpm_fileconflict_t *conflict)
|
2008-01-11 01:01:58 -05:00
|
|
|
{
|
2015-10-25 07:39:27 -04:00
|
|
|
ASSERT(conflict != NULL, return);
|
2011-05-04 16:48:47 -04:00
|
|
|
FREE(conflict->ctarget);
|
|
|
|
FREE(conflict->file);
|
2008-01-11 01:01:58 -05:00
|
|
|
FREE(conflict->target);
|
|
|
|
FREE(conflict);
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
2013-04-12 22:26:14 -04:00
|
|
|
* @brief Recursively checks if a set of packages own all subdirectories and
|
|
|
|
* files in a directory.
|
2013-01-19 15:21:36 -05:00
|
|
|
*
|
|
|
|
* @param handle the context handle
|
|
|
|
* @param dirpath path of the directory to check
|
2013-04-12 22:26:14 -04:00
|
|
|
* @param pkgs packages being checked against
|
2013-01-19 15:21:36 -05:00
|
|
|
*
|
2013-04-12 22:26:14 -04:00
|
|
|
* @return 1 if a package owns all subdirectories and files, 0 otherwise
|
2013-01-19 15:21:36 -05:00
|
|
|
*/
|
2013-04-12 22:26:14 -04:00
|
|
|
static int dir_belongsto_pkgs(alpm_handle_t *handle, const char *dirpath,
|
|
|
|
alpm_list_t *pkgs)
|
2009-07-17 09:48:57 -04:00
|
|
|
{
|
2013-04-12 22:26:14 -04:00
|
|
|
char path[PATH_MAX], full_path[PATH_MAX];
|
2009-07-17 09:48:57 -04:00
|
|
|
DIR *dir;
|
2012-07-08 07:36:36 -04:00
|
|
|
struct dirent *ent = NULL;
|
2009-07-17 09:48:57 -04:00
|
|
|
|
2013-04-12 22:26:14 -04:00
|
|
|
snprintf(full_path, PATH_MAX, "%s%s", handle->root, dirpath);
|
|
|
|
dir = opendir(full_path);
|
2009-07-17 09:48:57 -04:00
|
|
|
if(dir == NULL) {
|
2013-04-12 22:26:14 -04:00
|
|
|
return 0;
|
2009-07-17 09:48:57 -04:00
|
|
|
}
|
2011-06-16 14:16:49 -04:00
|
|
|
|
2009-07-17 09:48:57 -04:00
|
|
|
while((ent = readdir(dir)) != NULL) {
|
|
|
|
const char *name = ent->d_name;
|
2013-08-09 09:15:40 -04:00
|
|
|
int owned = 0, is_dir = 0;
|
2013-04-12 22:26:14 -04:00
|
|
|
alpm_list_t *i;
|
|
|
|
struct stat sbuf;
|
2009-07-17 09:48:57 -04:00
|
|
|
|
|
|
|
if(strcmp(name, ".") == 0 || strcmp(name, "..") == 0) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-04-12 22:26:14 -04:00
|
|
|
|
2013-08-09 09:15:40 -04:00
|
|
|
snprintf(full_path, PATH_MAX, "%s%s%s", handle->root, dirpath, name);
|
|
|
|
|
|
|
|
if(lstat(full_path, &sbuf) != 0) {
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "could not stat %s\n", full_path);
|
|
|
|
closedir(dir);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
is_dir = S_ISDIR(sbuf.st_mode);
|
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s%s%s", dirpath, name, is_dir ? "/" : "");
|
2013-04-12 22:26:14 -04:00
|
|
|
|
|
|
|
for(i = pkgs; i && !owned; i = i->next) {
|
|
|
|
if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
|
|
|
|
owned = 1;
|
2009-07-17 09:48:57 -04:00
|
|
|
}
|
|
|
|
}
|
2013-04-12 22:26:14 -04:00
|
|
|
|
2013-08-09 09:15:40 -04:00
|
|
|
if(owned && is_dir) {
|
2013-04-12 22:26:14 -04:00
|
|
|
owned = dir_belongsto_pkgs(handle, path, pkgs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!owned) {
|
|
|
|
closedir(dir);
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"unowned file %s found in directory\n", path);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-07-17 09:48:57 -04:00
|
|
|
}
|
|
|
|
closedir(dir);
|
2011-03-20 20:45:57 -04:00
|
|
|
return 1;
|
2009-07-17 09:48:57 -04:00
|
|
|
}
|
|
|
|
|
2013-04-12 22:26:14 -04:00
|
|
|
static alpm_list_t *alpm_db_find_file_owners(alpm_db_t* db, const char *path)
|
|
|
|
{
|
|
|
|
alpm_list_t *i, *owners = NULL;
|
|
|
|
for(i = alpm_db_get_pkgcache(db); i; i = i->next) {
|
|
|
|
if(alpm_filelist_contains(alpm_pkg_get_files(i->data), path)) {
|
|
|
|
owners = alpm_list_add(owners, i->data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return owners;
|
|
|
|
}
|
|
|
|
|
2013-01-19 15:21:36 -05:00
|
|
|
/**
|
|
|
|
* @brief Find file conflicts that may occur during the transaction.
|
|
|
|
*
|
|
|
|
* @details Performs two checks:
|
|
|
|
* 1. check every target against every target
|
|
|
|
* 2. check every target against the filesystem
|
|
|
|
*
|
|
|
|
* @param handle the context handle
|
|
|
|
* @param upgrade list of packages being installed
|
|
|
|
* @param rem list of packages being removed
|
|
|
|
*
|
|
|
|
* @return list of file conflicts
|
|
|
|
*/
|
2011-06-28 00:04:00 -04:00
|
|
|
alpm_list_t *_alpm_db_find_fileconflicts(alpm_handle_t *handle,
|
2012-05-08 17:23:58 -04:00
|
|
|
alpm_list_t *upgrade, alpm_list_t *rem)
|
2005-03-22 15:21:12 -05:00
|
|
|
{
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_list_t *i, *conflicts = NULL;
|
2010-12-08 00:13:36 -05:00
|
|
|
size_t numtargs = alpm_list_count(upgrade);
|
|
|
|
size_t current;
|
2011-12-12 14:05:10 -05:00
|
|
|
size_t rootlen;
|
2005-03-22 15:21:12 -05:00
|
|
|
|
2011-06-03 14:18:36 -04:00
|
|
|
if(!upgrade) {
|
2011-03-20 20:45:57 -04:00
|
|
|
return NULL;
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2007-02-13 23:52:17 -05:00
|
|
|
|
2011-12-12 14:05:10 -05:00
|
|
|
rootlen = strlen(handle->root);
|
|
|
|
|
2007-11-11 12:30:16 -05:00
|
|
|
/* TODO this whole function needs a huge change, which hopefully will
|
|
|
|
* be possible with real transactions. Right now we only do half as much
|
|
|
|
* here as we do when we actually extract files in add.c with our 12
|
|
|
|
* different cases. */
|
2011-02-08 22:16:04 -05:00
|
|
|
for(current = 0, i = upgrade; i; i = i->next, current++) {
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_pkg_t *p1 = i->data;
|
Convert package filelists to an array instead of linked list
This accomplishes quite a few things with one rather invasive change.
1. Iteration is much more performant, due to a reduction in pointer
chasing and linear item access.
2. Data structures are smaller- we no longer have the overhead of the
linked list as the file struts are now laid out consecutively in
memory.
3. Memory allocation has been massively reworked. Before, we would
allocate three different pieces of memory per file item- the list
struct, the file struct, and the copied filename. What this resulted
in was massive fragmentation of memory when loading filelists since
the memory allocator had to leave holes all over the place. The new
situation here now removes the need for any list item allocation;
allocates the file structs in contiguous memory (and reallocs as
necessary), leaving only the strings as individually allocated. Tests
using valgrind (massif) show some pretty significant memory
reductions on the worst case `pacman -Ql > /dev/null` (366387 files
on my machine):
Before:
Peak heap: 54,416,024 B
Useful heap: 36,840,692 B
Extra heap: 17,575,332 B
After:
Peak heap: 38,004,352 B
Useful heap: 28,101,347 B
Extra heap: 9,903,005 B
Several small helper methods have been introduced, including a list to
array conversion helper as well as a filelist merge sort that works
directly on arrays.
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-19 05:47:29 -04:00
|
|
|
alpm_list_t *j;
|
2013-02-15 19:22:15 -05:00
|
|
|
alpm_list_t *tmpfiles = NULL;
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_pkg_t *dbpkg;
|
2007-02-21 23:42:59 -05:00
|
|
|
|
2011-01-09 21:36:42 -05:00
|
|
|
int percent = (current * 100) / numtargs;
|
2011-09-01 18:35:50 -04:00
|
|
|
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", percent,
|
2007-08-05 11:50:24 -04:00
|
|
|
numtargs, current);
|
2012-07-20 08:25:18 -04:00
|
|
|
|
2007-02-13 23:52:17 -05:00
|
|
|
/* CHECK 1: check every target against every target */
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "searching for file conflicts: %s\n",
|
2011-08-18 00:25:19 -04:00
|
|
|
p1->name);
|
2007-02-13 03:15:38 -05:00
|
|
|
for(j = i->next; j; j = j->next) {
|
2011-06-14 10:30:46 -04:00
|
|
|
alpm_list_t *common_files;
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_pkg_t *p2 = j->data;
|
2012-07-20 08:25:18 -04:00
|
|
|
|
2013-02-12 07:00:53 -05:00
|
|
|
alpm_filelist_t *p1_files = alpm_pkg_get_files(p1);
|
|
|
|
alpm_filelist_t *p2_files = alpm_pkg_get_files(p2);
|
|
|
|
|
|
|
|
common_files = _alpm_filelist_intersection(p1_files, p2_files);
|
2007-02-13 03:15:38 -05:00
|
|
|
|
2011-06-14 10:30:46 -04:00
|
|
|
if(common_files) {
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_list_t *k;
|
|
|
|
char path[PATH_MAX];
|
2011-06-14 10:30:46 -04:00
|
|
|
for(k = common_files; k; k = k->next) {
|
2013-02-15 19:21:35 -05:00
|
|
|
char *filename = k->data;
|
|
|
|
snprintf(path, PATH_MAX, "%s%s", handle->root, filename);
|
2013-02-12 07:00:53 -05:00
|
|
|
|
|
|
|
/* can skip file-file conflicts when forced *
|
|
|
|
* checking presence in p2_files detects dir-file or file-dir
|
|
|
|
* conflicts as the path from p1 is returned */
|
|
|
|
if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
|
|
|
|
alpm_filelist_contains(p2_files, filename)) {
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"%s exists in both '%s' and '%s'\n", filename,
|
|
|
|
p1->name, p2->name);
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"file-file conflict being forced\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-09-26 18:31:34 -04:00
|
|
|
conflicts = add_fileconflict(handle, conflicts, path, p1, p2);
|
2011-07-01 12:01:39 -04:00
|
|
|
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
2014-08-20 17:09:52 -04:00
|
|
|
alpm_list_free_inner(conflicts,
|
|
|
|
(alpm_list_fn_free) alpm_conflict_free);
|
|
|
|
alpm_list_free(conflicts);
|
2013-02-15 13:08:32 -05:00
|
|
|
alpm_list_free(common_files);
|
2011-06-14 10:30:46 -04:00
|
|
|
return NULL;
|
2011-06-07 17:06:16 -04:00
|
|
|
}
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2011-06-16 14:16:49 -04:00
|
|
|
alpm_list_free(common_files);
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-15 19:31:21 -04:00
|
|
|
/* CHECK 2: check every target against the filesystem */
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "searching for filesystem conflicts: %s\n",
|
2011-06-14 10:30:46 -04:00
|
|
|
p1->name);
|
2011-06-03 14:18:36 -04:00
|
|
|
dbpkg = _alpm_db_get_pkgfromcache(handle->db_local, p1->name);
|
2007-02-13 23:52:17 -05:00
|
|
|
|
2009-01-02 11:43:05 -05:00
|
|
|
/* Do two different checks here. If the package is currently installed,
|
2007-02-13 23:52:17 -05:00
|
|
|
* then only check files that are new in the new package. If the package
|
2011-06-14 10:30:46 -04:00
|
|
|
* is not currently installed, then simply stat the whole filelist. Note
|
|
|
|
* that the former list needs to be freed while the latter list should NOT
|
|
|
|
* be freed. */
|
2007-02-13 23:52:17 -05:00
|
|
|
if(dbpkg) {
|
|
|
|
/* older ver of package currently installed */
|
2013-02-15 19:22:15 -05:00
|
|
|
tmpfiles = _alpm_filelist_difference(alpm_pkg_get_files(p1),
|
2012-07-17 22:09:24 -04:00
|
|
|
alpm_pkg_get_files(dbpkg));
|
2007-02-13 23:52:17 -05:00
|
|
|
} else {
|
|
|
|
/* no version of package currently installed */
|
2013-02-15 19:22:15 -05:00
|
|
|
alpm_filelist_t *fl = alpm_pkg_get_files(p1);
|
|
|
|
size_t filenum;
|
|
|
|
for(filenum = 0; filenum < fl->count; filenum++) {
|
2013-04-12 20:37:56 -04:00
|
|
|
tmpfiles = alpm_list_add(tmpfiles, fl->files[filenum].name);
|
2013-02-15 19:22:15 -05:00
|
|
|
}
|
2007-02-19 21:14:27 -05:00
|
|
|
}
|
2007-02-13 23:52:17 -05:00
|
|
|
|
2013-02-15 19:22:15 -05:00
|
|
|
for(j = tmpfiles; j; j = j->next) {
|
|
|
|
const char *filestr = j->data;
|
2011-06-16 14:16:49 -04:00
|
|
|
const char *relative_path;
|
2011-06-16 16:40:02 -04:00
|
|
|
alpm_list_t *k;
|
2011-06-27 10:07:06 -04:00
|
|
|
/* have we acted on this conflict? */
|
|
|
|
int resolved_conflict = 0;
|
2011-06-16 16:40:02 -04:00
|
|
|
struct stat lsbuf;
|
|
|
|
char path[PATH_MAX];
|
2011-11-13 18:19:28 -05:00
|
|
|
size_t pathlen;
|
2007-02-19 21:14:27 -05:00
|
|
|
|
2011-11-13 18:19:28 -05:00
|
|
|
pathlen = snprintf(path, PATH_MAX, "%s%s", handle->root, filestr);
|
2013-05-10 16:26:19 -04:00
|
|
|
relative_path = path + rootlen;
|
2007-02-19 21:14:27 -05:00
|
|
|
|
2007-07-13 04:41:40 -04:00
|
|
|
/* stat the file - if it exists, do some checks */
|
2014-06-26 11:50:34 -04:00
|
|
|
if(llstat(path, &lsbuf) != 0) {
|
2007-07-13 04:41:40 -04:00
|
|
|
continue;
|
|
|
|
}
|
2007-11-11 12:30:16 -05:00
|
|
|
|
2011-10-26 18:32:46 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "checking possible conflict: %s\n", path);
|
|
|
|
|
2013-05-10 16:26:19 -04:00
|
|
|
if(path[pathlen - 1] == '/') {
|
2008-01-06 04:59:41 -05:00
|
|
|
if(S_ISDIR(lsbuf.st_mode)) {
|
2011-10-26 18:32:46 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG, "file is a directory, not a conflict\n");
|
2009-01-02 11:43:05 -05:00
|
|
|
continue;
|
2011-06-14 10:30:46 -04:00
|
|
|
}
|
2011-06-27 10:07:06 -04:00
|
|
|
/* if we made it to here, we want all subsequent path comparisons to
|
|
|
|
* not include the trailing slash. This allows things like file ->
|
|
|
|
* directory replacements. */
|
2011-11-13 18:19:28 -05:00
|
|
|
path[pathlen - 1] = '\0';
|
2007-02-21 23:42:59 -05:00
|
|
|
|
2013-05-10 16:26:19 -04:00
|
|
|
/* Check if the directory was a file in dbpkg */
|
|
|
|
if(alpm_filelist_contains(alpm_pkg_get_files(dbpkg), relative_path)) {
|
|
|
|
size_t fslen = strlen(filestr);
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"replacing package file with a directory, not a conflict\n");
|
|
|
|
resolved_conflict = 1;
|
|
|
|
|
|
|
|
/* go ahead and skip any files inside filestr as they will
|
|
|
|
* necessarily be resolved by replacing the file with a dir
|
|
|
|
* NOTE: afterward, j will point to the last file inside filestr */
|
|
|
|
for( ; j->next; j = j->next) {
|
|
|
|
const char *filestr2 = j->next->data;
|
|
|
|
if(strncmp(filestr, filestr2, fslen) != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-01-02 11:43:05 -05:00
|
|
|
|
|
|
|
/* Check remove list (will we remove the conflicting local file?) */
|
2012-05-08 17:23:58 -04:00
|
|
|
for(k = rem; k && !resolved_conflict; k = k->next) {
|
2011-06-28 09:26:39 -04:00
|
|
|
alpm_pkg_t *rempkg = k->data;
|
2012-07-12 16:29:59 -04:00
|
|
|
if(rempkg && alpm_filelist_contains(alpm_pkg_get_files(rempkg),
|
2011-06-16 14:16:49 -04:00
|
|
|
relative_path)) {
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
2011-10-26 18:32:46 -04:00
|
|
|
"local file will be removed, not a conflict\n");
|
2009-01-02 11:43:05 -05:00
|
|
|
resolved_conflict = 1;
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2009-01-02 11:43:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Look at all the targets to see if file has changed hands */
|
|
|
|
for(k = upgrade; k && !resolved_conflict; k = k->next) {
|
2013-05-04 09:37:38 -04:00
|
|
|
alpm_pkg_t *localp2, *p2 = k->data;
|
|
|
|
if(!p2 || p1 == p2) {
|
|
|
|
/* skip p1; both p1 and p2 come directly from the upgrade list
|
|
|
|
* so they can be compared directly */
|
2009-01-02 11:43:05 -05:00
|
|
|
continue;
|
|
|
|
}
|
2013-05-04 09:37:38 -04:00
|
|
|
localp2 = _alpm_db_get_pkgfromcache(handle->db_local, p2->name);
|
2009-01-02 11:43:05 -05:00
|
|
|
|
|
|
|
/* localp2->files will be removed (target conflicts are handled by CHECK 1) */
|
2013-05-10 16:44:33 -04:00
|
|
|
if(localp2 && alpm_filelist_contains(alpm_pkg_get_files(localp2), relative_path)) {
|
2015-12-04 14:14:32 -05:00
|
|
|
size_t fslen = strlen(filestr);
|
|
|
|
|
2009-01-02 11:43:05 -05:00
|
|
|
/* skip removal of file, but not add. this will prevent a second
|
|
|
|
* package from removing the file when it was already installed
|
|
|
|
* by its new owner (whether the file is in backup array or not */
|
2011-06-07 17:06:16 -04:00
|
|
|
handle->trans->skip_remove =
|
2013-05-10 16:44:33 -04:00
|
|
|
alpm_list_add(handle->trans->skip_remove, strdup(relative_path));
|
2011-07-01 12:01:38 -04:00
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
2011-10-26 18:32:46 -04:00
|
|
|
"file changed packages, adding to remove skiplist\n");
|
2009-01-02 11:43:05 -05:00
|
|
|
resolved_conflict = 1;
|
2015-12-04 14:14:32 -05:00
|
|
|
|
|
|
|
if(filestr[fslen - 1] == '/') {
|
|
|
|
/* replacing a file with a directory:
|
|
|
|
* go ahead and skip any files inside filestr as they will
|
|
|
|
* necessarily be resolved by replacing the file with a dir
|
|
|
|
* NOTE: afterward, j will point to the last file inside filestr */
|
|
|
|
for( ; j->next; j = j->next) {
|
|
|
|
const char *filestr2 = j->next->data;
|
|
|
|
if(strncmp(filestr, filestr2, fslen) != 0) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-02-22 01:36:05 -05:00
|
|
|
}
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2009-01-02 11:43:05 -05:00
|
|
|
|
2009-07-17 09:48:57 -04:00
|
|
|
/* check if all files of the dir belong to the installed pkg */
|
2013-04-12 22:26:14 -04:00
|
|
|
if(!resolved_conflict && S_ISDIR(lsbuf.st_mode)) {
|
|
|
|
alpm_list_t *owners;
|
2013-05-10 16:44:33 -04:00
|
|
|
char *dir = malloc(strlen(relative_path) + 2);
|
|
|
|
sprintf(dir, "%s/", relative_path);
|
2013-04-12 22:26:14 -04:00
|
|
|
|
|
|
|
owners = alpm_db_find_file_owners(handle->db_local, dir);
|
|
|
|
if(owners) {
|
|
|
|
alpm_list_t *pkgs = NULL, *diff;
|
|
|
|
|
|
|
|
if(dbpkg) {
|
|
|
|
pkgs = alpm_list_add(pkgs, dbpkg);
|
|
|
|
}
|
|
|
|
pkgs = alpm_list_join(pkgs, alpm_list_copy(rem));
|
|
|
|
if((diff = alpm_list_diff(owners, pkgs, _alpm_pkg_cmp))) {
|
|
|
|
/* dir is owned by files we aren't removing */
|
|
|
|
/* TODO: with better commit ordering, we may be able to check
|
|
|
|
* against upgrades as well */
|
|
|
|
alpm_list_free(diff);
|
|
|
|
} else {
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"checking if all files in %s belong to removed packages\n",
|
|
|
|
dir);
|
|
|
|
resolved_conflict = dir_belongsto_pkgs(handle, dir, owners);
|
|
|
|
}
|
|
|
|
alpm_list_free(pkgs);
|
|
|
|
alpm_list_free(owners);
|
2009-07-17 09:48:57 -04:00
|
|
|
}
|
|
|
|
free(dir);
|
|
|
|
}
|
|
|
|
|
2011-07-14 16:32:03 -04:00
|
|
|
/* is the file unowned and in the backup list of the new package? */
|
2013-05-10 16:44:33 -04:00
|
|
|
if(!resolved_conflict && _alpm_needbackup(relative_path, p1)) {
|
2011-07-14 16:32:03 -04:00
|
|
|
alpm_list_t *local_pkgs = _alpm_db_get_pkgcache(handle->db_local);
|
|
|
|
int found = 0;
|
|
|
|
for(k = local_pkgs; k && !found; k = k->next) {
|
2013-05-10 16:44:33 -04:00
|
|
|
if(alpm_filelist_contains(alpm_pkg_get_files(k->data), relative_path)) {
|
2011-07-14 16:32:03 -04:00
|
|
|
found = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!found) {
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
2011-10-26 18:32:46 -04:00
|
|
|
"file was unowned but in new backup list\n");
|
2011-07-14 16:32:03 -04:00
|
|
|
resolved_conflict = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-12 07:00:53 -05:00
|
|
|
/* skip file-file conflicts when being forced */
|
|
|
|
if((handle->trans->flags & ALPM_TRANS_FLAG_FORCE) &&
|
|
|
|
!S_ISDIR(lsbuf.st_mode)) {
|
|
|
|
_alpm_log(handle, ALPM_LOG_DEBUG,
|
|
|
|
"conflict with file on filesystem being forced\n");
|
|
|
|
resolved_conflict = 1;
|
|
|
|
}
|
|
|
|
|
2009-01-02 11:43:05 -05:00
|
|
|
if(!resolved_conflict) {
|
2011-09-26 18:31:34 -04:00
|
|
|
conflicts = add_fileconflict(handle, conflicts, path, p1, NULL);
|
2011-07-01 12:01:39 -04:00
|
|
|
if(handle->pm_errno == ALPM_ERR_MEMORY) {
|
2014-08-20 17:09:52 -04:00
|
|
|
alpm_list_free_inner(conflicts,
|
|
|
|
(alpm_list_fn_free) alpm_conflict_free);
|
|
|
|
alpm_list_free(conflicts);
|
2013-02-15 19:22:15 -05:00
|
|
|
alpm_list_free(tmpfiles);
|
2011-06-14 10:30:46 -04:00
|
|
|
return NULL;
|
2011-06-07 17:06:16 -04:00
|
|
|
}
|
2009-01-02 11:43:05 -05:00
|
|
|
}
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2013-02-15 19:22:15 -05:00
|
|
|
alpm_list_free(tmpfiles);
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
2011-09-01 18:35:50 -04:00
|
|
|
PROGRESS(handle, ALPM_PROGRESS_CONFLICTS_START, "", 100,
|
2011-02-08 22:16:04 -05:00
|
|
|
numtargs, current);
|
2005-03-22 15:21:12 -05:00
|
|
|
|
2011-03-20 20:45:57 -04:00
|
|
|
return conflicts;
|
2005-03-22 15:21:12 -05:00
|
|
|
}
|
|
|
|
|
2014-01-22 18:06:11 -05:00
|
|
|
/* vim: set noet: */
|