1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-08-13 17:03:46 -04:00
Commit Graph

3480 Commits

Author SHA1 Message Date
Dan McGee
735a197fc2 Use name hashes in depends to avoid strcmp calls
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>
2010-12-21 17:25:34 -06:00
Dan McGee
34a78d935a Remove need for memory allocation in _alpm_depcmp
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>
2010-12-21 17:25:02 -06:00
Dan McGee
e3c19569cf Add pactest to test long archive reads
This creates two packages with extremely long description lines (500KB and
600 KB), causing our archive read code to perform reallocation to store the
whole contents. One of the packages will successfully read while the other
will fail for the time being.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-21 14:58:17 -06:00
Dan McGee
fbcc427754 pactest: allow testing of package description
And modify the code to not print the full rule string if it is more than 40
characters long; truncate it instead.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-21 14:58:17 -06:00
Dan McGee
f2dff08600 Overhaul archive fgets function
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>
2010-12-21 14:58:17 -06:00
Dan McGee
126f50ab0b testdb: update for new database format
Sync DB's no longer have an extracted directory, so remove the files check
for those. Local databases no longer have a 'depends' file, so kill that
check as well. Finally, do a little other cleanup and remove the need for
PATH_MAX.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-20 19:54:33 -06:00
Allan McRae
c78a808c49 Only check diskspace availability if needs more than zero
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>
2010-12-20 18:03:34 -06:00
Allan McRae
a611879318 Always specify arguement type in function delcarations
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-20 18:03:21 -06:00
Allan McRae
5776090055 makepkg: remove last inappropriate PKGBUILD usage
We should always use $BUILDSCRIPT instead of PKGBUILD.  The only
remaining uses of PKGBUILD in makekg are in comments.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-20 18:03:01 -06:00
Dan McGee
8ac7f7e6e5 Use macros in sync DB parsing
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-20 18:02:47 -06:00
Dan McGee
45146dccbb Merge branch 'maint' 2010-12-15 00:41:59 -06:00
Dan McGee
ab9c0814d2 Add a cushion for diskspace checking
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-15 00:41:41 -06:00
Allan McRae
6605637b53 Document PKGEXT and SRCEXT
Add some basic documentation for the PKGEXT and SRCEXT options in
makepkg.conf.  Fixes FS#21302.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-15 00:36:16 -06:00
Dan McGee
c7d332a26a Reorganize fields in package struct
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-14 17:46:02 -06:00
Dan McGee
919bb6c9e0 Used hashed package name in _alpm_pkg_find
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-14 12:36:02 -06:00
Dan McGee
c2a73ba989 When setting package name, set hash value as well
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14 12:06:31 -06:00
Dan McGee
dbf59a6b14 Add hash_sdbm function
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-14 11:56:32 -06:00
Dan McGee
d1d163c5a3 Use _alpm_pkg_find in deps search
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14 11:50:50 -06:00
Dan McGee
ba45cb4590 doc/PKGBUILD: document that functions run in -e mode
Caught this noted on the forums, but it is definitely worth a note in the
manpage as well.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 22:36:10 -06:00
Dan McGee
c5f6995aeb Fix manpage wrap not at 80 characters
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 22:35:24 -06:00
Dan McGee
a5e43b1605 Correctly force load of package reason
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 21:25:14 -06:00
Dan McGee
580fe21065 Abstract has_scriptlet() to package ops struct
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 21:25:14 -06:00
Dan McGee
c00e05992e Remove non-public functions from header
And rename accordingly.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 21:16:47 -06:00
Dan McGee
94d3d665f0 Mark sync_db_read() as static
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13 21:14:03 -06:00
Bruno Widmann
5f36523af9 Abort db_populate if dbpath is not set
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-13 16:45:22 -06:00
Dan McGee
8f18798d10 Update news and bump versions
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 23:07:54 -06:00
Dan McGee
ed367fe96d Update scripts/ .gitignore
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 22:42:22 -06:00
Dan McGee
1ff8118212 Create sync/ DB directory if it does not exist
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-12 22:41:02 -06:00
Dan McGee
13a2847aa1 pacman-optimize: ensure database directory contains local/
And also default dbpath to the one we may find in pacman.conf.

Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 21:42:54 -06:00
Allan McRae
d98bacd4ec Add script to update pacman database format
The pacman-db-upgrade script was added to detect old pacman database
formats and upgrade them.

Currently performs the merging of depends files into desc files in
the local database.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 21:42:41 -06:00
Allan McRae
8f3b485517 Update pactest suite for change in db structure
Merging desc and depends files in sync and local db.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 21:42:41 -06:00
Allan McRae
21833d90e2 Merge desc and depends files in local db
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-12 21:42:41 -06:00
Dan McGee
209d0643e5 Attempt to stop installation when we encounter problems
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-12 21:42:41 -06:00
Dan McGee
b276a76dc9 Turn libarchive warnings into libalpm warnings
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-12 21:42:41 -06:00
Dan McGee
3030542d10 Make reading from any file possible in sync DB
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-12 20:38:20 -06:00
Allan McRae
9f96c5433a Explicitly test time difference is greater than zero
We are comparing a floating point number so should use an inequality
rather than implicitly testing != 0.

Prevents warning given by -Wfloat-equal.

Signed-off-by: Allan McRae <allan@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-12 20:32:32 -06:00
Allan McRae
ef977865a1 makepkg: perform sanity checks on variables in package functions
Check the over-ridden entries for provides, backup, optdepends and
options for illegal entries.  Partially fixes FS#16004.

Signed-off-by: Allan McRae <allan@archlinux.org>
2010-12-12 20:32:13 -06:00
Dan McGee
b7015af0fc diskspace style cleanups and small fixes
* 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-12 20:32:05 -06:00
Dan McGee
ec136784d4 Refactor statfs/statvfs type check
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-12 20:31:51 -06:00
Allan McRae
24684a616e Display progress bar for disk space checking
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-12 20:30:11 -06:00
Allan McRae
e22aa23c8f Add configuration option to control disk space checking
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-12 20:30:05 -06:00
Allan McRae
3f0d98c124 Implement disk space checking
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-12 20:29:59 -06:00
Allan McRae
e527699ddd Add functions to calculate approximate disk usage by packages
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-12 20:29:54 -06:00
Allan McRae
695656d252 Add function to match file to mount point
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-12 20:29:49 -06:00
Allan McRae
f4e9deb6d7 Add function for listing system mount points
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-12 20:29:43 -06:00
Allan McRae
adb10c3ab2 Prototype disk space checking functionality
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-12 20:29:37 -06:00
Dan McGee
f0051a7678 Remove AC_TYPE_SIGNAL usage
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-12 20:29:30 -06:00
Dan McGee
fc74ef93b6 dirent usage cleanup
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-12 20:29:20 -06:00
Allan McRae
8e9a69e8f6 Move MAX_DELTA_RATIO definition
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-12 20:29:05 -06:00
Allan McRae
a44c7b8956 Combine reading from depends and desc in sync db
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-12 20:25:35 -06:00