mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-08 12:28:00 -05:00
Implement a -Qt operation in frontend to test the database
After adding a alpm_db_check() operation in the back end, we can call it in the front end and present a user-friendly interface to it. Inspired-by: VMiklos <vmiklos@frugalware.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
dfc85cb5f5
commit
b6f3fe6957
@ -157,6 +157,10 @@ useful in combination with \fB--info\fP and \fB--list\fP.
|
||||
This will search each locally-installed package for names or descriptions that
|
||||
matche \fIregexp\fP.
|
||||
.TP
|
||||
.B \-t, --test
|
||||
Test the consistancy of the local pacman database, and alert you of any
|
||||
problems found while searching. Returns 0 on success, >0 otherwise.
|
||||
.TP
|
||||
.B \-u, --upgrades
|
||||
Lists all packages that are out of date on the local system. This option works
|
||||
best if the sync database is refreshed using \fB-Sy\fP.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user