mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-09 04:57:59 -05:00
Remove the DB consistency check from pacman and libalpm.
This reverts commitdfc85cb5f5
andb6f3fe6957
. This DB check is already in testdb (among others). Also testdb now uses the db path set at make time by default, so specifying the db path is optional. Signed-off-by: Chantry Xavier <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
7daf5a038d
commit
046c8a6819
@ -157,10 +157,6 @@ useful in combination with \fB--info\fP and \fB--list\fP.
|
|||||||
This will search each locally-installed package for names or descriptions that
|
This will search each locally-installed package for names or descriptions that
|
||||||
matche \fIregexp\fP.
|
matche \fIregexp\fP.
|
||||||
.TP
|
.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
|
.B \-u, --upgrades
|
||||||
Lists all packages that are out of date on the local system. This option works
|
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.
|
best if the sync database is refreshed using \fB-Sy\fP.
|
||||||
|
@ -164,7 +164,6 @@ alpm_list_t *alpm_db_whatprovides(pmdb_t *db, const char *name);
|
|||||||
|
|
||||||
pmgrp_t *alpm_db_readgrp(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_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_search(pmdb_t *db, const alpm_list_t* needles);
|
||||||
|
|
||||||
alpm_list_t *alpm_db_get_upgrades(void);
|
alpm_list_t *alpm_db_get_upgrades(void);
|
||||||
|
@ -62,38 +62,6 @@ int _alpm_db_install(pmdb_t *db, const char *dbfile)
|
|||||||
return unlink(dbfile);
|
return unlink(dbfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
alpm_list_t *_alpm_db_test(pmdb_t *db)
|
|
||||||
{
|
|
||||||
struct dirent *ent;
|
|
||||||
char path[PATH_MAX];
|
|
||||||
char text[PATH_MAX+1];
|
|
||||||
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(text, PATH_MAX, _("%s: description file is missing"), ent->d_name);
|
|
||||||
ret = alpm_list_add(ret, strdup(text));
|
|
||||||
}
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s/depends", db->path, ent->d_name);
|
|
||||||
if(stat(path, &buf)) {
|
|
||||||
snprintf(text, PATH_MAX, _("%s: dependency file is missing"), ent->d_name);
|
|
||||||
ret = alpm_list_add(ret, strdup(text));
|
|
||||||
}
|
|
||||||
snprintf(path, PATH_MAX, "%s/%s/files", db->path, ent->d_name);
|
|
||||||
if(stat(path, &buf)) {
|
|
||||||
snprintf(text, PATH_MAX, _("%s: file list is missing"), ent->d_name);
|
|
||||||
ret = alpm_list_add(ret, strdup(text));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
int _alpm_db_open(pmdb_t *db)
|
int _alpm_db_open(pmdb_t *db)
|
||||||
{
|
{
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
@ -420,19 +420,6 @@ alpm_list_t SYMEXPORT *alpm_db_getgrpcache(pmdb_t *db)
|
|||||||
return(_alpm_db_get_grpcache(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
|
/** Searches a database
|
||||||
* @param db pointer to the package database to search in
|
* @param db pointer to the package database to search in
|
||||||
* @param needles the list of strings to search for
|
* @param needles the list of strings to search for
|
||||||
|
@ -57,7 +57,6 @@ pmdb_t *_alpm_db_register_sync(const char *treename);
|
|||||||
|
|
||||||
/* be.c, backend specific calls */
|
/* be.c, backend specific calls */
|
||||||
int _alpm_db_install(pmdb_t *db, const char *dbfile);
|
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);
|
int _alpm_db_open(pmdb_t *db);
|
||||||
void _alpm_db_close(pmdb_t *db);
|
void _alpm_db_close(pmdb_t *db);
|
||||||
void _alpm_db_rewind(pmdb_t *db);
|
void _alpm_db_rewind(pmdb_t *db);
|
||||||
|
@ -48,7 +48,6 @@ typedef struct __config_t {
|
|||||||
unsigned short op_q_owns;
|
unsigned short op_q_owns;
|
||||||
unsigned short op_q_search;
|
unsigned short op_q_search;
|
||||||
unsigned short op_q_changelog;
|
unsigned short op_q_changelog;
|
||||||
unsigned short op_q_test;
|
|
||||||
unsigned short op_q_upgrade;
|
unsigned short op_q_upgrade;
|
||||||
|
|
||||||
unsigned short op_s_clean;
|
unsigned short op_s_clean;
|
||||||
|
@ -121,7 +121,6 @@ static void usage(int op, char *myname)
|
|||||||
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
|
printf(_(" -s, --search <regex> search locally-installed packages for matching strings\n"));
|
||||||
printf(_(" -t, --orphans list all packages not required by any package\n"));
|
printf(_(" -t, --orphans list all packages not required by any package\n"));
|
||||||
printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
|
printf(_(" -u, --upgrades list all packages that can be upgraded\n"));
|
||||||
printf(_(" --test check the consistency of the local database\n"));
|
|
||||||
} else if(op == PM_OP_SYNC) {
|
} else if(op == PM_OP_SYNC) {
|
||||||
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
|
printf("%s: %s {-S --sync} [%s] [%s]\n", str_usg, myname, str_opt, str_pkg);
|
||||||
printf("%s:\n", str_opt);
|
printf("%s:\n", str_opt);
|
||||||
@ -284,7 +283,6 @@ static int parseargs(int argc, char *argv[])
|
|||||||
{"ask", required_argument, 0, 1006},
|
{"ask", required_argument, 0, 1006},
|
||||||
{"cachedir", required_argument, 0, 1007},
|
{"cachedir", required_argument, 0, 1007},
|
||||||
{"asdeps", no_argument, 0, 1008},
|
{"asdeps", no_argument, 0, 1008},
|
||||||
{"test", no_argument, 0, 1009},
|
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -338,9 +336,6 @@ static int parseargs(int argc, char *argv[])
|
|||||||
case 1008:
|
case 1008:
|
||||||
config->flags |= PM_TRANS_FLAG_ALLDEPS;
|
config->flags |= PM_TRANS_FLAG_ALLDEPS;
|
||||||
break;
|
break;
|
||||||
case 1009:
|
|
||||||
config->op_q_test = 1;
|
|
||||||
break;
|
|
||||||
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
|
case 'A': config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_ADD); break;
|
||||||
case 'F':
|
case 'F':
|
||||||
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
|
config->op = (config->op != PM_OP_MAIN ? 0 : PM_OP_UPGRADE);
|
||||||
|
@ -213,29 +213,6 @@ static int query_group(alpm_list_t *targets)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int query_test(void)
|
|
||||||
{
|
|
||||||
int ret = 0;
|
|
||||||
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 */
|
|
||||||
alpm_list_t *i;
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int query_upgrades(void)
|
static int query_upgrades(void)
|
||||||
{
|
{
|
||||||
alpm_list_t *syncpkgs;
|
alpm_list_t *syncpkgs;
|
||||||
@ -338,12 +315,6 @@ int pacman_query(alpm_list_t *targets)
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check DB consistancy */
|
|
||||||
if(config->op_q_test) {
|
|
||||||
ret = query_test();
|
|
||||||
return(ret);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* check for package upgrades */
|
/* check for package upgrades */
|
||||||
if(config->op_q_upgrade) {
|
if(config->op_q_upgrade) {
|
||||||
ret = query_upgrades();
|
ret = query_upgrades();
|
||||||
|
@ -1,5 +1,16 @@
|
|||||||
|
# paths set at make time
|
||||||
|
conffile = ${sysconfdir}/pacman.conf
|
||||||
|
dbpath = ${localstatedir}/lib/pacman/
|
||||||
|
cachedir = ${localstatedir}/cache/pacman/pkg/
|
||||||
|
|
||||||
bin_PROGRAMS = vercmp testpkg testdb
|
bin_PROGRAMS = vercmp testpkg testdb
|
||||||
|
|
||||||
|
DEFS = -DLOCALEDIR=\"@localedir@\" \
|
||||||
|
-DCONFFILE=\"$(conffile)\" \
|
||||||
|
-DROOTDIR=\"$(ROOTDIR)\" \
|
||||||
|
-DDBPATH=\"$(dbpath)\" \
|
||||||
|
-DCACHEDIR=\"$(cachedir)\" \
|
||||||
|
@DEFS@
|
||||||
INCLUDES = -I$(top_srcdir)/lib/libalpm
|
INCLUDES = -I$(top_srcdir)/lib/libalpm
|
||||||
|
|
||||||
AM_CFLAGS = -pedantic -D_GNU_SOURCE
|
AM_CFLAGS = -pedantic -D_GNU_SOURCE
|
||||||
|
@ -135,19 +135,23 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int retval = 0; /* default = false */
|
int retval = 0; /* default = false */
|
||||||
pmdb_t *db = NULL;
|
pmdb_t *db = NULL;
|
||||||
char dbpath[PATH_MAX];
|
char *dbpath;
|
||||||
|
char localdbpath[PATH_MAX];
|
||||||
alpm_list_t *i;
|
alpm_list_t *i;
|
||||||
|
|
||||||
if(argc != 2) {
|
if(argc == 1) {
|
||||||
fprintf(stderr, "usage: %s <pacman db>\n", basename(argv[0]));
|
dbpath = DBPATH;
|
||||||
|
} else if(argc == 3 && strcmp(argv[1], "-b") == 0) {
|
||||||
|
dbpath = argv[2];
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "usage: %s -b <pacman db>\n", basename(argv[0]));
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(dbpath, PATH_MAX, "%s/local", argv[1]);
|
snprintf(localdbpath, PATH_MAX, "%s/local", dbpath);
|
||||||
|
retval = db_test(localdbpath);
|
||||||
retval = db_test(dbpath);
|
|
||||||
if(retval) {
|
if(retval) {
|
||||||
exit(retval);
|
return(retval);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(alpm_initialize() == -1) {
|
if(alpm_initialize() == -1) {
|
||||||
@ -158,7 +162,7 @@ int main(int argc, char **argv)
|
|||||||
/* let us get log messages from libalpm */
|
/* let us get log messages from libalpm */
|
||||||
alpm_option_set_logcb(output_cb);
|
alpm_option_set_logcb(output_cb);
|
||||||
|
|
||||||
alpm_option_set_dbpath(argv[1]);
|
alpm_option_set_dbpath(dbpath);
|
||||||
|
|
||||||
db = alpm_db_register_local();
|
db = alpm_db_register_local();
|
||||||
if(db == NULL) {
|
if(db == NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user