summaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2010-12-21Always specify arguement type in function delcarationsAllan McRae4-26/+26
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>
2010-12-21Use macros in sync DB parsingDan McGee1-99/+52
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>
2010-12-15Add a cushion for diskspace checkingDan McGee1-3/+8
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>
2010-12-15Reorganize fields in package structDan McGee1-13/+15
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>
2010-12-14Used hashed package name in _alpm_pkg_findDan McGee1-2/+13
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>
2010-12-14When setting package name, set hash value as wellDan McGee4-0/+4
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Add hash_sdbm functionDan McGee2-0/+22
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>
2010-12-14Use _alpm_pkg_find in deps searchDan McGee1-2/+2
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Correctly force load of package reasonDan McGee1-5/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Abstract has_scriptlet() to package ops structDan McGee3-14/+19
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Remove non-public functions from headerDan McGee3-7/+4
And rename accordingly. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Mark sync_db_read() as staticDan McGee2-3/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Abort db_populate if dbpath is not setBruno Widmann1-0/+3
Rather than segfault. Fixes FS#21345. Signed-off-by: Bruno Widmann <bruno.widmann@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Create sync/ DB directory if it does not existDan McGee1-0/+18
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>
2010-12-13Merge desc and depends files in local dbAllan McRae3-94/+61
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>
2010-12-13Attempt to stop installation when we encounter problemsDan McGee1-32/+48
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>
2010-12-13Turn libarchive warnings into libalpm warningsDan McGee2-3/+3
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>
2010-12-13Make reading from any file possible in sync DBDan McGee1-12/+8
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>
2010-12-13diskspace style cleanups and small fixesDan McGee2-50/+55
* 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>
2010-12-13Refactor statfs/statvfs type checkDan McGee2-41/+21
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>
2010-12-13Display progress bar for disk space checkingAllan McRae3-3/+27
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>
2010-12-13Add configuration option to control disk space checkingAllan McRae4-4/+24
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-12-13Implement disk space checkingAllan McRae3-1/+45
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>
2010-12-13Add functions to calculate approximate disk usage by packagesAllan McRae1-0/+100
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>
2010-12-13Add function to match file to mount pointAllan McRae1-0/+28
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>
2010-12-13Add function for listing system mount pointsAllan McRae2-0/+139
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>
2010-12-13Prototype disk space checking functionalityAllan McRae4-0/+66
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>
2010-12-13Remove AC_TYPE_SIGNAL usageDan McGee1-1/+1
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>
2010-12-13dirent usage cleanupDan McGee4-4/+1
We were including the header in a lot of places it is no longer used. Additionally, use the correct autoconf macro for determining whether d_type is available as a member: HAVE_STRUCT_DIRENT_D_TYPE. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Move MAX_DELTA_RATIO definitionAllan McRae2-3/+3
This is a delta specific definition so it makes more sense to put it in the delta specific header file. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Combine reading from depends and desc in sync dbAllan McRae1-7/+2
This will allow us to eventually combine the depends and desc entries within the sync database. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13alpm/remove.c : respect --dbonly during remove-upgradeXavier Chantry1-0/+5
When a -Sk or -Uk operation induced a removal of an existing local package, --dbonly was not in effect and the files were all removed. Fixing this behavior was already marked as TODO in database012 pactest ------------ TODO: I honestly think the above should NOT delete the original les, it hould upgrade the DB entry without touching anything on the file stem. E.g. this test should be the same as: pacman -R --dbonly dummy && pacman -U --dbonly dummy.pkg.tar.gz ------------ Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> [Dan: small coding style touchup] Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13alpm: don't expose alpm_depcmpXavier Chantry5-9/+9
Either we expose all low levels function dealing with pmdepend_t (splitdep and depfree come to mind), or we don't. Since none of the tools use depcmp, I chose to remove it. In the future, we might want to expose higher level functions such as alpm_find_satisfier, or just lower level functions like splitdep and depfree together with depcmp. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13alpm: kill alpm_deptestXavier Chantry2-26/+0
This has been replaced by the more flexible alpm_find_satisfier function, and alpm_deptest was completely unsused now. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13alpm: add new alpm_find_satisfier functionXavier Chantry2-0/+15
whatprovides and splitdep were removed, so depcmp alone is quite useless now without splitdep, and deptest is not flexible enough. Introduce a new alpm_find_satisfier which is hopefully more flexible, this should make implementation of deptest very easy, and also help alpm tools such as pactree. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Fix a few problems reported by clang-analyzerXavier Chantry2-9/+6
One missing NULL-check and 3 dead assignments. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13Merge branch 'maint'Dan McGee1-1/+1
Conflicts: lib/libalpm/be_local.c lib/libalpm/trans.c
2010-12-13be_files: write EPOCH instead of FORCEXavier Chantry1-3/+4
This patch is only meant for 3.4.x. It prepares the place for the future epoch-aware release. All force packages that get reinstalled or upgraded will get an EPOCH entry in the local database, and thus the new pacman with epoch won't reinstall them by mistake on the first -Su. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-11Fix possible null pointer deref in check_archDan McGee1-1/+1
If we have a corrupted database, a package can come through without an arch, causing the code to blow up when making strcmp() calls. It might even be possible with perfectly valid database entries lacking an 'arch =' line. This behavior was seen as at least one of the problems in FS#21668. Ensure pkgarch is not null before doing anything further. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-18Merge branch 'maint'Dan McGee2-1/+7
2010-10-18alpm/sync: very small memleak fixXavier Chantry1-1/+3
Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-18libalpm/remove: fix funny progress bar problem with empty packagesXavier Chantry1-0/+4
$ pacman -Rd kde-meta Remove (15): kde-meta-kdewebdev-4.5-1 [0.00 MB] kde-meta-kdeutils-4.5-1 [0.00 MB] kde-meta-kdetoys-4.5-1 [0.00 MB] kde-meta-kdesdk-4.5-1 [0.00 MB] kde-meta-kdeplasma-addons-4.5-1 [0.00 MB] kde-meta-kdepim-4.5-1 [0.00 MB] kde-meta-kdenetwork-4.5-1 [0.00 MB] kde-meta-kdemultimedia-4.5-1 [0.00 MB] kde-meta-kdegraphics-4.5-1 [0.00 MB] kde-meta-kdegames-4.5-1 [0.00 MB] kde-meta-kdeedu-4.5-1 [0.00 MB] kde-meta-kdebase-4.5-1 [0.00 MB] kde-meta-kdeartwork-4.5-1 [0.00 MB] kde-meta-kdeadmin-4.5-1 [0.00 MB] kde-meta-kdeaccessibility-4.5-1 [0.00 MB] Total Removed Size: 0.06 MB Do you want to remove these packages? [Y/n] ( 1/15) removing kde-meta-kdewebdev [------------------------] 100% $ it stopped here.. On one side, libalpm did not initialize the progress bar at 0 percent. So with meta-packages that have 0 files, there was only one progress bar call with percent == 100. On the other side, pacman callback kept track of the last percent that it received. When there are only meta-packages, we always received only 100, so pacman believed the progress bar needed not update. Thus only the first package was actually displayed. A proper fix for the callback would be to keep track of last package name to make sure the recorded prev percent applies. But since we now specify that both Add and Remove should at least send percent=0 at beginning and percent=100 at the end, there is no need for that. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-15be_package: read force entry and convert to epochXavier Chantry1-0/+5
We still need to read force entry in epoch-aware pacman, so that when we install an old force package, EPOCH gets written to the local db. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-14Add epoch support to pacman/libalpmDan McGee6-22/+47
This will allow for better control of what was previously the 'force' option in a PKGBUILD and transferred into the built package. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-14Small tweaks after backend mergeDan McGee3-19/+4
Just a few small things I noticed looking through the code. Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-14Only write to local reposAllan McRae1-53/+38
We do not write to sync repos so kill the code for that. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-14Clean-up parsing sync databaseAllan McRae1-26/+1
Remove unnecessary parsing of fields not found in sync desc file. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-14Clean-up parsing local databaseAllan McRae1-24/+3
Remove unnecessary parsing of fields not found in local desc files. Leave %FORCE% parsing as this likely will make an appearance in desc files in the future. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-14Remove lazy loading of deltasAllan McRae2-26/+3
Local packages do not have deltas so remove lazy loading of delta information. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-14Move and rename splitnameAllan McRae6-50/+49
The splitname function is a general utility function and so is better suited to util.h. Rename it to _alpm_splitname to indicate it is an internal libalpm function as was the case prior to splitting local and sync db handling. Signed-off-by: Allan McRae <allan@archlinux.org>