summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/package.c
AgeCommit message (Collapse)AuthorFilesLines
2008-01-12Add functions to manipulate pmdepend_t objectsDan McGee1-4/+7
We didn't have a free function before, causing some memory leaks. We also need a dup function now that strings are not in the structure but are dynamically allocated. Also adapt pmdepmissing_t to use a pointer to a depend struct instead of an inclusive one so we can use the functions we created here. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-11Use dynamic string allocation in package structuresDan McGee1-30/+56
This also affects all structures with static strings, such as depmiss, conflict, etc. This should help a lot with memory usage, and hopefully make things a bit more "idiot proof". Currently our pactest pass/fail rate is identical before and after this patch. This is not to say it is a perfect patch- I have yet to pull valgrind out. However, this should be quite safe to use in all situations from here on out, and we can start plugging the memleaks. Original-work-by: Aaron Griffin <aaronmgriffin@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-08Remove upgradedelay and all code associated with itDan McGee1-23/+0
It wasn't even implemented correctly, and it really doesn't have a use if packagers just do their job correctly anyway for a distro. Let's not try to solve a problem with the wrong solution now. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-08Remove unused date element from pmpkg_t structDan McGee1-2/+3
We had an unused date element in the pmpkg_t struct (not builddate or installdate). Kill it off and fix the one function that was using it. Signed-off-by: Dan McGee <dan@archlinux.org>
2008-01-02Small code cleanups with indents/spacesDan McGee1-3/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-29Remove .FILELIST generation from makepkg (and elsewhere)Dan McGee1-45/+19
This is something pacman can do on its own straight from the archive, and we will reduce the chance of problems occurring becuase of inproper FILELIST generation as we have had in the past with special characters in filenames. Once we remove it from makepkg. we can remove any usage of it from all of our other tools, including pacman, pactest, and contrib/ utilities. Note that removing it from pacman uncovered a few other bugs anyway, so this was probably a good move. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-17Check for errors on descfile extractionDan McGee1-1/+5
If /tmp was full during the early stages of package extraction, we were unable to extract the package description file with the call to archive_read_data_into_fd(archive, fd) becuase we never checked the return code. Add a check to ensure the extraction was successful and print and return an error if it was not instead of falling through to a possibly untrue error message. This should fix FS #8885. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-11Update GNU GPL boilerplate and copyright datesDan McGee1-4/+2
Update the GPL boilerplate to direct people to the GNU website for a copy of the license, as well as bump all of Judd's copyrights to 2007. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-12-09Improve changelog handling through addition of open/read/close functionsDan McGee1-0/+109
Thanks to Allan for inspiring all this work on what was one little TODO item in the codebase. :) Change changelog handling so we can now dump a changelog from both installed packages and package files (fixes FS#7371). We do this by moving all of the machinery to the backend where it should have been in the first place. The changelog reading is now done through a open/read/close interface similar to the fopen/fread/fclose functions (can you guess how it is done?). It is buffered by the frontend, so programs using the library can read as much or as little as they want at a time. Unfortunately, I could not implement a changelog_feof function due to some shortcomings of libarchive. However, I left the stub code in there, commented out, in case it becomes possible later or anyone wants to take a stab at it. Original-work-by: Allan McRae <mcrae_allan@hotmail.com> Improved-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-20Add missing header includes for setlocaleDan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-18Remove the IgnorePkg handling from alpm_pkg_compare_version.Chantry Xavier1-10/+0
And check the IgnorePkg handling is done correctly in the other places. For example, -Qu and -Su will automatically skip the ignored packages (-Su will print a warning), but -S will install ignored packages anyway, because it was asked explicitly. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-11-17Remove provide.c and provide.h .Chantry Xavier1-1/+0
This file only contained one private function : _alpm_db_whatprovides . And the public alpm_db_whatprovides was in db.c , so I moved everything there. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> [Dan: updated POTFILES.in as well] Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17libalpm: use FREELIST when possibleDan McGee1-2/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-17War on whitespaceDan McGee1-5/+5
Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-15Fix alpm_list_copy_dataDan McGee1-2/+4
So I spent a good 4 hours tracking a bug down tonight due to alpm_list_copy_data not actually doing what I expected to do. We can't find the size of an object we don't know the type of, so rewrite it so we pass in the size explicitly. This was making _alpm_pkg_dup fail and causing all sorts of other issues. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-15Move alpm_splitdep usage to db_readDan McGee1-13/+5
Holy inefficient batman! For a pacman -Qt operation (when we are using compute_requiredby and not database entries), splitdep was being called ~1.3 million times on my local database. By splitting when we read the DB, we drop this number to around 1700 and save a LOT of time in doing so (a 5x increase in pacman -Qt speed here). Note that the depends alpm_list_t in the package struct is no longer a string list, but a list of pmdepent_t objects. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-15Remove REQUIREDBY usage from libalpmDan McGee1-23/+0
Instead of using the often-busted REQUIREDBY entries in the pacman database, compute them each time they are required. This should help many things: 1. Simplify the codebase 2. Prevent future database corruption 3. Ensure when we do use requiredby, it is always correct 4. Shrink the pmpkg_t memory overhead Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-11Implement IgnoreGroup.Nathan Jones1-1/+31
This option acts as if IgnorePkg was set on each package in the group. This closes FS#1592. Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-11-09Fix some issues with localized dates/epoch usageDan McGee1-0/+2
Commit 47622eef4dd8fd86a0aa0e3ebdb7b33f7c9d6804 introduced localized times in the metadata by way of storing the UNIX epoch value instead of a hard coded date string. However, it missed a few things: * If we weren't in the C/POSIX/en_US locale, the date parsing would fail as it tried to use the abbreviations of the locale being used. Fix this by switching the LC_TIME value before we parse a date. * We used ctime to print the date value, which is always the C locale string. Instead, use strftime to print a localized date string. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-30Copy pmdelta_t objects in _alpm_pkg_dup()Dan McGee1-0/+2
This was forgotten in the original set of patches. CC: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-29libalpm: introduce MALLOC and CALLOC macrosDan McGee1-14/+5
These macros take the place of the common 4 or 5 line blocks of code we had in most places that called malloc or calloc. This should reduce some code duplication and make memory allocation more standard in libalpm. Highlights: * Note that the MALLOC macro actually uses calloc, this is just for safety so that memory is initialized to 0. This can be easily changed in one place. * One malloc call was completely eliminated- it made more sense to do it on the stack. * The use of RET_ERR in public functions (mainly the alpm_*_new functions) was standardized, this makes sense so pm_errno is set. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-20Add pmdelta_t structure and functions to libalpm.Nathan Jones1-0/+15
Signed-off-by: Nathan Jones <nathanj@insightbb.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-18libalpm/package.c : fix requiredby with multiple providers.Chantry Xavier1-5/+2
The code didn't match the following comment : "A depends on B through n depends <=> A listed in B's requiredby n times" It stopped at n=1 with a break. I was surprised to see this case happens in real, that's how I noticed the bug: wine depends on both freeglut and glut, while freeglut provides glut. So when installing wine, the update_depends function listed wine twice in freeglut's requiredby. But the compute_requiredby function (used when installing freeglut, and used by testdb) listed wine only once in freeglut's requiredby. That made testdb unhappy. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-09libalpm/package.c: ensure we use package name when loading packagesDan McGee1-4/+7
Some of the error messages in _alpm_pkg_load failed to use the pkgname value when printing, which made error messages rather hard to decode. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-10-09Fix backward compatibility with non-epoch builddatesDan McGee1-3/+8
Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28Support for localized times in metadataAaron Griffin1-7/+9
Packages and DBs now support using the UNIX epoch (seconds since Jan 1, 1970) for use in builddate and installdate. This will only affect newly built packages. Old existing packages with the text format are still supported, but this is deprecated. In the case of removal of text time support, this code will fail gracefully, returning the start of the epoch for broken packages. Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-09-28Add 'full' parameter to alpm_pkg_loadDan McGee1-14/+26
In most cases, we want to fully scan a package when we load it, which serves as a integrity verification check. However, there are times when it is only desired to read the metadata and nothing else, so allow the caller of pkg_load to choose the behavior they need. This pays big dividends in speeding up pacman cache cleaning functionality. Old (729 packages): real 1m43.717s user 1m20.785s sys 0m2.993s New (729 packages): real 0m25.607s user 0m19.389s sys 0m0.543s Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-28Remove package name dependency from libalpmDan McGee1-99/+2
Previously, package names must match a specified scheme or they will cause pacman add operations to fail. This is not a very intelligent or necessary way to act, so remove the dependency on the name of the package to be installed and read all relevant information from the metadata instead. This does have one causality to be addressed later- pacman cache cleaning functionality, which has never been phenomenal, just lost most capability. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-26Preliminary support for optdependsDan McGee1-1/+18
Add some alpm functions for getting optdepends, have makepkg include them in the PKGINFO file, and have a pacman -Qi operation display the raw string as stored by libalpm. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-23alpm: removed unused strtoupper wrapper, remove installeddate on parse_descfileDan McGee1-2/+0
installdate should never be present in a package descfile, so get rid of it. With the last commit, we also don't need the util strtoupper function. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-09-23libalpm/package.c : fix for FS#8081, case sensitive comparisons in ↵Chantry Xavier1-17/+16
parse_descfile. This fix FS#8081. The tr_TR locale has known issue with case insensitive comparisons, mostly because upper(i) != I. So the .PKGINFO files generated by makepkg MUST contain all keywords in lowercases now. This was already done, but was not mandatory. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-09-12libalpm/package.c : add new alpm_pkg_compute_requiredby function.Chantry Xavier1-38/+47
Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-24libalpm: add newlines to all strings passed to log callbackDan McGee1-22/+22
This allows us to remove the hack in the frontend where we added a newline to everything coming out of the pm_printf functions, and instead let the developer put newlines where they want them. This should be the last hangover of that auto-newline stuff. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-22Post trial install changes, round oneDan McGee1-1/+1
A bunch of changes related to my first "real" install of pacman-git into /usr/local and trying to use it. * Shift some uses of free -> FREE in libalpm. * Move stat and sanity checks of config paths into libalpm from the config and argument parsing in pacman.c. * Fix issue where dbpath still was not defined early enough due to its requirement for being used in alpm_db_register. This should be rewritten so it doesn't have this dependency, but this will work for now. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-20libalpm/add.c,trans.c : cleanup of requiredby handling.Nagy Gabor1-0/+3
This patch cleans up and fix the _alpm_trans_update_depends function and ensure that all requiredby fields are filled in case of multiple satisfiers (previously, the handling of mutliple satisfiers in that function was inconsistent). This makes a special case handling of requiredby in commit_single_pkg() obsolete, and so allows cleaning that code as well. Also fixed upgrade056 pactest because : 1) the requiredby fields were wrong, and this wouldn't happen with the fixed _alpm_trans_update_depends(). 2) this is a very unusual case anyway (and handling all corner cases combined to a broken database seems nearly impossible to achieve). References : http://www.archlinux.org/pipermail/pacman-dev/2007-July/008919.html http://www.archlinux.org/pipermail/pacman-dev/2007-July/008920.html Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
2007-08-20Fix for FS 6404 and functionalize some cachedir handling stuffDan McGee1-12/+4
In order to best resolve bug 6404, move some cachedir handling stuff out of sync.c and into util.c and create two new functions: filecache_find and filecache_setup. sync.c was rewritten to use these, and alpm_fetch_pkgurl now also uses these routines. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-16Remove support for SHA1 from pacman.Andrew Fyfe1-65/+0
There's no need for a second hashing algorithm. MD5 serves the purpose of verifying that a package file hasn't been corrupted during download. Signed-off-by: Andrew Fyfe <andrew@neptune-one.net> Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-14package.h: implement origin_data union in pmpkg_t structDan McGee1-35/+40
We were using a void *data element in pmpkg_t before, which is unsafe by its nature of being untyped. Reimplement data as origin_data being a union that can hold either a path to a package file or a pointer to a cache database, and make the other necesary updates in the code to reflect this. See package.h for details. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-08-14Code cleanupDan McGee1-17/+0
Remove the commented desc_localized stuff, we can find it later in version control. Also remove some unnecessary includes of the stat header and use -fstack-protector-all which is a bit more broad. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-18Reorder functions in libalpm/package.c for Doxygen purposesDan McGee1-414/+413
Put all of the public functions at the top and inside the Doxygen packages group. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-12Remove versioncmp.{c,h}, clean up selective #ifdefsDan McGee1-1/+95
Remove versioncmp.c by moving all functions to locations that make sense. Move replacement functions (for building without glibc) into util.c where they belong, and do proper checks for them instead of using __sun__, etc. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-12Remove 'buildtype' from libalpm and pacmanDan McGee1-16/+0
Remove unused buildtype field from pmpkg_t struct and anything associated with it, as it is unused at the moment. If we need to readd it, it is an easy revert of this commit. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-10Remove gettext calls from all PM_LOG_DEBUG messagesDan McGee1-5/+5
There is no real reason to burden our translators with these messages, as anyone helping to debug these will probably want them in English. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-07-09Add top level hidden file code to package.cDan McGee1-0/+3
This was already taken care of in add.c by commit 2ae043866045bbeef129a4b503ee1f5486545821, but was missed in package.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-09Allow multiple CacheDirs to be specifiedDan McGee1-4/+23
This should hopefully allow multiple cache dirs to be specified in pacman.conf and/or on the command line, and allow pacman to test each one for the package file. The first one found to be writeable is used as the download cache. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Const correctness!Dan McGee1-3/+3
Add some 'const' keywords all over the code to make it a bit more strict on what you can and can't do with data. This is especially important when we return pointers to the pacman frontend- ideally this would always be untouchable data. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-06-05Move functions out of alpm.c to where they belongDan McGee1-1/+194
alpm.h is the only "publically viewable" file, so there is no reason to have functions in alpm.c that belong in package.c, db.c, etc. Move the functions where they belong and leave only the library init functions in alpm.c. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-31Move DB and cache dirs away from there dependence on ROOTDIRDan McGee1-3/+3
This change allows us to use all autoconf specified paths, most notably $(localstatedir). It is quite a change and touches a lot of files, as all references to the DB and cache were done with the ROOTDIR as a prefix. * add --lock command-line option to pacman to specify the location of the lockfile (this can now be specified at configure time by setting the $localstatedir path). * Rip quite a few settings out of configure.ac as they are now picked by setting the paths during configure or make. * Fix bug with /tmp fallback for sync downloads not working correctly (related to root location, now the system tmp dir is used). * Simplified the parameters to some libalpm functions, and added get/set for the new lockfile option. * Renamed several of the DEFS to names without the PM_ prefix. Signed-off-by: Dan McGee <dan@archlinux.org>
2007-05-18Fix extraneous "ignoring upgrade" output on Ignore'd packagesChantry Xavier1-6/+8
Reorder package version checking so there is no output when a package is listed in IgnorePkg. Closes FS#7111 Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
2007-05-14Use alpm_depcmp in _alpm_pkg_update_requiredbyNagy Gabor1-28/+13
The old function did too much on its own; let alpm_depcmp do the hard work. This will allow for future versioned provisions if necessary. Signed-off-by: Dan McGee <dan@archlinux.org>