summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
Commit message (Collapse)AuthorAge
* Introduce _alpm_pkg_free_trans()Nagy Gabor2009-06-07
| | | | | | | | | The main purpose of this function to make our code more readable. It frees transaction specific fields of pmpkg_t. (It is used when a package is removed from the target list.) Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove pmsyncpkg_tNagy Gabor2009-04-11
| | | | | | | | | | | | | | | | | | | | | pmsyncpkg_t data sructure was removed: 1. pmpkg_t.reason is used instead of pmsyncpkg_t.newreason. (The target packages come from sync repos, so we can use this field without any problems. Upgrade transaction also uses this field to store this info.) 2. pmsyncpkg_t.removes was moved to pmpkg_t.removes. This step requires careful programming, because we don't duplicate packages when we add them to trans->packages. So we modify sync pkgcache when we add this transaction-only info to our package. Hence it is important to free this list when we remove any package from the target list (remove_unresolvable, remove_conflicts, trans_free), otherwise this could confuse the new sync transactions (with non-pacman GUI). Overall, our code became ~100 line shorter, and we can call our helper functions directly on trans->packages in sync.c, we don't need to maintain parallel package lists. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2008-10-12
|\
| * Remove unnecessary unistd.h header inclusionDan McGee2008-10-12
| | | | | | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* | New public alpm_pkg_get_db functionNagy Gabor2008-08-23
|/ | | | | | | This function returns with the origin database of a package. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Cleanup of _alpm_pkg_compare_versions.Xavier Chantry2008-08-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Change the return values to be more informative. It was previously boolean, only indicating if a sync package was newer than a local package. Now it is a simple wrapper to vercmp, handling the force flag. * Remove the verbose output from _alpm_pkg_compare_versions. The "force" message is not so useful. The "package : local (v1) is newer than repo (v2)" message can be moved to -Su operation. For the -S operation, it is better to have something like : "downgrading package from v1 to v2" * Don't display the "up to date -- skipping" and "up to date -- reinstalling" messages, when the local version is newer than the sync one. * Fix the behavior of --needed option to not skip a target when the local version is newer, and clarify its description. * Add a new alpm_pkg_has_force function This allows us to access the pkg->force field like any other package fields. Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm/package.c : fix infolevel bug in pkg_dupXavier Chantry2008-07-24
| | | | | | | | | | The pkg_dup function shouldn't call any alpm_pkg_get_ accessors because this can fill the old package with all INFRQ_DESC fields for example, and this won't necessarily be reproduced in the new package (for all the fields that were copied before). Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix vercmp and add additional testsDan McGee2008-07-24
| | | | | | | | | | | | | | | | | | | | | | This vercmp issue has been a sticking point but this should resolve many of the issues that have come up. Only a few minor code changes were necessary to get the behavior we desired, and this version appears to beat any other vercmp rendition on a few more cases added in this commit. This commit passes all 58 vercmp tests currently out there. Other 'fixes' still fail on a few tests, namely these ones: test: ver1: 1.5.a ver2: 1.5 ret: -1 expected: 1 ==> FAILURE test: ver1: 1.5 ver2: 1.5.a ret: 1 expected: -1 ==> FAILURE test: ver1: 1.5-1 ver2: 1.5.b ret: 1 expected: -1 ==> FAILURE test: ver1: 1.5.b ver2: 1.5-1 ret: -1 expected: 1 ==> FAILURE 4 of 58 tests failed Signed-off-by: Dan McGee <dan@archlinux.org>
* New _alpm_dep_edge functionNagy Gabor2008-07-07
| | | | | | | | The function is introduced to kill some code duplication. The function name uses the 'dependency graph' terminology. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Don't duplicate packages in requiredby listNagy Gabor2008-07-07
| | | | | | | | | This is a "fix" for FS#10226. I think that multiple versioned dependencies are quite common now, and the old behavior is quite annoying there. This patch won't cause any slow-down. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Use correct C type for file sizesDan McGee2008-06-04
| | | | | | | | | | | | | | We have been using unsigned long as a file size type for a while, which works but isn't quite correct and could easily break. Worse was probably our use of int in the download callback functions, which could be restrictive for packages > 2GB in size. Switch all file size variables to use off_t, which is the preferred type for file sizes. Note that at least on Linux, all applications compiled against libalpm must now be sure to use large file support, where _FILE_OFFSET_BITS is defined to be 64 or there will be some weird issues that crop up. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix versioncmp regression after updateDan McGee2008-05-30
| | | | | | | | | | | | | | | Commit 84283672853350a84d2a71b72dc06e180cad1587 introduced the regression, and a previous commit introduced the vercmptest.sh test script to track down these issues. This commit solves the problem by removing the previous attempt at locating the pkgrel portions and replacing it with something that performs the correct logic. While tracking down everything I needed to, I also found a mistake in one of the pactests which is fixed here as well as increased the functionality and verbosity of the vercmptest script to both print out each test it is running as well as automatically run the mirror of each test case. Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove wrapper call around versioncmpDan McGee2008-05-14
| | | | | | | Actually, just rename _alpm_versioncmp to alpm_pkg_vercmp and get rid of the need for a wrapper since it did nothing anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
* Update _alpm_versioncmpDan McGee2008-05-14
| | | | | | | | | | | | | | This code hasn't been looked at in some time. I grabbed a more recent version of the RPM source (4.4.2.3) and attempted to sync up any changes they have made, as well as make the libalpm additional code much cleaner and limited to only a few added lines of code. The size of this patch might make you think we added code, but bloat-o-meter actually tells us otherwise: <function> <old> <new> <diff> _alpm_versioncmp 1485 1021 -464 Signed-off-by: Dan McGee <dan@archlinux.org>
* Simplify _alpm_pkg_new()Dan McGee2008-05-13
| | | | | | | | Any real call of this function doesn't specify a name or version ahead of time, so just kill that functionality off. Now to remove those dummy packages... Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove lazy init code from pkg name and version functionsDan McGee2008-05-13
| | | | | | | | | | If we have a package without name and/or version, we are really out of luck. Speed these functions up by removing unnecessary code. Note that both the splitname and pkg_load functions, where the name and version of packages are initially populated for databases and pkg.tar.gz files respectively, enforce that every new package struct created has a name and version. Signed-off-by: Dan McGee <dan@archlinux.org>
* Cleanup usages of alpm_list_find and alpm_list_remove.Chantry Xavier2008-05-13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * remove obsolete and unused *_cmp helper functions like deppkg_cmp and _alpm_grp_cmp * new alpm_list_remove_str function, used 6 times in handle.c * remove _alpm_prov_cmp / _alpm_db_whatprovides and replace them by a more general alpm_find_pkg_satisfiers with a cleaner implementation. before: alpm_db_whatprovides(db, targ) after: alpm_find_pkg_satisfiers(alpm_db_getpkgcache(db), targ) * remove satisfycmp and replace alpm_list_find + satisfycmp usage by _alpm_find_dep_satisfiers. before : alpm_list_find(_alpm_db_get_pkgcache(db), dep, satisfycmp) after : _alpm_find_dep_satisfiers(_alpm_db_get_pkgcache(db), dep) * remove _alpm_pkgname_pkg_cmp, which was used with alpm_list_remove, and use _alpm_pkg_find + alpm_list_remove with _alpm_pkg_cmp instead. This commit actually get rids of all complicated and asymmetric _cmp functions. I first thought these functions were worth it, be caused it allowed us to reuse list_find and list_remove. But this was at the detriment of the clarity and also the ease of use of these functions, dangerous because of their asymmetricity. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Swap the parameters of alpm_pkg_findNagy Gabor2008-05-13
| | | | | | | Now the syntax is coherent with alpm_list_find and alpm_sync_find. Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* Refactor pkg_load/parse_descfile into a new backend fileDan McGee2008-05-11
| | | | | | | | | | alpm_pkg_load() and parse_descfile() are specific to getting information from package files, just as other code is specific to getting information into or out of a package database. Move this code out of package.c, which should eventually only contain operators on the pmpkg_t struct that do not depend at all on where the data came from. Signed-off-by: Dan McGee <dan@archlinux.org>
* get_filename : use the FILENAME db field only.Chantry Xavier2008-04-26
| | | | | | | | | | | | | | | | | | Reference : FS#9547. The get_filename function first tries to get the filename field from the database, and if it doesn't find it, it tries to guess it based on the name, version and arch. This field was introduced in 3.0, but there are still many old entries in the official databases without it. So the databases need to be regenerated first before this patch can be applied. There is a second problem with the delta code, which needs the filename for locally installed packages too, but this field is not present in the local db. So the delta code needs to be fixed first. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* Completely rework delta algorithmChantry Xavier2008-04-26
| | | | | | | | | | | | | | | | | | | | Using the graph structures that Nagy set up for dependency sorting, we now do a similar process for deltas. Load up all of the deltas into a graph object on which we can then apply Dijkstra's algorithm, using the new weight field of graph struct. We initialize the nodes weight using the base files that we can use in our filecache (both filename and md5sum must match). The algorithm then picks the best path among those that can be resolved. Note that this algorithm has a few advantages over the old one: 1. It is completely file agnostic. These delta chains do not have to consist of package files- this could be adopted to do delta-fied DBs. 2. It does not use the local_db anymore, or even care if a package or file is currently installed. Instead, it only looks in the filecache for files and packages that match delta chain entries. Original-work-by: Dan McGee <dan@archlinux.org> Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* Remove unnecessary header file, move one macro to util.cDan McGee2008-04-06
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* libalpm error cleanup, step 1Dan McGee2008-04-06
| | | | | | Remove unused error codes, begin refactoring some of the others. Signed-off-by: Dan McGee <dan@archlinux.org>
* Read .PKGINFO directly from package fileDan McGee2008-03-27
| | | | | | | | | With the addition of the archive_fgets() function, we can now skip the temp file usage in pkg_load/parse_descfile that was not needed. This has a nice benefit of probably being both faster, reducing code, and getting rid of "expensive" file operations. Signed-off-by: Dan McGee <dan@archlinux.org>
* Merge branch 'maint'Dan McGee2008-03-01
|\
| * Set a missing pm_errno in _alpm_pkg_load()Nagy Gabor2008-03-01
| | | | | | | | | | Signed-off-by: Nagy Gabor <ngaba@bibl.u-szeged.hu> Signed-off-by: Dan McGee <dan@archlinux.org>
* | libalpm: clean up of md5sum functions.Chantry Xavier2008-02-27
| | | | | | | | | | | | | | | | | | test_delta_md5sum and test_pkg_md5sum were simple wrappers to test_md5sum, and only used once, so not very useful. I removed them. Also, test_md5sum and alpm_pkg_checkmd5sum functions were a bit duplicated, so I refactored them with a new _alpm_test_md5sum function in libalpm/util.c Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* | Merge branch 'maint'Dan McGee2008-02-15
|\| | | | | | | | | | | | | Conflicts: lib/libalpm/be_files.c lib/libalpm/package.c
| * Ensure DESC infolevel is loaded before checking pkg->filenameDan McGee2008-02-13
| | | | | | | | | | | | | | | | | | | | | | This is the first step of fixing FS#9547. This should not break any existing code that may rely on this function behaving the way it did, and should be good for inclusion in a maint release. In addition, update pactest so it fills the FILENAME field in the DB entries it creates so we can move forward with a real fix to this issue. Signed-off-by: Dan McGee <dan@archlinux.org>
* | libalpm/package.c : add _alpm_pkgname_pkg_cmp function.Nagy Gabor2008-02-06
| | | | | | | | | | | | | | | | | | | | | | _alpm_pkgname_pkg_cmp(pkgname, pkg) returns true iff pkg's name is pkgname. This is useful if you want to remove a package from pmpkg_t* list, and you want to search for package name. This allows cleaning the -Ru code a bit, by removing the need of a dummy pkg. Signed-off-by: Chantry Xavier <shiningxc@gmail.com>
* | Move the deptest code from frontend to backend.Chantry Xavier2008-01-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The deptest code (pacman -T) used by makepkg was mostly in the frontend. There were 2 drawbacks: 1) the public splitdep function returns a pmdepend_t struct, but the _alpm_dep_free function for freeing it is private. So there was a memleak. 2) there is a helper in the backend (satisfycmp in deps.c) which makes this function much easier. So this adds a new public alpm_deptest in libalpm/deps.c, which cleans pacman_deptest in pacman/deptest.c a lot. Besides, alpm_splitdep was made private, because the frontend no longer requires it, and _alpm_dep_free is also private. Finally the deptest001 pactest was extended. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
* | Convert deltas to dynamic allocationDan McGee2008-01-21
| | | | | | | | | | | | | | | | Another elimination of a static length structure in libalpm. Should result in a little more memory saved during execution of packages with lots of deltas attached. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Merge branch 'maint'Dan McGee2008-01-11
|\|
| * Fix library interfaceDan McGee2008-01-11
| | | | | | | | | | | | | | | | | | | | | | | | Two functions defined in alpm.h were not marked with SYMEXPORT, causing linking errors if they were used. In addition, remove the incorrect use of the 'alpm_' prefix from an internal function and replace it with '_alpm_'. Fixes FS#9155. Signed-off-by: Dan McGee <dan@archlinux.org>
* | Add functions to manipulate pmdepend_t objectsDan McGee2008-01-11
| | | | | | | | | | | | | | | | | | | | | | 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>
* | Use dynamic string allocation in package structuresDan McGee2008-01-11
|/ | | | | | | | | | | | | | 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>
* Remove upgradedelay and all code associated with itDan McGee2008-01-08
| | | | | | | | 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>
* Remove unused date element from pmpkg_t structDan McGee2008-01-08
| | | | | | | 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>
* Small code cleanups with indents/spacesDan McGee2008-01-01
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove .FILELIST generation from makepkg (and elsewhere)Dan McGee2007-12-29
| | | | | | | | | | | | | | 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>
* Check for errors on descfile extractionDan McGee2007-12-16
| | | | | | | | | | | | | 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>
* Update GNU GPL boilerplate and copyright datesDan McGee2007-12-10
| | | | | | | 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>
* Improve changelog handling through addition of open/read/close functionsDan McGee2007-12-09
| | | | | | | | | | | | | | | | | | | | | | | 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>
* Add missing header includes for setlocaleDan McGee2007-11-20
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* Remove the IgnorePkg handling from alpm_pkg_compare_version.Chantry Xavier2007-11-18
| | | | | | | | 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>
* Remove provide.c and provide.h .Chantry Xavier2007-11-17
| | | | | | | | | 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>
* libalpm: use FREELIST when possibleDan McGee2007-11-16
| | | | Signed-off-by: Dan McGee <dan@archlinux.org>
* War on whitespaceDan McGee2007-11-16
| | | | | | Run the kernel's cleanfile script on all of our source files. Signed-off-by: Dan McGee <dan@archlinux.org>
* Fix alpm_list_copy_dataDan McGee2007-11-14
| | | | | | | | | | 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>
* Move alpm_splitdep usage to db_readDan McGee2007-11-14
| | | | | | | | | | | | | 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>