summaryrefslogtreecommitdiff
path: root/lib/libalpm/package.c
AgeCommit message (Collapse)Author
2011-08-18Remove use of no-op accessor functions in libraryDan McGee
The functions alpm_db_get_name(), alpm_pkg_get_name(), and alpm_pkg_get_version() are not necessary at all, so remove the calling and indirection when used in the backend, which makes things slightly more efficient and reduces code size. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-18Enhance and utilize database status flagsDan McGee
* Move is_local standalone field to status enum * Create VALID/INVALID flag pair * Create EXISTS/MISSING flag pair With these additional fields, we can be more intelligent with database loading and messages to the user. We now only warn once if a sync database does not exist and do not continue to try to load it once we have marked it as missing. The reason for the flags existing in pairs is so the unknown case can be represented. There should never be a time when both flags in the same group are true, but if they are both false, it represents the unknown case. Care is taken to always manipulate both flags at the same time. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Parse conflicts/provides/replaces at database load timeDan McGee
We did this with depends way back in commit c244cfecf654d3 in 2007. We can do it with these fields as well. Of note is the inclusion of provides even though only '=' is supported- we'll parse other things, but no guarantees are given as to behavior, which is more or less similar to before since we only looked for the equals sign. Also of note is the non-inclusion of optdepends; this will likely be resolved down the road. The biggest benefactors of this change will be the resolving code that formerly had to parse and reparse several of these fields; it only happens once now at load time. This does lead to the disadvantage that we will now always be parsing this information up front even if we never need it in the split form, but as these are uncommon fields and our parser is quite efficient it shouldn't be a big concern. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Validate the sha256sum if availableDan McGee
Adjust load_internal() to check the sha256sum value if we have it. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Remove checksum access indirectionDan McGee
These items are never present in anything but sync databases, nor do we even try to load them from the local database. Remvoe the indirection meant to allow the caching layer to work since it will never do anything anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15Load and allow access to sha256sumDan McGee
This adds a field in the package struct for this checksum type as well as allowing access via the API to it. The frontend is now able to display any read value. Note that this does not implement any use or verification of the value internally. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-15pacman/package: show presence of signature in in -SiDave Reisner
adds a new API method: alpm_pkg_get_base64_sig [Dan: don't use a new header string in frontend] Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-08-09Depend on name_hash being setDan McGee
This is a fairly valid assumption at this point, or at least as good of one as assuming packages all have names. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-21Convert package filelists to an array instead of linked listDan McGee
This accomplishes quite a few things with one rather invasive change. 1. Iteration is much more performant, due to a reduction in pointer chasing and linear item access. 2. Data structures are smaller- we no longer have the overhead of the linked list as the file struts are now laid out consecutively in memory. 3. Memory allocation has been massively reworked. Before, we would allocate three different pieces of memory per file item- the list struct, the file struct, and the copied filename. What this resulted in was massive fragmentation of memory when loading filelists since the memory allocator had to leave holes all over the place. The new situation here now removes the need for any list item allocation; allocates the file structs in contiguous memory (and reallocs as necessary), leaving only the strings as individually allocated. Tests using valgrind (massif) show some pretty significant memory reductions on the worst case `pacman -Ql > /dev/null` (366387 files on my machine): Before: Peak heap: 54,416,024 B Useful heap: 36,840,692 B Extra heap: 17,575,332 B After: Peak heap: 38,004,352 B Useful heap: 28,101,347 B Extra heap: 9,903,005 B Several small helper methods have been introduced, including a list to array conversion helper as well as a filelist merge sort that works directly on arrays. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-03Merge remote-tracking branch 'allan/ALPM'Dan McGee
Conflicts: lib/libalpm/be_local.c lib/libalpm/be_package.c lib/libalpm/conflict.c lib/libalpm/diskspace.c lib/libalpm/dload.c lib/libalpm/remove.c
2011-07-03Move alpm filelists to a struct objectDan McGee
This allows us to capture size and mode data when building filelists from package files. Future patches will take advantage of this newly available information, and frontends can use it as well. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-07-02Prefix _alpm_errno_t members with ALPMAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-30Make local_db_read() private to the local backendDan McGee
There is little need to expose the guts of this function even within the library. Make it static in be_local.c, and clean up a few other things since we know exactly where it is being called from: * Remove unnecessary origin checks in _cache_get_*() methods- if you are calling a cache method your package type will be correct. * Remove sanity checks within local_db_read() itself- packages will always have a name and version if they get this far, and the package object will never be NULL either. The one case calling this from outside the backend was in add.c, where we forced a full load of a package before we duplicated it. Move this concern elsewhere and have pkg_dup() always force a full package load via a new force_load() function on the operations callback struct. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-29Use ignoregroup rather than ignoregrp in the handleAllan McRae
This matches the naming in pacman.conf. Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmpkg_t to alpm_pkg_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmdb_t to alpm_db_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmhandle_t to alpm_handle_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-28Rename pmpkgreason_t to alpm_pkgreason_tAllan McRae
Signed-off-by: Allan McRae <allan@archlinux.org>
2011-06-27Fix several -Wshadow warningsDan McGee
Only one of these looked like a real red flag, in find_requiredby(), but it doesn't hurt to fix several of them up anyway. Unfortunately, we can't turn this on universally due to things like the sync(), remove(), etc. builtins which we often use as variable names. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-22Convert backup list to new pmbackup_t typeDan McGee
This allows us to separate the name and hash elements in one place and not scatter different parsing code all over the place, including both the frontend and backend. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-20Correctly duplicate delta objectsDan McGee
We were using copy_data before; this works for the struct itself but not the strings contained within. Fix it up by duplicating all the data as we do with our other structures. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Alpm pkg accessors: ensure pkg argument is non-NULLDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Ensure handle is valid and pm_errno is reset when calling into APIDan McGee
We didn't do due diligence before and ensure prior pm_errno values weren't influencing what happened in further ALPM calls. I observed one case of early setup code setting pm_errno to PM_ERR_WRONG_ARGS and that flag persisting the entire time we were calling library code. Add a new CHECK_HANDLE() macro that does two things: 1) ensures the handle variable passed to it is non-NULL and 2) clears any existing pm_errno flag set on the handle. This macro can replace many places we used the ASSERT(handle != NULL, ...) pattern before. Several other other places only need a simple 'set to zero' of the pm_errno field. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Small handle related cleanupsDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Add handle argument to _alpm_pkg_should_ignore()Dan McGee
This allows callers to retrieve it from wherever is convenient, which may or may not be on the package object itself. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-13Move pm_errno onto the handleDan McGee
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee
This requires a lot of line changes, but not many functional changes as more often than not our handle variable is already available in some fashion. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove global handle from some package and db codeDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Push down extern handle variable to files that need itDan McGee
This will make the patching process less invasive as we start to remove this variable from all source files. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Add handle attribute to pmpkg_t structDan McGee
Similar to what we just did for the database; this will make it easy to always know what handle a given package originated from. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove ALPM_LOG_FUNC macroDan McGee
The usefulness of this is rather limited due to it not being compiled into production builds. When you do choose to see the output, it is often overwhelming and not helpful. The best bet is to use a debugger and/or well-placed fprintf() statements. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-05-05Dan broke my patchAllan McRae
Add a missing space. Signed-off-by: Allan McRae <allan@archlinux.org>
2011-05-04Deal with unused function parameters correctlyAllan McRae
This started off removing the "(void)foo" hacks to work around unused function parameters and ended up fixing every warning generated by -Wunused-parameter. Dan: rename to UNUSED. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-24Rein in the complexity of the signature typeDan McGee
Given that we offer no transparency into the pmpgpsig_t type, we don't really need to expose it outside of the library, and at this point, we don't need it at all. Don't decode anything except when checking signatures. For packages/files not from a sync database, we now just read the signature file directly anyway. Also push the decoding logic down further into the check method so we don't need this hanging out in a less than ideal place. This will make it easier to conditionally compile things down the road. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20Rename gpgsig struct fields for clarityDan McGee
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20Header inclusion cleanupDan McGee
This does touch a lot of things, and hopefully doesn't break things on other platforms, but allows us to also clean up a bunch of crud that no longer needs to be there. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20syntax: if/while statements should have no trailing spaceDan McGee
This is the standard, and we have had a few of these introduced lately that should not be here. Done with: find -name '*.c' | xargs sed -i -e 's#if (#if(#g' find -name '*.c' | xargs sed -i -e 's#while (#while(#g' Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-20style cleanup: cast as (type *) not (type*)Dave Reisner
Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/alpm.h lib/libalpm/trans.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-15Remove indirection on get_name and get_version operationsDan McGee
For a package to be loaded from any of our backends, these two fields are always required upfront. Due to this fact, we don't need them to be backend-specific operations and can just refer to the field directly. Additionally, our static (and thus private) cache package accessors had a NULL check on pkg before returning the relevant field. Eliminate this since they only way they are ever called is via the packages attached callback struct, which would have caused the NULL pointer dereference in the first place. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-09Move documentation for public package function to alpm.hRémy Oudompheng
2011-04-05Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/be_sync.c lib/libalpm/db.c src/pacman/util.c
2011-04-01Add default changelog functions to pkg_operationsDan McGee
So we don't segfault when calling this on be_sync loaded packages. They return logical values as much as possible for indicating there is no changelog available. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-27Merge branch 'maint'Dan McGee
Conflicts: lib/libalpm/deps.c
2011-03-25Rework find_requiredby() to not use _alpm_dep_edge()Dan McGee
And move the sort after the final loop; we don't need to sort once for each database we look at. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23Allow PGP signature to be read from sync databaseDan McGee
Add a new field to the package struct to hold PGP information and instruct db_read to pick it up from the database. It is currently unused internally but this is the first step. Due to the fact that we store the PGP sig as binary data, we need to store both the data and the length so we have a small utility struct to assist us. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-21Merge branch 'maint'Dan McGee
Conflicts due to change in return calling style. Conflicts: src/pacman/pacman.c src/pacman/sync.c
2011-03-20Fix comparison to 0 rather than NULLDan McGee
Another fix found by Coccinelle example semantic patches. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-20Style change: return(x) --> return xDan McGee
This was discussed and more or less agreed upon on the mailing list. A huge checkin, but if we just do it and let people adjust the pain will end soon enough. Rebasing should be relatively straighforward for anyone that sees conflicts; just be sure you use the new return style if possible. The following semantic patch was used to do the change, along with some hand-massaging in order to preserve parenthesis where appropriate: The semantic match that finds this problem is as follows, although some hand-massaging was done in order to keep parenthesis where appropriate: (http://coccinelle.lip6.fr/) // <smpl> @@ expression a; @@ - return(a); + return a; // </smpl> A macros_file was also provided with the following content: Additional steps taken, mainly for ASSERT() macros: $ sed -i -e 's#return(NULL)#return NULL#' lib/libalpm/*.c $ sed -i -e 's#return(-1)#return -1#' lib/libalpm/*.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25alpm: alpm_db_get_pkgcache_list => alpm_db_get_pkgcacheDave Reisner
This avoids needless breakage of the public API. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>