Here's the quick-and-dirty version of moving repos to $DBPATH/sync/$REPO. I don't much like it, to be honest - I'd prefer to separate the concept of the local repo from the sync repos entirely, but that would break the current interface into libalpm, as alpm_db_register("local") would, ideally, register a sync repo named "local", and we'd have to add another method like alpm_localdb_register() or something of that sort to register the local database. I could do the less-dirty fix, but I quite imagine the current API is supposed to remain decently stable, so here's one that works with the current setup. From 552b39f5dafdf4e1104ee7f4876f6a1a7115a736 Mon Sep 17 00:00:00 2001 From: Travis Willard <travis@archlinux.org> Date: Fri, 24 Aug 2007 22:28:15 -0400 Subject: [PATCH] Quick and dirty change to move sync repos. This is a quick-n-dirty fix to place all sync repos into the $DBPATH/sync/$REPO path instead of the previous $DBPATH/$REPO - this differentiates sync repos from local repos structurally. Signed-off-by: Travis Willard <travis@archlinux.org> --- lib/libalpm/db.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 0cb375d..6bc85b7 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -695,7 +695,9 @@ pmdb_t *_alpm_db_register(const char *treename) struct stat buf; pmdb_t *db; const char *dbpath; + char real_dbpath[PATH_MAX]; char path[PATH_MAX]; + char local; ALPM_LOG_FUNC; @@ -704,6 +706,7 @@ pmdb_t *_alpm_db_register(const char *treename) _alpm_log(PM_LOG_WARNING, _("attempt to re-register the 'local' DB")); RET_ERR(PM_ERR_DB_NOT_NULL, NULL); } + local = 1; } else { alpm_list_t *i; for(i = handle->dbs_sync; i; i = i->next) { @@ -713,6 +716,7 @@ pmdb_t *_alpm_db_register(const char *treename) return sdb; } } + local = 0; } _alpm_log(PM_LOG_DEBUG, "registering database '%s'", treename); @@ -723,7 +727,8 @@ pmdb_t *_alpm_db_register(const char *treename) _alpm_log(PM_LOG_WARNING, _("database path is undefined")); RET_ERR(PM_ERR_DB_OPEN, NULL); } - snprintf(path, PATH_MAX, "%s%s", dbpath, treename); + snprintf(real_dbpath, PATH_MAX, "%s%s", dbpath, local? "":"sync/"); + snprintf(path, PATH_MAX, "%s%s", real_dbpath, treename); /* TODO this is rediculous, we try to do this even if we can't */ if(stat(path, &buf) != 0 || !S_ISDIR(buf.st_mode)) { _alpm_log(PM_LOG_DEBUG, "database dir '%s' does not exist, creating it", @@ -733,7 +738,7 @@ pmdb_t *_alpm_db_register(const char *treename) } } - db = _alpm_db_new(dbpath, treename); + db = _alpm_db_new(real_dbpath, treename); if(db == NULL) { RET_ERR(PM_ERR_DB_CREATE, NULL); } @@ -744,7 +749,7 @@ pmdb_t *_alpm_db_register(const char *treename) RET_ERR(PM_ERR_DB_OPEN, NULL); } - if(strcmp(treename, "local") == 0) { + if(local) { handle->db_local = db; } else { handle->dbs_sync = alpm_list_add(handle->dbs_sync, db); -- 1.5.2.5