summaryrefslogtreecommitdiffstats
path: root/src/pacman/sync.c
AgeCommit message (Collapse)AuthorFilesLines
2008-02-20Lock the database on -Sc operation.Chantry Xavier1-1/+12
This partly fixes FS#9609. Weird things could happen when running -Sc while another instance was already running. The cleancache function could delete packages that were just being downloaded. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-20Add new sync_trans_init and sync_trans_release.Chantry Xavier1-22/+28
Factorize these two functions to avoid code duplication, especially since they could be used for locking the database during -Sc and -Sy operation too. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2008-02-19When cleaning DBs, only look at directoriesDan McGee1-3/+11
FS#9609 brought up an interesting issue where a user was prompted to remove db.lck when running a -Sc operation concurrently with an -Syu operation during a long download. Although there are other problems here, this fixes the issue where files other than directories could be considered to be databases. Fix this. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-03Clarify the "failed to add target" errors.Chantry Xavier1-1/+1
Make the error message printed when addtarget fails consistent between add.c, remove.c and sync.c. The main problem was that the "failed to add target" in case of a removal operation could sound confusing. There was also a little output problem with -U ("failed" was missing). Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-27Clarify the "cancel current operation" message.Chantry Xavier1-6/+3
Fixes FS#9295. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: 'new pacman' -> 'new pacman version'] Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-10Move the fallback on providers from backend to frontend.Chantry Xavier1-3/+31
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.
2007-12-21Check ignored packages in _alpm_sync_addtarget().Nathan Jones1-1/+1
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-18Only query pacman upgrade when performing actual upgradeAllan McRae1-36/+38
Fixes FS#7147. Do not ask about upgrading pacman when -w and -p flags are used. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-11Update GNU GPL boilerplate and copyright datesDan McGee1-3/+1
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-09src/pacman/: use the FREELIST macro when possible.Chantry Xavier1-2/+1
Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-06pacman/sync.c : improve the sync db cleanup feature.Chantry Xavier1-10/+14
This feature (introduced by b118ce55bd01c7ebd42b5b6d4a0f34aa925701d8 as a part of -Sc) could actually be helpful in the 3.0 -> 3.1 transition, because all sync dbs will be left in /var/lib/pacman/, while the updated ones will go to /var/lib/pacman/sync/. So it'll now clean everything in /var/lib/pacman/, and only the unused databases in /var/lib/pacman/sync/ (with the exception of local/ and sync/ in both cases). Note: This feature is undocumented. I wonder if moving it to another option, something like -S --dbclean, wouldn't help for documenting it. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-04pacman/sync.c: mark sync_trans as staticDan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-01Unify dump_pkg_full in pacman [-Si, -Qip, -Qi and -Qii]Nagy Gabor1-3/+0
dump_pkg_sync is now a trivial wrapper for dump_pkg_full Some smaller changes: * string_display function added to util.c [prints None in case of empty string] * Filename field added to -Qip * rename License to Licenses * 'Compressed Size' used instead of 'Download Size' for -Qip Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> [Dan: fix whitespace errors, spacing issues, const modifiers] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25Add -q/--quiet option for controlling output.Artyom1-9/+19
Currently this only affects -Ss, -Sl, and -Q to output less information (only package names). In the future, we can reuse this flag for other things as well. [Aaron: rewritten as a front-end flag] Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com> [Dan: squashed commits together] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-25Fix several memleaks, mostly related to errors handling.Chantry Xavier1-1/+2
* 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-18Add the pmconflict_t type.Nagy Gabor1-3/+2
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-18Simple s/conflict/fileconflict/ renaming.Chantry Xavier1-9/+9
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-18Minor rephrasing of the question asked by -Sc.Chantry Xavier1-1/+1
Suggested by stonecrest on irc : 'I think "uninstalled" would be better, as it implies that the package was once installed and since removed. Otherwise a user might wonder why there are non-installed pkgs in cache' Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-18Extend the -Sc operation to also clean up unused sync databases.Chantry Xavier1-1/+73
We discussed this with stonecrest on IRC : 20:46 stonecrest >> someone brings up a good point.. why aren't repos that aren't in the pacman.conf removed from /var/lib/pacman? 20:46 stonecrest >> i have 118mb and 24 dirs in there, but only 5 repos at present 21:26 stonecrest >> shining: i guess you could prompt the user on deleting every dir in /var/lib/pacman.. since it shouldn't happen that often except for the first time 21:30 stonecrest >> could be part of pacman -Sc.. what else were you thinking? I already heard about this before, but it sounded dangerous to me. I didn't even think about a simple prompt. I also didn't know where this code would fit. And it fits well with -Sc, I borrowed most of the code from sync_cleancache. Example session : Cache directory: /var/cache/pacman/pkg/ Do you want to remove non-installed packages from cache? [Y/n] n Database directory: /var/lib/pacman/ Do you want to remove unused repositories? [Y/n] Do you want to remove /var/lib/pacman/sync/pacman-git? [Y/n] Do you want to remove /var/lib/pacman/sync/deltatest? [Y/n] Database directory cleaned up Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17pacman/sync.c : remove duplicated fallback on providers.Chantry Xavier1-20/+3
The fallback on providers when a target is not found was already made in the backend : libalpm/sync.c , _alpm_sync_addtarget . So I removed it from the frontend. The sync500 pactest proves this fallback still works correctly. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17Two memleak fixes in pacman.Nagy Gabor1-0/+1
Both memleak was an unfreed alpm_db_whatprovides list. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
2007-11-11Typo fix (sepArately)Aaron Griffin1-1/+1
Found by Giovanni Scafora <linuxmania@gmail.com> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-11-11Missing quote in outputAaron Griffin1-1/+1
Found by Giovanni Scafora <linuxmania@gmail.com> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-11-05Remove the newline automatically added by alpm_logaction.Chantry Xavier1-2/+2
This way, _alpm_logaction behaves like _alpm_log, and gives more control. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-04Clean up usage of extern variablesDan McGee1-1/+0
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-10-25Add alpm_dep_get_string methodNagy Gabor1-15/+3
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-23Fix broken or missing includesDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-20Add download size to target list.Nathan Jones1-1/+1
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-05Fix -Sy and -Sp operations.Chantry Xavier1-1/+2
When the -Sy operation failed, the lock wasn't removed because alpm_trans_release wasn't called. This is fixed now. Also, after my last change in commit 52e7e6d74733f7a431376a9e528c4fe4d3732068 , Sp didn't do anything anymore. That's because needs_transaction returned false for -Sp, so the sync transaction wasn't run. However, the current implementation of -Sp requires a sync transaction. Also, since a transaction creates the lock file at the beginning, and releases it at the end, this mean that -Sp requires root access anyway.. I think I understand now why Aaron found that the current -Sp implementation is hackish :) Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-10-04needs_transaction adjustmentsChantry Xavier1-50/+65
I just moved the root path check out of needs_transaction, and put it directly in pacman.c . I think this part is alright. For the other problems, I thought about doing the transaction first, in a new sync trans function, which will init and release a transaction. And then doing the commands like -Ss / -Sl / -Sg / -Si. The problem is that for commands like -Sys / -Syl / etc, only the refresh part of the transaction should be done. So I had to introduce an ugly sync_only hack. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-09-28Allow --refresh specified for most -S optionsAaron Griffin1-24/+27
Included options are -g, -i, -s, and -l All of these will sync the DB if -y is specified and permissions are appropriate. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-09-28Add 'full' parameter to alpm_pkg_loadDan McGee1-2/+3
In most cases, we want to fully scan a package when we load it, which serves as a integrity verification check. However, there are times when it is only desired to read the metadata and nothing else, so allow the caller of pkg_load to choose the behavior they need. This pays big dividends in speeding up pacman cache cleaning functionality. Old (729 packages): real 1m43.717s user 1m20.785s sys 0m2.993s New (729 packages): real 0m25.607s user 0m19.389s sys 0m0.543s Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28Reimplement pacman cache cleaning the right wayDan McGee1-5/+54
Partial cache cleaning was eliminated in a previous commit because it relied on package naming conventions. Re-add it the correct way- we actually open up each package in the cache and get a name and version out of it. If the name and version match that of an installed package, keep it. If the package is not installed or the version does not match the locally-installed version, get rid of it. This can easily be modified if some other heuristic of keeping and removing packages is desired, or if we should clean out the cache dir of any files that are not packages, etc. The biggest current problem with this new approach- speed. Here is one run on my local machine, going from 1643 to 729 packages in the cache (753 in the local DB): real 4m25.829s user 3m22.527s sys 0m6.713s This is likely best addressed by the package loading scheme, which may be loading the entirety of each package archive, which is a waste when we only need the .PKGINFO file read. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28Remove package name dependency from libalpmDan McGee1-114/+6
Previously, package names must match a specified scheme or they will cause pacman add operations to fail. This is not a very intelligent or necessary way to act, so remove the dependency on the name of the package to be installed and read all relevant information from the metadata instead. This does have one causality to be addressed later- pacman cache cleaning functionality, which has never been phenomenal, just lost most capability. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-12make alpm_strerror binding friendlyStefano Esposito1-10/+10
I'm currently working on python bindings for alpm written in pyrex. While working i found that declaring alpm_strerror as char * alpm_strerror (void) instead of char * alpm_strerror (int err) and then using pm_errno in the implementation instead of err, could make it more bindings-friendly. Dan: cleaned up and added void to declaration. Instead of replacing existing function, add a new function called 'alpm_strerrorlast(void)'. Signed-off-by: Stefano Esposito <stefano.esposito87@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-26pacman/sync.c : kill extra newline with groups on -Ss operation.Chantry Xavier1-1/+1
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-14Code cleanupDan McGee1-1/+0
Remove the commented desc_localized stuff, we can find it later in version control. Also remove some unnecessary includes of the stat header and use -fstack-protector-all which is a bit more broad. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-13pacman/sync.c : return 0 on succesful search, 1 otherwise.Chantry Xavier1-1/+4
Closes FS#7690. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-07-16new pmdepend_t / pmdepmissing_t accessors.Chantry Xavier1-8/+9
Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-15Add --asdeps option to pacmanDan McGee1-8/+3
This replaces the former -D operation that was undocumented and rather hacky. It can be used with add, upgrade, or sync transactions and will affect all packages installed. Should close FS #7193. Also tell makepkg to use this new flag. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-09Remove gettext from any alpm_logaction callsDan McGee1-2/+2
We shouldn't translate log messages to pacman.log so it is consistant and can be parsed by other tools. Remove all gettext _() around these strings. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-13Clean up pacman/sync.c and organize it a bitDan McGee1-10/+38
Re-add some checks for a valid target list. In addition, move variable declarations to the most local scope possible, which should help in finding errors that were previously uncaught. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-13Remove some more diskspace checking holdover stuffDan McGee1-10/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-11Ensure correct and consistent usage of depmissChantry Xavier1-2/+2
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-09Allow multiple CacheDirs to be specifiedDan McGee1-1/+3
This should hopefully allow multiple cache dirs to be specified in pacman.conf and/or on the command line, and allow pacman to test each one for the package file. The first one found to be writeable is used as the download cache. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Const correctness!Dan McGee1-1/+2
Add some 'const' keywords all over the code to make it a bit more strict on what you can and can't do with data. This is especially important when we return pointers to the pacman frontend- ideally this would always be untouchable data. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Rip alpm_parse_config out of libalpmDan McGee1-1/+1
Switch over to the new frontend parseconfig. * Fix a few issues in parseconfig * Remove unused callback upon database registration * Remove conf file related errors from error.c/alpm.h Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-04Remove hardcoded defines from libalpmDan McGee1-1/+1
Remove any use of the former path variables defined by the Makefiles or config.h. These are now runtime configurable only with pacman.conf (or by using flags on the command line). Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-02Move parts of pacman_query into subfunctions (query_search, query_group, ↵Chantry Xavier1-14/+13
query_isfile) Clean up pacman_query so functionality is actually in functions, similar to how sync.c is organized. After doing this, it is easy to see similarity in the code between sync.c and query.c, so we should be able to consolidate some of this. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-01Change -z|--showsize flag to ShowSize pacman.conf optionNathan Jones1-9/+6
Also cleaned up some duplicate printf lines related to the ShowSize option. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>