summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/conflict.c
AgeCommit message (Collapse)AuthorFilesLines
2014-01-06Update copyright years for 2014Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2013-08-21conflict.c: fix directory ownership checkAndrew Gregory1-4/+12
* append "/" to directories before searching package file lists * use lstat over stat so symlinks aren't resolved * fix the inverted check for stat's return value Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03improve dir->file transition conflict resolutionAndrew Gregory1-68/+65
Packages removed due to conflicts are always removed at the beginning of the transaction and as such can be included in the check for whether all owners of a directory will be removed in a transaction. Installed versions of packages being upgraded, other than the one with the conflict, cannot be used because our transaction ordering is not intelligent enough to ensure that they are removed prior to the installation of the conflicted package. Also, return false from dir_belongsto_pkgs on errors. Previously, we simply continued which could return true even if we were unable to actually establish that the package owned the entire tree. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03conflict.c: check for file -> dir replacementsAndrew Gregory1-19/+20
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03conflict.c: exclude trailing slash from file pathAndrew Gregory1-6/+6
After the initial checks, we either use the path as a directory and have to append the trailing slash anyway or use it as a file in which case the trailing slash should be excluded. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03conflict.c: do not ignore symlink<->dir conflictsAndrew Gregory1-7/+0
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-06-03alpm_filelist: remove resolved_pathAndrew Gregory1-13/+1
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-05-05conflict.c: compare package pointers directlyAndrew Gregory1-3/+5
p1 and p2 both come directly from the upgrade list without being copied so they can be compared directly instead of comparing their names. Also fix minor style violation. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24Perform limited conflict checking with --forceAllan McRae1-2/+26
Pacman currently bails when trying to extract a file over a directory when using --force. Instead of ignoring all conflict, perform the check and skip any file-file conflicts. Conflicts between directories and files are still flagged and cause the transation to abort. As a bonus, we now know about files changing packages when using --force, so we can skip removing them fixing upgrade046. Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24use resolved_path for filelist_containsAndrew Gregory1-0/+5
alpm_filelist_contains was being used to search for resolved paths, but searching in the unresolved paths, causing it to miss matches. We always search unresolved paths and search the resolved paths if available because _alpm_filelist_resolve is not public and requires a context handle, so it can't be called from alpm_filelist_contains. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24return resolved paths from filelist_differenceAndrew Gregory1-22/+14
We were comparing files based on resolved paths but returning the original file_t structures, which were not necessarily in the same order. The extra file_t information was only being used to determine if the file was a directory which can be accomplished by testing for a trailing slash, so just return the resolved path. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24return resolved paths from filelist_intersectionAndrew Gregory1-2/+2
We were comparing files based on resolved paths but returning the original file_t structures, which were not necessarily in the same order. The additional file_t information was never used, so just return the resolved path. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-24use alpm_list_free on filelist intersectionAndrew Gregory1-1/+1
alpm_filelist_intersection returns a list of pointers to internal file_t struct's, so only the list itself should be freed. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-02-16find_fileconflicts: reduce path resolution callsAndrew Gregory1-4/+6
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-28add doxygen comments to conflict.cAndrew Gregory1-14/+80
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-04Fix open braces styleGerardo Exequiel Pozzi1-1/+2
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> Signed-off-by: Allan McRae <allan@archlinux.org>
2013-01-03Update copyright year for 2013Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Avoid upgrade conflict with unchanged effective pathAllan McRae1-0/+1
This applies to a case such as when /lib is a symlink to /usr/lib. If a package is installed which contains /lib/libfoo.so, pacman will complain if this package is then "fixed" to contain /usr/lib/libfoo.so. Since these have the same effective path and it exists within the same package, ignore the conflict. Fixes FS#30681. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-12-14Resolve file paths during inter-package conflict checkAllan McRae1-0/+5
File paths are resolved if necessary during inter-package conflict checks so that packages carrying the same effective file due to directory symlinks on the filesystem are flagged as conflicting. Signed-off-by: Allan McRae <allan@archlinux.org>
2012-08-02Split _alpm_filelist_operation functionAllan McRae1-6/+6
To improve conflict checking, we will need to make these functions diverge to an extent where having two separate functions will be preferable. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-02Move filelist functions into separate source fileDan McGee1-86/+11
We have a few of these and might as well gather them together. This also cleans up the code a bit by using an enum instead of integer values, as well as makes a "search for file in filelist" function public so frontends can do better than straight linear search of the filelists. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01Merge branch 'maint'Dan McGee1-1/+8
2012-08-01lib/conflict: use a binary search within filelistsDave Reisner1-8/+5
Take advantage of the fact that our filelists are arrays sorted by filename with a known length and use a binary search. This should speed up file conflict checking, particularly when larger packages are involved. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-08-01Add more debug logging to dir_belongsto_pkg() functionDan McGee1-1/+8
Now that we pass in the handle, we might as well add logging. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-10Merge branch 'maint'Dan McGee1-6/+31
Conflicts: etc/makepkg.conf.in
2012-07-10Check empty subdirectory ownershipAllan McRae1-0/+5
When checking if a package owns a directory, it is important to check not only that all the files in the directory are part of the package, but also if the directory is part of a package. This catches empty subdirectories during conflict checking for directory to file/symlink replacements. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-07-10Add conflict for replacing owned empty directoryAllan McRae1-6/+26
When two packages own an empty directory, pacman finds no conflict when one of those packages wants to replace the directory with a file or a symlink. When it comes to actually extracting the new file/symlink, pacman sees the directory is still there (we do not remove empty directories if they are owned by a package) and refuses to extract. Detect this potential conflict early and bail. Note that it is a _potential_ conflict and not a guaranteed one as the other package owning the directory could be updated or removed first which would remove the conflict. However, pacman currently can not sort package installation order to ensure this, so this conflict requires manual upgrade ordering. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-05-20fix -Wshadow warnings as reported by gcc 4.4.3Dave Reisner1-2/+2
Apparently gcc 4.7 has decided that -Wshadow warnings aren't worth reporting anymore even with the flag enabled. These were found on an Ubuntu 10.04 install. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2012-04-29Move short-lived realpath buffers to the stackDan McGee1-2/+1
There is little reason here to grab 4K from the heap only to return it a few lines later. Instead, just use the stack to hold the returned value saving ourselves the malloc/free cycle. Signed-off-by: Dan McGee <dan@archlinux.org>
2012-02-20Update copyright yearsAllan McRae1-1/+1
Add 2012 to the copyright range for all libalpm and pacman source files. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-21include config.h via MakefilesDave Reisner1-2/+0
Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12Calculate root length only once when checking for file conflictsDan McGee1-3/+5
It is quite easy to hoist this potentially repeated computation out of the loop; even if we don't end up using it, it is super cheap to do it only once. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-12-12lib/conflict: save strlen call by reusing snprintf returnDave Reisner1-2/+3
The return should probably be checked to ensure its not longer than PATH_MAX, but I have no idea what the correct behavior is when that happens. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Merge branch 'maint'Dan McGee1-14/+19
2011-10-26Fix issues with replacing unowned symlinksDan McGee1-14/+19
There aretwo seperate issues in the same block of file conflict checking code here: 1) If realpath errored, such as when a symlink was broken, we would call 'continue' rather than simply exit this particular method of resolution. This was likely just a copy-paste mistake as the previous resolving steps all use loops where continue makes sense. Refactor the check so we only proceed if realpath is successful, and continue with the rest of the checks either way. 2) The real problem this code was trying to solve was canonicalizing path component (e.g., directory) symlinks. The final component, if not a directory, should not be handled at all in this loop. Add a !S_ISLNK() condition to the loop so we only call this for real files. There are few other small cleanups to the debug messages that I made while debugging this problem- we don't need to keep printing the file name, and ensure every block that sets resolved_conflict to true prints a debug message so we know how it was resolved. This fixes the expected failures from symlink010.py and symlink011.py, while still ensuring the fix for fileconflict007.py works. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Make _alpm_filelist_contains() NULL-safeDan McGee1-3/+7
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-26Ensure fileconflict value is actually a stringDan McGee1-16/+14
When we switched to a file object and not just a simple string, we missed an update along the way here in target-target conflicts. This patch looks large, but it really comes down to one errant (char *) cast before that has been reworked to explicitly point to the alpm_file_t object. The rest is simply code cleanup. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02Former transaction callback rename refactorDan McGee1-2/+2
Put all the callback stuff in alpm.h in one spot, and make the following renames for clarity with the new structure: ALPM_TRANS_EVT_* --> ALPM_EVENT_* ALPM_TRANS_CONV_* --> ALPM_QUESTION_* ALPM_TRANS_PROGRESS_* --> ALPM_PROGRESS_* alpm_option_get_convcb() --> alpm_option_get_questioncb() alpm_option_set_convcb() --> alpm_option_set_questioncb() Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-02Move all callbacks up to the handle levelDan McGee1-3/+2
This was just disgusting before, unnecessary to limit these to only usage in a transaction. Still a lot of more room for cleanup but we'll start by attaching them to the handle rather than the transaction we may or may not even want to use these callbacks. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-30Remove outdated comment for _alpm_outerconflictsAllan McRae1-4/+1
Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Remove use of no-op accessor functions in libraryDan McGee1-3/+2
The functions alpm_db_get_name(), alpm_pkg_get_name(), and alpm_pkg_get_version() are not necessary at all, so remove the calling and indirection when used in the backend, which makes things slightly more efficient and reduces code size. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Parse conflicts/provides/replaces at database load timeDan McGee1-11/+10
We did this with depends way back in commit c244cfecf654d3 in 2007. We can do it with these fields as well. Of note is the inclusion of provides even though only '=' is supported- we'll parse other things, but no guarantees are given as to behavior, which is more or less similar to before since we only looked for the equals sign. Also of note is the non-inclusion of optdepends; this will likely be resolved down the road. The biggest benefactors of this change will be the resolving code that formerly had to parse and reparse several of these fields; it only happens once now at load time. This does lead to the disadvantage that we will now always be parsing this information up front even if we never need it in the split form, but as these are uncommon fields and our parser is quite efficient it shouldn't be a big concern. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09Conflict comparison performance enhancementsDan McGee1-17/+17
* Add *_hash fields to conflict struct and populate them * Remove unnecessary backwards string comparisons Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-21Convert package filelists to an array instead of linked listDan McGee1-29/+36
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-14Allow fileconflict if unowned file moving into backup arrayDan McGee1-0/+16
The bulk of this commit is adding new tests to ensure the new behavior works without disrupting old behavior. This is a relatively sane maneuver when a package adds a conf file (e.g. '/etc/mercurial/hgrc') that was not previously in the package, but it is placed in the backup array. In essence, we can treat the existing file as having always been a part of the package and do our normal compare/install as pacnew logic checks. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Merge remote-tracking branch 'allan/ALPM'Dan McGee1-21/+21
Conflicts: lib/libalpm/be_local.c lib/libalpm/be_package.c lib/libalpm/conflict.c lib/libalpm/diskspace.c lib/libalpm/dload.c lib/libalpm/remove.c
2011-07-03conflict code tweaks and cleanupsDan McGee1-20/+14
We can take advantage of a few things on our new and improved filelist in this code. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Move alpm filelists to a struct objectDan McGee1-16/+39
This allows us to capture size and mode data when building filelists from package files. Future patches will take advantage of this newly available information, and frontends can use it as well. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-02Prefix _alpm_errno_t members with ALPMAllan McRae1-3/+3
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_transprog_t members with ALPMAllan McRae1-2/+2
Signed-off-by: Allan McRae <allan@archlinux.org>