Commit 258ca45a authored by Ting-Wei Lan's avatar Ting-Wei Lan

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.
parent 9aef95de
......@@ -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')
......
......@@ -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' ],
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment