index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Aurelien Foret <aurelien@archlinux.org> | 2005-03-16 19:31:20 +0000 |
---|---|---|
committer | Aurelien Foret <aurelien@archlinux.org> | 2005-03-16 19:31:20 +0000 |
commit | 606c70fdc9a0ee295fe81ec7e6efbbbe142d01be (patch) | |
tree | 81a14a4b7111a8f18399aeaf7db820f52bc27dad /lib/libalpm/db.c | |
parent | 5faecdb523a8a6d1bff082f55d35d4ada6b9a257 (diff) |
-rw-r--r-- | lib/libalpm/db.c | 32 |
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c index 3fad4bb6..ddf06a89 100644 --- a/lib/libalpm/db.c +++ b/lib/libalpm/db.c @@ -97,6 +97,38 @@ int db_create(char *root, char *dbpath, char *treename) return(0); } +int db_update(char *root, char *dbpath, char *treename, char *archive) +{ + char ldir[PATH_MAX]; + + snprintf(ldir, PATH_MAX, "%s%s/%s", root, dbpath, treename); + /* remove the old dir */ + /* ORE - do we want to include alpm.h and use the log mechanism from db.c? + _alpm_log(PM_LOG_FLOW2, "removing %s (if it exists)\n", ldir);*/ + /* ORE + We should only rmrf the database content, and not the top directory, in case + a (DIR *) structure is associated with it (i.e a call to db_open). */ + _alpm_rmrf(ldir); + + /* make the new dir */ + if(db_create(root, dbpath, treename) != 0) { + return(-1); + } + + /* uncompress the sync database */ + /* ORE + _alpm_log(PM_LOG_FLOW2, "Unpacking %s...\n", archive);*/ + if(_alpm_unpack(archive, ldir, NULL)) { + return(-1); + } + + /* ORE + Should we let the the library manage updates only if needed? + Create a .lastupdate file in ldir? Ask for a timestamp as db_update argument? */ + + return(0); +} + void db_rewind(pmdb_t *db) { if(db == NULL || db->dir == NULL) { |