summaryrefslogtreecommitdiff
path: root/lib/libalpm
Commit message (Collapse)AuthorAge
* Ensure we use local package when calculating removed sizeDan McGee2011-01-10
| | | | | | | | | | | We were checking if a package existed locally, but then using the incoming package to calculate removed size rather than the currently installed package. Also adjust the local variable in the replaces loop to make it more clear that we are always dealing with local packages here. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove need for floating point division in backendDan McGee2011-01-10
| | | | | | | | | | | All of these can be done with integer division; the only slightly interesting part is ensuring we round up like before with calling the ceil() function. We can also remove the math library from requirements; now that the only ceil() calls are gone, we don't need this anymore. Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm/be_package.c: fix small memleakXavier Chantry2011-01-07
| | | | | | | | | | file_pkg_ops can be a static struct like in other backends, we just need to initialize it at some point. Dan: add initialization flag. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix some more simple conversion "errors"Dan McGee2011-01-07
| | | | | | | | None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
* Use size_t for alpm_list sizesAllan McRae2011-01-07
| | | | | | | | | | | | | There is a lot of swtiching between size_t and int for alpm_list sizes in the codebase. Start converting these to all be size_t by adjusting the return type of alpm_list_count and fixing all additional warnings given by -Wconversion that are generated by this change. Dan: a few more small changes to ensure things compile, adjusting some printf format string characters to accommodate the larger size on x86_64. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor old date parsing into single methodDan McGee2011-01-07
| | | | | | | We've managed to duplicate this four times at this point, so make it a method in util.c instead. Signed-off-by: Dan McGee <dan@archlinux.org>
* Update copyright years for 2011Allan McRae2011-01-07
| | | | | Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove FORCE reading from local DBDan McGee2011-01-05
| | | | | | We never wrote it here, so no need to read it in either. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix function indentationDan McGee2011-01-02
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2010-12-30
|\ | | | | | | | | | | Conflicts: lib/libalpm/sync.c test/pacman/tests/ignore007.py
| * Respect Ignore{Pkg,Group} for group membersJakob Gruber2010-12-30
| | | | | | | | | | | | Fixes FS#19854. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Move group code to separate functionJakob Gruber2010-12-30
| | | | | | | | | | | | | | This makes the following commits more readable. No logic was changed in this commit. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Declare all local functions staticAllan McRae2010-12-30
| | | | | | | | | | | | | | | | | | | | | | | | All functions that are limited to the local translation unit are declared static. This exposed that the _pkg_get_deltas declaration in be_local.c was being satified by the function in packages.c which when declared static caused linker failures. Fixes all warnings with -Wmissing-{declarations,prototypes}. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add const to some ALPM function signaturesJakob Gruber2010-12-30
| | | | | | | | | | | | char * -> const char *. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use limits.h for PATH_MAXAllan McRae2010-12-29
| | | | | | | | | | | | | | | | | | | | | | | | We use PATH_MAX everywhere by including limits.h so there is no point in doing a check for it in a different header when dealing with FreeBSD's libfetch. Also, remove autoconf check for strings.h header as it is not used anywhere. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Detect undefined PATH_MAXAllan McRae2010-12-29
| | | | | | | | | | | | | | | | | | | | | | | | | | POSIX does not require PATH_MAX be defined when there is not actual limit to its value. This affects HURD based systems. Work around this by defining PATH_MAX to 4096 (as on Linux) when this is not defined. Also, clean up inclusions of limits.h and remove autoconf check for this header as we do not use macro shields for its inclusion anyway. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Correct type for hash value storageAllan McRae2010-12-29
| | | | | | | | | | Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'depcmp-perf'Dan McGee2010-12-29
|\ \
| * | Use name hashes in depends to avoid strcmp callsDan McGee2010-12-21
| | | | | | | | | | | | | | | | | | | | | | | | Just like we did for package name comparsions, if we add a depend name_hash field on depend struct initialization, we can use it instead of doing a string name comparison, saving us a lot of checks in the depcmp code. Signed-off-by: Dan McGee <dan@archlinux.org>
| * | Remove need for memory allocation in _alpm_depcmpDan McGee2010-12-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Noticed when tweaking testdb, when we run _alpm_depcmp in loops and call it seven million times, the strdup()/free() combo can add up. Remove the need for any string duplication by some pointer manipulation and use of strncmp instead of strcmp. Also kill the function logger and add an escape so we don't needlessly retrieve the list of provides. Signed-off-by: Dan McGee <dan@archlinux.org>
* | | Overhaul archive fgets functionDan McGee2010-12-21
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The old function was written in a time before we relied on it for nearly every operation. Since then, we have switched to the archive backend and now fast parsing is a big deal. The former function made a per-character call to the libarchive archive_read_data() function, which resulted in some 21 million calls in a typical "load all sync dbs" operation. If we instead do some buffering of our own and read the blocks directly, and then find our newlines from there, we can cut out the multiple layers of overhead and go from archive to parsed data much quicker. Both users of the former function are switched over to the new signature, made easier by the macros now in place in the sync backend parsing code. Performance: for a `pacman -Su` (no upgrades available), _alpm_archive_fgets() goes from being 29% of the total time to 12% The time spent on the libarchive function being called dropped from 24% to 6%. This pushes _alpm_pkg_find back to the title of slowest low-level function. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Only check diskspace availability if needs more than zeroAllan McRae2010-12-20
| | | | | | | | | | | | | | | | | | | | The amount of diskspace needed for a transaction can be less than zero. Only test this against the available disk space if it is positive, which avoids a comparison being made between signed and unsigned types (-Wsign-compare). Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Always specify arguement type in function delcarationsAllan McRae2010-12-20
| | | | | | | | | | | | | | | | Always declare a function with (void) rather than () when we expect no arguements. Fixes all warnings with -Wstrict-prototypes. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use macros in sync DB parsingDan McGee2010-12-20
| | | | | | | | | | | | | | | | | | | | This simplifies a lot of the repetative code and makes it obvious where the tricky or different ones are (e.g. depends, dates). It also makes it significantly easier to change the way this code works in the future. There should be no functional change with this patch. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add a cushion for diskspace checkingDan McGee2010-12-15
| | | | | | | | | | | | It is the minimum of 5% of disk capacity or 20 MiB on a per-partition basis. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Reorganize fields in package structDan McGee2010-12-14
| | | | | | | | | | | | | | Saves a few bytes due to padding (256 -> 248 bytes), especially on x86_64, so we get the overhead of our new hash field right back. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Used hashed package name in _alpm_pkg_findDan McGee2010-12-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This results in huge gains to a lot of our codepaths since this is the most frequent method of random access to packages in a list. The gains are seen in both profiling and real life. $ pacman -Sii zvbi real: 0.41 sec -> 0.32 sec strcmp: 16,669,760 calls -> 473,942 calls _alpm_pkg_find: 52.73% -> 26.31% of time $ pacman -Su (no upgrades found) real: 0.40 sec -> 0.50 sec strcmp: 19,497,226 calls -> 524,097 calls _alpm_pkg_find: 52.36% -> 26.15% of time There is some minor risk with this patch, but most of it should be avoided by falling back to strcmp() if we encounter a package with a '0' hash value (which we should not via any existing code path). We also do a strcmp once hash values match to ensure against hash collisions. The risk left is that a package name is modified once it was originally set, but the hash value is left alone. That would probably result in a lot of other problems anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* | When setting package name, set hash value as wellDan McGee2010-12-14
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add hash_sdbm functionDan McGee2010-12-14
| | | | | | | | | | | | | | | | This is prepping for the addition of a hash field to each package to greatly speed up the string comparisons we frequently do on package name in _alpm_pkg_find. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use _alpm_pkg_find in deps searchDan McGee2010-12-14
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Correctly force load of package reasonDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Abstract has_scriptlet() to package ops structDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove non-public functions from headerDan McGee2010-12-13
| | | | | | | | | | | | And rename accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Mark sync_db_read() as staticDan McGee2010-12-13
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Abort db_populate if dbpath is not setBruno Widmann2010-12-13
| | | | | | | | | | | | | | Rather than segfault. Fixes FS#21345. Signed-off-by: Bruno Widmann <bruno.widmann@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Create sync/ DB directory if it does not existDan McGee2010-12-12
| | | | | | | | | | | | | | Rather than error out, this is easy enough. Looks quite similar to the code in be_local for creating the local directory. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge desc and depends files in local dbAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | Whenever depends is needed from the local db, so is desc. The only disadvantage to merging them is the additional time taken to read the depends entries when they are not needed. As depends is in general relatively small, the additional time taken to read it in will be negligable. Also, merging these files will speed up local database access due to less file seeks. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Attempt to stop installation when we encounter problemsDan McGee2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This should hopefully address some of the concerns raised in FS#11639 with regards to continuing after filling the disk up. Add some more checks and passing of error conditions between our functions. When a libarchive warning is encountered, check if it is due to lack of disk space and if so upgrade it to an error condition. A review of other libarchive warnings suggests that these are less critical and can remain as informative warning messages at this stage. Note the presence of errors after extraction of an entire package is complete. If so, we abort the transaction to be on the safe side and keep damage to a minimum. Signed-off-by: Dan McGee <dan@archlinux.org> [Allan: make ENOSPC warning into an error] Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Turn libarchive warnings into libalpm warningsDan McGee2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | Rather than hiding these warnings, show them to the user as they happen. This will prevent things such as hiding full filesystem errors (ENOSPC) from the user as seen in FS#11639. Signed-off-by: Dan McGee <dan@archlinux.org> [Allan: adjust warning wording and add gettext calls] Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Make reading from any file possible in sync DBDan McGee2010-12-12
| | | | | | | | | | | | | | | | Whether it be "desc", "depends", or "deltas", it really doesn't matter- treat them all the same and have the ability to read any data from any file in that list. This continues the work in a44c7b8956. Signed-off-by: Dan McGee <dan@archlinux.org>
* | diskspace style cleanups and small fixesDan McGee2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Use our normal return() function syntax * Rework a few things to reduce number of casts * Fix void function argument declaration * Add missing gettext _() call * Remove need for seperate malloc() of statvfs/statfs structure * Unify argument order of static functions- mountpoints now always passed first * Count all files that start with '.' in a package against the DB * Rename db to db_local in check_diskspace to clarify some code * Fix some line wrapping to respect 80 characters Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* | Refactor statfs/statvfs type checkDan McGee2010-12-12
| | | | | | | | | | | | | | | | | | | | | | Turn it into a configure-type typedef, which allows us to reduce the amount of duplicated code and clean up some #ifdef magic in the code itself. Adjust some of the other defined checks to look at the headers available rather than trying to pull in the right ones based on configure checks. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
* | Display progress bar for disk space checkingAllan McRae2010-12-12
| | | | | | | | | | | | | | | | Checking disk space needed for a transaction can take a while so add an informative progress bar. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add configuration option to control disk space checkingAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | 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>
* | Implement disk space checkingAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | Pull together the work of the previous commits to implement a check for enough free space before performing an install transaction. Abort if there is not enough free space with an appropriate pm_errno.. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add functions to calculate approximate disk usage by packagesAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Two helper function are added to calculate the disk usage from packages that are either currently installed on the system or from a package archive. Some minor approximations have been made: 1. Size for directories is not considered when removing a package from the filesystem to avoid multiple counting across packages. Also, these are reported to take zero size while installing. 2. Symlinks are reported to contribute zero size towards removal as libarchive reports them to have zero size for install. 3. Package data files (.PKGINFO, .INSTALL, .CHANGELOG) are counted towards usage on dbpath on install, but their size is not counted on package removal. 4. No handling of extra size needed for .pacsave/.pacnew files. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add function to match file to mount pointAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | | | | | | | For a given file, determine which mount point it is on or will be installed to. Take into account that we might be using an alternative installation root. Add additional helper function added to sort mount point list for easier matching. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add function for listing system mount pointsAllan McRae2010-12-12
| | | | | | | | | | | | | | | | | | | | | | Add a mount_point_list() function that attempts to portably obtain a list of system mount points and a struct to hold needed mount point information. Abort the transaction if we are unable to determine the mount points. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Prototype disk space checking functionalityAllan McRae2010-12-12
| | | | | | | | | | | | | | | | Very basic prototyping for adding functionality to check free disk space before performing package installs. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove AC_TYPE_SIGNAL usageDan McGee2010-12-12
| | | | | | | | | | | | | | | | | | This macro is deemed unnecessary by even the autoconf guys, so we really don't need to use it. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>