summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2014-11-16 17:41:00 -0500
committerDave Reisner <dreisner@archlinux.org>2014-11-16 17:42:23 -0500
commit1f4a917495864544862f28b080a5b9fe6dd8865b (patch)
treebd18f6261360f4eab5110a52d79ec5ed5242bc54
parente54969e6ad8f6fe23c2703ef100e9dbeb050b1fe (diff)
downloadexpac-1f4a917495864544862f28b080a5b9fe6dd8865b.tar.xz
handle RootDir and DBPath from pacman config
-rw-r--r--conf.c11
-rw-r--r--conf.h3
-rw-r--r--expac.c14
3 files changed, 25 insertions, 3 deletions
diff --git a/conf.c b/conf.c
index 5aedc6e..c4927c5 100644
--- a/conf.c
+++ b/conf.c
@@ -156,6 +156,14 @@ static int parse_one_file(config_t *config, const char *filename, char **section
k = parse_include(config, val, section);
if (k < 0)
return k;
+ } else if (strcmp(line, "DBPath") == 0) {
+ config->dbpath = strdup(val);
+ if (config->dbpath == NULL)
+ return -ENOMEM;
+ } else if (strcmp(line, "RootDir") == 0) {
+ config->dbroot = strdup(val);
+ if (config->dbpath == NULL)
+ return -ENOMEM;
}
}
}
@@ -170,6 +178,9 @@ void config_reset(config_t *config) {
for (int i = 0; i < config->size; ++i)
free(config->repos[i]);
+ free(config->dbroot);
+ free(config->dbpath);
+
free(config->repos);
}
diff --git a/conf.h b/conf.h
index 1ce6a17..da2e64b 100644
--- a/conf.h
+++ b/conf.h
@@ -5,6 +5,9 @@ typedef struct config_t {
char **repos;
int size;
int capacity;
+
+ char *dbroot;
+ char *dbpath;
} config_t;
int config_parse(config_t *config, const char *filename);
diff --git a/expac.c b/expac.c
index ff13007..ebbaaa6 100644
--- a/expac.c
+++ b/expac.c
@@ -53,7 +53,6 @@
static char const digits[] = "0123456789";
static char const printf_flags[] = "'-+ #0I";
-alpm_db_t *db_local = NULL;
alpm_list_t *targets = NULL;
bool opt_readone = false;
bool opt_verbose = false;
@@ -353,6 +352,7 @@ static bool backup_file_is_modified(const alpm_backup_t *backup_file) {
_cleanup_free_ char *md5sum = NULL;
bool modified;
+ /* TODO: respect expac->dbroot */
snprintf(fullpath, sizeof(fullpath), "/%s", backup_file->name);
md5sum = alpm_compute_md5sum(fullpath);
@@ -655,7 +655,9 @@ void expac_free(Expac *expac) {
int expac_new(Expac **expac, int argc, char **argv) {
Expac *e;
enum _alpm_errno_t alpm_errno = 0;
- config_t config = { NULL, 0, 0 };
+ config_t config = { NULL, 0, 0, NULL, NULL };
+ const char *dbroot = "/";
+ const char *dbpath = "/var/lib/pacman";
int r;
r = parse_options(argc, argv);
@@ -670,7 +672,13 @@ int expac_new(Expac **expac, int argc, char **argv) {
if (r < 0)
return r;
- e->alpm = alpm_initialize("/", "/var/lib/pacman", &alpm_errno);
+ if (config.dbpath)
+ dbpath = config.dbpath;
+
+ if (config.dbroot)
+ dbroot = config.dbroot;
+
+ e->alpm = alpm_initialize(dbroot, dbpath, &alpm_errno);
if (!e->alpm)
return -alpm_errno;