summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/db.c
AgeCommit message (Collapse)AuthorFilesLines
2011-06-24Add a 'valid' flag to the database objectDan McGee1-23/+26
Start by converting all of our flags to a 'status' bitmask (pkgcache status, grpcache status). Add a new 'valid' flag as well. This will let us keep track if the database itself has been marked valid in whatever fashion. For local databases at the moment we ensure there are no depends files; for sync databases we ensure the PGP signature is valid if required/requested. The loading of the pkgcache is prohibited if the database is invalid. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24Move database 'version' check to registration timeDan McGee1-13/+0
This is another step toward doing both local database validation (ensuring we don't have depends files) and sync database validation (via signatures if present) when the database is registered. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-24Do database signature checking at load timeDan McGee1-2/+3
This is the ideal place to do it as all clients should be checking the return value and ensuring there are no errors. This is similar to pkg_load(). We also add an additional step of validation after we download a new database; a subsequent '-y' operation can potentially invalidate the original check at registration time. Note that this implementation is still a bit naive; if a signature is invalid it is currently impossible to refresh and re-download the file without manually deleting it first. Similarly, if one downloads a database and the check fails, the database object is still there and can be used. These shortcomings will be addressed in a future commit. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Ensure handle is valid and pm_errno is reset when calling into APIDan McGee1-4/+16
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-14Remove alpm_db_get_url()Dan McGee1-14/+0
This method is old, it doesn't adequately check for a NULL server list, and can easily be done using better API method we provide these days. All former users of this method can get similar results by calling alpm_db_get_servers() and using the data from the returned server list. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Add a helper method for retrieving the DB signature pathDan McGee1-0/+14
Note that is a bit different than the normal _alpm_db_path() method; the caller is expected to free the result. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Switch all logging to use handle directlyDan McGee1-23/+19
This is the last user of our global handle object. Once again the diff is large but the functional changes are not. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Move pm_errno onto the handleDan McGee1-38/+37
This involves some serious changes and a very messy diff, unfortunately. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Added initialization code for database siglevelKerrick Staley1-0/+1
The siglevel field of a newly created pmdb_t struct is now initialized when it is created in _alpm_db_new(). Signed-off-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-14Fix all current return(x) usagesDan McGee1-2/+2
A few of these snuck in as of late, some from the table display patches that were using the previous format before we changed it after the 3.5.X major release. Noticed-by: Kerrick Staley <mail@kerrickstaley.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle for alpm_db_register_sync()Dan McGee1-4/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-09Require handle argument to all alpm_option_(get|set)_*() methodsDan McGee1-1/+1
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-07New signatures for alpm initialize and releaseDan McGee1-1/+1
These new method signatures return and take handle objects to operate on so we can move away from the idea of one global handle in the API. There is also another important change and that deals with the setting of root and dbpaths. These are now done at initialization time instead of using setter methods. This allows the library to operate more safely knowing that paths won't change underneath it. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove global handle from some package and db codeDan McGee1-6/+5
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Push down extern handle variable to files that need itDan McGee1-0/+3
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-03Remove unnecessary handle != NULL assertsDan McGee1-8/+0
These are simple accessor functions for a struct; the handle never even comes into play when calling these functions. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-06-03Remove ALPM_LOG_FUNC macroDan McGee1-60/+0
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-05Improve database server APIDan McGee1-16/+80
Currently we have one call that has all sorts of crazy behavior and doesn't make a whole lot of sense. Go from one method to the normal four methods we have for all of our other lists we use in the library to make it a lot easier for a frontend to manipulate server lists. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-24signing: let GPGME handle loading signatures from filesDan McGee1-23/+0
Rather than go through all the hassle of doing this ourselves, just let GPGME handle the work by passing it a file handle. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-21Rename gpgsig struct fields for clarityDan McGee1-3/+3
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-21Form the signature file location in one placeDan McGee1-8/+1
Since we do this for all cases anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-21Header inclusion cleanupDan McGee1-3/+0
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-21syntax: if/while statements should have no trailing spaceDan McGee1-3/+3
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-21style cleanup: cast as (type *) not (type*)Dave Reisner1-1/+1
Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-16Merge branch 'maint'Dan McGee1-53/+12
Conflicts: lib/libalpm/alpm.h lib/libalpm/trans.c Signed-off-by: Dan McGee <dan@archlinux.org>
2011-04-09Move documentation of public database functions to alpm.hRémy Oudompheng1-53/+12
2011-04-05Merge branch 'maint'Dan McGee1-1/+1
Conflicts: lib/libalpm/be_sync.c lib/libalpm/db.c src/pacman/util.c
2011-04-05db.c: set pm_errno appropriately in alpm_db_set_pkgreason()Rémy Oudompheng1-1/+1
Signed-off-by: Rémy Oudompheng <remy@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-29Merge branch 'maint'Dan McGee1-4/+1
2011-03-29Fix an outdated commentDan McGee1-4/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-28Temporary fix for new warnings from gcc 4.6Dan McGee1-0/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-25Merge branch 'maint'Dan McGee1-6/+2
2011-03-24alpm/db: do not close local DB in alpm_db_unregister_allDave Reisner1-6/+2
pacman 3.5.0 removed alpm_db_register_local, so calling alpm_db_unregister_all leaves the front end in a position where there's no local db, and no way to re-register it. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-24Refactor signature loading code into common functionDan McGee1-50/+14
We can use this for both standalone package signatures as well as standalone database signatures. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-24Add functions for verifying database signatureAllan McRae1-0/+65
Add a pmpgpsig_t struct to the database entry struct and functions for the lazy loading of database signatures. Add a function for checking database signatures, reusing (and generalizing) the code currently used for checking package signatures. TODO: The code for reading in signature files from the filesystem is duplicated for local packages and database and needs refactoring. Signed-off-by: Allan McRae <allan@archlinux.org>
2011-03-23Added gpg verification options per repo to the config file.Xavier Chantry1-0/+18
Once we do this, add support for VerifySig to pactest. We just check if the repo name contains Always, Never or Optional to determine the value of VerifySig. The default is Never. pacman uses Always by default but this is not suitable for pactest. Original-work-by: shankar <jatheendra@gmail.com> Signed-off-by: Xavier Chantry <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-23Remove unnecessary sanity check on db->setserverDan McGee1-12/+0
We pass in a db object, so no need to go looking for it in the list on the handle. This is a remnant of when we passed in a treename, more than likely. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-03-21Style change: return(x) --> return xDan McGee1-60/+60
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-28Check local DB version before continuing transactionDan McGee1-0/+8
Ensure we have a local DB version that is up to par with what we expect before we go down any road that might modify it. This should prevent stupid mistakes with the 3.5.X upgrade and people not running pacman-db-upgrade after the transaction as they will need to. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25alpm: alpm_db_get_pkgcache_list => alpm_db_get_pkgcacheDave Reisner1-6/+6
This avoids needless breakage of the public API. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-25alpm: remove public visibility of pmpkghash_tDave Reisner1-18/+3
There's no API functions exposed which allow manipulation of this type, so remove it from public view. Also, rename the public and private alpm_db_get_pkgcache symbol to alpm_db_get_pkgcache_has. Signed-off-by: Dave Reisner <d@falconindy.com> Signed-off-by: Dan McGee <dan@archlinux.org>
2011-02-04Actually remove packages from pkghash on removalAllan McRae1-1/+1
Fully removes a package from the hash. Also unify prototype with removal from an alpm_list_t, fixing issues when removing a package from the pkgcache. Signed-off-by: Allan McRae <allan@archlinux.org>
2011-02-04Read pkgcache into hashAllan McRae1-14/+41
Read the package information for sync/local databases into a pmpkghash_t structure. Provide a alpm_db_get_pkgcache_list() method that returns the list from the hash object. Most usages of alpm_db_get_pkgcache are converted to this at this stage for ease of implementation. Review whether these are better accessing the hash table directly at a later stage. Signed-off-by: Allan McRae <allan@archlinux.org>
2011-01-29Remove need to explicitly register the local DBDan McGee1-15/+0
Perform the cheap struct and string setup of the local DB at handle initialization time to match the teardown we do when releasing the handle. If the local DB is not needed, all real initialization is done lazily after DB paths and other things have been configured anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-08Fix some more simple conversion "errors"Dan McGee1-1/+1
None of these warn at the normal "-Wall -Werror" level, but casts do occur that we are fine with. Make them explicit to silence some warnings when using "-Wconversion". Signed-off-by: Dan McGee <dan@archlinux.org>
2011-01-08Update copyright years for 2011Allan McRae1-1/+1
Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-14Correctly force load of package reasonDan McGee1-5/+1
Signed-off-by: Dan McGee <dan@archlinux.org>
2010-12-13dirent usage cleanupDan McGee1-1/+0
We were including the header in a lot of places it is no longer used. Additionally, use the correct autoconf macro for determining whether d_type is available as a member: HAVE_STRUCT_DIRENT_D_TYPE. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
2010-10-14Move and rename splitnameAllan McRae1-46/+0
The splitname function is a general utility function and so is better suited to util.h. Rename it to _alpm_splitname to indicate it is an internal libalpm function as was the case prior to splitting local and sync db handling. Signed-off-by: Allan McRae <allan@archlinux.org>
2010-10-14Restrict visibility of checkdbdir and get_pkgpathAllan McRae1-37/+0
These functions are only needed by be_local and were only promoted to db.{h,c} as part of the splitting of handling the local and sync dbs. Move them into be_local.c and make them static again. Signed-off-by: Allan McRae <allan@archlinux.org>