[gnome-builder/wip/lantw/freebsd-improvement-and-gtk-doc: 3/5] subprocess: add a meson option to set PATH to run build commands
- From: Ting-Wei Lan <lantw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/lantw/freebsd-improvement-and-gtk-doc: 3/5] subprocess: add a meson option to set PATH to run build commands
- Date: Tue, 30 Jan 2018 19:19:14 +0000 (UTC)
commit 258ca45a1dcd52652814a912268b6640bcaecf7a
Author: Ting-Wei Lan <lantw src gnome org>
Date: Wed Jan 31 02:10:31 2018 +0800
subprocess: add a meson option to set PATH to run build commands
The previous commit unconditionally adds /usr/local/bin to PATH on
FreeBSD. It should work for most people, but the maintainer is still
required to patch the hard-coded /usr/local to the prefix chosen by
users because it is not possible to change the value after the build.
Since each operating system organizes its files in a different way, we
cannot expect a single PATH value to work on all operating systems.
This commit sets PATH for the four major BSD systems to the default
values used by their /bin/sh shell when PATH is unset with directories
including sbin in their names removed. It also add a meson option to
allow the package maintainer to set a different value without patching.
meson.build | 18 ++++++++++++++++++
meson_options.txt | 1 +
src/libide/subprocess/ide-subprocess-launcher.c | 9 +++------
3 files changed, 22 insertions(+), 6 deletions(-)
---
diff --git a/meson.build b/meson.build
index 066f0b71c..a1247fbca 100644
--- a/meson.build
+++ b/meson.build
@@ -25,6 +25,22 @@ pkggirdir = join_paths(get_option('datadir'),'gnome-builder', 'gir-1.0')
pkgtypelibdir = join_paths(get_option('libdir'), 'gnome-builder', 'girepository-1.0')
pkgvapidir = join_paths(get_option('datadir'), 'gnome-builder/vapi')
+safe_path = get_option('with_safe_path')
+
+# These default values are obtained by running /bin/sh without setting PATH
+if safe_path == ''
+ if host_machine.system() == 'freebsd'
+ safe_path = '/bin:/usr/bin:/usr/local/bin'
+ elif host_machine.system() == 'dragonfly'
+ safe_path = '/bin:/usr/bin:/usr/local/bin:/usr/pkg/bin'
+ elif host_machine.system() == 'netbsd'
+ safe_path = '/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin'
+ elif host_machine.system() == 'openbsd'
+ safe_path = '/usr/bin:/bin:/usr/X11R6/bin:/usr/local/bin'
+ else
+ safe_path = '/usr/bin:/bin'
+ endif
+endif
status = [
'', '',
@@ -49,6 +65,7 @@ status += [
'',
'Prefix ................ : @0@'.format(get_option('prefix')),
'Libdir ................ : @0@'.format(join_paths(get_option('prefix'), get_option('libdir'))),
+ 'Safe PATH ............. : @0@'.format(safe_path),
'',
'Tracing ............... : @0@'.format(get_option('enable_tracing')),
'Profiling ............. : @0@'.format(get_option('enable_profiling')),
@@ -68,6 +85,7 @@ config_h.set_quoted('PACKAGE_DOCDIR', join_paths(get_option('prefix'), get_optio
config_h.set_quoted('PACKAGE_LIBDIR', join_paths(get_option('prefix'), get_option('libdir')))
config_h.set_quoted('PACKAGE_LOCALE_DIR', join_paths(get_option('prefix'), get_option('datadir'), 'locale'))
config_h.set_quoted('PACKAGE_LIBEXECDIR', join_paths(get_option('prefix'), get_option('libexecdir')))
+config_h.set_quoted('SAFE_PATH', safe_path)
config_h.set('GETTEXT_PACKAGE', 'PACKAGE_NAME')
config_h.set('LOCALEDIR', 'PACKAGE_LOCALE_DIR')
diff --git a/meson_options.txt b/meson_options.txt
index 5d279fe8a..3b97300c8 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -2,6 +2,7 @@ option('enable_tracing', type: 'boolean', value: false, description: 'Enable tra
option('enable_profiling', type: 'boolean', value: false, description: 'Enable profiling of the Builder
codebase')
option('enable_rdtscp', type: 'boolean', value: false, description: 'High performance counters')
+option('with_safe_path', type: 'string', value: '', description: 'PATH variable to run build commands
(default: platform-specific)')
option('with_channel',
type: 'combo',
choices: [ 'other', 'flatpak-stable', 'flatpak-nightly' ],
diff --git a/src/libide/subprocess/ide-subprocess-launcher.c b/src/libide/subprocess/ide-subprocess-launcher.c
index 62ed01110..4dcb162fc 100644
--- a/src/libide/subprocess/ide-subprocess-launcher.c
+++ b/src/libide/subprocess/ide-subprocess-launcher.c
@@ -18,6 +18,8 @@
#define G_LOG_DOMAIN "ide-subprocess-launcher"
+#include "config.h"
+
#include <dazzle.h>
#include <fcntl.h>
#include <errno.h>
@@ -394,12 +396,7 @@ ide_subprocess_launcher_real_spawn (IdeSubprocessLauncher *self,
* that it can get /app/bin too. Since it chains up to us, we wont
* overwrite PATH in that case (which is what we want).
*/
-#ifdef __FreeBSD__
- /* FreeBSD puts third-party components in /usr/local/bin */
- ide_subprocess_launcher_setenv (self, "PATH", "/usr/local/bin:/usr/bin:/bin", FALSE);
-#else
- ide_subprocess_launcher_setenv (self, "PATH", "/usr/bin:/bin", FALSE);
-#endif
+ ide_subprocess_launcher_setenv (self, "PATH", SAFE_PATH, FALSE);
ide_subprocess_launcher_setenv (self, "HOME", g_get_home_dir (), FALSE);
ide_subprocess_launcher_setenv (self, "USER", g_get_user_name (), FALSE);
ide_subprocess_launcher_setenv (self, "LANG", g_getenv ("LANG"), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]