mirror of
https://github.com/moparisthebest/pacman
synced 2024-11-11 03:54:59 -05:00
added PM_OPT_CACHEDIR library option
This commit is contained in:
parent
b817883cdd
commit
609466fdeb
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user