Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/db.c
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-03-16 19:31:20 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-03-16 19:31:20 +0000
commit606c70fdc9a0ee295fe81ec7e6efbbbe142d01be (patch)
tree81a14a4b7111a8f18399aeaf7db820f52bc27dad /lib/libalpm/db.c
parent5faecdb523a8a6d1bff082f55d35d4ada6b9a257 (diff)
Added a db_update() function to manage sync databases updates.
The API provides a wrapper alpm_db_update().
Diffstat (limited to 'lib/libalpm/db.c')
-rw-r--r--lib/libalpm/db.c32
1 files changed, 32 insertions, 0 deletions
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) {