summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/cache.c
AgeCommit message (Collapse)AuthorFilesLines
2008-10-12Remove unnecessary unistd.h header inclusionDan McGee1-1/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-07-15_alpm_db_add_pkgincache reworkNagy Gabor1-2/+20
Commit 8240da6cb3ff95ad480efe3e1876104024398fae broke some alpm hierarchy and introduced a new memleak (trans->packages was never freed in case of add transaction, even if the transaction wasn't committed), so it is reverted now. We follow a different approach to reduce memory usage: _alpm_db_add_pkgincache doesn't duplicate the whole package before adding it to the cache, only the package name and version (INFRQ_BASE). This method needs very small extra memory (compared to the reverted method), and after transaction commit we use less memory than before (since the big 'files' fields are not copied to cache), this is useful in GUIs. Note: The old add_pkgincache was a bit broken, since pkg->origin wasn't filled in correctly. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Acked-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-13Fix rewinddir regression by cleaning up db_scanXavier Chantry1-15/+5
Commit 046003844739416ff6d168dd2dec76490adb0727 caused a regression when rereading the pkgcache after updating the on-disk databases. A rewinddir call was errantly removed. Instead of replacing the call to rewindir, clean up this whole mess. db_scan is used only once and with target == NULL so there was actually half the code of db_scan which was unused. This is gone now and replaced by a single new db_populate function. Dan: add_sorted ended up being 3x slower than one msort at the end, so I changed back to that. I also made one pointer variable const and merged this whole patch with my original fix for the rewinddir issue. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-13Swap the parameters of alpm_pkg_findNagy Gabor1-1/+1
Now the syntax is coherent with alpm_list_find and alpm_sync_find. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-05-11Remove some useless abstraction and start db cleanupDan McGee1-1/+0
We have some useless abstractions like an alpm_db_rewind function. I've read somewhere that readdir() was the worst filesystem function call invented, and what do we do? Add a wrapper around it. Kill this abstraction and move some other things into be_files that should be there anyway because they are so tied to how a files backend works. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-04-06Remove unnecessary header file, move one macro to util.cDan McGee1-1/+0
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-03-23Switch pmgrp_t to dynamic allocation, general group cleanupDan McGee1-29/+21
Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-23libalpm/cache.c : don't duplicate packages in pkgcache.Chantry Xavier1-12/+3
Edit _alpm_db_add_pkgincache to not duplicate packages, because this is not needed, is slower, and uses more memory. This made the max memory usage during base reinstall go from 10.4MB to 9.7MB. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-01Remove gettext calls from debug-level messagesDan McGee1-1/+1
These used FUNCTION output level and not DEBUG, so I didn't catch them way back when I removed those gettext calls. Remove them now (which exposed a nice little memory access error elsewhere in the code). This should have a slight speedup effect on the code too as we no longer have to make the gettext call even when these messages aren't printed. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-10Update 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-16War 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-08-23libalpm: add newlines to all strings passed to log callbackDan McGee1-9/+9
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-21Various valgrind mem leak fixesDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-14package.h: implement origin_data union in pmpkg_t structDan McGee1-1/+1
We were using a void *data element in pmpkg_t before, which is unsafe by its nature of being untyped. Reimplement data as origin_data being a union that can hold either a path to a package file or a pointer to a cache database, and make the other necesary updates in the code to reflect this. See package.h for details. Signed-off-by: Dan McGee <dan@archlinux.org>
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-07-10Remove gettext calls from all PM_LOG_DEBUG messagesDan McGee1-8/+10
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-06-05Const correctness!Dan McGee1-1/+1
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-04-28Remove FREELISTPTR macroDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-28Remove FREEPKG macro and correctly type _alpm_pkg_freeDan McGee1-2/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-27Remove FREEGRP macro and correctly type _alpm_grp_freeDan McGee1-1/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-04-26Clean up gettext on the libalpm sideDan McGee1-1/+0
Remove inclusion of libintl.h from all files, because we can do it once in util.c where the _() macro is defined. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-03-11* Fix group comparison issue and associated compilation warnings by usingDan McGee1-3/+5
the alpm strcmp operation which takes void* references. * We had this great visibility patch, but never actually took advantage of it. Added the right compile flag to make it work and added some more SYMEXPORTs where necessary to have a successful compile.
2007-03-09fixed string comparison callback (patch from Nagy Gabor)Jürgen Hötzel1-2/+2
2007-03-05This commit looks much more monumental than it is. Almost all just #includeDan McGee1-3/+5
reordering and adding ones that were forgotten (noticed when trying to compile after reordering). * Updated the HACKING file to include information on #include usage. * print -> vprint in "making dir" function in pactest.
2007-03-03Big commit this time:Aaron Griffin1-50/+32
* Moved entirely to alpm_pkg_get_* accessors, to read data on demand * Mostly removed the INFRQ_ parameters from outside the be_files backend (making the backend more extensible in the long run) * packages created from _alpm_db_scan now have the db and origin set (making accessors actually work for these packages) * removed _alpm_db_ensure_pkgcache * totally revamped the _alpm_checkconflicts function, making it cleaner and easier to read (and thus fix in the long run) - maintainable code ftw NOTE: feel free to rename the functions... I couldn't think of anything better * removed an extra loop in sync.c:find_replacements - no sense in looping over an entire DB while strcmp'ing the name, when we have get_pkgfromcache Other: * package struct "license" -> "licenses" * Created _alpm_sync_find (duplicate code in some places, find_pkginsync * Minor const correctness changes along the way * fixed a couple extra '/' pathing issues (non-issues really) * removed a duplicate pkg_cmp function
2007-03-01* Modified values of INFRQ_* options so we start at 0x01 and not 0x00. ThisDan McGee1-2/+2
allows for the same bit operators to be used across the board on pkg_get operations. * Changed name of INFRQ_NONE -> INFRQ_BASE to more clearly reflect what it does (loads pkg name and version). * Added a few missing things on package functions, such as SYMEXPORT and ALPM_LOG_FUNC. * Slight updates to pmenv to print 'pass' and 'fail' instead of 'passed' and 'failed'. Keeps output a bit more concise. * Fixed a doxygen comment spelling error. :P
2007-02-26* Enforce const char* params when using stringsAaron Griffin1-3/+3
* Unified some functions names "package" -> "pkg" for consistency * Removed the goofy 'faketarget' stuff used for dep testing * Renamed alpm_pkg_isin -> alpm_pkg_find * Renamed alpm_db_readpkg -> alpm_db_get_pkg
2007-02-22* debug cleanup (more)Aaron Griffin1-2/+2
* Fixed conflict checking. I had mistakenly assumed that the transaction packages were of type 'pmsyncpkg_t', but that is not the case. Reverted back to pmpkg_t's and fixed some checking a bit. * pactest results: PASSED = 71 (100.00%)
2007-02-22* Cleaned up some debug outputAaron Griffin1-2/+8
* Fixed a segfault in the conflict checking code * Added an automatic failure in the case of -A/-U for a replacement of an existing package. This requires a large amount of work and is postponed for now. Example: If ncmpc is installed, pacman -U /path/to/ncmpc-svn.pkg.tar.gz will fail with and appropriate error message
2007-02-21* Fixed inconsistency of args- _alpm_db_read, _alpm_db_write.Dan McGee1-1/+1
2007-02-21* Re-added a compare function for syncpkg's - it was removed without thinkingAaron Griffin1-0/+4
properly * Error when re-reading the DB for replacements, wrong info level * Removed an duplicate debug message "checking for package replacements" * Check ignorepkg for REAL upgrades... * Properly check the NOSAVE flag * some unlink_file (remove.c) cleanup * fix indent level on handle.c * Force libalpm paths to end with a '/' char * Fixed 'target' looping in conflict.c (pmsyncpkg_t, not pmpkg_t) * Added some debug output to cache and db scanning ** All pactest tests succeed again, yay **
2007-01-31Fix corrupt DB entry handling when loading package entries.Aaron Griffin1-3/+2
* scan loops no longer abort on corrupt entries * reloading a cache package (and discovering it corrupt) no longer prints 2 messages and uses the pre-build "remove from package cache" function NOTE: The TODOs in there are important for later w.r.t. cleaning up corrupt DB entries but there are some logical complexities with doing so, so I'm holding off for now.
2007-01-30K. Piche <kevin.piche@cgi.com>Aaron Griffin1-0/+22
* ALPM_LOG_FUNCTION macro and all the great work to add this macro everywhere
2007-01-30Discussed on IRC for a bit, this makes the following changes for clarity:Dan McGee1-2/+2
* alpm_list_is_in --> alpm_list_find * alpm_list_is_strin --> alpm_list_find_str * Flip parameters of both functions to be inline with rest of alpm_list. First commit, woohoo.
2007-01-24* Shuffled some of the alpm_list free funtions - still not perfect, but betterAaron Griffin1-2/+7
* Added alpm_list_remove_node for single list node removal * Proper error checking/output for failed db_read/db_write (missing files) * Invalid packages (missing files) are now removed from the package cache * -Qs and -Ss output now look the same * config.rpath causes errors on one machine I had, so I added it to CVS * Fixed a "clobbered memory" issue when installing groups - only the outer list should be free'd, not the contained data
2007-01-24This mainly deals with code clarity- removing currently unneededAaron Griffin1-4/+4
optimizations in order to make the code much more readable and type-checkable. Every enum in the library now has it's own type that should be used instead of the generic 'unsigned char'. In addition, several #define statements dealing with constants were converted to enums. Signed-off-by: Dan McGee <dpmcgee@gmail.com>
2007-01-19Preliminary checkin for alpm_list conversionAaron Griffin1-18/+18
* renamed pmlist_t -> alpm_list_t * made alpm_list_t a public type (alpm_list.h header) * removed additional storage for registered DBs in pacman source * some code cleanup * removed duplicate (pm)list_display functions from pacman source * misc code cleanup
2007-01-11* Jürgen Hötzel <juergen@hoetzel.info>Aaron Griffin1-1/+4
_alpm_db_load_pkgcache: use mergesort to improve performance
2006-11-01Fixed pacman -U:Aaron Griffin1-1/+1
* Accidental database read of a file-based package (whoops) * Proper fetching of url-based -U or -A Removed some newlines from _alpm_log calls, to make debug output more concise
2006-10-31Numerous changes:Aaron Griffin1-12/+35
* Furthered the "lazy caching" to force the pkgcache to read nothing (INFRQ_NONE) by default. Anything requiring package data should now check the infolevel of each package and attempt to update it. This could be ironed out a bit more later (by using the front-end get_info function * Switched to libfetch. Drastic changes to the download code and the callback progress bar functions. Also fixed the return value of _alpm_downloadfiles_forreal. Downloading now supports http, ftp, https, and files urls, along with 'mtime's and numerous other fancy features from libfetch.
2006-10-20A handful of minor changes:Aaron Griffin1-7/+7
* Removed the PMList typedef, in favor of the same naming scheme other structs use 'pmlist_t' * Added a time stamp on debug output, to make it more informational * Moved alpm_db_register to _alpm_db_register, making the public function not take a callback parameter
2006-05-15first stage of i18n stuff from VMiklosJudd Vinet1-5/+6
2006-03-08all _alpm_XXX_cmp functions are now publicAurelien Foret1-10/+3
2006-03-07fixed a commentaryAurelien Foret1-1/+0
2006-03-07code cleanupAurelien Foret1-2/+2
2006-03-04make cache works when loading it with DEPENDS info onlyAurelien Foret1-0/+4
2006-02-17prepend library function names with _alpm (helped with the patch from ↵Aurelien Foret1-30/+30
VMiklos <vmiklos@frugalware.org>) added log and event callbacks to sync_commit internal transactions
2006-01-18more code cleanup yetAurelien Foret1-12/+2
2006-01-16more code cleanupAurelien Foret1-2/+2
2006-01-02code cleanupAurelien Foret1-1/+0