summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAge
* Merge branch 'maint'Dan McGee2012-02-06
|\ | | | | | | | | Conflicts: lib/libalpm/alpm_list.c
| * Update translations from TransifexDan McGee2012-02-06
| | | | | | | | | | | | | | The pacman-scripts catalog is omitted here due to various newline errors I don't have the time to fix right now. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Fix rare segfault on package removalAllan McRae2012-01-31
| | | | | | | | | | | | | | | | | | | | Very rarely a segfault would occur when removing a number of packages due to a corrupted list for the local database (FS#27805, FS#28195). This was caused by the alpm_list_msort function not correctly dealing with the two new head node's prev values. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | ALPM API adjustments for sanity and consistencyDan McGee2012-02-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes several small adjustments to our exposed method names, and in one case, parameters. The justification here is to make methods less odd in their naming convention. If a method takes an alpm_db_t argument, the method should be named 'alpm_db_*', but perhaps more importantly, if it doesn't take a database as the first parameter, it should not. Summary of changes: alpm_db_register_sync -> alpm_register_syncdb alpm_db_unregister_all -> alpm_unregister_all_syncdbs alpm_option_get_localdb -> aplpm_get_localdb alpm_option_get_syncdbs -> aplpm_get_syncdbs alpm_db_readgroup -> alpm_db_get_group alpm_db_set_pkgreason -> alpm_pkg_set_reason All methods keep the same argument list except for alpm_pkg_set_reason; there we drop the 'handle' argument as it can be retrieved from the passed in package object. Signed-off-by: Dan McGee <dan@archlinux.org>
* | alpm.h: enum cleanups, comment formatting cleanupDan McGee2012-02-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use trailing commas in enums if people really want to use a strict C89 compiler, and document why on earth one particular enum uses bitmask values when it doesn't seem necessary. With comments, shoot for more consistency. When something is a one-liner, keep it that way and move the whole /** sequence */ to one line. When it needs more than one line, ensure we format most of them in a similar fashion. Two minor function signature adjustments are made that don't change anything other than matching the parameter name (name -> filename) and fitting in with our coding style (type* var -> type *var). Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove last explicit include of config.hDan McGee2012-02-06
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2012-01-30
|\| | | | | | | | | Conflicts: scripts/makepkg.sh.in
| * Update translationsDan McGee2012-01-30
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove rmrf implementation from backendDan McGee2012-01-23
| | | | | | | | | | | | | | | | | | This moves the code for removal of local database entries right into be_local.c, which was the last user of the rmrf() function we had in our utility source file. We can simplify the implementation and make it non-recursive as we know the structure of the local database entries. Signed-off-by: Dan McGee <dan@archlinux.org>
* | libalpm/deps.c: access trans flags directlyDan McGee2012-01-23
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2012-01-23
|\| | | | | | | | | | | Conflicts: lib/libalpm/diskspace.c src/pacman/util.h
| * lib/dload: give uniform naming to curl CB functionsDave Reisner2012-01-23
| | | | | | | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
| * Fix sys/mnttab.h header includeDan McGee2012-01-23
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
| * lib/dload: enforce usage of TCP keepalivesDave Reisner2012-01-23
| | | | | | | | | | | | | | | | | | This is particularly important in the case of FTP control connections, which may be closed by rogue NAT/firewall devices detecting idle connections on larger transfers which may take 5-10+ minutes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
| * Add diskspace checking support for Solaris/IllumosDan McGee2012-01-19
| | | | | | | | | | | | | | | | | | Was able to get my hands on one of these boxes today, so add yet another new way of doing this. I'm glad these calls are so standardized. This was compile tested on Linux and Illumos and seems to still be working in both places. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Update copyright on changed files since beginning of yearDan McGee2012-01-18
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
| * util.c, rmrf(): only create string when neededOlivier Brunel2012-01-18
| | | | | | | | | | | | | | | | The entry's name is only used when not "." or ".." so only print the string then. Signed-off-by: Olivier Brunel <i.am.jack.mail@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
| * fetch_url: look for files in cache before downloadingDave Reisner2012-01-18
| | | | | | | | | | | | | | | | | | | | We lost this logic somewhere between the libfetch and libcurl transition, as it existed in the internal downloader, but was pulled back only into the sync workflow. Add a helper function that will let us check for existance in the filecache prior to calling the downloader. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
| * Use isdigit() rather than character range comparisonsDan McGee2012-01-18
| | | | | | | | | | | | This is safer and guaranteed to work with even exotic character sets. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Allow UseDelta option to specify a delta ratioDan McGee2012-01-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rework the frontend and backend to allow passing a ratio value in for UseDelta rather than having a hardcoded #define-d 0.7 value always used. This is useful for those with fast connections, who would likely benefit from tuning this ratio to lower values; it is also useful for general testing purposes. The libalpm API changes for this, but we do support the old config file format with a no-value 'UseDelta' option; in this case we simply use the old default of 0.7. We clamp the ratio values to a sane range between 0.0 and 2.0, allowing ratios above 1.0 for testing purposes. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Reorder some operations in sig check for efficiencyDan McGee2012-01-12
| | | | | | | | | | | | | | | | We don't need to open the data to be checked if we don't have a signature to check against, so postpone that open until we know we have either the base64_data or a valid signature file. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2012-01-08
|\| | | | | | | | | | | | | Conflicts: lib/libalpm/signing.c Signed-off-by: Dan McGee <dan@archlinux.org>
| * Remove useless logger messageDan McGee2012-01-05
| | | | | | | | | | | | We don't need two log messages back-to-back about the same thing here. Signed-off-by: Dan McGee <dan@archlinux.org>
| * Search for PGP subkeys in a keyserver-acceptable wayDan McGee2012-01-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | PGP keyservers are pieces of sh** when it comes to searching for subkeys, and only allow it if you submit an 8-character fingerprint rather than the recommended and less chance of collision 16-character fingerprint. Add a second remote lookup for the 8-character version of a key ID if we don't find anything the first time we look up the key. This fixes FS#27612 and the deficiency has been sent upstream to the GnuPG users mailing list as well. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Fix segfaults on opening invalid archive filesDan McGee2012-01-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "invalid" in this case simply means files that may or may not be archives. Discovered via a `pacman -Sc` operation with delta files in the package cache directory, but can be triggered if any file is passed to `pacman -Ql` that isn't an archive, for instance, or if the sync database file is not an archive. Fix it up so we are more careful about calling archive_read_finish() only on archives that are valid and have not already been closed, and teach our archive open function to set the returned archive to NULL if we aren't going to be returning something valid anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Update sync database size estimation valuesDan McGee2012-01-07
| | | | | | | | | | | | As the comment states, this is more like a dartboard than science. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Clean up <inttypes.h> header inclusionsDan McGee2012-01-07
| | | | | | | | | | | | | | In both cases we can go with the slightly leaner <stdint.h> header include since we aren't using the print macros. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Use 32-bit wide integer type in PolarSSL codeDan McGee2012-01-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A look at what this does on 64 bit systems since we were using the unnecessarily large 'unsigned long' type before even though it was 64 bits wide: $ ~/bin/bloat-o-meter libalpm.so.old lib/libalpm/.libs/libalpm.so add/remove: 0/0 grow/shrink: 0/4 up/down: 0/-10412 (-10412) function old new delta md5_finish 370 356 -14 sha2_finish 547 531 -16 md5_process 3762 2643 -1119 sha2_process 20356 11093 -9263 The code size is nearly halved in the sha2 case (44% smaller code size), and md5 gets a nice size reduction (27% smaller) as well. We also move base64 code to <stdint.h> types as well; we can use 'uint32_t' rather than 'unsigned long' for at least two variables in the decode function. This doesn't net the same size benefit as the hash code case, but it is more proper. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2012-01-02
|\| | | | | | | | | Conflicts: doc/Makefile.am
| * Fix bogus string cast in search debug messageDan McGee2011-12-29
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | pkghash improvements/modificationsDan McGee2012-01-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes a variety of small things related to our pkghash implementation with an eye toward performance, especially on native 32-bit systems. * Use `unsigned int` rather than `size_t` for hash sizes. We already return ERANGE for any attempted creation of a hash greater than 1 million elements, so unsigned int is more than large enough for our purposes. Switching to this type allows 32 bit systems to do native math without helper functions from libgcc. * _alpm_pkghash_create() now internally adds extra padding for additional array elements, rather than that being the responsibility of the caller. * #define values are moved into static const values in pkghash.c; a new `stride` value is also extracted (but remains set at 1). * Division and modulus operators are removed from the normal find and add paths if possible. We store the upper limit of the number of elements in the hash so we no longer need to calculate this every element addition. When doing wraparound position calculations, we only apply the modulus operator if the value is greater than the number of buckets. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Minor optimization on likely sync package lookupDan McGee2012-01-02
| | | | | | | | | | | | | | We have a name_hash value here, so add a cheap compare of it before falling to the strcmp() call. Signed-off-by: Dan McGee <dan@archlinux.org>
* | be_package.c: fix compiler warningAllan McRae2012-01-02
| | | | | | | | | | | | | | | | | | | | | | be_package.c: In function 'parse_descfile': be_package.c:181:28: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] ptr - key + 2 is guaranteed to be > 0 so we can cast to size_t Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove unnecessary counters in file removal codeDan McGee2012-01-02
| | | | | | | | | | | | | | | | Now that filelist arrays know their own size, we don't need to do the bookkeeping we used to do when they were linked lists. Remove some of the counter variables and use math instead. Signed-off-by: Dan McGee <dan@archlinux.org>
* | alpm_list_msort: inline alpm_list_nth() callDan McGee2012-01-02
| | | | | | | | | | | | | | | | This reduces the number of functions we call by log(n) in this function, and the inlined version is trivial and barely increases the size of the function. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Only compile delta regex onceDan McGee2012-01-02
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces the number of regcomp() calls when parsing delta entries in the database from once per entry to once for the entire context handle by storing the compiled regex data on the handle itself. Just as we do with the cURL handle, we initialize it the first time it is needed and free it when releasing the handle. A few other small tweaks to the parsing function also take place, including using the stack to store the transient and short file size string while parsing it. When parsing a sync database with 1378 delta entries, this reduces the time of a `pacman -Sl deltas` operation by 50% from 0.22s to 0.12s. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Fix delta parsingDan McGee2011-12-31
| | | | | | | | | | | | | | | | | | In commit 4c5e7af32f9, we changed this code to use the regex gathered substrings. However, we failed to correctly store the delta file name (leaking memory), as well as freeing the temporary string used to hold the file size string. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Simplify hash function to a single multiplicationDan McGee2011-12-31
| | | | | | | | | | | | | | | | | | | | More than likely the compiler will do the three operation breakdown we had here before (2 shifts + subtraction), but let the compiler do the optimizations and make the actual operation more obvious. This actually slightly shrinks the function binary size, likely due to instruction reordering or something. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Remove strtrim function from backendDan McGee2011-12-23
| | | | | | | | | | | | | | The last user of this was the code in the backend for loading packages, but this no longer uses it. Signed-off-by: Dan McGee <dan@archlinux.org>
* | be_package: be more explicit parsing key/value pairsDan McGee2011-12-23
| | | | | | | | | | | | | | | | This eliminates the need for strtrim() usage completely, instead relying on the fact that the only allowed delimiter between key and value is the " = " string. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Rework package removal codeDan McGee2011-12-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extract the actual unlinking of files into a new method, which eliminates a goto used for flow control. Also fix up a few small issues in the code: * Unnecessary (unsigned long) cast, use '%zd' instead * Total up errors returned from unlink_file calls and return to caller * Be consistent with scriptlets- we run pre_remove on dbonly, so we should also run post_remove. Both can be disabled by way of the --noscriptlet argument. * Don't pass an invalid pointer to oldpkg to the event callbacks; instead call the callback before we free the object. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Created hex_representation() in lib/libalpm/util.cDiogo Sousa2011-12-21
| | | | | | | | | | | | | | Used in alpm_compute_md5sum() and alpm_compute_sha256sum(). Signed-off-by: Diogo Sousa <diogogsousa@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | include config.h via MakefilesDave Reisner2011-12-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Ensures that config.h is always ordered correctly (first) in the includes. Also means that new source files get this for free without having to remember to add it. We opt for -imacros over -include as its more portable, and the added constraint by -imacros doesn't bother us for config.h. This also touches the HACKING file to remove the explicit mention of config.h as part of the includes. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Don't check diskspace when using --dbonlyDan McGee2011-12-21
| | | | | | | | | | | | | | | | Mostly a waste of time. Sure, we no longer make sure your pacman database partition has enough space, but if you are using this option you better know what you are doing anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* | sync: avoid checking file conflicts with --dbonlyDave Reisner2011-12-13
| | | | | | | | | | | | | | Scratches my own itch from FS#25667 Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | delta: use regex substring matchingDave Reisner2011-12-13
| | | | | | | | | | Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Calculate root length only once when checking for file conflictsDan McGee2011-12-12
| | | | | | | | | | | | | | | | It is quite easy to hoist this potentially repeated computation out of the loop; even if we don't end up using it, it is super cheap to do it only once. Signed-off-by: Dan McGee <dan@archlinux.org>
* | lib/conflict: save strlen call by reusing snprintf returnDave Reisner2011-12-12
| | | | | | | | | | | | | | | | | | The return should probably be checked to ensure its not longer than PATH_MAX, but I have no idea what the correct behavior is when that happens. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | code syntax cleanupDave Reisner2011-12-12
| | | | | | | | | | | | | | As per HACKING file, we use 'CTRL(' rather than 'CTRL (' Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Move items around in the alpm handle structDan McGee2011-12-07
| | | | | | | | | | | | This allows for the struct layout to have no empty spaces. Signed-off-by: Dan McGee <dan@archlinux.org>