summaryrefslogtreecommitdiff
path: root/lib/libalpm/deps.c
Commit message (Collapse)AuthorAge
* Look in target-list first to resolve dependenciesBryan Ischo2009-04-11
| | | | | | | | | | | | | | | This fixes a bug introduced by my previous changes which changes the behavior of IgnorePkg/IgnoreGroup to allow the user to remove unresolvable packages from the transaction. The bug is that the target-list was no longer being consulted first to resolve dependencies, which means that if two packages in the sync database satisfied a dependency, and the user explicitly requested one of those two packages in the sync, the other package was still being pulled in. A new test was added, sync993.py, to verify the desired behavior. Signed-off-by: Bryan Ischo <bji-keyword-pacman.3644cb@www.ischo.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Print warning in _alpm_resolvedep() if a satisfier package is ignored ↵Nagy Gabor2009-04-11
| | | | | | | | | | | | | without QUESTION After commit f57f8d33862050acc8d131710c100ba47877e675 pacman *silently* ignores packages from IgnorePkg/IgnoreGroup during dependency resolving, if prompt == 0. This behavior is changed to "give warning + ignore". (Otherwise the user is not informed about the fact that the package resolving was blocked by ignorepkg.) Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* New error type: PM_ERR_PKG_IGNOREDNagy Gabor2009-04-11
| | | | | | | | | | This patch fixes FS#12059. Now sync_addtarget can return with PM_ERR_PKG_IGNORED, which indicates that although the requested package was found it is in ignorepkg, so alpm could not add it to the transaction. So the front-end can decide what to do. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Don't prompt the user for unignore of IgnorePkg/IgnoreGroup packagesBryan Ischo2009-02-23
| | | | | | | | | | Don't prompt the user for unignore of IgnorePkg/IgnoreGroup packages, except for packages explicitly listed for sync by the user. This eliminates many unnecessary prompts when IgnorePkg/IgnoreGroup is used. Signed-off-by: Bryan Ischo <bryan@ischo.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Enabled new interactive prompt and updated some testsBryan Ischo2009-02-23
| | | | | | | | | | | | | | | Enabled a new prompt to ask the user if they'd like to remove unresolvable packages from the transaction rather than failing it. Many pactest tests that used to fail now return success codes, because pacman now issues a prompt allowing the user to cancel rather than failing many transactions, and the pactest scripts always choose to cancel with no error rather than failing. The only net effect is that the return status of pacman is now 0 in cases where it used to be nonzero. Signed-off-by: Bryan Ischo <bryan@ischo.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Reorganize code for one-at-a-time resolvingBryan Ischo2009-02-18
| | | | | | | | | | | | This change reorganizes the internal code so that packages are resolved one at a time instead of all at once from a list. This will allow a future checkin to prompt the user to see if they'd rather remove unresolvable packages from the transaction and continue, or fail the transaction. This change does not affect the actual behavior of libalpm and all tests pass without changes. Signed-off-by: Bryan Ischo <bryan@ischo.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Rename alpm_get_md5sum to alpm_compute_md5sum and alpm_dep_get_string to ↵Nagy Gabor2009-01-12
| | | | | | | | | | | alpm_dep_compute_string This patch introduces the following function name convention: _compute_ in function name: the return value must be freed. _get_ in function name: the return value must not be freed. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Change checkdeps and checkdbconflicts to be more flexible.Xavier Chantry2008-08-25
| | | | | | | | These two functions now take directly a package list rather than a database. checkdbconflicts was renamed to checkconflicts. Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
* Use NULL instead of "" as no causingpkgNagy Gabor2008-07-19
| | | | | | | Our STRDUP macro (used in _alpm_depmiss_new) is NULL safe. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* sync_addtarget reworkNagy Gabor2008-07-13
| | | | | | | | | | | | | | | | | | | | | | Now '-S provision' handling is done in the back-end. In case of multiple providers, the first one is selected (behavior change: deleted provision002.py). The old processing order was: literal, group, provision; the new one: literal, provision, group. This is more rational, but "pacman -S group" will be slower now. "pacman -S repo/provision" also works. Provision was generalized to dependencies, so you can resolve deps by hand: "pacman -S 'bash>2.0'" or "pacman -S 'core/bash>2.0'" etc. This can be useful in makepkg dependency resolving. The changes were documented in pacman manual. alpm_find_pkg_satisfiers and _alpm_find_dep_satisfiers functions were removed, since they are no longer needed. I added some verbosity to "select provider instead of literal" and "fallback to group". Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Resolvedeps reworkNagy Gabor2008-07-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I divided resolvedeps into 2 functions. The new _alpm_resolvedep function will resolve one dependency, for example the 'foo>=1.0-1' dependency. It can be useful in sync_addtarget refactoring. The resolvedeps parameters were changed, to be coherent with recursedeps: * the target-list is an alpm_list* instead of alpm_list**. This is OK, because alpm_list_add == alpm_list_add_last * syncpkg param was removed. list contains the to-be-installed packages, resolvedeps will add the required dependencies into this list * trans param was removed, it was used in QUESTION() only, which can be used on the main (handle->trans) transaction only (because the front-end cannot access our pseudo-transactions at all!). The patch fixes some wrong dynamic pmdepmissing_t usage. I did a behavior change (and sync1003.py was modified accordingly), which needs some explanation: The old resolvedeps didn't elect packages from 'remove' list. I've dropped this because I don't want that 2nd excluding list param. In fact, in real life, we ~never need this rule. Resolvedeps is called before checkconflicts, so only -Su's %REPLACES% packages are sitting in 'remove' list. This means, that we have the replacement packages in our target list. Usually "foo replaces bar" means, that bar isn't in our repos any more, so resolvedeps *cannot* elect it; but usually it won't try it at all, because foo is in the target list, and it is expected to satisfy 'bar>=1.0-1'-like dependencies too. Since checkdeps and checkconflicts is done after resolvedeps, this cannot cause any harm. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Swap parameters on PM_TRANS_CONV_INSTALL_IGNOREPKG callback functionNagy Gabor2008-07-07
| | | | | | | | | | | | | | | PM_TRANS_CONV_INSTALL_IGNOREPKG callback function can get 2 params: foo, bar in this order (packages), bar can be NULL. Old API: foo, NULL: Do you want to install foo from IgnorePkg? foo, bar: foo requires bar from IgnorePkg. Do you want to install bar? New API: foo, bar: Do you want to install foo from IgnorePkg? (If bar!=NULL:) bar requires it. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* New _alpm_find_dep_satisfier functionNagy Gabor2008-07-07
| | | | | | | | | | This function finds the first satisfier package in a pkglist. Using it instead of _alpm_find_dep_satisfiers eliminates some memleaks and it is faster. (_alpm_find_dep_satisfiers and _alpm_find_pkg_satisfiers will be removed soon.) Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* New _alpm_dep_edge functionNagy Gabor2008-07-07
| | | | | | | | The function is introduced to kill some code duplication. The function name uses the 'dependency graph' terminology. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove wrapper call around versioncmpDan McGee2008-05-14
| | | | | | | Actually, just rename _alpm_versioncmp to alpm_pkg_vercmp and get rid of the need for a wrapper since it did nothing anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* Simplify _alpm_pkg_new()Dan McGee2008-05-13
| | | | | | | | Any real call of this function doesn't specify a name or version ahead of time, so just kill that functionality off. Now to remove those dummy packages... Signed-off-by: Dan McGee <dan@archlinux.org>
* Cleanup usages of alpm_list_find and alpm_list_remove.Chantry Xavier2008-05-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * remove obsolete and unused *_cmp helper functions like deppkg_cmp and _alpm_grp_cmp * new alpm_list_remove_str function, used 6 times in handle.c * remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by a more general alpm_find_pkg_satisfiers with a cleaner implementation. before: alpm_db_whatprovides(db, targ) after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ) * remove satisfycmp and replace alpm_list_find + satisfycmp usage by _alpm_find_dep_satisfiers. before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp) after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep) * remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead. This commit actually get rids of all complicated and asymmetric _cmp functions. I first thought these functions were worth it, be caused it allowed us to reuse list_find and list_remove. But this was at the detriment of the clarity and also the ease of use of these functions, dangerous because of their asymmetricity. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Swap the parameters of alpm_pkg_findNagy Gabor2008-05-13
| | | | | | | Now the syntax is coherent with alpm_list_find and alpm_sync_find. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Kill compute_requiredby usage in can_remove_package()Nagy Gabor2008-04-25
| | | | | | | | | | | | | In the can_remove_package function, we don't need to compute the whole requiredby list, we just need to find one member of it that doesn't belong to the targets list. That way we get a small speedup and remove the only usage of alpm_pkg_compute_requiredby in the backend, so that it can be tweaked for frontend usage. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove unnecessary header file, move one macro to util.cDan McGee2008-04-06
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Avoid duplicated target names.Nagy Gabor2008-03-23
| | | | | | | | | | | | | | | | | | | | | | | | | This patch should avoid duplicated target names in the backend. 1. sync_loadtarget will return with PM_ERR_TRANS_DUP_TARGET when trying to add a duplicated target 2. sysupgrade never pulls duplicated targets 3. resolvedeps won't pull duplicated targets anymore A pulled list was introduced in sync_prepare to improve the pmsyncpkg_t<->pmpkg_t list conversion by making it more direct. Also replace sync1005 and sync1006 by the sync1008 pactest, which is similar but more interesting (the provisions are dependencies instead of explicit targets). sync1005 didn't work as expected anyway. It was expecting that pacman failed, and pacman indeed failed, but not for the good reason. It didn't fail during the preparation step because of conflicting targets, but during the commit step, because of a md5 error... And sync1006 didn't pass and was not really worth fixing. We have already enough failing pactests more important than these two. sync1008 pass with this patch. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Kill PM_TRANS_TYPE_ADD.Chantry Xavier2008-03-17
| | | | | | | This was totally useless. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2008-03-09
|\ | | | | | | | | | | Conflicts: configure.ac
| * Remove a bogus commentNagy Gabor2008-03-04
| | | | | | | | | | | | | | This comment was created for the old provision version format and needless. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Move pmgraph_t struct and functions to their own header fileDan McGee2008-02-16
| | | | | | | | | | | | | | | | This will allow us to utilize this helpful type and functions in places besides dependency calculations. In addition, remove the public declaration of pmgraph_t in alpm.h- there is zero need to expose this internal type. Signed-off-by: Dan McGee <dan@archlinux.org>
* | New remove option : -u / --unneeded (FS#6505).Nagy Gabor2008-02-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With --unneeded option 'pacman -R' doesn't stop in case of dependency error; it removes the needed-dependency targets from the target-list instead. See also: http://archlinux.org/pipermail/pacman-dev/2007-October/009653.html . The patch also adds a new causingpkg field to pmdepmissing_t which indicates the to-be-removed package which would cause a dependency break. This is needed, because miss->depend.name may be a provision. miss->causingpkg will be useful in -R dependency error messages too. [Xavier: renamed inducer to causingpkg, removed the _alpm_pkgname_pkg_cmp helper function as requested by Aaron. This might be added by a further commit. Other small cleanups, updated manpage and bash completion.] Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* | Fix flip-flopped parameters to CALLOC macroDan McGee2008-01-23
| | | | | | | | | | | | | | The mixup causes a fail in the build using --enable-debug on x86_64 but not i686, so none of us caught this right away. Fix it. FS#9297. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Move the deptest code from frontend to backend.Chantry Xavier2008-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The deptest code (pacman -T) used by makepkg was mostly in the frontend. There were 2 drawbacks: 1) the public splitdep function returns a pmdepend_t struct, but the _alpm_dep_free function for freeing it is private. So there was a memleak. 2) there is a helper in the backend (satisfycmp in deps.c) which makes this function much easier. So this adds a new public alpm_deptest in libalpm/deps.c, which cleans pacman_deptest in pacman/deptest.c a lot. Besides, alpm_splitdep was made private, because the frontend no longer requires it, and _alpm_dep_free is also private. Finally the deptest001 pactest was extended. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2008-01-14
|\|
| * Change the versioned provision format.Chantry Xavier2008-01-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the 'provname provver' format to 'provname=provver'. In .PKGINFO, the provisions are copied from the PKGBUILD without quotes. So the provision version was actually handled as a different provision... See FS#9171. Dan: Unfortunately we have to change our original specification for versioned provisions with this patch, but it ends up being the simpler and cleaner solution in the long run, and if there is any time to change it the time is now before many packages have been built. Keeping the ' ' based format would have required us to do special parsing in repo-add, as well as being susceptible to users not using quotes in their provides array. Hopefully this will resolve the issues we had with our initial plan. Sorry for the confusion. Acked-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2008-01-13
|\|
| * small checkdeps speed-upNagy Gabor2008-01-12
| | | | | | | | | | | | | | | | | | | | | | | | | | In the old code 'alpm_list_diff(_alpm_db_get_pkgcache(db), dblist, _alpm_pkg_cmp);' was slow. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xav: In my opinion, computing both dblist and modified in one for loop also makes the code clearer, besides being more efficient. Also renamed joined to targets since I also find that clearer.] Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* | Add functions to manipulate pmdepend_t objectsDan McGee2008-01-11
| | | | | | | | | | | | | | | | | | | | | | We didn't have a free function before, causing some memory leaks. We also need a dup function now that strings are not in the structure but are dynamically allocated. Also adapt pmdepmissing_t to use a pointer to a depend struct instead of an inclusive one so we can use the functions we created here. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use dynamic string allocation in package structuresDan McGee2008-01-11
|/ | | | | | | | | | | | | | This also affects all structures with static strings, such as depmiss, conflict, etc. This should help a lot with memory usage, and hopefully make things a bit more "idiot proof". Currently our pactest pass/fail rate is identical before and after this patch. This is not to say it is a perfect patch- I have yet to pull valgrind out. However, this should be quite safe to use in all situations from here on out, and we can start plugging the memleaks. Original-work-by: Aaron Griffin <aaronmgriffin@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* PM_DEP_MOD_LT and PM_DEP_MOD_GT depmods addedNagy Gabor2007-12-19
| | | | | | | | You can use foo<2.0 and foo>2.0 as depend add046.py and add047.py pactests were added to check this Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Update GNU GPL boilerplate and copyright datesDan McGee2007-12-10
| | | | | | | Update the GPL boilerplate to direct people to the GNU website for a copy of the license, as well as bump all of Judd's copyrights to 2007. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove duplicated PM_TRANS_CONV_INSTALL_IGNOREPKG messageNagy Gabor2007-12-05
| | | | | | | | Now alpm_checkdeps first search for literals, then search for no-literal satisfiers Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Dan: fix spelling of INTALL, fix line wrapping] Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove _alpm_depmiss_isinDan McGee2007-12-02
| | | | | | | This is unneeded now that commit 2ed6b482d2fce916466e44e37930f0b0c0d928bb has eliminated the last user of this function. Signed-off-by: Dan McGee <dan@archlinux.org>
* Add 4 new pactests to get better code coverage by pactestDan McGee2007-12-02
| | | | | | | | I started playing around with gcov today and it showed a few places in the code that we don't test at all. This is the start of ensuring that we execute most of the code in our codebase. Signed-off-by: Dan McGee <dan@archlinux.org>
* Minor fixes in sync.c and deps.c.Chantry Xavier2007-12-01
| | | | | | | | | | * memleak found by Nagy in checkdeps * an useless line found by Nagy in resolvedeps * data wasn't set to the missing dependencies in sync_prepare * use the MALLOC macro in resolvedeps Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove alpm_depcmp DEBUG outputDan McGee2007-11-30
| | | | | | | | | | alpm_depcmp is simple enough that we shouldn't need constant debug logging, and the logging we do have in there negatively impacts our speed regardless of whether we actually are seeing it or not. If it ever needs debugging, it would be trivial to reimplement it by just temporarily reverting this commit. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove some null checks in _alpm_checkdepsDan McGee2007-11-30
| | | | | | | | Hopefully these are unnecessary, as they were probably added originally to cover up a problem instead of finding the root cause. I'd rather fail hard in these cases anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* alpm_checkdeps clean-upNagy Gabor2007-11-30
| | | | | | | No bugfixes, just makes the code human-readable Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix for sync1003 and sync1004 pactestsNagy Gabor2007-11-25
| | | | | | | | | | | | | | | checkdeps and resolvedeps now take both a remove list and an install list as arguments, allowing dependencies to be calculated correctly. This broke the sync990 pactest, but this pactest used dependencies and provides in an unusual way, so it has been changed. Dan: the sync990 pactest was just plain wrong. It didn't satisfy the dependencies correctly, so should never have succeeded. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: some variable renaming, clarification in commit message] Signed-off-by: Dan McGee <dan@archlinux.org>
* Improved 'dependency cycle' warningNagy Gabor2007-11-21
| | | | | | | | From now on libalpm informs user about packages which will be installed/removed in wrong order. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Versioned provisions.Nagy Gabor2007-11-18
| | | | | | | | | | | | | | | | | | | This patch introduces versioned provisions in "provision 1.0-1" format. _alpm_db_whatprovides was modified accordingly (added sync500.py), alpm_depcmp was modified accordingly (add043.py passes now; added add044.py and add045.py). Notes: alpm_db_search now uses the whole versioned %PROVIDES% string in its search. debug logging was simplified in alpm_depcmp. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Xavier: fixed a few typos, duplicate const strings with strdup before modifying them, put some debugging back in alpm_depcmp, minor code cleanups (var/function renaming), added a note in PKGBUILD man page.] Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: made strcmp checks clearer, added a comment] Signed-off-by: Dan McGee <dan@archlinux.org>
* Add the pmconflict_t type.Nagy Gabor2007-11-18
| | | | | | | | | | | | | | | | | | pmdepmissing_t was used for two totally different things : missing dependencies, and dependency conflicts. So this patch simply adds a type for dep conflicts, and convert the code to use it. This fix the TODO in conflict.c : /* TODO WTF is a 'depmissing' doing indicating a conflict? */ Additionally, the code in conflict.c now eliminates the duplicated conflicts. If pkg1 conflicts with pkg2, and pkg2 conflicts with pkg1, only one of them will be stored. However the conflict handling in sync_prepare (sync.c) is still very asymetrical, and very ugly too. This should be improved in the future (there is already a pending patch from Nagy that cleans it a lot). Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* libalpm/deps.c : improves IgnorePkg handling in resolvedeps.Nagy Gabor2007-11-18
| | | | | | | resolvedeps will now search for other satisfiers when we don't let it add a package from IgnorePkg. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Remove provide.c and provide.h .Chantry Xavier2007-11-17
| | | | | | | | | This file only contained one private function : _alpm_db_whatprovides . And the public alpm_db_whatprovides was in db.c , so I moved everything there. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: updated POTFILES.in as well] Signed-off-by: Dan McGee <dan@archlinux.org>
* War on whitespaceDan McGee2007-11-16
| | | | | | Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>