Commit Graph

146 Commits

Author SHA1 Message Date
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 38e981fab3 Merge branch 'maint' 2008-01-14 22:58:44 -06:00
Chantry Xavier 0c5b68877b Change the versioned provision format.
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>
2008-01-14 22:03:03 -06:00
Dan McGee 521de7ceed Merge branch 'maint' 2008-01-13 12:27:17 -06:00
Nagy Gabor 633dbeac88 small checkdeps speed-up
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>
2008-01-12 11:05:52 -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
Nagy Gabor 13dd2864ca PM_DEP_MOD_LT and PM_DEP_MOD_GT depmods added
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>
2007-12-19 14:48:05 -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
Nagy Gabor 43eacf2852 Remove duplicated PM_TRANS_CONV_INSTALL_IGNOREPKG message
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>
2007-12-05 11:28:47 -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
Dan McGee 7341d09541 Add 4 new pactests to get better code coverage by pactest
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>
2007-12-02 17:24:22 -06:00
Chantry Xavier 22c2043160 Minor fixes in sync.c and deps.c.
* 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>
2007-12-01 11:10:22 -06:00
Dan McGee cff1e2a58f Remove alpm_depcmp DEBUG output
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>
2007-11-30 23:02:06 -06:00
Dan McGee e95e346ac7 Remove some null checks in _alpm_checkdeps
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>
2007-11-30 22:57:47 -06:00
Nagy Gabor 2ed6b482d2 alpm_checkdeps clean-up
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>
2007-11-30 21:17:04 -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 7cf28a7595 Improved 'dependency cycle' warning
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>
2007-11-21 10:25:52 -06:00
Nagy Gabor 84ebf82319 Versioned provisions.
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>
2007-11-18 20:05:51 -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
Nagy Gabor 55a7455135 libalpm/deps.c : improves IgnorePkg handling in resolvedeps.
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>
2007-11-18 12:37:16 -06:00
Chantry Xavier c8be7540a5 Remove provide.c and provide.h .
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>
2007-11-17 09:50:05 -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
Dan McGee 4ce13e2398 Fix a would-be memleak with the new compute requiredby stuff
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-15 08:05:10 -06:00
Dan McGee c8243bb8ed libalpm: change graph malloc to MALLOC macro
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14 22:51:47 -06:00
Dan McGee c244cfecf6 Move alpm_splitdep usage to db_read
Holy inefficient batman! For a pacman -Qt operation (when we are using
compute_requiredby and not database entries), splitdep was being called ~1.3
million times on my local database. By splitting when we read the DB, we
drop this number to around 1700 and save a LOT of time in doing so (a 5x
increase in pacman -Qt speed here).

Note that the depends alpm_list_t in the package struct is no longer a
string list, but a list of pmdepent_t objects.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14 21:00:02 -06:00
Dan McGee 7219326dd4 Remove REQUIREDBY usage from libalpm
Instead of using the often-busted REQUIREDBY entries in the pacman database,
compute them each time they are required. This should help many things:

1. Simplify the codebase
2. Prevent future database corruption
3. Ensure when we do use requiredby, it is always correct
4. Shrink the pmpkg_t memory overhead

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-14 18:49:50 -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
Dan McGee 1b2817f539 Enforce const correctness on dep functions and rewrite alpm_dep_get_string
Add some const specifiers to the dep functions that can have them. In
addition, rewrite alpm_dep_get_string to use snprintf and cover all of
the bases (operators).

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-13 00:13:05 -06:00
Nathan Jones 3312de65e6 Implement IgnoreGroup.
This option acts as if IgnorePkg was set on each package in the group.

This closes FS#1592.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11 09:44:30 -06:00
Dan McGee 86ca39d15e Clean up usage of extern variables
Instead of declaring the extern variable in every *.c file, include it in
the header file that makes sense. This means handle.h for the handle, and
conf.h for the pacman side config object.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-04 12:05:22 -06:00
Dan McGee 6aeda5fbff When printing size_t, use %zd
%d was used, which worked for Linux and FreeBSD. Not so for Darwin. The
warning was probably spat out when compiling on x68_64 as well, but no
developers use this architecture as their primary one.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29 23:32:58 -05:00
Dan McGee cc754bc6e3 libalpm: introduce MALLOC and CALLOC macros
These macros take the place of the common 4 or 5 line blocks of code we had
in most places that called malloc or calloc. This should reduce some code
duplication and make memory allocation more standard in libalpm.

Highlights:
* Note that the MALLOC macro actually uses calloc, this is just for safety
  so that memory is initialized to 0. This can be easily changed in one
  place.
* One malloc call was completely eliminated- it made more sense to do it
  on the stack.
* The use of RET_ERR in public functions (mainly the alpm_*_new functions)
  was standardized, this makes sense so pm_errno is set.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29 01:00:52 -05:00
Dan McGee fe3a461703 Add some more debugging output to dep checking code
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29 00:01:17 -05:00
Dan McGee b38e046621 Explicitly cast void* to char* during printf call
If we don't have an explicit cast, make fails during -Wall -Werror.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-26 19:09:21 -05:00
Nagy Gabor d903fc607e Dependency error/log messages fix
The old code used only the depend.name in messages, which might have not
been informative. The new code uses the whole dependency string in
%DEPENDS% format.

(Dan: slight English clarification in one of the messages)
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-26 18:54:21 -05:00
Nagy Gabor 0cff7c6bdf Add alpm_dep_get_string method
Public alpm_dep_get_string function is introduced, which converts a
pmdepend_t structure to printable string in %DEPENDS% format.  This
function is now used in pacman to print dependency error messages.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-25 07:10:08 -05:00
Nagy Gabor 89ac8aa9c4 _alpm_depmiss_isin fix
The old code used memcmp, which is not good for comparing strings:
"pkgname"'\0''\0' should be equal to "pkgname"'\0''a' for example.
The new code uses strcmp.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-24 16:51:12 -05:00
Dan McGee 01e92e9ded libalpm/deps.c: fix memleak found by valgrind
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28 23:27:14 -05:00
Chantry Xavier f21c45c0dd libalpm/deps.c : export _alpm_checkdeps (-> alpm_checkdeps).
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-11 20:42:03 -05:00
Dan McGee 5c9eec5570 libalpm: add newlines to all strings passed to log callback
This allows us to remove the hack in the frontend where we added a newline
to everything coming out of the pm_printf functions, and instead let the
developer put newlines where they want them. This should be the last hangover
of that auto-newline stuff.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-23 22:26:55 -04:00
Dan McGee c22e381a8b Post trial install changes, round one
A bunch of changes related to my first "real" install of pacman-git into
/usr/local and trying to use it.

* Shift some uses of free -> FREE in libalpm.
* Move stat and sanity checks of config paths into libalpm from the
  config and argument parsing in pacman.c.
* Fix issue where dbpath still was not defined early enough due to its
  requirement for being used in alpm_db_register. This should be rewritten
  so it doesn't have this dependency, but this will work for now.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-21 21:28:05 -04:00
Chantry Xavier 240bdf5971 libalpm/deps.c : split alpm_depcmp.
That function wasn't big, but this might be useful
for later refactoring of the search for satisfier code.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-17 10:10:27 -04:00
Chantry Xavier c68d3cc38a libalpm/deps.c : split sortbydeps function.
The _alpm_sortbydeps function has two main part :
1) initialization of the graph structure
2) the sorting itself

So it didn't seem bad to move the first part to a second function.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-17 10:06:26 -04:00
Chantry Xavier 99572ed8f6 new pmdepend_t / pmdepmissing_t accessors.
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-16 09:21:13 -04: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
Andrew Fyfe c0a7d9d82d Some doxygen comments.
Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
2007-07-12 16:00:58 -04:00
Dan McGee d402583c43 Remove some more conditional include stuff
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-12 16:00:35 -04:00
Dan McGee 20f73d6299 Remove versioncmp.{c,h}, clean up selective #ifdefs
Remove versioncmp.c by moving all functions to locations that make sense.

Move replacement functions (for building without glibc) into util.c where
they belong, and do proper checks for them instead of using __sun__, etc.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-12 15:20:43 -04:00