diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2015-10-16 20:28:27 -0400 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2015-10-18 10:59:23 +1000 |
commit | 7000bf919812f3ed56969a86b4aebf90e98ec6a3 (patch) | |
tree | 0cbf71072c97a77a5a65d8f15c7b508f078313d5 /src/pacman/conf.c | |
parent | e8e872c8f93ba13f67b882d64c16606973f0ff67 (diff) | |
download | pacman-7000bf919812f3ed56969a86b4aebf90e98ec6a3.tar.xz |
pacman: add user hook directories
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src/pacman/conf.c')
-rw-r--r-- | src/pacman/conf.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c index 738b0261..6a2b2067 100644 --- a/src/pacman/conf.c +++ b/src/pacman/conf.c @@ -146,6 +146,7 @@ int config_free(config_t *oldconfig) free(oldconfig->dbpath); free(oldconfig->logfile); free(oldconfig->gpgdir); + FREELIST(oldconfig->hookdirs); FREELIST(oldconfig->cachedirs); free(oldconfig->xfercommand); free(oldconfig->print_format); @@ -515,6 +516,8 @@ static int _parse_options(const char *key, char *value, setrepeatingoption(value, "HoldPkg", &(config->holdpkg)); } else if(strcmp(key, "CacheDir") == 0) { setrepeatingoption(value, "CacheDir", &(config->cachedirs)); + } else if(strcmp(key, "HookDir") == 0) { + setrepeatingoption(value, "HookDir", &(config->hookdirs)); } else if(strcmp(key, "Architecture") == 0) { if(!config->arch) { config_set_arch(value); @@ -751,6 +754,25 @@ static int setup_libalpm(void) return ret; } + /* Set user hook directory. This is not relative to rootdir, even if + * rootdir is defined. Reasoning: hookdir contains configuration data. */ + if(config->hookdirs == NULL) { + if((ret = alpm_option_add_hookdir(handle, HOOKDIR)) != 0) { + pm_printf(ALPM_LOG_ERROR, _("problem adding hookdir '%s' (%s)\n"), + HOOKDIR, alpm_strerror(alpm_errno(handle))); + return ret; + } + } else { + /* add hook directories 1-by-1 to avoid overwriting the system directory */ + for(i = config->hookdirs; i; i = alpm_list_next(i)) { + if((ret = alpm_option_add_hookdir(handle, i->data)) != 0) { + pm_printf(ALPM_LOG_ERROR, _("problem adding hookdir '%s' (%s)\n"), + (char *) i->data, alpm_strerror(alpm_errno(handle))); + return ret; + } + } + } + /* add a default cachedir if one wasn't specified */ if(config->cachedirs == NULL) { alpm_option_add_cachedir(handle, CACHEDIR); |