summaryrefslogtreecommitdiffstats
path: root/lib
AgeCommit message (Collapse)AuthorFilesLines
2011-10-25lib/sync: inform callers of compute_download_size of a partialDave Reisner1-2/+6
Extend the return values of compute_download_size to allow callers to know that a .part file exists for the package. This extra value isn't currently used, but it'll be needed later on. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-24Add more logging to download codeDan McGee1-3/+11
This adds a logger to the CURLE_OK case so we can always know the return code if it was >= 400, and debug log it regardless. Also adjust another logger to use the cURL error message directly, as well as use fstat() when we have an open file handle rather than stat(). Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-22Merge branch 'maint'Dan McGee1-2/+2
Conflicts: src/pacman/package.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-22sync: move file download loop out of download_filesDave Reisner1-21/+25
Create a new static function called 'download_single_file' which iterates over the servers for each payload. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-22sync: check for necessary disk space for downloadDave Reisner1-0/+28
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-22sync: extract build_payload() method from find_dl_candidatesDan McGee2-15/+19
This is done by both the delta and regular file code, so we can extract a little helper method. Done mostly to satisfy my "why are we repeating code here" itch. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21sync: dont group sync records by repositoryDave Reisner1-80/+85
Break out the logic of finding payloads into a separate static function to avoid nesting mayhem. After gathering all the records, download them all at once. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17base64: don't compile base64_encode() functionDan McGee2-0/+4
We don't use this anywhere; "comment" it out so we still remain relatively close to the upstream sources. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17Show an error message on failed remote key lookupDan McGee1-2/+2
The absolutely terrible part about this is the failure on GPGME's part to distinguish between "key not found" and "keyserver timeout". Instead, it returns the same silly GPG_ERR_EOF in both cases (why isn't GPG_ERR_TIMEOUT being used?), leaving us helpless to tell them apart. Spit out a generic enough error message that covers both cases; unfortunately we can't provide much guidance to the user because we aren't sure what actually happened. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17dload: add pointer to server list for each payloadDave Reisner2-0/+3
Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17diskspace: create static function mount_point_list_freeDave Reisner1-11/+14
This logic is reused in both diskspace and downloadspace check functions, so pull it out into its own static method. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-17diskspace: add _alpm_check_downloadspace()Dave Reisner2-0/+51
This function determines if the given cachedir has at least the given amount of free space on it. This will be later used in the sync code to preemptively halt downloads. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Large performance improvement for check for owned directoriesDan McGee1-5/+11
We can take a large shortcut here that saves us a lot of time, especially when upgrading packages with lots of directories. Obviously iterating the full file list of every single package to determine if this directory was present in any other package can take quite some time on a system with many packages installed. We don't need to remove a directory at all if we are upgrading a package and the version we are moving to still had the directory. Also make a small optimization on the package comparsion- we really only care about equality here, not the result of the compare, so we can shortcut using our name_hash. What kind of benefit does this give us? Oh, only a reduction from 295.7 million to 1.4 million strcmp() calls (99.5% fewer) during a `pacman -S linux libreoffice-common` operation. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Make _alpm_filelist_contains() NULL-safeDan McGee1-3/+7
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Merge branch 'maint'Dan McGee2-10/+16
2011-10-14Add missing #ifdef around cURL error code in download structDan McGee1-0/+2
Thanks to Eduardo Tongson on the mailing list. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13Fix some strict 32-bit gcc warningsDan McGee1-1/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13curl_gethost() potential bug fixupsDan McGee1-10/+14
This is in the realm of "probably not going to happen", but if someone were to translate "disk" to a string longer than 256 characters, we would have a smashed/corrupted stack due to our unchecked strcpy() call. Rework the function to always length-check the value we copy into the hostname buffer, and do it with memcpy rather than the more cumbersome and unnecessary snprintf. Finally, move the magic 256 value into a constant and pass it into the function which is going to get inlined anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13Merge branch 'maint'Dan McGee1-19/+30
Conflicts: src/pacman/util.c
2011-10-13Add user-visible warning message if public keyring not foundDan McGee1-0/+3
This should help point users in the right direction if they have not initialized via pacman-key just yet. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Remove alpm_list_getdata wrapper functionDan McGee2-14/+0
This one is pretty darn useless. Just derefence the ->data attribute since the type is public anyway and save yourself the function call. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12diskspace: extract check_mountpoint() functionDan McGee1-17/+23
This will be useful when extending disk space checks to free space checking before we download package files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12_alpm_archive_fgets: optimize EOL searchDan McGee1-17/+17
Instead of iterating character by character, use memchr() calls to hopefully speed up the search. A newline is the most likely culprit, so search for that first followed by a NULL byte if there was no newline in the buffer. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12signing: delay gpgme_init() until latest possible momentDan McGee1-19/+27
In the default configuration, we can enter the signing code but still have nothing to do with GPGME- for example, if database signatures are optional but none are present. Delay initialization of GPGME until we know there is a signature file present or we were passed base64-encoded data. This also makes debugging with valgrind a lot easier as you don't have to deal with all the GPGME error noise because their code leaks like a sieve. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Convert MALLOC to actually call malloc()Dan McGee2-3/+3
If you need zero-filled allocations, call CALLOC() instead. This was from the original definition of these macros in commit cc754bc6e3be0f3; hopefully our code is in the shape it needs to be to switch this behavior. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Move infrequently used path variables off the stackDan McGee1-23/+30
These backup-related paths in package extraction are used on relatively few files during the install process, so bump them off the stack and into the heap. This removes the artificial PATH_MAX limitation on their length as well. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Extract a try_rename helper from extract_single_file()Dan McGee1-20/+18
This moves the repetitive (and highly unlikely) logging work to a single location. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Introduce alpm_time_t typeDan McGee9-35/+29
This will always be a 64-bit signed integer rather than the variable length time_t type. Dates beyond 2038 should be fully supported in the library; the frontend still lags behind because 32-bit platforms provide no localtime64() or equivalent function to convert from an epoch value to a broken down time structure. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12_alpm_parsedate: use strtoll() to parse numeric valueDan McGee1-1/+20
This prepares the function to handle values past year 2038. The return type is still limited to 32-bits on 32-bit systems; this will be adjusted in a future patch. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-12Final Transifex update before 4.0Dan McGee3-55/+59
We have a few incomplete translations, but these should be addressable before the 4.0.1 maint release that is surely not that far in the future. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-11Update translations from TransifexDan McGee27-188/+331
In prep for the 4.0.0 release. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-11dload: unhook error buffer after transfer finishesDave Reisner1-1/+4
Similar to what we did in edd9ed6a, disconnect the relationship with our stack allocated error buffer from the curl handle. Just as an FTP connection might have some network chatter on teardown causing the progress callback to be triggered, we might also hit an error condition that causes curl to write to our (now out of scope) error buffer. I'm unable to reproduce FS#26327, but I have a suspicion that this should fix it. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-06Update translation message catalogs in prep for 4.0 releaseDan McGee1-2/+6
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-06Update translations from TransifexDan McGee27-280/+267
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-04Parse '0' as a valid package installed sizeDan McGee1-1/+1
This was a bad oversight on my part, pointed out by Jakob. Whoops. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-30Use _alpm_local_db_pkgpath in _cache_changelog_openDan McGee1-4/+4
Another place where we were doing the dirty work by hand. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-30Revamp scriptlet path formation for scriptlets in local databaseDan McGee4-18/+20
Expose the current static get_pkgpath() function internally to the rest of the library as _alpm_local_db_pkgpath(). This allows use of this convenience function in add.c and remove.c when forming the path to the scriptlet location. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-30Refactor _alpm_runscriptlet()Dan McGee4-51/+58
Add an is_archive parameter to reduce the amount of black magic going on. Rework to use fewer PATH_MAX sized local variables, and simplify some of the logic where appropriate in both this function and in the callers where duplicate calls can be replaced by some conditional parameter code. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-29move prevprogress onto payload handleDave Reisner2-8/+4
This is a poor place for it, and it will likely move again in the future, but it's better to have it here than as a static variable. Initialization of this variable is now no longer necessary as its zeroed on creation of the payload struct. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Refactor download payload reset and freeDan McGee4-48/+51
This was done to squash a memory leak in the sync database download code. When we downloaded a database and then reused the payload struct, we could find ourselves calling get_fullpath() for the signatures and overwriting non-freed values we had left over from the database download. Refactor the payload_free function into a payload_reset function that we can call that does NOT free the payload itself, so we can reuse payload structs. This also allows us to move the payload to the stack in some call paths, relieving us of the need to alloc space. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Initialize cURL library on first useDan McGee4-40/+44
Rather than always initializing it on any handle creation. There are several frontend operations (search, info, etc.) that never need the download code, so spending time initializing this every single time is a bit silly. This makes it a bit more like the GPGME code init path. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Track unresolvable transaction packagesDan McGee3-9/+18
Rather than free them right away, keep the list on the transaction as we already do with add and remove lists. This is necessary because we may be manipulating pointers the frontend needs to refer to packages, and we are breaking our contract as stated in the alpm_add_pkg() documentation of only freeing packages at the end of a transaction. This fixes an issue found when refactoring the package list display code. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Move pacsave path construction code off the stackDan McGee1-2/+6
This is definitely not in the normal hot path, so we can afford to do some temporary heap allocation here. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Use the full buffer when computing md5/sha256 sumsDan McGee1-4/+6
No wonder these were slower than expected. We were only reading 4 (32-bit) or 8 (64-bit) bytes at a time and feeding it to the hash functions. Define a buffer size constant and use it correctly so we feed 8K at a time into the hashing algorithm. This cut one larger `-Sw --noconfirm` operation, with nothing to actually download so only timing integrity, from 3.3s to 1.7s. This has been broken since the original commit eba521913d6 introducing OpenSSL usage for crypto hash functions. Boy do I feel stupid. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Fix memory leak in download payload->remote_nameDan McGee3-12/+18
In the sync code, we explicitly allocated a string for this field, while in the dload code itself it was filled in with a pointer to another string. This led to a memory leak in the sync download case. Make remote_name non-const and always explicitly allocate it. This patch ensures this as well as uses malloc + snprintf (rather than calloc) in several codepaths, and eliminates the only use of PATH_MAX in the download code. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28Revert "libalpm: compare pkgname with strcoll"Dan McGee1-1/+1
This commit was made with the intent of displaying "correctly" sorted package lists to users. Here are some reasons I think this is incorrect: * It is done in the wrong place. If a frontend application wants to show a different order of packages dependent on locale, it should do that on its own. * Even if one wants a locale-specific order, almost all package names are all ASCII and language agnostic, so this different comparison makes little sense and may serve only to confuse people. * _alpm_pkg_cmp was unlike any other comparator function. None of the rest had any dependency on anything but the content of the structs being compared (e.g., they only used strcmp() or other basic comparison operators). This reverts commit 3e4d2c3aa65416487939148828afb385de2ee146. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28_alpm_splitdep: use malloc instead of callocDan McGee1-3/+5
There was only one simple to handle case where we left a field uninitialized; set it to NULL and use malloc() instead. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28be_sync: fetch only entry mode, not full stat structDan McGee1-5/+2
This saves a lot of unnecessary work since we don't need any of the other fields in the stat struct. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-28alpm_list: use malloc instead of callocDan McGee2-8/+8
In every case we were calling calloc, the struct we allocated (or the memory to be used) is fully specified later in the method. For alpm_list_t allocations, we always set all of data, next, and prev. For list copying and transforming to an array, we always copy the entire data element, so no need to zero it first. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-09-27Fix compilation using --without-gpgmeDan McGee1-3/+10
I'm really good at breaking this on a regular basis. If only we had some sort of automated testing for this... Signed-off-by: Dan McGee <dan@archlinux.org>