Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pacman/Makefile.am2
-rw-r--r--src/pacman/conf.c22
-rw-r--r--src/pacman/conf.h2
-rw-r--r--src/pacman/pacman.c10
4 files changed, 36 insertions, 0 deletions
diff --git a/src/pacman/Makefile.am b/src/pacman/Makefile.am
index d3ae071e..b07c6706 100644
--- a/src/pacman/Makefile.am
+++ b/src/pacman/Makefile.am
@@ -4,6 +4,7 @@ SUBDIRS = po
conffile = ${sysconfdir}/pacman.conf
dbpath = ${localstatedir}/lib/pacman/
gpgdir = ${sysconfdir}/pacman.d/gnupg/
+hookdir = ${sysconfdir}/pacman.d/hooks/
cachedir = ${localstatedir}/cache/pacman/pkg/
logfile = ${localstatedir}/log/pacman.log
@@ -16,6 +17,7 @@ AM_CPPFLAGS = \
-DCONFFILE=\"$(conffile)\" \
-DDBPATH=\"$(dbpath)\" \
-DGPGDIR=\"$(gpgdir)\" \
+ -DHOOKDIR=\"$(hookdir)\" \
-DCACHEDIR=\"$(cachedir)\" \
-DLOGFILE=\"$(logfile)\"
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);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 3fff9008..cde67414 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -66,6 +66,7 @@ typedef struct __config_t {
char *dbpath;
char *logfile;
char *gpgdir;
+ alpm_list_t *hookdirs;
alpm_list_t *cachedirs;
unsigned short op_q_isfile;
@@ -156,6 +157,7 @@ enum {
OP_NOSCRIPTLET,
OP_ASK,
OP_CACHEDIR,
+ OP_HOOKDIR,
OP_ASDEPS,
OP_LOGFILE,
OP_IGNOREGROUP,
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index c680067c..d777663d 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -210,6 +210,7 @@ static void usage(int op, const char * const myname)
addlist(_(" -v, --verbose be verbose\n"));
addlist(_(" --arch <arch> set an alternate architecture\n"));
addlist(_(" --cachedir <dir> set an alternate package cache location\n"));
+ addlist(_(" --hookdir <dir> set an alternate hook location\n"));
addlist(_(" --color <when> colorize the output\n"));
addlist(_(" --config <path> set an alternate configuration file\n"));
addlist(_(" --debug display debug messages\n"));
@@ -463,6 +464,9 @@ static int parsearg_global(int opt)
free(config->gpgdir);
config->gpgdir = strdup(optarg);
break;
+ case OP_HOOKDIR:
+ config->hookdirs = alpm_list_add(config->hookdirs, strdup(optarg));
+ break;
case OP_LOGFILE:
free(config->logfile);
config->logfile = strndup(optarg, PATH_MAX);
@@ -959,6 +963,7 @@ static int parseargs(int argc, char *argv[])
{"noscriptlet", no_argument, 0, OP_NOSCRIPTLET},
{"ask", required_argument, 0, OP_ASK},
{"cachedir", required_argument, 0, OP_CACHEDIR},
+ {"hookdir", required_argument, 0, OP_HOOKDIR},
{"asdeps", no_argument, 0, OP_ASDEPS},
{"logfile", required_argument, 0, OP_LOGFILE},
{"ignoregroup", required_argument, 0, OP_IGNOREGROUP},
@@ -1274,6 +1279,11 @@ int main(int argc, char *argv[])
printf("%s ", (const char *)j->data);
}
printf("\n");
+ printf("Hook Dirs : ");
+ for(j = alpm_option_get_hookdirs(config->handle); j; j = alpm_list_next(j)) {
+ printf("%s ", (const char *)j->data);
+ }
+ printf("\n");
printf("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle));