summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/alpm.c3
-rw-r--r--lib/libalpm/alpm.h3
-rw-r--r--lib/libalpm/be_sync.c17
-rw-r--r--lib/libalpm/db.c6
-rw-r--r--lib/libalpm/handle.c22
-rw-r--r--lib/libalpm/handle.h1
6 files changed, 44 insertions, 8 deletions
diff --git a/lib/libalpm/alpm.c b/lib/libalpm/alpm.c
index 21102860..d77b43ab 100644
--- a/lib/libalpm/alpm.c
+++ b/lib/libalpm/alpm.c
@@ -64,6 +64,9 @@ alpm_handle_t SYMEXPORT *alpm_initialize(const char *root, const char *dbpath,
goto cleanup;
}
+ /* set default database extension */
+ STRDUP(myhandle->dbext, ".db", goto cleanup);
+
lockfilelen = strlen(myhandle->dbpath) + strlen(lf) + 1;
myhandle->lockfile = calloc(lockfilelen, sizeof(char));
snprintf(myhandle->lockfile, lockfilelen, "%s%s", myhandle->dbpath, lf);
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index 06e080be..594f0b6d 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -859,6 +859,9 @@ int alpm_option_set_deltaratio(alpm_handle_t *handle, double ratio);
int alpm_option_get_checkspace(alpm_handle_t *handle);
int alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace);
+const char *alpm_option_get_dbext(alpm_handle_t *handle);
+int alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext);
+
alpm_siglevel_t alpm_option_get_default_siglevel(alpm_handle_t *handle);
int alpm_option_set_default_siglevel(alpm_handle_t *handle, alpm_siglevel_t level);
diff --git a/lib/libalpm/be_sync.c b/lib/libalpm/be_sync.c
index ea979e6d..a4ba0f79 100644
--- a/lib/libalpm/be_sync.c
+++ b/lib/libalpm/be_sync.c
@@ -174,6 +174,7 @@ valid:
int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
{
char *syncpath;
+ const char *dbext;
alpm_list_t *i;
int ret = -1;
mode_t oldmask;
@@ -208,6 +209,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
RET_ERR(handle, ALPM_ERR_HANDLE_LOCK, -1);
}
+ dbext = db->handle->dbext;
+
for(i = db->servers; i; i = i->next) {
const char *server = i->data, *final_db_url = NULL;
struct dload_payload payload;
@@ -220,10 +223,10 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
payload.max_size = 25 * 1024 * 1024;
/* print server + filename into a buffer */
- len = strlen(server) + strlen(db->treename) + 5;
+ len = strlen(server) + strlen(db->treename) + strlen(dbext) + 2;
/* TODO fix leak syncpath and umask unset */
MALLOC(payload.fileurl, len, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
- snprintf(payload.fileurl, len, "%s/%s.db", server, db->treename);
+ snprintf(payload.fileurl, len, "%s/%s%s", server, db->treename, dbext);
payload.handle = handle;
payload.force = force;
payload.unlink_on_fail = 1;
@@ -244,7 +247,9 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* check if the final URL from internal downloader looks reasonable */
if(final_db_url != NULL) {
- if(strlen(final_db_url) < 3 || strcmp(final_db_url + strlen(final_db_url) - 3, ".db") != 0) {
+ if(strlen(final_db_url) < 3
+ || strcmp(final_db_url + strlen(final_db_url) - strlen(dbext),
+ dbext) != 0) {
final_db_url = NULL;
}
}
@@ -254,8 +259,8 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
/* print final_db_url into a buffer (leave space for .sig) */
len = strlen(final_db_url) + 5;
} else {
- /* print server + filename into a buffer (leave space for separator and .db.sig) */
- len = strlen(server) + strlen(db->treename) + 9;
+ /* print server + filename into a buffer (leave space for separator and .sig) */
+ len = strlen(server) + strlen(db->treename) + strlen(dbext) + 6;
}
/* TODO fix leak syncpath and umask unset */
@@ -264,7 +269,7 @@ int SYMEXPORT alpm_db_update(int force, alpm_db_t *db)
if(final_db_url != NULL) {
snprintf(payload.fileurl, len, "%s.sig", final_db_url);
} else {
- snprintf(payload.fileurl, len, "%s/%s.db.sig", server, db->treename);
+ snprintf(payload.fileurl, len, "%s/%s%s.sig", server, db->treename, dbext);
}
payload.handle = handle;
diff --git a/lib/libalpm/db.c b/lib/libalpm/db.c
index fe208be0..b94d3342 100644
--- a/lib/libalpm/db.c
+++ b/lib/libalpm/db.c
@@ -375,10 +375,12 @@ const char *_alpm_db_path(alpm_db_t *db)
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
sprintf(db->_path, "%s%s/", dbpath, db->treename);
} else {
- pathsize = strlen(dbpath) + 5 + strlen(db->treename) + 4;
+ const char *dbext = db->handle->dbext;
+
+ pathsize = strlen(dbpath) + 5 + strlen(db->treename) + strlen(dbext) + 1;
CALLOC(db->_path, 1, pathsize, RET_ERR(db->handle, ALPM_ERR_MEMORY, NULL));
/* all sync DBs now reside in the sync/ subdir of the dbpath */
- sprintf(db->_path, "%ssync/%s.db", dbpath, db->treename);
+ sprintf(db->_path, "%ssync/%s%s", dbpath, db->treename, dbext);
}
_alpm_log(db->handle, ALPM_LOG_DEBUG, "database path for tree %s set to %s\n",
db->treename, db->_path);
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 4915d0bf..5c665dbb 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -81,6 +81,7 @@ void _alpm_handle_free(alpm_handle_t *handle)
_alpm_trans_free(handle->trans);
FREE(handle->root);
FREE(handle->dbpath);
+ FREE(handle->dbext);
FREELIST(handle->cachedirs);
FREE(handle->logfile);
FREE(handle->lockfile);
@@ -284,6 +285,12 @@ int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle)
return handle->checkspace;
}
+const char SYMEXPORT *alpm_option_get_dbext(alpm_handle_t *handle)
+{
+ CHECK_HANDLE(handle, return NULL);
+ return handle->dbext;
+}
+
int SYMEXPORT alpm_option_set_logcb(alpm_handle_t *handle, alpm_cb_log cb)
{
CHECK_HANDLE(handle, return -1);
@@ -664,6 +671,21 @@ int SYMEXPORT alpm_option_set_checkspace(alpm_handle_t *handle, int checkspace)
return 0;
}
+int SYMEXPORT alpm_option_set_dbext(alpm_handle_t *handle, const char *dbext)
+{
+ CHECK_HANDLE(handle, return -1);
+ ASSERT(dbext, RET_ERR(handle, ALPM_ERR_WRONG_ARGS, -1));
+
+ if(handle->dbext) {
+ FREE(handle->dbext);
+ }
+
+ STRDUP(handle->dbext, dbext, RET_ERR(handle, ALPM_ERR_MEMORY, -1));
+
+ _alpm_log(handle, ALPM_LOG_DEBUG, "option 'dbext' = %s\n", handle->dbext);
+ return 0;
+}
+
int SYMEXPORT alpm_option_set_default_siglevel(alpm_handle_t *handle,
alpm_siglevel_t level)
{
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index 58931395..315d9878 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -95,6 +95,7 @@ struct __alpm_handle_t {
double deltaratio; /* Download deltas if possible; a ratio value */
int usesyslog; /* Use syslog instead of logfile? */ /* TODO move to frontend */
int checkspace; /* Check disk space before installing */
+ char *dbext; /* Sync DB extension */
alpm_siglevel_t siglevel; /* Default signature verification level */
alpm_siglevel_t localfilesiglevel; /* Signature verification level for local file
upgrade operations */