summaryrefslogtreecommitdiff
path: root/lib/libalpm/deps.c
AgeCommit message (Collapse)Author
2011-09-02Former transaction callback rename refactorDan McGee
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 McGee
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-29Streamline alpm_splitdep() comparisonsDan McGee
This reduces from 5 to 3 the number of searches needed on the string looking for a comparison operator, since we can so a second quick comparison looking for '=' if we find '<' or '>'. It also makes every search doable with strchr() or memchr() rather than the slower strstr() method. In testing, only 10% of splitdep calls (~1600 / 16000) during an -Ss database load found a version comparison operator, so optimizing the not found path to be require less work makes sense. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-28_alpm_splitdep(): don't pass bogus length value to strndupDan McGee
If we fell through to the ALPM_DEP_MOD_ANY case, ptr would be NULL, and we would pass (0 - <str>), which is a rather large negative number or bogus positive number, depending on signed/unsigned. Just use strdup in the case where we don't have a ptr available. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-19Be more robust when copying package dataDan McGee
This changes the signature of _alpm_pkg_dup() to return an integer error code and provide the new package in a passed pointer argument. All callers are now more robust with checking the return value of this function to ensure a fatal error did not occur. We allow load failures to proceed as otherwise we have a chicken and egg problem- if a 'desc' local database entry is missing, the best way of restoring said file is `pacman -Sf --dbonly packagename`. This patch fixes a segfault that was occurring in this case. Fixes the segfault reported in FS#25667. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Convert resolvedep() to use _alpm_depcmp_literal()Dan McGee
The whole first loop is trying to check literals only, so teach it to do so. Also, reorder operations to make more sense by putting the strcmp() first in the literal loop, and using a very cheap name_hash check first in the second loop. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Add an _alpm_depcmp_literal() functionDan McGee
This omits the finding of matching provisions and only checks the package itself against the provided dep. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Remove usages of alpm_list_next() in backendDan McGee
Another function call that can be replaced by a single pointer dereference. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Parse conflicts/provides/replaces at database load timeDan McGee
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-11Add -S --recursive operationDan McGee
This closely matches what we had before for -R --recursive. Basically, when specifying a target (e.g., pacman), we can now recursively pull all dependencies, regardless of version specifiers and whether they are already satisfied in the local database. This could be used to update pacman on a system with an old glibc, for example, as both pacman and glibc would get pulled into the transaction. This is most useful with --needed to prevent needless reinstalls as described in the man page changes. The end goal of this change is to wire it into SyncFirst and have it be the default mode of operation there, but that belongs in a separate changeset. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-11Dependency code style cleanupsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09Depend on name_hash being setDan McGee
This is a fairly valid assumption at this point, or at least as good of one as assuming packages all have names. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Merge remote-tracking branch 'allan/ALPM'Dan McGee
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-03checkdeps: remove unnecessary list join and copyDan McGee
We can just perform the same search operation on both lists. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-02Prefix _alpm_errno_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_transconv_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_transflag_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_loglevel_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_depmod_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-07-02Prefix alpm_pkgreason_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmgraph_t to alpm_graph_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdepmissing_t to alpm_depmissing_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdepend_t to alpm_depend_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmpkg_t to alpm_pkg_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdb_t to alpm_db_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmhandle_t to alpm_handle_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdepmod_t to alpm_depmod_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-16Make pmdepend_t and pmdepmissing_t publicDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Ensure handle is valid and pm_errno is reset when calling into APIDan McGee
We didn't do due diligence before and ensure prior pm_errno values weren't influencing what happened in further ALPM calls. I observed one case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that flag persisting the entire time we were calling library code. Add a new CHECK_HANDLE() macro that does two things: 1) ensures the handle variable passed to it is non-NULL and 2) clears any existing pm_errno flag set on the handle. This macro can replace many places we used the ASSERT(handle != NULL, ...) pattern before. Several other other places only need a simple 'set to zero' of the pm_errno field. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Add handle argument to _alpm_pkg_should_ignore()Dan McGee
This allows callers to retrieve it from wherever is convenient, which may or may not be on the package object itself. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Switch all logging to use handle directlyDan McGee
This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Move pm_errno onto the handleDan McGee
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Add handle argument to two more alpm methodsDan McGee
This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier(). Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_trans_*() methodsDan McGee
Begin enforcing the need to pass a handle. This allows us to remove one more extern handle declaration from the backend. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-07Add helper methods for setting directory optionsDan McGee
This keeps duplicate code to a minimum. This will come in more handy as we refactor some of these option setters away. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Push down extern handle variable to files that need itDan McGee
This will make the patching process less invasive as we start to remove this variable from all source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove ALPM_LOG_FUNC macroDan McGee
The usefulness of this is rather limited due to it not being compiled into production builds. When you do choose to see the output, it is often overwhelming and not helpful. The best bet is to use a debugger and/or well-placed fprintf() statements. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20syntax: if/while statements should have no trailing spaceDan McGee
This is the standard, and we have had a few of these introduced lately that should not be here. Done with: find -name '*.c' | xargs sed -i -e 's#if (#if(#g' find -name '*.c' | xargs sed -i -e 's#while (#while(#g' Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/alpm.h lib/libalpm/trans.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-09Fix broken documentation for alpm_trans_prepare()Rémy Oudompheng
The current state of the code does not allow to see immediately that it returns a list of pmdepmissing_t structures. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/deps.c
2011-03-25Ensure reported missing dependencies show correct version comparisonDan McGee
This addresses FS#23424. The -dd backend code was introduced in commit b6ec9019d77, and unfortunately the munged depend used for comparison did not carry through to the eventual display of this version. To fix this, we undo some of the depcmp_tolerant() business introduced, and instead make a new pmdepend_t object if necessary when the no dependency version flag is set. This results in the correct depend being copied to the missing depend passed onto the frontend. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25Mark various functions in deps.c staticDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25Move alpm_find_dbs_satisfier() function down in deps.cDan McGee
This will make sense for a later commit when static/non-static properties of other functions are changed. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25Don't include version in dep string if mod == ANYDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20Style change: return(x) --> return xDan McGee
This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25alpm: alpm_db_get_pkgcache_list => alpm_db_get_pkgcacheDave Reisner
This avoids needless breakage of the public API. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25alpm: remove public visibility of pmpkghash_tDave Reisner
There's no API functions exposed which allow manipulation of this type, so remove it from public view. Also, rename the public and private alpm_db_get_pkgcache symbol to alpm_db_get_pkgcache_has. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25Continue resolving dependencies rather than bailing on first errorDan McGee
This allows error messages emitted by the frontend to be a bit more descriptive and not have the annoying "well why didn't you tell me that the first time" problem. If a package had multiple missing deps, we would bail on the first one before rather than finish processing all missing dependencies, and only print one error message. Instead, continue through this entire set of missing deps and append all eventual errors. The added pactest tests this case, as the to be installed package has two missing dependencies. However, pactest does not actually test or see the difference in output from before and after, so it passes in both cases, but it is clearly visible in the logs. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25Various small spelling fixes and small tweaksDan McGee
Nothing that changes behavior here. Spelling fixes and pushing a variable down to the scope it is used. Signed-off-by: Dan McGee <dan@archlinux.org>