Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.c17
-rw-r--r--lib/libalpm/be_files.c62
-rw-r--r--lib/libalpm/db.h2
-rw-r--r--lib/libalpm/util.c2
-rw-r--r--lib/libalpm/util.h2
5 files changed, 37 insertions, 48 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index df267e31..f0798316 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -364,7 +364,7 @@ int alpm_db_update(int force, PM_DB *db)
_alpm_log(PM_LOG_ERROR, _("could not remove database entry %s/%s"), db->treename,
((pmpkg_t *)lp->data)->name);
}
- RET_ERR(PM_ERR_DB_REMOVE, 1);
+ RET_ERR(PM_ERR_DB_REMOVE, -1);
}
}
@@ -372,20 +372,9 @@ int alpm_db_update(int force, PM_DB *db)
_alpm_db_free_pkgcache(db);
/* uncompress the sync database */
- /* ORE
- we should not simply unpack the archive, but better parse it and
- db_write each entry (see sync_load_dbarchive to get archive content) */
- _alpm_log(PM_LOG_FLOW2, _("unpacking %s"), path);
- if(_alpm_unpack(path, db->path, NULL)) {
- RET_ERR(PM_ERR_SYSTEM, 1);
+ if(_alpm_db_install(db, path) == -1) {
+ return -1;
}
-
- /* remove the .tar.gz */
- /* aaron: let's not do this... we'll keep the DB around to be read for the
- * "new and improved" db routines
-
- unlink(path);
- */
}
return(0);
diff --git a/lib/libalpm/be_files.c b/lib/libalpm/be_files.c
index dad406dc..c2acb66a 100644
--- a/lib/libalpm/be_files.c
+++ b/lib/libalpm/be_files.c
@@ -44,15 +44,33 @@
#include "error.h"
#include "handle.h"
+
+/* This function is used to convert the downloaded db file to the proper backend
+ * format
+ */
+int _alpm_db_install(pmdb_t *db, const char *dbfile)
+{
+ /* ORE
+ we should not simply unpack the archive, but better parse it and
+ db_write each entry (see sync_load_dbarchive to get archive content) */
+ _alpm_log(PM_LOG_FLOW2, _("unpacking database '%s'"), dbfile);
+
+ if(_alpm_unpack(dbfile, db->path, NULL)) {
+ RET_ERR(PM_ERR_SYSTEM, -1);
+ }
+
+ return unlink(dbfile);
+}
+
int _alpm_db_open(pmdb_t *db)
{
if(db == NULL) {
- return(-1);
+ RET_ERR(PM_ERR_DB_NULL, -1);
}
db->handle = opendir(db->path);
if(db->handle == NULL) {
- return(-1);
+ RET_ERR(PM_ERR_DB_OPEN, -1);
}
return(0);
@@ -90,7 +108,7 @@ pmpkg_t *_alpm_db_scan(pmdb_t *db, char *target, unsigned int inforeq)
pmpkg_t *pkg;
if(db == NULL) {
- return(NULL);
+ RET_ERR(PM_ERR_DB_NULL, NULL);
}
if(target != NULL) {
@@ -166,7 +184,12 @@ int _alpm_db_read(pmdb_t *db, unsigned int inforeq, pmpkg_t *info)
pmlist_t *tmplist;
char *foo;
- if(db == NULL || info == NULL || info->name[0] == 0 || info->version[0] == 0) {
+ if(db == NULL) {
+ RET_ERR(PM_ERR_DB_NULL, -1);
+ }
+
+ if(info == NULL || info->name[0] == 0 || info->version[0] == 0) {
+ _alpm_log(PM_LOG_ERROR, _("invalid package entry provided to _alpm_db_read"));
return(-1);
}
@@ -606,38 +629,13 @@ cleanup:
int _alpm_db_remove(pmdb_t *db, pmpkg_t *info)
{
char path[PATH_MAX];
- int local = 0;
if(db == NULL || info == NULL) {
- return(-1);
+ RET_ERR(PM_ERR_DB_NULL, -1);
}
- if(strcmp(db->treename, "local") == 0) {
- local = 1;
- }
-
- /* DESC */
- snprintf(path, PATH_MAX, "%s/%s-%s/desc", db->path, info->name, info->version);
- unlink(path);
- /* DEPENDS */
- snprintf(path, PATH_MAX, "%s/%s-%s/depends", db->path, info->name, info->version);
- unlink(path);
- if(local) {
- /* FILES */
- snprintf(path, PATH_MAX, "%s/%s-%s/files", db->path, info->name, info->version);
- unlink(path);
- /* INSTALL */
- snprintf(path, PATH_MAX, "%s/%s-%s/install", db->path, info->name, info->version);
- unlink(path);
- /* CHANGELOG */
- snprintf(path, PATH_MAX, "%s/%s-%s/changelog", db->path, info->name, info->version);
- unlink(path);
- }
-
- /* Package directory */
- snprintf(path, PATH_MAX, "%s/%s-%s",
- db->path, info->name, info->version);
- if(rmdir(path) == -1) {
+ snprintf(path, PATH_MAX, "%s/%s-%s", db->path, info->name, info->version);
+ if(_alpm_rmrf(path) == -1) {
return(-1);
}
diff --git a/lib/libalpm/db.h b/lib/libalpm/db.h
index 571bf2ee..bffae081 100644
--- a/lib/libalpm/db.h
+++ b/lib/libalpm/db.h
@@ -51,7 +51,9 @@ pmdb_t *_alpm_db_new(char *root, char *dbpath, char *treename);
void _alpm_db_free(void *data);
int _alpm_db_cmp(const void *db1, const void *db2);
pmlist_t *_alpm_db_search(pmdb_t *db, pmlist_t *needles);
+
/* Prototypes for backends functions */
+int _alpm_db_install(pmdb_t *db, const char *dbfile);
int _alpm_db_open(pmdb_t *db);
void _alpm_db_close(pmdb_t *db);
void _alpm_db_rewind(pmdb_t *db);
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 1b7065ec..98f16406 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -259,7 +259,7 @@ int _alpm_lckrm(char *file)
/* Compression functions
*/
-int _alpm_unpack(char *archive, const char *prefix, const char *fn)
+int _alpm_unpack(const char *archive, const char *prefix, const char *fn)
{
register struct archive *_archive;
struct archive_entry *entry;
diff --git a/lib/libalpm/util.h b/lib/libalpm/util.h
index 63ba00c1..c96c13bf 100644
--- a/lib/libalpm/util.h
+++ b/lib/libalpm/util.h
@@ -60,7 +60,7 @@ char *_alpm_strtoupper(char *str);
char *_alpm_strtrim(char *str);
int _alpm_lckmk(char *file);
int _alpm_lckrm(char *file);
-int _alpm_unpack(char *archive, const char *prefix, const char *fn);
+int _alpm_unpack(const char *archive, const char *prefix, const char *fn);
int _alpm_rmrf(char *path);
int _alpm_logaction(unsigned char usesyslog, FILE *f, char *fmt, ...);
int _alpm_ldconfig(char *root);