forked from containers/toolbox
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Add options to override the locations for the shell completions
This is particularly relevant for Z shell, because, unlike Bash's bash-completion.pc and fish's fish.pc, it doesn't have an API to detect the location for the shell completions and Debian and Fedora use different locations [1, 2]. Namely, /usr/share/zsh/vendor-completions and /usr/share/zsh/site-functions. An option to specify the locations for the shell completions can optimize the build if there's an alternate API for the location that doesn't involve using bash-completion.pc and fish.pc as build dependencies. eg., Fedora provides the _tmpfilesdir RPM macro to specify the location for vendor-supplied tmpfiles.d(5) files, which makes it possible to avoid having systemd as a build dependency [3]. Finally, when installing to a non-system-wide prefix while hacking on Toolbox as a non-root user, the locations for the completions in the shells' APIs might not be accessible. Being able to override the locations prevents the installation from failing. [1] Debian zsh commit bf0a44a8744469b5 https://salsa.debian.org/debian/zsh/-/commit/bf0a44a8744469b5 https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=620452 [2] https://src.fedoraproject.org/rpms/zsh/blob/f37/f/zsh.spec [3] Fedora toolbox commit 9bebde5bb60f36e3 https://src.fedoraproject.org/rpms/toolbox/c/9bebde5bb60f36e3 containers#1123 containers#840
- Loading branch information
1 parent
299fab4
commit 459acab
Showing
3 changed files
with
59 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,35 @@ | ||
generate_completions_program = find_program('generate_completions.py') | ||
|
||
if bash_completion_dep.found() | ||
bashcompletionsdir = bash_completion_dep.get_variable(pkgconfig: 'completionsdir') | ||
else | ||
bashcompletionsdir = get_option('datadir') / 'bash-completion' / 'completions' | ||
message('bash-completion not found: using', get_option('prefix') / bashcompletionsdir, 'as a falback install directory') | ||
endif | ||
|
||
if fish_dep.found() | ||
fishcompletionsdir = fish_dep.get_variable(pkgconfig: 'completionsdir') | ||
else | ||
fishcompletionsdir = get_option('datadir') / 'fish' / 'completions' | ||
message('fish not found: using', get_option('prefix') / fishcompletionsdir, 'as a fallback install directory') | ||
if bashcompletionsdir != '' | ||
custom_target( | ||
'bash-completion', | ||
capture: true, | ||
command: [generate_completions_program, meson.global_source_root() / 'src', 'bash'], | ||
depends: [toolbox_go], | ||
install: true, | ||
install_dir: bashcompletionsdir, | ||
output: 'toolbox' | ||
) | ||
endif | ||
|
||
custom_target( | ||
'bash-completion', | ||
capture: true, | ||
command: [generate_completions_program, meson.global_source_root() / 'src', 'bash'], | ||
depends: [toolbox_go], | ||
install: true, | ||
install_dir: bashcompletionsdir, | ||
output: 'toolbox' | ||
if fishcompletionsdir != '' | ||
custom_target( | ||
'fish-completion', | ||
capture: true, | ||
command: [generate_completions_program, meson.global_source_root() / 'src', 'fish'], | ||
depends: [toolbox_go], | ||
install: true, | ||
install_dir: fishcompletionsdir, | ||
output: 'toolbox.fish' | ||
) | ||
endif | ||
|
||
custom_target( | ||
'zsh-completion', | ||
capture: true, | ||
command: [generate_completions_program, meson.global_source_root() / 'src', 'zsh'], | ||
depends: [toolbox_go], | ||
install: true, | ||
install_dir: get_option('datadir') / 'zsh' / 'site-functions', | ||
install_dir: zshcompletionsdir, | ||
output: '_toolbox' | ||
) | ||
|
||
custom_target( | ||
'fish-completion', | ||
capture: true, | ||
command: [generate_completions_program, meson.global_source_root() / 'src', 'fish'], | ||
depends: [toolbox_go], | ||
install: true, | ||
install_dir: fishcompletionsdir, | ||
output: 'toolbox.fish' | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters