summaryrefslogtreecommitdiff
path: root/src/pacman/sync.c
Commit message (Collapse)AuthorAge
* Add SyncFirst option.Chantry Xavier2008-05-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch offers a way to fix FS#9228. By putting "SyncFirst = pacman" in pacman.conf, the version check will happen before the transaction really starts, and before any replacements is made. Otherwise, no version check is done. The sync301 pactest was updated to use this SyncFirst option. Example session with SyncFirst = pacman, and a newer pacman version available : $ pacman -Su (or pacman -S <any targets>) :: the following packages should be upgraded first : pacman :: Do you want to cancel the current operation :: and upgrade these packages now? [Y/n] resolving dependencies... looking for inter-conflicts... Targets: pacman-x.y.z-t Total Download Size: x.xx MB Total Installed Size: x.xx MB Proceed with installation? [Y/n] n As Nagy previously noted, doing this check on any -S operations might look intrusive, but it can be required. For example, the case where you want to install a package with versioned provisions, using a pacman version which didn't support that feature yet (and there is already a newer pacman in sync db supporting it). Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Cleanup usages of alpm_list_find and alpm_list_remove.Chantry Xavier2008-05-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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>
* Make all error messages use pm_fprintfAllan McRae2008-05-11
| | | | | | | | | | Tested using many easily generated error conditions. Also added "malloc failure" (conf.c) and "segmentation fault" (pacman.c) error messages for translation. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> [Dan: fix trailing whitespace errors, other compilation issues] Signed-off-by: Dan McGee <dan@archlinux.org>
* pacman-side code cleanupsDan McGee2008-05-08
| | | | | | | When taking a look at PATH_MAX usage, I found a few small things we can clean up or fix. Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor the trans init and release code.Chantry Xavier2008-04-26
| | | | | | | | | | | | | The calls to alpm_trans_init and alpm_trans_release (+ error checking) were duplicated between remove.c, sync.c and upgrade.c This patch introduces trans_init and trans_release functions in util.c to have this code just once. So instead of having to do the same change 3 times for fixing FS#10273, I just had to do it once (so I did it too :)) Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove libdownload reference from pacman frontendDan McGee2008-04-06
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Enable display of multiple groups in -Ss and -Qs outputDan McGee2008-03-30
| | | | | | | Not too complicated of a fix, but just adds some code to loop over the entire group list and space it out. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix segfault on -Qs usageDan McGee2008-03-30
| | | | | | | | | | | This segfault creeped in as a result of commit bf867003. We were incorrectly assuming the group member of our package was a pmgrp_t list when in fact it is just a string list, which caused a segfault on any -Qs operation. Also slightly cleanup the -Ss code (which was originally correct unlike the -Qs code). Signed-off-by: Dan McGee <dan@archlinux.org>
* Switch pmgrp_t to dynamic allocation, general group cleanupDan McGee2008-03-23
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Add new CleanMethod option.Chantry Xavier2008-03-23
| | | | | | | | | | | | | | | | As it was already mentioned several times, the new -Sc behavior in 3.1 is great, but only when the package cache is not shared. This option has two possible values : KeepInstalled and KeepCurrent With KeepCurrent, -Sc will clean packages that are no longer available in any sync db, rather than packages that are no longer in the local db. The resulting behavior should be better for shared cache. Ref : http://www.archlinux.org/pipermail/pacman-dev/2008-February/011140.html Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm: clean up of md5sum functions.Chantry Xavier2008-02-27
| | | | | | | | | 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>
* Improve yesno function.Chantry Xavier2008-02-24
| | | | | | | | | | | | | | | | | | | Add a preset paramater to yesno function saying which answer should be the default. Ref: http://www.archlinux.org/pipermail/pacman-dev/2007-June/008470.html This allows us to answer no by default to some questions, like the -Scc one mentioned in the above thread, and implemented by this patch. Another advantage is that we don't have to repeat the [Y/n] in every questions. It's only put once in yesno function. This highly reduces the chances that YES and NO strings are translated, but not some questions, which lead to obvious confusions. Finally, the noconfirm variable only needs to be used in that yesno function. So all other usages of it were removed. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Move -Sy operation into its own transactionChantry Xavier2008-02-20
| | | | | | | | | | | | | This allows us to remove the sync_only flag, and also do the following steps in the future : 1) refresh the database (if asked) 2) do other stuff (eg checking if a newer pacman version is available) 3) start the actual transaction Currently when we detect a newer pacman version, we have to release the current transaction and start a new one. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Lock the database on -Sc operation.Chantry Xavier2008-02-19
| | | | | | | | | | 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>
* Add new sync_trans_init and sync_trans_release.Chantry Xavier2008-02-19
| | | | | | | | 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>
* When cleaning DBs, only look at directoriesDan McGee2008-02-19
| | | | | | | | | | 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>
* Clarify the "failed to add target" errors.Chantry Xavier2008-02-02
| | | | | | | | | | | | 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>
* Clarify the "cancel current operation" message.Chantry Xavier2008-01-27
| | | | | | | | 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>
* Move the fallback on providers from backend to frontend.Chantry Xavier2008-01-09
| | | | | | | | | | | 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.
* Check ignored packages in _alpm_sync_addtarget().Nathan Jones2007-12-21
| | | | | | | | 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>
* Only query pacman upgrade when performing actual upgradeAllan McRae2007-12-17
| | | | | | | | 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>
* Update GNU GPL boilerplate and copyright datesDan McGee2007-12-10
| | | | | | | 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>
* src/pacman/: use the FREELIST macro when possible.Chantry Xavier2007-12-08
| | | | | Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* pacman/sync.c : improve the sync db cleanup feature.Chantry Xavier2007-12-05
| | | | | | | | | | | | | | | | 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>
* pacman/sync.c: mark sync_trans as staticDan McGee2007-12-03
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Unify dump_pkg_full in pacman [-Si, -Qip, -Qi and -Qii]Nagy Gabor2007-12-01
| | | | | | | | | | | | | 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>
* Add -q/--quiet option for controlling output.Artyom2007-11-25
| | | | | | | | | | | | 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>
* Fix several memleaks, mostly related to errors handling.Chantry Xavier2007-11-25
| | | | | | | | | | | | | | | | | | | | | | | * 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>
* Add the pmconflict_t type.Nagy Gabor2007-11-18
| | | | | | | | | | | | | | | | | | 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>
* Simple s/conflict/fileconflict/ renaming.Chantry Xavier2007-11-18
| | | | | | | | | | | | | | | | | | | | 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>
* Minor rephrasing of the question asked by -Sc.Chantry Xavier2007-11-18
| | | | | | | | | 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>
* Extend the -Sc operation to also clean up unused sync databases.Chantry Xavier2007-11-18
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* pacman/sync.c : remove duplicated fallback on providers.Chantry Xavier2007-11-17
| | | | | | | | | | | 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>
* Two memleak fixes in pacman.Nagy Gabor2007-11-17
| | | | | | Both memleak was an unfreed alpm_db_whatprovides list. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu>
* Typo fix (sepArately)Aaron Griffin2007-11-11
| | | | | | Found by Giovanni Scafora <linuxmania@gmail.com> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
* Missing quote in outputAaron Griffin2007-11-11
| | | | | | Found by Giovanni Scafora <linuxmania@gmail.com> Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
* Remove the newline automatically added by alpm_logaction.Chantry Xavier2007-11-04
| | | | | | This way, _alpm_logaction behaves like _alpm_log, and gives more control. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Clean up usage of extern variablesDan McGee2007-11-04
| | | | | | | | 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>
* Add alpm_dep_get_string methodNagy Gabor2007-10-25
| | | | | | | | 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>
* Fix broken or missing includesDan McGee2007-10-22
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Add download size to target list.Nathan Jones2007-10-19
| | | | | | | | | | 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>
* Fix -Sy and -Sp operations.Chantry Xavier2007-10-04
| | | | | | | | | | | | | | | | | | 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>
* needs_transaction adjustmentsChantry Xavier2007-10-03
| | | | | | | | | | | | | | | 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>
* Allow --refresh specified for most -S optionsAaron Griffin2007-09-28
| | | | | | | | 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>
* Add 'full' parameter to alpm_pkg_loadDan McGee2007-09-28
| | | | | | | | | | | | | | | | | | | 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>
* Reimplement pacman cache cleaning the right wayDan McGee2007-09-28
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove package name dependency from libalpmDan McGee2007-09-28
| | | | | | | | | | | | 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>
* make alpm_strerror binding friendlyStefano Esposito2007-09-11
| | | | | | | | | | | | | | | | | 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>
* pacman/sync.c : kill extra newline with groups on -Ss operation.Chantry Xavier2007-08-26
| | | | Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Code cleanupDan McGee2007-08-14
| | | | | | | | 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>