mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 04:57:59 -05:00
Add a alpm_db_test() function to the backend for checking DB consistency
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
25c5b39d05
commit
dfc85cb5f5
lib/libalpm
@ -157,6 +157,7 @@ alpm_list_t *alpm_db_whatprovides(pmdb_t *db, const char *name);
|
||||
|
||||
pmgrp_t *alpm_db_readgrp(pmdb_t *db, const char *name);
|
||||
alpm_list_t *alpm_db_getgrpcache(pmdb_t *db);
|
||||
alpm_list_t *alpm_db_test(pmdb_t *db);
|
||||
alpm_list_t *alpm_db_search(pmdb_t *db, const alpm_list_t* needles);
|
||||
|
||||
alpm_list_t *alpm_db_get_upgrades();
|
||||
|
@ -65,6 +65,37 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile)
|
||||
return unlink(dbfile);
|
||||
}
|
||||
|
||||
alpm_list_t *_alpm_db_test(pmdb_t *db)
|
||||
{
|
||||
struct dirent *ent;
|
||||
char path[PATH_MAX];
|
||||
struct stat buf;
|
||||
alpm_list_t *ret = NULL;
|
||||
|
||||
while ((ent = readdir(db->handle)) != NULL) {
|
||||
if(!strcmp(ent->d_name, ".") || !strcmp(ent->d_name, "..")) {
|
||||
continue;
|
||||
}
|
||||
/* check for desc, depends, and files */
|
||||
snprintf(path, PATH_MAX, "%s/%s/desc", db->path, ent->d_name);
|
||||
if(stat(path, &buf)) {
|
||||
snprintf(path, LOG_STR_LEN, _("%s: description file is missing"), ent->d_name);
|
||||
ret = alpm_list_add(ret, strdup(path));
|
||||
}
|
||||
snprintf(path, PATH_MAX, "%s/%s/depends", db->path, ent->d_name);
|
||||
if(stat(path, &buf)) {
|
||||
snprintf(path, LOG_STR_LEN, _("%s: dependency file is missing"), ent->d_name);
|
||||
ret = alpm_list_add(ret, strdup(path));
|
||||
}
|
||||
snprintf(path, PATH_MAX, "%s/%s/files", db->path, ent->d_name);
|
||||
if(stat(path, &buf)) {
|
||||
snprintf(path, LOG_STR_LEN, _("%s: file list is missing"), ent->d_name);
|
||||
ret = alpm_list_add(ret, strdup(path));
|
||||
}
|
||||
}
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int _alpm_db_open(pmdb_t *db)
|
||||
{
|
||||
ALPM_LOG_FUNC;
|
||||
|
@ -368,6 +368,19 @@ alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db)
|
||||
return(_alpm_db_get_grpcache(db));
|
||||
}
|
||||
|
||||
/** Tests a database
|
||||
* @param db pointer to the package database to search in
|
||||
* @return the list of problems found on success, NULL on error
|
||||
*/
|
||||
alpm_list_t SYMEXPORT *alpm_db_test(pmdb_t *db)
|
||||
{
|
||||
/* Sanity checks */
|
||||
ASSERT(handle != NULL, return(NULL));
|
||||
ASSERT(db != NULL, return(NULL));
|
||||
|
||||
return(_alpm_db_test(db));
|
||||
}
|
||||
|
||||
/** Searches a database
|
||||
* @param db pointer to the package database to search in
|
||||
* @param needles the list of strings to search for
|
||||
|
@ -56,6 +56,7 @@ pmdb_t *_alpm_db_register(const char *treename);
|
||||
|
||||
/* be.c, backend specific calls */
|
||||
int _alpm_db_install(pmdb_t *db, const char *dbfile);
|
||||
alpm_list_t *_alpm_db_test(pmdb_t *db);
|
||||
int _alpm_db_open(pmdb_t *db);
|
||||
void _alpm_db_close(pmdb_t *db);
|
||||
void _alpm_db_rewind(pmdb_t *db);
|
||||
|
Loading…
Reference in New Issue
Block a user