summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/sync.c
AgeCommit message (Collapse)AuthorFilesLines
2008-02-25Move download code out of server.cDan McGee1-0/+1
This is the first in what will be a series of patches to clean up the current download code in libalpm. Start by moving download code out of server.c and into download.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-21Merge branch 'maint'Dan McGee1-2/+4
Remove gettext() function addition from gensync and updatesync in master as gettext is no longer used in them anyway.
2008-02-18Do not warn about up to date package when downloading onlyAllan McRae1-2/+4
Stops the "<pkg> is up to date -- reinstalling" message when using the download only flag. Ref: http://archlinux.org/pipermail/pacman-dev/2008-January/010952.html Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-08Remove alpm_sync_get_newversion functionNagy Gabor1-8/+0
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-08alpm_sync_sysupgrade splitNagy Gabor1-44/+65
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-01-27pmsyncpkg_t cleanupNagy Gabor1-58/+40
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-27Fix PM_ERR_CONFLICTING_DEPS handling in sync.cNagy Gabor1-13/+14
* eliminate asymmetry (innerconflict vs. outerconflict) * fix a memleak (in case of PM_ERR_MEMORY deps wasn't freed) * fix wrong pmconflict_t duplication (*retconflict = *conflict) Note: the new code introduces some code duplication which shall disappear by fixing FS#7524. 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-27small sync.c code clean-upNagy Gabor1-16/+6
Remove unnecessary synclist_free function, and use our standard way (alpm_list_free_inner + alpm_list_free) instead. This slightly reduces code duplication. 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-24libalpm/sync.c : conflicts resolving cleanup.Chantry Xavier1-153/+110
The original patch from Nagy tried to resolve target vs target conflicts, and so broke the following pactests : sync040, sync041 and sync990 Nagy's proposal to solve this situation was to choose the interactive way, ask the user how to deal with it: either remove pkg1 or remove pkg2 or stop here. So he left this as a TODO. But instead of trying to resolve these conflicts or asking the user, I tried to find a more conservative way, looking at what the current pactests expected: If between the two conflicting packages, one provides the other, pacman will keep that one and remove the other from the target list. That breaks sync893 and sync897. But Dan agreed these two looked weird and should be changed. This commit should close FS#8897, FS#8899 and FS#9024. Reference: http://www.archlinux.org/pipermail/pacman-dev/2007-October/009745.html http://www.archlinux.org/pipermail/pacman-dev/2007-December/010393.html Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-24Add new public alpm_checkdbconflicts function.Chantry Xavier1-1/+2
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-24small memleak fix in sync.c.Chantry Xavier1-1/+2
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-01-13libalpm/sync.c: don't duplicate packages for the sync->data field.Chantry Xavier1-35/+7
Packages put in the sync->data field were always duplicated with pkg_dup, and then freed, This is not needed. Killing this duplication of packages made the memory usage during base reinstall go from 10.4 MB to 8.1 MB. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-01-12Merge branch 'maint'Dan McGee1-2/+2
2008-01-11Fix library interfaceDan McGee1-2/+2
Two functions defined in alpm.h were not marked with SYMEXPORT, causing linking errors if they were used. In addition, remove the incorrect use of the 'alpm_' prefix from an internal function and replace it with '_alpm_'. Fixes FS#9155. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-11Use dynamic string allocation in package structuresDan McGee1-10/+23
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-10Move the fallback on providers from backend to frontend.Chantry Xavier1-26/+2
This reverts commit e28973169d2e5eda8b64ebdda11ece0dc761d978. This code might fit better in the frontend than in the backend finally. Ref: http://www.archlinux.org/pipermail/pacman-dev/2007-November/010150.html I also changed it for fixing FS#8763 : if there is exactly one provider, pacman will pull it and print a warning. if there are several providers, pacman will list them and fail. It's up to the user to pick one. Add sync501 pactest to reflect that.
2008-01-06sync.c: add sanity check so we don't dereference a null pointerDan McGee1-6/+8
Originally noticed in FS#9024, but was fixed in previous changes anyway. However, it doesn't hurt to still check it. Also add a pactest from Chantry Xavier for the original problem to ensure we can't reproduce it. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-02Fix another usage of pkg_new in _alpm_sync_addtargetDan McGee1-2/+1
Use _alpm_pkg_dup instead. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-02Switch pkg_new -> pkg_dup in find_replacementsDan McGee1-1/+1
Ugh, it was a pain to figure out why the Total Removed Size was showing up wrong in the output of removed packages, but this was why- we used a stupid _alpm_pkg_new call instead of just duping the package. Fix this. In the long run, we really need to figure out better ways to not duplicate all this package information. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-29Allow NULL parameter in alpm_trans_commitAllan McRae1-18/+28
Fixes FS#7380: alpm crashes on passing NULL to alpm_trans_commit in a sync operation. Adds check that data parameter is not NULL in several functions. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> [Dan: fix whitespace] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-21Check ignored packages in _alpm_sync_addtarget().Nathan Jones1-0/+8
This will allow someone to install a group but ignore individual packages inside the group. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-11Update GNU GPL boilerplate and copyright datesDan McGee1-4/+2
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-03alpm_list : change the alpm_list_find* to return the matching item.Chantry Xavier1-1/+1
alpm_list_find and alpm_list_find_ptr will now return a void *, and alpm_list_find_str will return a char *, instead of an int. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-02Add new --needed option for -S.Chantry Xavier1-9/+8
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-01Minor fixes in sync.c and deps.c.Chantry Xavier1-1/+1
* 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-11-25Fix for sync1003 and sync1004 pactestsNagy Gabor1-68/+32
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-25Fix several memleaks, mostly related to errors handling.Chantry Xavier1-24/+18
* The frontend calls alpm_trans_prepare(&data), and in case of errors, receive the missing dependencies / conflicts / etc in the data pointer. It apparently needs to free this structure totally with : alpm_list_free_inner(data, free) alpm_list_free(data) So I added alpm_list_free_inner(data, free) in pacman/{sync.c,remove.c,add,c} * in _alpm_sync_prepare, the deps and asked lists were not freed in case of errors (unresolvable conflicts). Besides the code for handling this case was duplicated. * in _alpm_remove_commit, free was used instead of alpm_list_free for newfiles. * newline fix in pacman/sync.c Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25Fix a memleak in _alpm_sync_free.Chantry Xavier1-5/+2
An alpm_list_free call was missing. Also make use of alpm_list_free_inner in both _alpm_sync_free and _alpm_trans_free. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-21Remove duplicated get_upgrades function, use sysupgrade instead.Chantry Xavier1-92/+129
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-19Versioned provisions.Nagy Gabor1-2/+2
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-18Add the pmconflict_t type.Nagy Gabor1-35/+35
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-18Remove the IgnorePkg handling from alpm_pkg_compare_version.Chantry Xavier1-18/+11
And check the IgnorePkg handling is done correctly in the other places. For example, -Qu and -Su will automatically skip the ignored packages (-Su will print a warning), but -S will install ignored packages anyway, because it was asked explicitly. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-17Remove provide.c and provide.h .Chantry Xavier1-1/+0
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-17War on whitespaceDan McGee1-5/+5
Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-15Remove REQUIREDBY usage from libalpmDan McGee1-49/+0
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-11Incorrect usage of alpm_db_whatprovides in sync.cNagy Gabor1-4/+4
The old code thought that alpm_db_whatprovides returns with a list of strings (package names). Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11Implement TotalDownload option.Nathan Jones1-1/+11
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-11Implement IgnoreGroup.Nathan Jones1-4/+3
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-10-30When printing size_t, use %zdDan McGee1-2/+2
%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-29libalpm/delta: add const to most methodsDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29libalpm: introduce MALLOC and CALLOC macrosDan McGee1-4/+1
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-29Add some more debugging output to dep checking codeDan McGee1-4/+5
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-27Dependency error/log messages fixNagy Gabor1-1/+3
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-20Add download size to target list.Nathan Jones1-0/+34
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-20Download delta files if UseDelta is set.Nathan Jones1-3/+245
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-20Refactor md5sum checking.Nathan Jones1-44/+89
This will allow deltas and packages to share the md5sum checking code. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-09Add gcc format attribute to _alpm_log, catch a few bugs in the processDan McGee1-2/+4
This fixed a few of our formatted output strings that were broken before but never being checked. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-24libalpm: add newlines to all strings passed to log callbackDan McGee1-52/+52
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-22Post trial install changes, round oneDan McGee1-4/+4
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-20Fix for FS 6404 and functionalize some cachedir handling stuffDan McGee1-92/+31
In order to best resolve bug 6404, move some cachedir handling stuff out of sync.c and into util.c and create two new functions: filecache_find and filecache_setup. sync.c was rewritten to use these, and alpm_fetch_pkgurl now also uses these routines. Signed-off-by: Dan McGee <dan@archlinux.org>