Commit Graph

168 Commits

Author SHA1 Message Date
Xavier Chantry 1cca4ef764 Remove PM_TRANS_EVT_EXTRACT_START.
This event was unused, was missing the equivalent EXTRACT_DONE event, and
was useless because we already have ADD / UPGRADE START and DONE events.

Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-29 06:37:21 -05:00
Dan McGee a8ee185413 Remove wrapper call around versioncmp
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>
2008-05-14 00:37:51 -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
Sebastian Nowicki 8f902865d9 Add documentation for transaction events
It is hard to decipher what the transaction events actually notify you
of, and what parameters are passed to the callback function, without
looking at the code. This patch adds documentation for the _pmtransevt_t
enum in order to clarify what the event is for and what data is passed
when the callback is called.

Signed-off-by: Sebastian Nowicki <sebnow@gmail.com>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-29 15:51:45 -05:00
Chantry Xavier 701a03dcdb Completely rework delta algorithm
Using the graph structures that Nagy set up for dependency sorting, we now
do a similar process for deltas. Load up all of the deltas into a graph
object on which we can then apply Dijkstra's algorithm, using the new weight
field of graph struct.
We initialize the nodes weight using the base files that we can use in our
filecache (both filename and md5sum must match). The algorithm then picks
the best path among those that can be resolved.

Note that this algorithm has a few advantages over the old one:
1. It is completely file agnostic. These delta chains do not have to consist
   of package files- this could be adopted to do delta-fied DBs.
2. It does not use the local_db anymore, or even care if a package or file
   is currently installed. Instead, it only looks in the filecache for files
   and packages that match delta chain entries.

Original-work-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-04-26 11:36:01 -05:00
Dan McGee 30bdf94c2b Rework delta struct and modify code accordingly
Start to move the delta struct away from an assumed package name scheme and
towards something that is package (or even filename) agnostic. This will
allow us much greater flexibility in the usage of deltas (maybe even sync
DBs some day) as well as allowing code outside of delta.h/delta.c to be much
cleaner with less of a need for snprintf() calls.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-26 11:30:12 -05:00
Dan McGee a708c6eadc Allow disabling of internal (libdownload) code
Add a new --disable-internal-download flag to configure allowing the
internal download code to be skipped. This will be helpful on platforms that
currently don't support either libdownload or libfetch (such as Cygwin) and
for just compiling a lighter weight pacman binary.

This was made really easy by our recent refactoring of the download code
into separate internal and external functions, as well as some error code
cleanup.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-06 21:00:11 -05:00
Dan McGee e4a4cf7ce5 libalpm error cleanup, step 1
Remove unused error codes, begin refactoring some of the others.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-06 20:16:57 -05:00
Dan McGee bf86700369 Switch pmgrp_t to dynamic allocation, general group cleanup
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-23 14:51:51 -05:00
Chantry Xavier 5af076f09f Kill the dependsonly option.
From the man page :
"This is pretty useless and we're not sure why it even exists."

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-03-22 18:39:15 +01: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
Nagy Gabor 35135c0a0c Add -Rss option
* -Rss removes all dependencies (including explicitly installed ones).
* updated documentation
* two pactest files added to test the difference between -Rs and -Rss

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
2008-03-10 19:16:01 -05:00
Nagy Gabor d060e31be3 Remove trans->targets
Its implementation was quite broken:
* add_loadtarget() might have silently filtered out some targets when
  replacing an older version.
* This was used in sync.c to determine whether a target is implicit or not,
  which is incorrect behavior. Before this patch we silently removed user
  confirmed replacements; now we always warn on a replacement.
* remove001.py behavior was quite odd in adding same target 5 times to the
  target list, we can change this behavior to be a failure.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
[Xav: changed remove001 pactest accordingly]
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
[Dan: rewrote commit message]
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-10 18:57:36 -05:00
Nagy Gabor 49197b7492 New alpm_version function
Now pacman frontend uses this function instead of the compile-time libalpm
version number.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
[Dan: fix one more spot where LIB_VERSION was used]
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-01 17:02:05 -06:00
Chantry Xavier d734ebdde2 libalpm: clean up of md5sum functions.
test_delta_md5sum and test_pkg_md5sum were simple wrappers to test_md5sum,
and only used once, so not very useful. I removed them.
Also, test_md5sum and alpm_pkg_checkmd5sum functions were a bit duplicated,
so I refactored them with a new _alpm_test_md5sum function in libalpm/util.c

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-27 19:02:17 -06:00
Dan McGee c2dbbd60bc Start removing some junk from the function template
I screwed up originally when I accepted the TotalDownload patch,
8ec27835f4. I didn't realize how deeply it
modified libalpm and I probably shouldn't have let it do what it did. This
commit reverts much of what that patch added in order to clean up our
internal function calls. We can find another way to do it right down the
road here but for now it has to go.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-27 18:58:24 -06:00
Dan McGee f159203f6f Remove pmserver_t abstraction
Remove what was a pretty weird abstraction in the libalpm backend. Instead
of parsing server URLs as we get them (of which we don't usually use more
than a handful anyway), wait until they are actually used, which allows us
to store them as a simple string list instead. This allows us to remove a
lot of code, and will greatly simplify the continuing refactoring of the
download code.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-24 20:21:58 -06: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 77c3cf9790 Remove alpm_sync_get_newversion function
sync->newversion shouldn't be public at all, and internally we access it directly.
(Before pmsyncpkg_t clean-up the analogue of this field [type] was needed in replaces computation.)

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-07 20:15:30 -06:00
Nagy Gabor 7dc37109b0 alpm_sync_sysupgrade split
This patch indroduces a new public alpm_sync_newversion, which scans for new
version of a package in sync repos.
Hopefully this will reduce code duplication in the future:
* check-for-pacman-new-version from front-end can be easier
* -Qu refactoring

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-07 20:15:23 -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
Nagy Gabor 1fc83f4af6 pmsyncpkg_t cleanup
Fix for sync044.py and reason001.py.
Rename sync->data to sync->removes (alpm_list_t *)
Replace pmsynctype_t sync->type by pmpkgreason_t sync->newreason

The type field was set to UPGRADE or DEPEND or REPLACE.
Instead of using type = UPGRADE or DEPEND, we now rather use a
"pmpkgreason_t newreason" field directly (= explicit or depend) which allows
a better handling of the install reason.
And the REPLACE type is now deduced implicitly when the sync->removes list
is not empty.

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>
2008-01-27 12:05:33 -06:00
Chantry Xavier 22c900e7d5 Add new public alpm_checkdbconflicts function.
This function has a limited purpose, but might be interesting to do a
sanity check from a frontend (eg testdb).

Also removed the private _alpm_checkconflicts function to avoid confusion.
This function was used only once in libalpm, in sync.c, and was just a
single line anyway. Having to do it manually makes it explicit that we are
looking for two kind of conflicts (targ vs targ and db vs targ).

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-23 20:12:41 -06:00
Nagy Gabor 2a7101c049 New --asexplicit option
This is the symmetric of --asdeps, install packages explicitly.
Documentation and completion files were updated accordingly.
Added sync301.py and upgrade032.py pactest files to test this.

I also made a little modification in ALLDEPS handling too.

Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-01-21 19:39:26 -06: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 9dd016001e Remove upgradedelay and all code associated with it
It wasn't even implemented correctly, and it really doesn't have a use if
packagers just do their job correctly anyway for a distro. Let's not try to
solve a problem with the wrong solution now.

Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-08 15:49:52 -06:00
Allan McRae cca4ec647e Add remove counterparts to alpm_option_add_* functions
Fixes FS#7428. Added functions to remove cachedir, noupgrade, noextract,
ignorepkg, holdpkg and ignoregrp.

Signed-off-by: Allan McRae <mcrae_allan@hotmail.com>
[Dan: fix whitespace]
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-28 19:43:59 -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
Dan McGee 7249c08bdf Improve changelog handling through addition of open/read/close functions
Thanks to Allan for inspiring all this work on what was one little TODO item
in the codebase. :)

Change changelog handling so we can now dump a changelog from both installed
packages and package files (fixes FS#7371). We do this by moving all of the
machinery to the backend where it should have been in the first place.

The changelog reading is now done through a open/read/close interface
similar to the fopen/fread/fclose functions (can you guess how it is done?).
It is buffered by the frontend, so programs using the library can read as
much or as little as they want at a time.

Unfortunately, I could not implement a changelog_feof function due to some
shortcomings of libarchive. However, I left the stub code in there,
commented out, in case it becomes possible later or anyone wants to take a
stab at it.

Original-work-by: Allan McRae <mcrae_allan@hotmail.com>
Improved-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-09 11:33:08 -06:00
Chantry Xavier 250331a636 Add new --needed option for -S.
During a pacman operation such as a group install, pacman can ask several
questions such as "local version is up to date. Upgrade anyway?". They are
usually all answered either by yes or by no:
* yes when you want to reinstall all the targets.
* no when you only want to install the missing ones (either because you are
installing a group, or because you are copying a pacman -S line from wiki or
whatever).

So instead of asking this question for each target, it is now now configured
with a flag.  Yes will be the default -S behavior, No will be achieved with
the --needed flag.

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-02 11:14:13 -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
Dan McGee f5d2150e9d Remove -F/--freshen operation
This operation made sense in the days before sync DBs existed, but it no
longer has the same usefulness it once did.

Signed-off-by: Dan McGee <dan@archlinux.org>
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-11-21 11:51:17 -06:00
Chantry Xavier 83fa6aa289 Remove duplicated get_upgrades function, use sysupgrade instead.
The alpm_get_upgrades was exactly the same as find_replacements +
_alpm_sync_sysupgrade, except that it automatically made the eventual
replacements, without asking the user : Replace %s with %s/%s? [Y/n]

The replace question, asked in find_replacements. can now be skipped by
using a NULL trans argument, so that we get the same behavior as with
alpm_get_upgrades.

So alpm_db_get_upgrades() can now be replaced by
alpm_sync_sysupgrade(db_local, syncdbs).

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21 00:05:05 -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
Chantry Xavier 65fb99133d Simple s/conflict/fileconflict/ renaming.
The names related to conflicts are misleading :
For dependencies conflicts, the type is pmdepmissing,
and the function names contain just "conflict".

For file conflicts, the type is pmconflict,
and some functions contained just "conflict", some others "fileconflict".

So this is the first step for improving the situation.
Original idea/patch from Nagy, but the patch already didn't apply anymore,
so I did it again.
The main difference is that I kept the conflictype, with the following renaming :

pmconflicttype_t -> pmfileconflicttype_t
PM_CONFLICT_TYPE_TARGET -> PM_FILECONFLICT_TARGET
PM_CONFLICT_TYPE_FILE -> PM_FILECONFLICT_FILESYSTEM

Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-18 12:42:34 -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 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
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 8ec27835f4 Implement TotalDownload option.
Setting this option will change the download progress to show the amount
downloaded, download rate, ETA, and download percent of the entire
download list rather than per each individual file.

The progress bar is still based on the completion of the current file
regardless if the TotalDownload option is set.

This closes FS#7205.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11 09:46:13 -06:00
Nathan Jones 5c58b3d500 Add IgnoreGroup and --ignoregroup option.
This will be used in the next commit.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11 09:44:26 -06:00
Dan McGee 006387828c Readd scriptlet logging that got lost in an earlier commit
I broke scriptlet logging with ad691001e2.
Readd more or less what was there before, although it still needs a lot of
work including hopefully rewriting it to a new event subsystem and having
it log to a seperate file.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-04 11:27:41 -06:00
Dan McGee 6cf8a5137e libalpm/delta: add const to most methods
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29 01:28:13 -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
Nathan Jones f5b77eb989 Add download size to target list.
This displays the download size, taking into account delta files and
cached files.

This closes FS#4182.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-19 19:30:06 -05:00
Nathan Jones e472e80c08 Download delta files if UseDelta is set.
Delta files will be used if the size is smaller than a percent
(MAX_DELTA_RATIO) of the package size.

Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-19 19:29:17 -05:00
Nathan Jones 0c2cc108d3 Add pmdelta_t structure and functions to libalpm.
Signed-off-by: Nathan Jones <nathanj@insightbb.com>
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-19 19:21:44 -05:00
Dan McGee 0adedc536f Updates to fix Doxygen documentation generation
We had way too much going on with the Doxygen manpage generation. Clean it
up quite a bit by removing directory manpages, using relative paths, not
having a manpage for every single alpm function, and ensuring internal
functions are not documented publicly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-14 17:29:32 -05:00
Aaron Griffin f2f4ada1d6 Remove buildtype package accessor prototype
This was removed a while ago, but the prototype was still hanging out.

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-09-28 00:25:57 -05:00
Aaron Griffin 47622eef4d Support for localized times in metadata
Packages and DBs now support using the UNIX epoch (seconds since Jan 1, 1970)
for use in builddate and installdate. This will only affect newly built
packages. Old existing packages with the text format are still supported, but
this is deprecated.

In the case of removal of text time support, this code will fail gracefully,
returning the start of the epoch for broken packages.

Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-09-28 00:25:57 -05:00