summaryrefslogtreecommitdiff
path: root/src/pacman
diff options
context:
space:
mode:
Diffstat (limited to 'src/pacman')
-rw-r--r--src/pacman/conf.h1
-rw-r--r--src/pacman/pacman.c7
-rw-r--r--src/pacman/query.c20
3 files changed, 27 insertions, 1 deletions
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 74d83e69..252bb95a 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -45,6 +45,7 @@ typedef struct __config_t {
unsigned short op_q_owns;
unsigned short op_q_search;
unsigned short op_q_changelog;
+ unsigned short op_q_test;
unsigned short op_q_upgrade;
unsigned short op_s_clean;
unsigned short op_s_dependsonly;
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index bfbfb1b9..2f0ed790 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -121,6 +121,7 @@ static void usage(int op, char *myname)
printf(_(" -o, --owns <file> query the package that owns <file>\n"));
printf(_(" -p, --file <package> query a package file instead of the database\n"));
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
+ printf(_(" -t, --test check the consistency of the local database\n"));
printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
} else if(op == PM_OP_SYNC) {
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
@@ -278,6 +279,7 @@ static int parseargs(int argc, char *argv[])
{"root", required_argument, 0, 'r'},
{"recursive", no_argument, 0, 's'},
{"search", no_argument, 0, 's'},
+ {"test", no_argument, 0, 't'},
{"upgrades", no_argument, 0, 'u'},
{"sysupgrade", no_argument, 0, 'u'},
{"verbose", no_argument, 0, 'v'},
@@ -296,7 +298,7 @@ static int parseargs(int argc, char *argv[])
};
struct stat st;
- while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepiuwygz", opts, &option_index))) {
+ while((opt = getopt_long(argc, argv, "ARUFQSTr:b:vkhscVfmnoldepituwygz", opts, &option_index))) {
if(opt < 0) {
break;
}
@@ -402,6 +404,9 @@ static int parseargs(int argc, char *argv[])
config->op_q_search = 1;
config->flags |= PM_TRANS_FLAG_RECURSE;
break;
+ case 't':
+ config->op_q_test = 1;
+ break;
case 'u':
config->op_s_upgrade = 1;
config->op_q_upgrade = 1;
diff --git a/src/pacman/query.c b/src/pacman/query.c
index 3863572f..6ca45d91 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -257,6 +257,26 @@ int pacman_query(alpm_list_t *targets)
return(ret);
}
+ if(config->op_q_test) {
+ alpm_list_t *testlist;
+ printf(_("Checking database for consistency..."));
+ testlist = alpm_db_test(db_local);
+ if(testlist == NULL) {
+ printf(_("check complete.\n"));
+ return(0);
+ } else {
+ /* on failure, increment the ret val by 1 for each failure */
+ ret = 0;
+ printf(_("check failed!\n"));
+ fflush(stdout);
+ for(i = testlist; i; i = alpm_list_next(i)) {
+ fprintf(stderr, "%s\n", (char*)alpm_list_getdata(i));
+ ret++;
+ }
+ return(ret);
+ }
+ }
+
if(config->op_q_foreign) {
sync_dbs = alpm_option_get_syncdbs();