From 5e61f077357de1767efada259aeb824bcbfe0086 Mon Sep 17 00:00:00 2001 From: Allan McRae Date: Sat, 9 Oct 2010 23:31:29 +1000 Subject: Populate sync db from archive Read in list of packages for sync db from tar archive. Breaks reading in _alpm_sync_db_read and a lot of pactests (which is expected as they do not handle sync db in archives...). Signed-off-by: Allan McRae --- lib/libalpm/db.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lib/libalpm/db.c') diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 2e6bf31b..1adf549b 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -414,10 +414,10 @@ const char *_alpm_db_path(pmdb_t *db) CALLOC(db->_path, 1, pathsize, RET_ERR(PM_ERR_MEMORY, NULL)); sprintf(db->_path, "%s%s/", dbpath, db->treename); } else { - pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 2; + pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 4; CALLOC(db->_path, 1, pathsize, RET_ERR(PM_ERR_MEMORY, NULL)); /* all sync DBs now reside in the sync/ subdir of the dbpath */ - sprintf(db->_path, "%ssync/%s/", dbpath, db->treename); + sprintf(db->_path, "%ssync/%s.db", dbpath, db->treename); } _alpm_log(PM_LOG_DEBUG, "database path for tree %s set to %s\n", db->treename, db->_path); @@ -766,6 +766,12 @@ int splitname(const char *target, pmpkg_t *pkg) STRDUP(tmp, target, RET_ERR(PM_ERR_MEMORY, -1)); p = tmp + strlen(tmp); + /* remove any trailing '/' */ + while (*(p - 1) == '/') { + --p; + *p = '\0'; + } + /* do the magic parsing- find the beginning of the version string * by doing two iterations of same loop to lop off two hyphens */ for(q = --p; *q && *q != '-'; q--); -- cgit v1.2.3-24-g4f1b