summaryrefslogtreecommitdiffstats
path: root/src/pacman/sync.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-01-29 00:41:15 +0100
committerDan McGee <dan@archlinux.org>2011-01-29 19:13:56 +0100
commitef86da97f54a90ee4ba3ba8ea7963135e7bae8ed (patch)
tree99c492d170d3780ac2530413031593cc248a8fd3 /src/pacman/sync.c
parent9b876fff09f2af10cba6824bec03d8fe3e167b5b (diff)
downloadpacman-ef86da97f54a90ee4ba3ba8ea7963135e7bae8ed.tar.gz
pacman-ef86da97f54a90ee4ba3ba8ea7963135e7bae8ed.tar.xz
Remove need to explicitly register the local DB
Perform the cheap struct and string setup of the local DB at handle initialization time to match the teardown we do when releasing the handle. If the local DB is not needed, all real initialization is done lazily after DB paths and other things have been configured anyway. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src/pacman/sync.c')
-rw-r--r--src/pacman/sync.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/pacman/sync.c b/src/pacman/sync.c
index 278f15e5..7353f7ee 100644
--- a/src/pacman/sync.c
+++ b/src/pacman/sync.c
@@ -37,8 +37,6 @@
#include "package.h"
#include "conf.h"
-extern pmdb_t *db_local;
-
/* if keep_used != 0, then the db files which match an used syncdb
* will be kept */
static int sync_cleandb(const char *dbpath, int keep_used) {
@@ -144,6 +142,7 @@ static int sync_cleancache(int level)
{
alpm_list_t *i;
alpm_list_t *sync_dbs = alpm_option_get_syncdbs();
+ pmdb_t *db_local = alpm_option_get_localdb();
int ret = 0;
for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
@@ -295,7 +294,7 @@ static int sync_synctree(int level, alpm_list_t *syncs)
return(success > 0);
}
-static void print_installed(pmpkg_t *pkg)
+static void print_installed(pmdb_t *db_local, pmpkg_t *pkg)
{
const char *pkgname = alpm_pkg_get_name(pkg);
const char *pkgver = alpm_pkg_get_version(pkg);
@@ -316,6 +315,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
alpm_list_t *i, *j, *ret;
int freelist;
int found = 0;
+ pmdb_t *db_local = alpm_option_get_localdb();
for(i = syncs; i; i = alpm_list_next(i)) {
pmdb_t *db = alpm_list_getdata(i);
@@ -366,7 +366,7 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
printf(")");
}
- print_installed(pkg);
+ print_installed(db_local, pkg);
/* we need a newline and initial indent first */
printf("\n ");
@@ -519,6 +519,7 @@ static int sync_info(alpm_list_t *syncs, alpm_list_t *targets)
static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
{
alpm_list_t *i, *j, *ls = NULL;
+ pmdb_t *db_local = alpm_option_get_localdb();
if(targets) {
for(i = targets; i; i = alpm_list_next(i)) {
@@ -556,7 +557,7 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
if (!config->quiet) {
printf("%s %s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
alpm_pkg_get_version(pkg));
- print_installed(pkg);
+ print_installed(db_local, pkg);
printf("\n");
} else {
printf("%s\n", alpm_pkg_get_name(pkg));