Skip to content

Commit

Permalink
meson: unify handling of executable paths, provide options for all progs
Browse files Browse the repository at this point in the history
This makes the meson build behave slightly differently than the autoconf-based
one, because we always first try to find the executable in the filesystem, and
fall back to the default. I think different handling of loadkeys, setfont, and
telinit was just a historical accident.

In addition to checking in $PATH, also check /usr/sbin/, /sbin for programs.
In Fedora $PATH includes /usr/sbin, (and /sbin is is a symlink to /usr/sbin),
but in Debian, those directories are not included in the path.

C.f. mesonbuild/meson#1576.

Also call all the options 'xxx-path' for clarity.
  • Loading branch information
keszybz committed Apr 9, 2017
1 parent d29c4b2 commit 0acf091
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
34 changes: 20 additions & 14 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ conf.set_quoted('SYSTEM_CONFIG_UNIT_PATH', pkgsysconfdir + '/
conf.set_quoted('SYSTEM_DATA_UNIT_PATH', systemunitdir)
conf.set_quoted('SYSTEM_SYSVINIT_PATH', sysvinit_path)
conf.set_quoted('SYSTEM_SYSVRCND_PATH', sysvrcnd_path)
conf.set_quoted('TELINIT', get_option('telinit'))
conf.set_quoted('USER_CONFIG_UNIT_PATH', pkgsysconfdir + '/user')
conf.set_quoted('USER_DATA_UNIT_PATH', userunitdir)
conf.set_quoted('CERTIFICATE_ROOT', get_option('certificate-root'))
Expand Down Expand Up @@ -171,8 +170,6 @@ conf.set_quoted('SYSTEMD_EXPORT_PATH', rootlibexecdir + '
conf.set_quoted('VENDOR_KEYRING_PATH', rootlibexecdir + '/import-pubring.gpg')
conf.set_quoted('USER_KEYRING_PATH', pkgsysconfdir + '/import-pubring.gpg')
conf.set_quoted('DOCUMENT_ROOT', pkgdatadir + '/gatewayd')
conf.set_quoted('KBD_LOADKEYS', get_option('loadkeys'))
conf.set_quoted('KBD_SETFONT', get_option('setfont'))

conf.set_quoted('ABS_BUILD_DIR', meson.build_root())
conf.set_quoted('ABS_SRC_DIR', meson.source_root())
Expand Down Expand Up @@ -382,19 +379,28 @@ awk = find_program('awk')
m4 = find_program('m4')
stat = find_program('stat')

progs = [['quotaon', '/usr/sbin/quotaon' ],
['quotacheck', '/usr/sbin/quotacheck'],
['kill', '/usr/bin/kill' ],
['kmod', '/usr/bin/kmod' ],
['kexec', '/usr/sbin/kexec' ],
['sulogin', '/usr/sbin/sulogin' ],
['mount', '/usr/bin/mount', 'MOUNT_PATH'],
['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
# if -Dxxx-path option is found, use that. Otherwise, check in $PATH,
# /usr/sbin, /sbin, and fall back to the default from middle column.
progs = [['telinit', '/lib/sysvinit/telinit'],
['quotaon', '/usr/sbin/quotaon' ],
['quotacheck', '/usr/sbin/quotacheck' ],
['kill', '/usr/bin/kill' ],
['kmod', '/usr/bin/kmod' ],
['kexec', '/usr/sbin/kexec' ],
['sulogin', '/usr/sbin/sulogin' ],
['mount', '/usr/bin/mount', 'MOUNT_PATH'],
['umount', '/usr/bin/umount', 'UMOUNT_PATH'],
['loadkeys', '/usr/bin/loadkeys', 'KBD_LOADKEYS'],
['setfont', '/usr/bin/setfont', 'KBD_SETFONT'],
]

foreach prog : progs
exe = find_program(prog[0], required: false)
path = exe.found() ? exe.path() : prog[1]
path = get_option(prog[0] + '-path')
if path != ''
message('Using @1@ for @0@'.format(prog[0], path))
else
exe = find_program(prog[0], '/usr/sbin/' + prog[0], '/sbin/' + prog[0], required: false)
path = exe.found() ? exe.path() : prog[1]
endif
name = prog.length() > 2 ? prog[2] : prog[0].to_upper()
conf.set_quoted(name, path)
endforeach
Expand Down
17 changes: 11 additions & 6 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ option('sysvinit-path', type : 'string', value : '/etc/init.d',
description : 'the directory where the SysV init scripts are located')
option('sysvrcnd-path', type : 'string', value : '/etc/rc.d',
description : 'the base directory for SysV rcN.d directories')
option('telinit', type : 'string', value : '/lib/sysvinit/telinit',
description : 'path to telinit')
option('telinit-path', type : 'string', description : 'path to telinit')

option('loadkeys', type : 'string', value : '/usr/bin/loadkeys',
description : 'path to loadkeys')
option('setfont', type : 'string', value : '/usr/bin/setfont',
description : 'path to setfont')
option('quotaon-path', type : 'string', description : 'path to quotaon')
option('quotacheck-path', type : 'string', description : 'path to quotacheck')
option('kill-path', type : 'string', description : 'path to kill')
option('kmod-path', type : 'string', description : 'path to kmod')
option('kexec-path', type : 'string', description : 'path to kexec')
option('sulogin-path', type : 'string', description : 'path to sulogin')
option('mount-path', type : 'string', description : 'path to mount')
option('umount-path', type : 'string', description : 'path to umount')
option('loadkeys-path', type : 'string', description : 'path to loadkeys')
option('setfont-path', type : 'string', description : 'path to setfont')

option('utmp', type : 'boolean',
description : 'support for utmp/wtmp log handling')
Expand Down

0 comments on commit 0acf091

Please sign in to comment.