Commit Graph

116 Commits

Author SHA1 Message Date
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
Dan McGee ea1fef69ad Remove gettext calls from all PM_LOG_DEBUG messages
There is no real reason to burden our translators with these messages, as
anyone helping to debug these will probably want them in English.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-10 14:24:58 -04:00
Andrew Fyfe 5e68e9d451 Cleanup of pacman_deptest()
Clean up some left over code from
http://projects.archlinux.org/git/gitweb.cgi?p=pacman.git;a=commitdiff;h=7653bb93997f52848b54ab80868cd6da52808a75

Signed-off-by: Andrew Fyfe <andrew@neptune-one.net>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-10 10:15:24 -04:00
Nagy Gabor 7653bb9399 Make alpm_splitdep immutable
The alpm_splitdep function formerly overwrote the input string, causing
a few issues. Fix this.

Signed-off-by: Nagy Gabor <ngaba@petra.hos.u-szeged.hu>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-26 11:49:00 -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
Chantry Xavier 8588b4823b Ensure correct and consistent usage of depmiss
See comment from Nagy here :
http://www.archlinux.org/pipermail/pacman-dev/2007-April/008134.html
This also makes easier correct usage of checkdeps in sync.c,
which fixes sync901 pactest (and so bug 6057).

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 21:41:06 -04:00
Chantry Xavier 796cc4e6ed Fix for removing a package that is no longer needed
Fix for remove041 pactest. You could not remove a package before that
was provided by something else already installed on the system. This fixes
this problem.

Reference:
http://archlinux.org/pipermail/pacman-dev/2007-April/008131.html
http://archlinux.org/pipermail/pacman-dev/2007-April/008134.html

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 21:25:01 -04:00
Nagy Gabor 0436601224 Small speed-tuning to upgrade-checkdep
Posted on the ML here:
http://archlinux.org/pipermail/pacman-dev/2007-April/008131.html

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 17:31:18 -04:00
Nagy Gabor 97ba9c9227 Fix issue when upgrading two packages that would break deps
Fixes for pactest upgrade060. Posted on the ML here:
http://archlinux.org/pipermail/pacman-dev/2007-April/008130.html

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 17:25:20 -04:00
Nagy Gabor 970f15d832 Fix breakage in checkdeps when upgrading a multiple-depend
Fixes pactest upgrade059. Posted on the ML in the following messages:
http://archlinux.org/pipermail/pacman-dev/2007-April/008127.html
http://archlinux.org/pipermail/pacman-dev/2007-April/008129.html

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-10 17:20:12 -04:00
Dan McGee 2bcecbd62c Remove unnecessary casts on malloc and elsewhere
We had many unnecessary casts, most of them dealing with malloc and
other memory allocations. The variable type should take care of it;
no need to do it explicitly. In addition, I caught a const error while
removing the casts.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-14 03:16:55 -04:00
Dan McGee a58e17a1d7 Remove STRNCPY macro from libalpm
Replaced calls to the STRNCPY macro with the actual strncpy function, and
pacman passes all pactests.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-29 12:03:09 -04:00
Dan McGee a57b2f233f Remove FREELISTPTR macro
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-28 03:54:25 -04:00
Dan McGee a3491224df Remove FREEPKG macro and correctly type _alpm_pkg_free
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-28 02:59:58 -04:00
Dan McGee 75efcbbff6 Clean up gettext on the libalpm side
Remove inclusion of libintl.h from all files, because we can do it once
in util.c where the _() macro is defined.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26 19:39:53 -04:00
Nagy Gabor 8e694dc40f Using wrong variable for depend lookup in sortbydeps
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-04-22 22:01:47 -05:00
Aaron Griffin bd55cf548c James Rosten <seinfeld90@gmail.com>
* Two new pactest test cases
* Fix some "required by" / "requires" output by unifying all "dependency types"
  to a single value (PM_DEP_TYPE_DEPEND)
2007-03-19 04:23:45 +00:00
Aaron Griffin 5f15a80274 * Fixed an error with 'cascade' removal due to creation of a new pmpkg_t struct
(and thus not copying pertinent data w.r.t. reading package files)
2007-03-12 05:55:14 +00:00
Dan McGee 7f7da2b5fc * Fix group comparison issue and associated compilation warnings by using
the alpm strcmp operation which takes void* references.
* We had this great visibility patch, but never actually took advantage of
  it. Added the right compile flag to make it work and added some more
  SYMEXPORTs where necessary to have a successful compile.
2007-03-11 21:10:02 +00: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 869e81e1cf This commit looks much more monumental than it is. Almost all just #include
reordering and adding ones that were forgotten (noticed when trying to
compile after reordering).

* Updated the HACKING file to include information on #include usage.
* print -> vprint in "making dir" function in pactest.
2007-03-05 22:13:33 +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 7f5dada885 Big commit this time:
* Moved entirely to alpm_pkg_get_* accessors, to read data on demand
* Mostly removed the INFRQ_ parameters from outside the be_files backend (making
  the backend more extensible in the long run)
* packages created from _alpm_db_scan now have the db and origin set (making
  accessors actually work for these packages)
* removed _alpm_db_ensure_pkgcache

* totally revamped the _alpm_checkconflicts function, making it cleaner and
  easier to read (and thus fix in the long run) - maintainable code ftw
  NOTE: feel free to rename the functions... I couldn't think of anything better

* removed an extra loop in sync.c:find_replacements - no sense in looping over
  an entire DB while strcmp'ing the name, when we have get_pkgfromcache

Other:
* package struct "license" -> "licenses"
* Created _alpm_sync_find (duplicate code in some places, find_pkginsync
* Minor const correctness changes along the way
* fixed a couple extra '/' pathing issues (non-issues really)
* removed a duplicate pkg_cmp function
2007-03-03 08:13:59 +00:00
Aaron Griffin ca139e9850 * Comment clarification 2007-03-01 07:08:48 +00:00
Aaron Griffin 3ebd125e1a * Switched some functions to alpm_pkg_get_* usage as I came across them
* Added some provision switching hackery.  This could probably use some
  refactoring,.. it solves the following case:

    pkg1 and pkg2 provide 'foo' and are both installed
    pkg3 depends on 'foo' and so lists 'pkg1' in the REQUIREDBY db section
    pkg1 is upgraded and no longer provides 'foo'
    ** This code ensures that the REQUIREDBY of pkg3 is updated to require pkg2
       now instead of pkg1
2007-03-01 07:03:05 +00:00
Dan McGee bd7eb9475c * Added another test as suggested by Nagy on the ML- a package both provides
for and is a dependency of another package. (upgrade057)
* Removed man2html stuff from doc/Makefile.am.
* Patch: improved depends checking in _alpm_checkdeps
  Nagy Gabor <ngaba@petra.hos.u-szeged.hu>
* Slight revisions to pmrule.py to allow for a PKG_PROVIDES test.
* Very quick updates to the pactest README.
* Added rules to some of the newer upgrade tests. Note: upgrade055 now fails
  due to requiredby entries not being written packages that are dependencies
  in a provides role.
2007-02-28 04:00:21 +00:00
Aaron Griffin 8fbdd03cce * Enforce const char* params when using strings
* Unified some functions names "package" -> "pkg" for consistency
* Removed the goofy 'faketarget' stuff used for dep testing
* Renamed alpm_pkg_isin -> alpm_pkg_find
* Renamed alpm_db_readpkg -> alpm_db_get_pkg
2007-02-26 08:38:48 +00:00
Dan McGee a5f630fda6 * Fixed inconsistency of args- _alpm_db_read, _alpm_db_write. 2007-02-21 08:34:36 +00:00
Aaron Griffin f62f37504a * Some cascade removal changes. Mainly code cleanup, but this is an attempt to
track down the great "Codemac Segfault"
* Fixed sortdeps - use the alpm_pkg_get functions to ensure data
2007-02-20 08:44:32 +00:00
Aaron Griffin d35e489499 * Fix version comparisons when one pkgrel doesn't exist (this ony fails on an ==
operation, technically, as 1.1.2-1 >= 1.1.2 is true.
2007-02-18 18:29:28 +00:00