Commit Graph

62 Commits

Author SHA1 Message Date
Allan McRae 6d876f9b6b Rename pmdepmissing_t to alpm_depmissing_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 9540dfc4d9 Rename pmdepend_t to alpm_depend_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:28:23 +10:00
Allan McRae 8a04bc25a1 Rename pmpkg_t to alpm_pkg_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 23:26:39 +10:00
Allan McRae 939d5a9511 Rename pmdb_t to alpm_db_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:16:12 +10:00
Allan McRae 64c1cf7921 Rename pmhandle_t to alpm_handle_t
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28 14:04:00 +10:00
Dan McGee 7f6c1a76c6 Make pmdepend_t and pmdepmissing_t public
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-16 11:57:33 -05:00
Dan McGee 52bffd2457 Switch all logging to use handle directly
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-13 19:41:16 -05:00
Dan McGee 8b62d9bc0a Add handle argument to two more alpm methods
This takes care of alpm_checkdeps() and alpm_find_dbs_satisfier().

Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13 19:35:22 -05:00
Dan McGee 68701a98af Ensure reported missing dependencies show correct version comparison
This addresses FS#23424. The -dd backend code was introduced in commit
b6ec9019d7, 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-25 15:43:08 -05:00
Dan McGee 3bc3999bd2 Mark various functions in deps.c static
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25 15:40:12 -05:00
Xavier Chantry b6ec9019d7 alpm/depcmp: new NODEPVERSION flag
This flag allows to disable version checking in dependency resolving
code.

depcmp_tolerant respects the NODEPVERSION flag but we still keep the
original strict depcmp. The idea is to reduce the impact of the
NODEPVERSION flag by using it in fewer places.

I replaced almost all depcmp calls by depcmp_tolerant in deps.c (except
in the public find_satisfier used by deptest / pacman -T), but I kept
depcmp in sync.c and conflict.c

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-31 10:49:39 -06:00
Allan McRae d288240426 Update copyright years for 2011
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-07 18:47:37 -06:00
Allan McRae fcc09bd7e3 Correct type for hash value storage
Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-29 19:10:49 -06:00
Dan McGee 735a197fc2 Use name hashes in depends to avoid strcmp calls
Just like we did for package name comparsions, if we add a depend name_hash
field on depend struct initialization, we can use it instead of doing a
string name comparison, saving us a lot of checks in the depcmp code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-21 17:25:34 -06:00
Xavier Chantry d0d8f605d5 alpm: don't expose alpm_depcmp
Either we expose all low levels function dealing with pmdepend_t
(splitdep and depfree come to mind), or we don't.

Since none of the tools use depcmp, I chose to remove it. In the future,
we might want to expose higher level functions such as
alpm_find_satisfier, or just lower level functions like splitdep and
depfree together with depcmp.

Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:08:54 -06:00
Nagy Gabor eada558e12 Partial fix for the phonon/qt issue
This patch fixes the phonon/qt issue, if all to-be-upgraded packages are
explicit targets (ie. only not-yet-installed packages are pulled by
resolvedeps). This condition covers the most common situations, for example
it should hold with every -Su operation.

After this patch sync405.py passes, but sync406.py doesn't.

The work is inspired by the patch of Henning Garus, thanks for his work:
http://mailman.archlinux.org/pipermail/pacman-dev/2010-February/010429.html
(I moved the alpm_list_diff computation to sync.c in order to compute it
only once.)

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-05-18 11:33:00 -05:00
Dan McGee a36ff9404b Bump copyright dates to 2010
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-14 19:46:59 -05:00
Dan McGee c72b4543b6 Update copyright headers and messages
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-01 02:08:33 -05:00
Bryan Ischo db3e166503 Look in target-list first to resolve dependencies
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>
2009-04-11 14:39:24 -05:00
Bryan Ischo f57f8d3386 Don't prompt the user for unignore of IgnorePkg/IgnoreGroup packages
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>
2009-02-23 20:37:14 -06:00
Bryan Ischo 6c4d702cb1 Reorganize code for one-at-a-time resolving
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>
2009-02-18 20:52:22 -06:00
Nagy Gabor fd8969f678 sync_addtarget rework
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>
2008-07-13 09:16:55 -05:00
Nagy Gabor 72c0ab5c51 Resolvedeps rework
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>
2008-07-07 21:12:55 -05:00
Nagy Gabor 616b5967b8 New _alpm_find_dep_satisfier function
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>
2008-07-07 21:04:37 -05:00
Nagy Gabor f7199f36ba New _alpm_dep_edge function
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>
2008-07-07 21:04:16 -05:00
Chantry Xavier f43805d875 Cleanup usages of alpm_list_find and alpm_list_remove.
* 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>
2008-05-13 15:49:02 -05:00
Chantry Xavier e7a2232934 Kill PM_TRANS_TYPE_ADD.
This was totally useless.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-17 21:01:22 -05:00
Dan McGee 92ab7c33fb Move pmgraph_t struct and functions to their own header file
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>
2008-02-16 11:58:49 -06:00
Nagy Gabor e63366ae5e New remove option : -u / --unneeded (FS#6505).
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>
2008-02-06 08:46:15 +01:00
Chantry Xavier b2914bf0af Move the deptest code from frontend to backend.
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>
2008-01-21 19:35:43 -06:00
Dan McGee 3e133524a5 Add functions to manipulate pmdepend_t objects
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>
2008-01-11 22:58:05 -06:00
Dan McGee ccc1c73152 Use dynamic string allocation in package structures
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>
2008-01-11 00:01:58 -06:00
Dan McGee 9781d0d637 Update GNU GPL boilerplate and copyright dates
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>
2007-12-10 22:55:39 -06:00
Dan McGee 0b6d73a5b4 Remove _alpm_depmiss_isin
This is unneeded now that commit 2ed6b482d2
has eliminated the last user of this function.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-02 17:25:34 -06:00
Nagy Gabor 7d37d9278d Fix for sync1003 and sync1004 pactests
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>
2007-11-25 15:29:37 -06:00
Nagy Gabor 2aa7e69da9 Add the pmconflict_t type.
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>
2007-11-18 12:42:39 -06:00
Dan McGee 2322909703 War on whitespace
Run the kernel's cleanfile script on all of our source files.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-16 20:18:45 -06:00
Nagy Gabor 85b06f1276 alpm_list_add == alpm_list_add_last
It's time to define that alpm_list_add(list, foo) adds 'foo' to the end of
'list' and returns with 'list', because:
1. list is a list, not a set.
2. sortbydeps _needs_ an alpm_list_add definition to work properly.

As a first step, I used this definition in recursedeps.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
[Dan: punctuation cleanup in commit message and code comments, added comment
to alpm_list_add]
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14 18:48:34 -06:00
Nagy Gabor c2920033d0 libalpm/deps.c : cleanup + little fix for resolvedeps.
The resolvedeps function was a bit negligent, as showed by the sync011 pactest.
Reference :
http://www.archlinux.org/pipermail/pacman-dev/2007-July/008782.html

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-07-15 10:37:38 -04:00
Chantry Xavier 1c9f30b9fa libalpm/deps.c : fix for remove044 pactest.
Patch from Nagy that makes removedeps use alpm_depcmp.

I also renamed removedeps to recursedeps, as it can have
a more general usage, and added an include_explicit argument,
so we can control if packages explictly installed are added or not.

Note: Small changes made by me (Dan) as well- mostly some English grammar
correction and a few other cleanups.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-13 10:37:13 -04:00
Nagy Gabor da66bedf4f Remove unnecessary trans parameter from _alpm_checkdeps
The trans parameter was never used, so remove it.

Signed-off-by: Nagy Gabor <ngaba@petra.hos.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-26 11:43:02 -04:00
Nagy Gabor 544bcbe664 Implement simple topological sort algorithm for sortbydeps
Based on the "depth first search" algorithm, for more infos visit:
http://en.wikipedia.org/wiki/Topological_sorting

The previous algorithm used by sortbydeps was too slow, and to work around
it the number of steps needed to get correct result was reduced greatly.
So it produced wrong results in several cases :
1) smoke001.py
2) http://bugs.archlinux.org/task/7229

More here: http://archlinux.org/pipermail/pacman-dev/2007-April/008057.html

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 22:13:58 -04:00
Aaron Griffin 166ffc4f9e * Bug fix for makepkg dependency testing. This requires that we
expose alpm_splitdep and alpm_depcmp as public symbols
* Removed a duplicate strtrim for question responses
2007-03-07 07:45:30 +00:00
Dan McGee e24c22e308 * A little more hacking with wchar_t output, but nothing really changed in
it. Eventually we'll make progress.
* Rewrote the _alpm_splitdep function to behave more like all our other
  function calls. Use heap instead of stack allocation for the depend struct,
  so now it needs to be freed by the caller.
2007-03-03 09:43:16 +00:00
Aaron Griffin 21729f0ce4 * Forgot the int->enum header checkin
* Removed the dep-sorting TODO item - switch the sorting to a topological sort
  later (I'll let Dan do the CS stuff, heh)
2007-01-31 08:10:01 +00:00
Aaron Griffin 1b61cc8c69 This mainly deals with code clarity- removing currently unneeded
optimizations in order to make the code much more readable and
type-checkable. Every enum in the library now has it's own type that
should be used instead of the generic 'unsigned char'. In addition,
several #define statements dealing with constants were converted to
enums.

Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2007-01-24 03:02:53 +00:00
Aaron Griffin 6167017264 Preliminary checkin for alpm_list conversion
* renamed pmlist_t -> alpm_list_t
* made alpm_list_t a public type (alpm_list.h header)
* removed additional storage for registered DBs in pacman source
* some code cleanup
* removed duplicate (pm)list_display functions from pacman source
* misc code cleanup
2007-01-19 09:28:44 +00:00
Aaron Griffin 986409f9bd * Completed getinfo api changes (pmmissing_t, pmtrans_t, etc)
* Modified some dependancy checking
* Changed "performing local database upgrade" message to be more clear
* Change 'usize' to 'isize' in database files
* Scriptlet output is now sent to pacman's log file
* Limited some debugging output to be more clear
2006-11-22 09:03:41 +00:00
Aaron Griffin aa1c0ba9f8 * repo-add script - to add entries to a db file directly from package data (no PKGBUILD)
* libalpm api changes - move from a _getinfo(p, WHAT_WE_WANT) scheme to a
  typesafe _get_what_we_want(p) scheme [not 100% complete yet]
* some const correctness changes
* removal of PM_* types in alpm.h in favor of the pm*_t types used throughout
  libalpm
2006-11-20 09:10:23 +00:00
Aaron Griffin 7131b7ac87 A handful of minor changes:
* Removed the PMList typedef, in favor of the same naming scheme other
      structs use 'pmlist_t'
    * Added a time stamp on debug output, to make it more informational
    * Moved alpm_db_register to _alpm_db_register, making the public function
      not take a callback parameter
2006-10-20 06:26:55 +00:00