libalpm
Arch Linux Package Manager Library
conflict.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <sys/stat.h>
#include <dirent.h>
#include "conflict.h"
#include "alpm_list.h"
#include "alpm.h"
#include "handle.h"
#include "trans.h"
#include "util.h"
#include "log.h"
#include "deps.h"
#include "filelist.h"
Include dependency graph for conflict.c:

Functions

static alpm_conflict_tconflict_new (alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, alpm_depend_t *reason)
 Creates a new conflict.
 
void alpm_conflict_free (alpm_conflict_t *conflict)
 Free a conflict and its members.
 
static int conflict_isin (alpm_conflict_t *needle, alpm_list_t *haystack)
 Searches for a conflict in a list.
 
static int add_conflict (alpm_handle_t *handle, alpm_list_t **baddeps, alpm_pkg_t *pkg1, alpm_pkg_t *pkg2, alpm_depend_t *reason)
 Adds the pkg1/pkg2 conflict to the baddeps list.
 
static void check_conflict (alpm_handle_t *handle, alpm_list_t *list1, alpm_list_t *list2, alpm_list_t **baddeps, int order)
 Check if packages from list1 conflict with packages from list2.
 
alpm_list_talpm_checkconflicts (alpm_handle_t *handle, alpm_list_t *pkglist)
 Check the package conflicts in a database.
 
static alpm_list_tadd_fileconflict (alpm_handle_t *handle, alpm_list_t *conflicts, const char *filestr, alpm_pkg_t *pkg1, alpm_pkg_t *pkg2)
 Creates and adds a file conflict to a conflict list.
 
void alpm_fileconflict_free (alpm_fileconflict_t *conflict)
 Free a fileconflict and its members.
 
static int dir_belongsto_pkgs (alpm_handle_t *handle, const char *dirpath, alpm_list_t *pkgs)
 Recursively checks if a set of packages own all subdirectories and files in a directory.
 
static alpm_list_talpm_db_find_file_owners (alpm_db_t *db, const char *path)
 

Function Documentation

◆ add_conflict()

static int add_conflict ( alpm_handle_t * handle,
alpm_list_t ** baddeps,
alpm_pkg_t * pkg1,
alpm_pkg_t * pkg2,
alpm_depend_t * reason )
static

Adds the pkg1/pkg2 conflict to the baddeps list.

Parameters
handlethe context handle
baddepslist to add conflict to
pkg1first package
pkg2package causing conflict
reasonreason for this conflict
Returns
0 on success, -1 on error

References alpm_conflict_free(), alpm_dep_compute_string(), alpm_list_add(), ALPM_LOG_DEBUG, conflict_isin(), and conflict_new().

Referenced by check_conflict().

◆ add_fileconflict()

static alpm_list_t * add_fileconflict ( alpm_handle_t * handle,
alpm_list_t * conflicts,
const char * filestr,
alpm_pkg_t * pkg1,
alpm_pkg_t * pkg2 )
static

Creates and adds a file conflict to a conflict list.

Parameters
handlethe context handle
conflictsthe list of conflicts to append to
filestrthe conflicting file path
pkg1package that wishes to install the file
pkg2package that currently owns the file, or NULL if unowned
Returns
the updated conflict list

References ALPM_ERR_MEMORY, ALPM_FILECONFLICT_FILESYSTEM, alpm_fileconflict_free(), ALPM_FILECONFLICT_TARGET, alpm_list_add(), ALPM_LOG_DEBUG, ALPM_PKG_FROM_LOCALDB, CALLOC, alpm_fileconflict_t::ctarget, error, alpm_fileconflict_t::file, RET_ERR, STRDUP, alpm_fileconflict_t::target, and alpm_fileconflict_t::type.

◆ alpm_db_find_file_owners()

static alpm_list_t * alpm_db_find_file_owners ( alpm_db_t * db,
const char * path )
static

◆ check_conflict()

static void check_conflict ( alpm_handle_t * handle,
alpm_list_t * list1,
alpm_list_t * list2,
alpm_list_t ** baddeps,
int order )
static

Check if packages from list1 conflict with packages from list2.

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.

Parameters
handlethe context handle
list1first list of packages
list2second list of packages
baddepslist to store conflicts
orderif >= 0 the conflict order is preserved, if < 0 it's reversed

References add_conflict(), alpm_pkg_get_conflicts(), alpm_list_t::data, and alpm_list_t::next.

◆ conflict_isin()

static int conflict_isin ( alpm_conflict_t * needle,
alpm_list_t * haystack )
static

Searches for a conflict in a list.

Parameters
needleconflict to search for
haystacklist of conflicts to search
Returns
1 if needle is in haystack, 0 otherwise

References alpm_list_t::data, alpm_list_t::next, alpm_conflict_t::package1, and alpm_conflict_t::package2.

Referenced by add_conflict().

◆ conflict_new()

static alpm_conflict_t * conflict_new ( alpm_pkg_t * pkg1,
alpm_pkg_t * pkg2,
alpm_depend_t * reason )
static

◆ dir_belongsto_pkgs()

static int dir_belongsto_pkgs ( alpm_handle_t * handle,
const char * dirpath,
alpm_list_t * pkgs )
static

Recursively checks if a set of packages own all subdirectories and files in a directory.

Parameters
handlethe context handle
dirpathpath of the directory to check
pkgspackages being checked against
Returns
1 if a package owns all subdirectories and files, 0 otherwise

References alpm_filelist_contains(), ALPM_LOG_DEBUG, alpm_pkg_get_files(), alpm_list_t::data, dir_belongsto_pkgs(), is_dir(), and alpm_list_t::next.

Referenced by dir_belongsto_pkgs().