diff options
Diffstat (limited to 'lib/libalpm')
-rw-r--r-- | lib/libalpm/alpm.h | 1 | ||||
-rw-r--r-- | lib/libalpm/be_files.c | 31 | ||||
-rw-r--r-- | lib/libalpm/db.c | 13 | ||||
-rw-r--r-- | lib/libalpm/db.h | 1 |
4 files changed, 46 insertions, 0 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h index 0e545dd1..9f029b2e 100644 --- a/lib/libalpm/alpm.h +++ b/lib/libalpm/alpm.h @@ -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(); diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c index 2cd14e15..b338af9d 100644 --- a/lib/libalpm/be_files.c +++ b/lib/libalpm/be_files.c @@ -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; diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 7536e678..9d75c5c0 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -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 diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h index 3c97e580..2597c8c4 100644 --- a/lib/libalpm/db.h +++ b/lib/libalpm/db.h @@ -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); |