summaryrefslogtreecommitdiffstats
path: root/lib/libalpm
diff options
context:
space:
mode:
authorAurelien Foret <aurelien@archlinux.org>2005-10-10 20:41:35 +0000
committerAurelien Foret <aurelien@archlinux.org>2005-10-10 20:41:35 +0000
commit609466fdeb614c8a7a7bb6b5e9921d2fd2fde17f (patch)
tree95dca1525ffc5ab45ca877f6f6c78f51c9f31efd /lib/libalpm
parentb817883cddb8817f49e234d321af289c1e4f68b8 (diff)
downloadpacman-609466fdeb614c8a7a7bb6b5e9921d2fd2fde17f.tar.xz
added PM_OPT_CACHEDIR library option
Diffstat (limited to 'lib/libalpm')
-rw-r--r--lib/libalpm/alpm.h6
-rw-r--r--lib/libalpm/handle.c8
-rw-r--r--lib/libalpm/handle.h1
-rw-r--r--lib/libalpm/sync.c6
4 files changed, 14 insertions, 7 deletions
diff --git a/lib/libalpm/alpm.h b/lib/libalpm/alpm.h
index a6bdf384..b12defee 100644
--- a/lib/libalpm/alpm.h
+++ b/lib/libalpm/alpm.h
@@ -27,8 +27,9 @@
#define PM_VERSION "0.1.0"
-#define PM_ROOT "/"
-#define PM_DBPATH "var/lib/pacman"
+#define PM_ROOT "/"
+#define PM_DBPATH "var/lib/pacman"
+#define PM_CACHEDIR "var/cache/pacman/pkg"
#define PM_EXT_PKG ".pkg.tar.gz"
#define PM_EXT_DB ".db.tar.gz"
@@ -80,6 +81,7 @@ enum {
PM_OPT_USESYSLOG,
PM_OPT_ROOT,
PM_OPT_DBPATH,
+ PM_OPT_CACHEDIR,
PM_OPT_LOGFILE,
PM_OPT_LOCALDB,
PM_OPT_SYNCDB,
diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c
index 8567b87d..568f0d28 100644
--- a/lib/libalpm/handle.c
+++ b/lib/libalpm/handle.c
@@ -109,6 +109,13 @@ int handle_set_option(pmhandle_t *handle, unsigned char val, unsigned long data)
handle->dbpath = strdup((data && strlen((char *)data) != 0) ? (char *)data : PM_DBPATH);
_alpm_log(PM_LOG_FLOW2, "PM_OPT_DBPATH set to '%s'", handle->dbpath);
break;
+ case PM_OPT_CACHEDIR:
+ if(handle->cachedir) {
+ FREE(handle->cachedir);
+ }
+ handle->cachedir = strdup((data && strlen((char *)data) != 0) ? (char *)data : PM_CACHEDIR);
+ _alpm_log(PM_LOG_FLOW2, "PM_OPT_CACHEDIR set to '%s'", handle->cachedir);
+ break;
case PM_OPT_LOGFILE:
if((char *)data == NULL || handle->uid != 0) {
return(0);
@@ -194,6 +201,7 @@ int handle_get_option(pmhandle_t *handle, unsigned char val, long *data)
switch(val) {
case PM_OPT_ROOT: *data = (long)handle->root; break;
case PM_OPT_DBPATH: *data = (long)handle->dbpath; break;
+ case PM_OPT_CACHEDIR: *data = (long)handle->cachedir; break;
case PM_OPT_LOCALDB: *data = (long)handle->db_local; break;
case PM_OPT_SYNCDB: *data = (long)handle->dbs_sync; break;
case PM_OPT_LOGFILE: *data = (long)handle->logfile; break;
diff --git a/lib/libalpm/handle.h b/lib/libalpm/handle.h
index a37ee0fd..df923a84 100644
--- a/lib/libalpm/handle.h
+++ b/lib/libalpm/handle.h
@@ -42,6 +42,7 @@ typedef struct __pmhandle_t {
/* parameters */
char *root;
char *dbpath;
+ char *cachedir;
char *logfile;
PMList *noupgrade; /* List of strings */
PMList *noextract; /* List of strings */
diff --git a/lib/libalpm/sync.c b/lib/libalpm/sync.c
index 60385d86..d3fe238d 100644
--- a/lib/libalpm/sync.c
+++ b/lib/libalpm/sync.c
@@ -43,10 +43,6 @@
#include "rpmvercmp.h"
#include "handle.h"
-/* ORE
-set CACHEDIR as a library option? */
-#define PM_CACHEDIR "var/cache/pacman/pkg"
-
extern pmhandle_t *handle;
pmsyncpkg_t *sync_new(int type, pmpkg_t *spkg, void *data)
@@ -548,7 +544,7 @@ int sync_commit(pmtrans_t *trans, pmdb_t *db_local)
pmsyncpkg_t *sync = i->data;
pmpkg_t *spkg = sync->pkg;
char str[PATH_MAX];
- snprintf(str, PATH_MAX, "%s" PM_CACHEDIR "/%s-%s" PM_EXT_PKG, handle->root, spkg->name, spkg->version);
+ snprintf(str, PATH_MAX, "%s%s/%s-%s" PM_EXT_PKG, handle->root, handle->cachedir, spkg->name, spkg->version);
if(trans_addtarget(tr, str) == -1) {
goto error;
}