summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2017-07-05 19:52:48 +0200
committerSébastien Helleu <flashcode@flashtux.org>2017-07-05 19:52:48 +0200
commitd6c1d02ecae43827830589dfcec57350998cabd5 (patch)
tree26720da6b6a0283711dacfebae7c7b1318c3263f /src/core
parent5e48b50da8e04d55f2a68ddc67758ddbf69fd01a (diff)
downloadweechat-d6c1d02ecae43827830589dfcec57350998cabd5.zip
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.
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-command.c8
-rw-r--r--src/core/wee-completion.c18
-rw-r--r--src/core/wee-debug.c12
-rw-r--r--src/core/wee-util.c29
4 files changed, 58 insertions, 9 deletions
diff --git a/src/core/wee-command.c b/src/core/wee-command.c
index 5c00f3d5b..21bae289a 100644
--- a/src/core/wee-command.c
+++ b/src/core/wee-command.c
@@ -4477,10 +4477,10 @@ COMMAND_CALLBACK(plugin)
{
plugin_argv = string_split (argv_eol[2], " ", 0, 0,
&plugin_argc);
- plugin_auto_load (plugin_argc, plugin_argv, 1, 1);
+ plugin_auto_load (plugin_argc, plugin_argv, 1, 1, 1);
}
else
- plugin_auto_load (0, NULL, 1, 1);
+ plugin_auto_load (0, NULL, 1, 1, 1);
return WEECHAT_RC_OK;
}
@@ -4514,7 +4514,7 @@ COMMAND_CALLBACK(plugin)
if (strcmp (argv[2], "*") == 0)
{
plugin_unload_all ();
- plugin_auto_load (plugin_argc, plugin_argv, 1, 1);
+ plugin_auto_load (plugin_argc, plugin_argv, 1, 1, 1);
}
else
{
@@ -4529,7 +4529,7 @@ COMMAND_CALLBACK(plugin)
else
{
plugin_unload_all ();
- plugin_auto_load (0, NULL, 1, 1);
+ plugin_auto_load (0, NULL, 1, 1, 1);
}
return WEECHAT_RC_OK;
}
diff --git a/src/core/wee-completion.c b/src/core/wee-completion.c
index 6c30084e7..96034f8d5 100644
--- a/src/core/wee-completion.c
+++ b/src/core/wee-completion.c
@@ -875,7 +875,7 @@ completion_list_add_plugins_installed_cb (const void *pointer, void *data,
struct t_gui_buffer *buffer,
struct t_gui_completion *completion)
{
- char *plugin_path, *plugin_path2, *dir_name;
+ char *plugin_path, *plugin_path2, *dir_name, *extra_libdir;
int length;
/* make C compiler happy */
@@ -884,6 +884,22 @@ completion_list_add_plugins_installed_cb (const void *pointer, void *data,
(void) completion_item;
(void) buffer;
+ /* plugins in WeeChat 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);
+ if (dir_name)
+ {
+ snprintf (dir_name, length, "%s/plugins", extra_libdir);
+ util_exec_on_files (dir_name, 1, 0,
+ &completion_list_add_plugins_installed_exec_cb,
+ completion);
+ free (dir_name);
+ }
+ }
+
/* plugins in WeeChat home dir */
if (CONFIG_STRING(config_plugin_path)
&& CONFIG_STRING(config_plugin_path)[0])
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index 9bd33b4ba..9dc9c2ec7 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -571,12 +571,18 @@ debug_libs_cb (const void *pointer, void *data,
void
debug_directories ()
{
+ char *extra_libdir;
+
+ extra_libdir = getenv ("WEECHAT_EXTRA_LIBDIR");
+
gui_chat_printf (NULL, "");
gui_chat_printf (NULL, _("Directories:"));
- gui_chat_printf (NULL, " home : %s (%s: %s)",
+ gui_chat_printf (NULL, " home: %s (%s: %s)",
weechat_home, _("default"), WEECHAT_HOME);
- gui_chat_printf (NULL, " lib : %s", WEECHAT_LIBDIR);
- gui_chat_printf (NULL, " share : %s", WEECHAT_SHAREDIR);
+ gui_chat_printf (NULL, " lib: %s", WEECHAT_LIBDIR);
+ gui_chat_printf (NULL, " lib (extra): %s",
+ (extra_libdir && extra_libdir[0]) ? extra_libdir : "-");
+ gui_chat_printf (NULL, " share: %s", WEECHAT_SHAREDIR);
gui_chat_printf (NULL, " locale: %s", LOCALEDIR);
}
diff --git a/src/core/wee-util.c b/src/core/wee-util.c
index 5e22e454d..d9cd4e2fe 100644
--- a/src/core/wee-util.c
+++ b/src/core/wee-util.c
@@ -541,7 +541,7 @@ char *
util_search_full_lib_name_ext (const char *filename, const char *extension,
const char *plugins_dir)
{
- char *name_with_ext, *final_name;
+ char *name_with_ext, *final_name, *extra_libdir;
int length;
struct stat st;
@@ -554,6 +554,33 @@ util_search_full_lib_name_ext (const char *filename, const char *extension,
filename,
(strchr (filename, '.')) ? "" : extension);
+ /* try libdir from environment variable WEECHAT_EXTRA_LIBDIR */
+ extra_libdir = getenv ("WEECHAT_EXTRA_LIBDIR");
+ if (extra_libdir && extra_libdir[0])
+ {
+ length = strlen (extra_libdir) + strlen (name_with_ext) +
+ strlen (plugins_dir) + 16;
+ final_name = malloc(length);
+ if (!final_name)
+ {
+ free (name_with_ext);
+ return NULL;
+ }
+ snprintf (final_name, length,
+ "%s%s%s%s%s",
+ extra_libdir,
+ DIR_SEPARATOR,
+ plugins_dir,
+ DIR_SEPARATOR,
+ name_with_ext);
+ if ((stat (final_name, &st) == 0) && (st.st_size > 0))
+ {
+ free (name_with_ext);
+ return final_name;
+ }
+ free (final_name);
+ }
+
/* try WeeChat user's dir */
length = strlen (weechat_home) + strlen (name_with_ext) +
strlen (plugins_dir) + 16;