summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/handle.c
AgeCommit message (Collapse)AuthorFilesLines
2011-03-29Merge branch 'maint'Dan McGee1-0/+23
2011-03-29alpm/handle.c: ensure handle is not NULL before proceedingRémy Oudompheng1-0/+23
Many alpm_option_get/set_*() functions already check this and set pm_errno to the right value, but not all, so this improves consistency. Signed-off-by: Rémy Oudompheng <remy@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23Add signature directory as option on libalpm handleDan McGee1-0/+28
This will serve as the home directory we pass to GPGME when making calls so we can have a libalpm-utilized keyring. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21Style change: return(x) --> return xDan McGee1-22/+22
This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-09handle: Add CURL* and CURLcode vars to structDave Reisner1-0/+6
Adding the CURLcode is necessary in order to return an error string from pm_error. Unlike libfetch, curl returns numerical error numbers and does not maintain a staticly allocated string with the last error generated. Adding the curl object itself to the handle is advantageous (and encouraged by curl_easy_perform(3)) because the handle is reusable for successive operations. This cuts back on overhead when downloading multiple files in a single transaction. Signed-off-by: Dave Reisner <d@falconindy.com>
2011-02-27Fix double close of the lock fileJonathan Conder1-1/+0
According to FOPEN(3), using fclose on an fdopen'd file stream also closes the underlying file descriptor. This happened in _alpm_lckmk (util.c), which meant that when alpm_trans_release closed it again, the log file (which reused the original file descriptor) was closed instead. Signed-off-by: Jonathan Conder <jonno.conder@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-08Update copyright years for 2011Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Add configuration option to control disk space checkingAllan McRae1-0/+14
Disk space checking is likely to be an unnecessary bottleneck to people with reasonable partition sizes so add a configuration option to allow it to be disabled/enabled as wanted. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-03-15Bump copyright dates to 2010Dan McGee1-1/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11Add missing get_usedelta() methodDan McGee1-0/+9
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-10-11int typing: s/unsigned short/int/ in libalpmDan McGee1-3/+3
After our recent screwup with size_t and ssize_t in the download code, I found the `-Wsign-conversion` flag to GCC to see if we were doing anything else boneheaded. I didn't find anything quite as bad, but we did have some goofups- most of our public unsigned methods would return -1 on error, which is a bit odd in an unsigned context. Signed-off-by: Dan McGee <dan@archlinux.org>
2009-09-06Add Architecture and --arch optionXavier Chantry1-0/+16
Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-08-19dload.c : various fixesXavier Chantry1-14/+0
- fix one memleak if get_filename failed - cleanup according to Joerg's feedback: "url_for_string: If fetchParseURL returned successful, you should always have a scheme set. The logic for anonftp should only be needed for very broken server -- do you know of any such? download_internal: Specifying 'p' is now a nop -- it is tried by default first with fall-back to active FTP." Signed-off-by: Xavier Chantry <shiningxc@gmail.com> [Dan: remove from pacman.conf and pacman.conf.5] Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-23Add a fetch callback to allow front-end download supportSebastian Nowicki1-16/+18
This allows a frontend to define its own download algorithm so that the libfetch dependency can be omitted without using an external process. The callback will be used when if it is defined, otherwise the old behavior applies. Signed-off-by: Sebastian Nowicki <sebnow@gmail.com> [Dan: minor cleanups] Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-20Fix 2 minor memleaksXavier Chantry1-0/+1
Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2009-07-01Update copyright headers and messagesDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2009-01-13HoldPkg reworkNagy Gabor1-32/+0
The HoldPkg feature is even more important when the packages to be held are pulled automatically by pacman, in a -Rc and -Rs operation. Before, it only applied when the packages were explicitly requested by the user to be removed. This patch extends holdpkg to -Rc and -Rs by doing the HoldPkg check just before trans_commit. Additionally, the whole HoldPkg stuff was moved to the front-end. I changed the default behavior to "don't remove", so I modified remove030.py pactest as well. See also: FS#9173. Original-work-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-09-03Remove unnecessary initialization in new functionsDan McGee1-9/+0
We don't need to zero things out, we are already using calloc for this purpose. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-06-04Reimplement TotalDownload functionalityDan McGee1-0/+18
Add a new totaldlcb callback function to libalpm and make pacman utilize it when the TotalDownload option is enabled. This callback function is pretty simple- it is meant to be called once at the beginning of a "list download" action, and once at the end (with value 0 to indicate the list has been finished). The frontend is responsible for keeping track of adding individual file download amounts to the total xfered amount in order to display some sort of overall progress. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-29Tidy up of the handle struct in libalpmAllan McRae1-3/+0
Removed unused handle->uid from pmhandle_t. The need to check permissions should be determined by the frontend (and is in pacman). Fixed comment on noextract in pmhandle_t. Signed-off-by: Allan McRae <mcrae_allan@hotmail.com> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-13Cleanup usages of alpm_list_find and alpm_list_remove.Chantry Xavier1-18/+12
* 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-04-07Remove unnecessary header file, move one macro to util.cDan McGee1-1/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-02Merge branch 'maint'Dan McGee1-0/+1
Conflicts: configure.ac contrib/Makefile.am
2008-04-02Set handle->logstream to null after fclose()Dan McGee1-0/+1
We correctly closed the logfile stream when recalling set_logfile, but did not NULL out the dead pointer once we did this. Fix the problem which was the cause of FS#10056. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-02-25Remove pmserver_t abstractionDan McGee1-1/+0
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-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-08Remove upgradedelay and all code associated with itDan McGee1-14/+0
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-06Don't stat cachedir immediatelyDan McGee1-5/+3
By attempting to stat the cachedir when we load the pacman config, pacman bails out if it is a non-existant directory, even if it will never be needed. This is unfortunate as it is only used for sync transactions anyway. Instead, wait until we need it in _alpm_filecache_setup to actually do anything. Reported as FS#9096. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-29Add remove counterparts to alpm_option_add_* functionsAllan McRae1-0/+83
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-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-11-17War on whitespaceDan McGee1-3/+3
Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11Add IgnoreGroup and --ignoregroup option.Nathan Jones1-0/+21
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-04libalpm: open the logstream on demandDan McGee1-23/+6
Don't open a stream to the logfile until necessary. This will allow us to catch any errors in opening the logfile instead of ignorning them. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-04Clean up usage of extern variablesDan McGee1-0/+3
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-30libalpm/handle.c: make realpath() call portableDan McGee1-4/+3
BSD didn't support the NULL second argument GNU extension, so do it the old fashioned way. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29libalpm: introduce MALLOC and CALLOC macrosDan McGee1-6/+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-20Download delta files if UseDelta is set.Nathan Jones1-0/+6
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-09-18Avoid segfaults whet calling alpm_option_get_* before initializationStefano Esposito1-19/+164
When calling a function of the alpm_option_get_* group, you get a segfault if you don't call alpm_initialize() first. With this patch those functions set pm_errno to PM_ERR_HANDLE_NULL and return an error value if handle == NULL. (Dan: modified to meet pacman coding standards) Signed-off-by: Stefano Esposito <stefano.esposito87@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-24libalpm: add newlines to all strings passed to log callbackDan McGee1-7/+7
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-59/+123
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-07-10Fix issue with <dbpath>/db.lck being truncatedDan McGee1-2/+2
snprintf takes a length including the '\0' character, this wasn't accounted for originally. Fix it. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-10Remove gettext calls from all PM_LOG_DEBUG messagesDan McGee1-1/+4
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-09Clean up the alpm handleDan McGee1-30/+9
Add some comments in handle.h, and remove the pmaccess_t part that we don't even use. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-28Remove lockfile configuration from frontend, make it job of libalpmDan McGee1-10/+7
I previously introduced some patches to make just about every path in pacman/libalpm configurable; doing this with the lockfile seemed a bit too far and we really should just place the lockfile where it belongs- with the DB that needs locking. More details in this thread: http://archlinux.org/pipermail/pacman-dev/2007-June/008499.html Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-09Allow multiple CacheDirs to be specifiedDan McGee1-8/+16
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-09Remove logmask stuff from backend; switch logging callback to new pm_printfDan McGee1-8/+8
Remove the logmask functionality from the backend as it has been moved to the frontend, and change the logging callback function to use pm_printf. In addition, make much better use of va_list- use the args list instead of a arbitrarily chosen string to print to in the logging functions. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Const correctness!Dan McGee1-4/+5
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-18/+0
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-05Add a parseconfig to the pacman frontend that compilesDan McGee1-25/+28
Warning: this compiles but may not work as intended quite yet. :) Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-04Remove hardcoded defines from libalpmDan McGee1-5/+5
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>