summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2011-11-30Merge branch 'maint'Dan McGee
2011-11-30_alpm_ldconfig: return value from _alpm_run_chrootDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-30Add helper function for duplicating depends listsDan McGee
We do this in several of the package duplication steps; add a helper function for doing so to reduce some of the repetitive code. Also add a free_deplist function for our repeated depend list free calls of both the data and the list. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-22added doxygen documentationandrew.gregory.8@gmail.com
Made existing documentation more consistent and added documentation where there was none. One function still needs documentation and is marked with 'TODO'. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-20add key algo to import msgFlorian Pritz
Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-20change gpg import message to resemble gpg --list-keysFlorian Pritz
Dan: const pointers, don't worry about bitfields. Signed-off-by: Florian Pritz <bluewind@xinu.at> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-16Update alpm_errno_t type to non-enum versionDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-16Merge branch 'maint'Dan McGee
2011-11-16Add helper method for creating and opening archive objectDan McGee
This moves the common setup code of about 5 different callers into one method. Error messages will now be common and shared in all places; several paths did not have any messages at all before. In addition, we now pick an ideal block size for the archive read based off the larger value of our default buffer size or the st.st_blksize field. For a filesystem such as NFS, this is often much larger than the default 8192- values such as 32768 and 131072 are common. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-16Update translations from TransifexDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-15Allow sync_prepare to work in certain cases without sync databasesDan McGee
When doing a bare -U operation on a local package that doesn't pull in any dependencies from the sync databases, we can get away with missing database files. This makes the check conditional on no sync targets found in the target list. This is not the prettiest code here so we have a bit of hackish behavior required to straighten both the behavior and the nonsensical error message out. Addresses FS#26899. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-14create a typedef for enum _alpm_errno_tJonathan Conder
This is consistent with the other enums and structs, and should be slightly more readable. Signed-off-by: Jonathan Conder <jonno.conder@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-13Update translations from TransifexDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-13Updates in preparation for 4.0.1 releaseDan McGee
Bump the version, update the translation template files, and fill in NEWS with relevant commits and changes since 4.0.0. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-13add support for back end fnmatch'd optionsDave Reisner
This is work originally provided by Sascha Kruse on FS#20360 with only minor adjustments to the implementation. It's been expanded to cover: NoUpgrade, NoExtract, IgnorePkg, IgnoreGroup. Adds tests ignore008, sync139, sync502, and sync503. Also satisfies FS#18988. Original-work-by: Sascha Kruse <knopwob@googlemail.com> Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-11-11invert iteration order for ignoregroupDave Reisner
This is a simple change that allows comparions to be more in line with how other checks are done. It will be necessary for ensuing patchwork that implements fnmatch for comparing and assumes a specific argument ordering. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-11-07Merge branch 'maint'Dan McGee
2011-11-01Fix thinko in _alpm_strip_newlineDan McGee
The point of this early compare to NULL byte check was so we could bail early and skip the strcmp() call. Given we weren't doing the check right, this never exited early. Fix it to work as intended. Noticed-by: Pepe Juárez <trulustapa@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01libalpm/util: don't use sprintf to convert from bin to hexDan McGee
This is a trivial operation that doesn't require calling a function over and over- just do some math and indexing into a character array. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Fix size reported in CALLOC allocation failure messageDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Convert package and database archive reads to use file descriptorsDan McGee
This gives us a bit more control and over the archive reading process, and a bit less is done behind the scenes. It also allows us to use fstat() in preference to stat(), which should avoid some potential race conditions. Some reorganization is necessary to move the stat calls after the open() calls. Error handling and cleanup in general is also improved, as we had several potential memory and file handle leaks before in some error paths. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01libalpm/util: use low-level I/O for copyfile and checksum routinesDan McGee
This removes an unnecessary level of buffering. We are not doing line-based I/O here, so we can read in blocks of 8K at a time directly from the file. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Add OPEN() and CLOSE() util macrosDan McGee
These wrap the normal open() and close() low-level I/O calls and ensure EINTR is handled correctly. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-11-01Merge branch 'maint'Dan McGee
2011-10-27dload: remove redundant conditionalDave Reisner
Replacing the strdup when after the first NULL check assures that we get continue with payload->remote_name defined. Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-27dload: chmod tempfiles to respect umaskDave Reisner
Dan: fix mask calculation, add it to the success/fail block instead. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-27Introduce ALPM_BUFFER_SIZE constantDan McGee
This takes the place of three previously used constants: ARCHIVE_DEFAULT_BYTES_PER_BLOCK, BUFFER_SIZE, and CPBUFSIZE. In libarchive 3.0, the first constant will be no more, so we can ensure we are forward-compatible by removing our usage of it now. The rest are unified for consistency. By default, we will use the value of BUFSIZ provided by <stdio.h>, which is 8192 on Linux. If that is undefined, a default value is provided. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-26Fix issues with replacing unowned symlinksDan McGee
There aretwo seperate issues in the same block of file conflict checking code here: 1) If realpath errored, such as when a symlink was broken, we would call 'continue' rather than simply exit this particular method of resolution. This was likely just a copy-paste mistake as the previous resolving steps all use loops where continue makes sense. Refactor the check so we only proceed if realpath is successful, and continue with the rest of the checks either way. 2) The real problem this code was trying to solve was canonicalizing path component (e.g., directory) symlinks. The final component, if not a directory, should not be handled at all in this loop. Add a !S_ISLNK() condition to the loop so we only call this for real files. There are few other small cleanups to the debug messages that I made while debugging this problem- we don't need to keep printing the file name, and ensure every block that sets resolved_conflict to true prints a debug message so we know how it was resolved. This fixes the expected failures from symlink010.py and symlink011.py, while still ensuring the fix for fileconflict007.py works. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-26Don't realloc a 0-length files array when loading packagesDan McGee
There is some pecular behavior going on here when a package is loaded that has no files, as is very common in our test suite. When we enter the realloc/sort code, a package without files will call the following: files = realloc(NULL, 0); One would assume this is a no-op, returning a NULL pointer, but that is not the case and valgrind later reports we are leaking memory. Fix the whole thing by skipping the reallocation and sort steps if the pointer is NULL, as we have nothing to do. Note that the package still gets marked as 'files loaded', becuase although there were none, we tried and were successful. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-26libalpm/util: two stat() related cleanupsDan McGee
First, use fstat() in preference to stat() since we already have an open file handle. This also removes the need to check for a symlink as that is not possible when a file is opened. Next, use archive_entry_mode() rather than archive_entry_stat() as we only use the mode portion of the stat struct and the call is much cheaper. Also delay it until it is necessary. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-25Merge branch 'maint'Dan McGee
2011-10-25lib/sync: inform callers of compute_download_size of a partialDave Reisner
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 McGee
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-21Merge branch 'maint'Dan McGee
Conflicts: src/pacman/package.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-21sync: move file download loop out of download_filesDave Reisner
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-21sync: check for necessary disk space for downloadDave Reisner
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2011-10-21sync: extract build_payload() method from find_dl_candidatesDan McGee
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 Reisner
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 McGee
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 McGee
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 Reisner
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 Reisner
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 Reisner
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 McGee
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 McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-14Merge branch 'maint'Dan McGee
2011-10-14Add missing #ifdef around cURL error code in download structDan McGee
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 McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-10-13curl_gethost() potential bug fixupsDan McGee
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 McGee
Conflicts: src/pacman/util.c