mirror of
https://github.com/moparisthebest/pacman
synced 2024-10-31 15:45:03 -04:00
pacman: add user hook directories
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
e8e872c8f9
commit
7000bf9198
@ -70,6 +70,14 @@ Options
|
|||||||
to the first cache directory with write access. *NOTE*: this is an absolute
|
to the first cache directory with write access. *NOTE*: this is an absolute
|
||||||
path, the root path is not automatically prepended.
|
path, the root path is not automatically prepended.
|
||||||
|
|
||||||
|
*HookDir =* path/to/hook/dir::
|
||||||
|
Add directories to search for alpm hooks. A typical default is
|
||||||
|
+{sysconfdir}/pacman.d/hooks+. Multiple directories can be specified with
|
||||||
|
hooks in later directories taking precedence over hooks in earlier
|
||||||
|
directories. *NOTE*: this is an absolute path, the root path is not
|
||||||
|
automatically prepended. For more information on the alpm hooks, see
|
||||||
|
linkman:alpm-hooks[5].
|
||||||
|
|
||||||
*GPGDir =* path/to/gpg/dir::
|
*GPGDir =* path/to/gpg/dir::
|
||||||
Overrides the default location of the directory containing configuration
|
Overrides the default location of the directory containing configuration
|
||||||
files for GnuPG. A typical default is +{sysconfdir}/pacman.d/gnupg/+.
|
files for GnuPG. A typical default is +{sysconfdir}/pacman.d/gnupg/+.
|
||||||
|
@ -4,6 +4,7 @@ SUBDIRS = po
|
|||||||
conffile = ${sysconfdir}/pacman.conf
|
conffile = ${sysconfdir}/pacman.conf
|
||||||
dbpath = ${localstatedir}/lib/pacman/
|
dbpath = ${localstatedir}/lib/pacman/
|
||||||
gpgdir = ${sysconfdir}/pacman.d/gnupg/
|
gpgdir = ${sysconfdir}/pacman.d/gnupg/
|
||||||
|
hookdir = ${sysconfdir}/pacman.d/hooks/
|
||||||
cachedir = ${localstatedir}/cache/pacman/pkg/
|
cachedir = ${localstatedir}/cache/pacman/pkg/
|
||||||
logfile = ${localstatedir}/log/pacman.log
|
logfile = ${localstatedir}/log/pacman.log
|
||||||
|
|
||||||
@ -16,6 +17,7 @@ AM_CPPFLAGS = \
|
|||||||
-DCONFFILE=\"$(conffile)\" \
|
-DCONFFILE=\"$(conffile)\" \
|
||||||
-DDBPATH=\"$(dbpath)\" \
|
-DDBPATH=\"$(dbpath)\" \
|
||||||
-DGPGDIR=\"$(gpgdir)\" \
|
-DGPGDIR=\"$(gpgdir)\" \
|
||||||
|
-DHOOKDIR=\"$(hookdir)\" \
|
||||||
-DCACHEDIR=\"$(cachedir)\" \
|
-DCACHEDIR=\"$(cachedir)\" \
|
||||||
-DLOGFILE=\"$(logfile)\"
|
-DLOGFILE=\"$(logfile)\"
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ int config_free(config_t *oldconfig)
|
|||||||
free(oldconfig->dbpath);
|
free(oldconfig->dbpath);
|
||||||
free(oldconfig->logfile);
|
free(oldconfig->logfile);
|
||||||
free(oldconfig->gpgdir);
|
free(oldconfig->gpgdir);
|
||||||
|
FREELIST(oldconfig->hookdirs);
|
||||||
FREELIST(oldconfig->cachedirs);
|
FREELIST(oldconfig->cachedirs);
|
||||||
free(oldconfig->xfercommand);
|
free(oldconfig->xfercommand);
|
||||||
free(oldconfig->print_format);
|
free(oldconfig->print_format);
|
||||||
@ -515,6 +516,8 @@ static int _parse_options(const char *key, char *value,
|
|||||||
setrepeatingoption(value, "HoldPkg", &(config->holdpkg));
|
setrepeatingoption(value, "HoldPkg", &(config->holdpkg));
|
||||||
} else if(strcmp(key, "CacheDir") == 0) {
|
} else if(strcmp(key, "CacheDir") == 0) {
|
||||||
setrepeatingoption(value, "CacheDir", &(config->cachedirs));
|
setrepeatingoption(value, "CacheDir", &(config->cachedirs));
|
||||||
|
} else if(strcmp(key, "HookDir") == 0) {
|
||||||
|
setrepeatingoption(value, "HookDir", &(config->hookdirs));
|
||||||
} else if(strcmp(key, "Architecture") == 0) {
|
} else if(strcmp(key, "Architecture") == 0) {
|
||||||
if(!config->arch) {
|
if(!config->arch) {
|
||||||
config_set_arch(value);
|
config_set_arch(value);
|
||||||
@ -751,6 +754,25 @@ static int setup_libalpm(void)
|
|||||||
return ret;
|
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 */
|
/* add a default cachedir if one wasn't specified */
|
||||||
if(config->cachedirs == NULL) {
|
if(config->cachedirs == NULL) {
|
||||||
alpm_option_add_cachedir(handle, CACHEDIR);
|
alpm_option_add_cachedir(handle, CACHEDIR);
|
||||||
|
@ -66,6 +66,7 @@ typedef struct __config_t {
|
|||||||
char *dbpath;
|
char *dbpath;
|
||||||
char *logfile;
|
char *logfile;
|
||||||
char *gpgdir;
|
char *gpgdir;
|
||||||
|
alpm_list_t *hookdirs;
|
||||||
alpm_list_t *cachedirs;
|
alpm_list_t *cachedirs;
|
||||||
|
|
||||||
unsigned short op_q_isfile;
|
unsigned short op_q_isfile;
|
||||||
@ -156,6 +157,7 @@ enum {
|
|||||||
OP_NOSCRIPTLET,
|
OP_NOSCRIPTLET,
|
||||||
OP_ASK,
|
OP_ASK,
|
||||||
OP_CACHEDIR,
|
OP_CACHEDIR,
|
||||||
|
OP_HOOKDIR,
|
||||||
OP_ASDEPS,
|
OP_ASDEPS,
|
||||||
OP_LOGFILE,
|
OP_LOGFILE,
|
||||||
OP_IGNOREGROUP,
|
OP_IGNOREGROUP,
|
||||||
|
@ -210,6 +210,7 @@ static void usage(int op, const char * const myname)
|
|||||||
addlist(_(" -v, --verbose be verbose\n"));
|
addlist(_(" -v, --verbose be verbose\n"));
|
||||||
addlist(_(" --arch <arch> set an alternate architecture\n"));
|
addlist(_(" --arch <arch> set an alternate architecture\n"));
|
||||||
addlist(_(" --cachedir <dir> set an alternate package cache location\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(_(" --color <when> colorize the output\n"));
|
||||||
addlist(_(" --config <path> set an alternate configuration file\n"));
|
addlist(_(" --config <path> set an alternate configuration file\n"));
|
||||||
addlist(_(" --debug display debug messages\n"));
|
addlist(_(" --debug display debug messages\n"));
|
||||||
@ -463,6 +464,9 @@ static int parsearg_global(int opt)
|
|||||||
free(config->gpgdir);
|
free(config->gpgdir);
|
||||||
config->gpgdir = strdup(optarg);
|
config->gpgdir = strdup(optarg);
|
||||||
break;
|
break;
|
||||||
|
case OP_HOOKDIR:
|
||||||
|
config->hookdirs = alpm_list_add(config->hookdirs, strdup(optarg));
|
||||||
|
break;
|
||||||
case OP_LOGFILE:
|
case OP_LOGFILE:
|
||||||
free(config->logfile);
|
free(config->logfile);
|
||||||
config->logfile = strndup(optarg, PATH_MAX);
|
config->logfile = strndup(optarg, PATH_MAX);
|
||||||
@ -959,6 +963,7 @@ static int parseargs(int argc, char *argv[])
|
|||||||
{"noscriptlet", no_argument, 0, OP_NOSCRIPTLET},
|
{"noscriptlet", no_argument, 0, OP_NOSCRIPTLET},
|
||||||
{"ask", required_argument, 0, OP_ASK},
|
{"ask", required_argument, 0, OP_ASK},
|
||||||
{"cachedir", required_argument, 0, OP_CACHEDIR},
|
{"cachedir", required_argument, 0, OP_CACHEDIR},
|
||||||
|
{"hookdir", required_argument, 0, OP_HOOKDIR},
|
||||||
{"asdeps", no_argument, 0, OP_ASDEPS},
|
{"asdeps", no_argument, 0, OP_ASDEPS},
|
||||||
{"logfile", required_argument, 0, OP_LOGFILE},
|
{"logfile", required_argument, 0, OP_LOGFILE},
|
||||||
{"ignoregroup", required_argument, 0, OP_IGNOREGROUP},
|
{"ignoregroup", required_argument, 0, OP_IGNOREGROUP},
|
||||||
@ -1274,6 +1279,11 @@ int main(int argc, char *argv[])
|
|||||||
printf("%s ", (const char *)j->data);
|
printf("%s ", (const char *)j->data);
|
||||||
}
|
}
|
||||||
printf("\n");
|
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("Lock File : %s\n", alpm_option_get_lockfile(config->handle));
|
||||||
printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
|
printf("Log File : %s\n", alpm_option_get_logfile(config->handle));
|
||||||
printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle));
|
printf("GPG Dir : %s\n", alpm_option_get_gpgdir(config->handle));
|
||||||
|
Loading…
Reference in New Issue
Block a user