1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-05 09:13:14 +02:00

core: search WEECHAT_EXTRA_LIBDIR for plugins (closes #971, issue #979)

In addition to searching the statically configured WEECHAT_LIBDIR
(weechat's installation directory) for plugins, search the path
given in the environment variable WEECHAT_EXTRA_LIBDIR. This makes
departing from the FHS standard while keeping the plugins packaged
separately easier. This change was made specifically with the Nix
package manager in mind, but can easily be used by others.
This commit is contained in:
Linus Heckemann
2017-07-05 19:52:48 +02:00
committed by Sébastien Helleu
parent 5e48b50da8
commit d6c1d02eca
7 changed files with 83 additions and 15 deletions
+21 -4
View File
@@ -992,10 +992,12 @@ plugin_arraylist_cmp_cb (void *data,
*/
void
plugin_auto_load (int argc, char **argv, int load_from_plugin_path,
plugin_auto_load (int argc, char **argv,
int load_from_plugin_path,
int load_from_extra_lib_dir,
int load_from_lib_dir)
{
char *dir_name, *plugin_path, *plugin_path2;
char *dir_name, *plugin_path, *plugin_path2, *extra_libdir;
struct t_weechat_plugin *ptr_plugin;
struct t_plugin_args plugin_args;
struct t_arraylist *arraylist;
@@ -1015,7 +1017,7 @@ plugin_auto_load (int argc, char **argv, int load_from_plugin_path,
&plugin_autoload_count);
}
/* auto-load plugins in WeeChat home dir */
/* auto-load plugins in custom path */
if (load_from_plugin_path
&& CONFIG_STRING(config_plugin_path)
&& CONFIG_STRING(config_plugin_path)[0])
@@ -1036,6 +1038,21 @@ plugin_auto_load (int argc, char **argv, int load_from_plugin_path,
free (plugin_path2);
}
/* auto-load plugins in WEECHAT_EXTRA_LIBDIR environment variable */
if (load_from_extra_lib_dir)
{
extra_libdir = getenv ("WEECHAT_EXTRA_LIBDIR");
if (extra_libdir && extra_libdir[0])
{
length = strlen (extra_libdir) + 16 + 1;
dir_name = malloc (length);
snprintf (dir_name, length, "%s/plugins", extra_libdir);
util_exec_on_files (dir_name, 1, 0,
&plugin_auto_load_file, &plugin_args);
free (dir_name);
}
}
/* auto-load plugins in WeeChat global lib dir */
if (load_from_lib_dir)
{
@@ -1337,7 +1354,7 @@ plugin_init (int auto_load, int argc, char *argv[])
if (auto_load)
{
plugin_quiet = 1;
plugin_auto_load (argc, argv, 1, 1);
plugin_auto_load (argc, argv, 1, 1, 1);
plugin_display_short_list ();
plugin_quiet = 0;
}