Merge branch 'terminfo-no-custom-install-location'

Closes #695
This commit is contained in:
Daniel Eklöf 2021-08-30 19:14:56 +02:00
commit 4e5c8fd1b0
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
6 changed files with 77 additions and 118 deletions

View file

@ -128,23 +128,35 @@ reasons for this:
used by e.g. tmux. used by e.g. tmux.
* New capabilities added to the `xterm-256color` terminfo could * New capabilities added to the `xterm-256color` terminfo could
potentially break foot. potentially break foot.
* There may be future additions or changes to foots terminfo.
As of ncurses 2021-07-31, ncurses ships a version of foots As of ncurses 2021-07-31, ncurses includes a version of foots
terminfo. I still recommend building and installing the version terminfo. **The recommendation is to use those**, and only install the
shipped with foot, since: terminfo definitions from this git repo if the systems ncurses
predates 2021-07-31.
* It will be more up to date (and more importantly, guaranteed to But, note that the foot terminfo definitions in ncurses lack the
match the installed version of foot). non-standard capabilities. This mostly affects tmux; without them,
* The ncurses version is missing several of the non-standard capabilities. `terminal-overrides` must be configured to enable truecolor
support. For this reason, it _is_ possible to install “our” terminfo
definitions as well, either in a non-default location, or under a
different name.
Foots terminfo will by default be built, and installed along with Both have their set of issues. When installing to a non-default
foot itself. This can be disabled (for example, to simplify packaging location, foot will set the environment variable `TERMINFO` in the
when the terminfo definitions are packaged in a separate child process. However, there are many situations where this simply
package). Instructions on how to do so is in [terminfo](#terminfo). does not work. See https://codeberg.org/dnkl/foot/issues/695 for
details.
I recommend packaging foots terminfo files in a separate package, to Installing them under a different name generally works well, but will
allow them to be installed on remote systems without having to install break applications that check if `$TERM == foot`.
foot itself.
Hence the recommendation to simply use ncurses terminfo definitions
if available.
If packaging “our” terminfo definitions, I recommend doing that as a
separate package, to allow them to be installed on remote systems
without having to install foot itself.
### Setup ### Setup
@ -158,44 +170,43 @@ mkdir -p bld/release && cd bld/release
Available compile-time options: Available compile-time options:
| Option | Type | Default | Description | Extra dependencies | | Option | Type | Default | Description | Extra dependencies |
|--------------------------------------|---------|----------------------------|----------------------------------|--------------------| |--------------------------------------|---------|-----------------------|----------------------------------|--------------------|
| `-Ddocs` | feature | `auto` | Builds and install documentation | scdoc | | `-Ddocs` | feature | `auto` | Builds and install documentation | scdoc |
| `-Dime` | bool | `true` | Enables IME support | None | | `-Dime` | bool | `true` | Enables IME support | None |
| `-Dgrapheme-clustering` | feature | `auto` | Enables grapheme clustering | libutf8proc | | `-Dgrapheme-clustering` | feature | `auto` | Enables grapheme clustering | libutf8proc |
| `-Dterminfo` | feature | `enabled` | Build and install terminfo files | tic (ncurses) | | `-Dterminfo` | feature | `enabled` | Build and install terminfo files | tic (ncurses) |
| `-Ddefault-terminfo` | string | `foot` | Default value of `TERM` | none | | `-Ddefault-terminfo` | string | `foot` | Default value of `TERM` | none |
| `-Dcustom-terminfo-install-location` | string | `${datadir}/foot/terminfo` | Value to set `TERMINFO` to | None | | `-Dcustom-terminfo-install-location` | string | `${datadir}/terminfo` | Value to set `TERMINFO` to | None |
Documentation includes the man pages, the example `foot.ini`, readme, Documentation includes the man pages, the example `foot.ini`, readme,
changelog and license files. changelog and license files.
`-Ddefault-terminfo`: I strongly recommend leaving the default `-Ddefault-terminfo`: I strongly recommend leaving the default
value. This option is meant to be used as a last resort on platforms value. Use this option if you plan on installing the terminfo files
where individual terminfo files cannot easily be installed. under a different name. Setting this changes the default value of
`$TERM`, and the names of the terminfo files (if
`-Dterminfo=enabled`).
`-Dcustom-terminfo-install-location` enables foots terminfo to `-Dcustom-terminfo-install-location` enables foots terminfo to
co-exist with ncurses version. The idea is that you install foots co-exist with ncurses version, without changing the terminfo
terminfo to a non-standard location, for example names. The idea is that you install foots terminfo to a non-standard
`/usr/share/foot/terminfo`. Use `-Dcustom-terminfo-install-location` location, for example `/usr/share/foot/terminfo`. Use
to tell foot where the terminfo is. Foot will set the environment `-Dcustom-terminfo-install-location` to tell foot where the terminfo
variable `TERMINFO` to this value (with `${prefix}` added). The value is. Foot will set the environment variable `TERMINFO` to this value
is **relative to ${prefix}**. (with `${prefix}` added). The value is **relative to ${prefix}**.
Conforming applications _should_ look in `TERMINFO` first, and Note that there are several issues with this approach:
fallback to the builtin default (e.g. `/usr/share/terminfo`) if not https://codeberg.org/dnkl/foot/issues/695.
found. Thus, it will prefer foots version, if it exists (which it
typically will on localhost), and fallback to ncurses version if not
(e.g. on remote systems, where foots terminfo package has not been
installed).
If set to `no`, foot will **not** set or modify `TERMINFO` at all. Use If left unset, foot will **not** set or modify `TERMINFO`.
this if you do not intend to use/support foots terminfo definitions
at all.
`-Dterminfo` can be used to disable building the terminfo definitions `-Dterminfo` can be used to disable building the terminfo definitions
in the meson build. It does **not** change the default value of in the meson build. It does **not** change the default value of
`TERM`, and it does **not** disable `TERMINFO`. `TERM`, and it does **not** disable `TERMINFO`, if
`-Dcustom-terminfo-install-location` has been set. Use this if
packaging the terminfo definitions in a separate package (and the
build script isnt shared with the foot package).
Example: Example:

View file

@ -402,36 +402,6 @@ The following environment variables are set in the child process:
set according to either the *--term* command-line option or the set according to either the *--term* command-line option or the
*term* config option in *foot.ini*(5). *term* config option in *foot.ini*(5).
*TERMINFO*
Path to foot's terminfo definitions. These are typically installed
in a non-standard location (though distributions may override
this), to allow them to co-exist with the foot terminfo
definitions in ncurses. Note that applications will search the
default location(s) if *TERM* does not exist in *TERMINFO*.
Note that applications like *sudo*, *doas* and *ssh* may remove
this environment variable.
For *sudo*, you can create a file under _/etc/sudoers.d_ (name
does not matter) with the following content:
*Defaults env_keep += "TERMINFO"*
For *doas*, edit _/etc/doas.conf_ and add:
*permit setenv { TERMINFO } :wheel*
Or, if you are not in the *wheel* group, replace *:wheel* with
your username.
For *ssh*, you can edit _/etc/ssh/sshd_config_ (on the *server*),
and add:
*SetEnv TERMINFO=*_<path>_
Where path is the location of the terminfo definitions on the
*server*, typically /usr/share/foot/terminfo.
*COLORTERM* *COLORTERM*
This variable is set to *truecolor*, to indicate to client This variable is set to *truecolor*, to indicate to client
applications that 24-bit RGB colors are supported. applications that 24-bit RGB colors are supported.

View file

@ -146,36 +146,6 @@ The following environment variables are set in the child process:
set according to either the *--term* command-line option or the set according to either the *--term* command-line option or the
*term* config option in *foot.ini*(5). *term* config option in *foot.ini*(5).
*TERMINFO*
Path to foot's terminfo definitions. These are typically installed
in a non-standard location (though distributions may override
this), to allow them to co-exist with the foot terminfo
definitions in ncurses. Note that applications will search the
default location(s) if *TERM* does not exist in *TERMINFO*.
Note that applications like *sudo*, *doas* and *ssh* may remove
this environment variable.
For *sudo*, you can create a file under _/etc/sudoers.d_ (name
does not matter) with the following content:
*Defaults env_keep += "TERMINFO"*
For *doas*, edit _/etc/doas.conf_ and add:
*permit setenv { TERMINFO } :wheel*
Or, if you are not in the *wheel* group, replace *:wheel* with
your username.
For *ssh*, you can edit _/etc/ssh/sshd_config_ (on the *server*),
and add:
*SetEnv TERMINFO=*_<path>_
Where path is the location of the terminfo definitions on the
*server*, typically /usr/share/foot/terminfo.
*COLORTERM* *COLORTERM*
This variable is set to *truecolor*, to indicate to client This variable is set to *truecolor*, to indicate to client
applications that 24-bit RGB colors are supported. applications that 24-bit RGB colors are supported.

View file

@ -1,17 +1,17 @@
foot|foot terminal emulator, @default_terminfo@|foot terminal emulator,
use=foot+base, use=@default_terminfo@+base,
colors#256, colors#256,
setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48\:5\:%p1%d%;m, setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48\:5\:%p1%d%;m,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38\:5\:%p1%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38\:5\:%p1%d%;m,
foot-direct|foot with direct color indexing, @default_terminfo@-direct|foot with direct color indexing,
use=foot+base, use=@default_terminfo@+base,
colors#16777216, colors#16777216,
RGB, RGB,
setab=\E[%?%p1%{8}%<%t4%p1%d%e48\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m, setab=\E[%?%p1%{8}%<%t4%p1%d%e48\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e38\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m, setaf=\E[%?%p1%{8}%<%t3%p1%d%e38\:2\:\:%p1%{65536}%/%d\:%p1%{256}%/%{255}%&%d\:%p1%{255}%&%d%;m,
foot+base|foot base fragment, @default_terminfo@+base|foot base fragment,
am, am,
bce, bce,
bw, bw,

View file

@ -35,17 +35,15 @@ add_project_arguments(
language: 'c', language: 'c',
) )
default_terminfo_install_location = join_paths(get_option('datadir'), 'foot', 'terminfo')
terminfo_install_location = get_option('custom-terminfo-install-location') terminfo_install_location = get_option('custom-terminfo-install-location')
if terminfo_install_location == ''
terminfo_install_location = default_terminfo_install_location
endif
if terminfo_install_location != 'no' if terminfo_install_location != ''
add_project_arguments( add_project_arguments(
['-DFOOT_TERMINFO_PATH="@0@"'.format( ['-DFOOT_TERMINFO_PATH="@0@"'.format(
join_paths(get_option('prefix'), terminfo_install_location))], join_paths(get_option('prefix'), terminfo_install_location))],
language: 'c') language: 'c')
else
terminfo_install_location = join_paths(get_option('datadir'), 'terminfo')
endif endif
# Compute the relative path used by compiler invocations. # Compute the relative path used by compiler invocations.
@ -246,15 +244,24 @@ endif
tic = find_program('tic', native: true, required: get_option('terminfo')) tic = find_program('tic', native: true, required: get_option('terminfo'))
if tic.found() if tic.found()
conf_data = configuration_data(
{
'default_terminfo': get_option('default-terminfo'),
}
)
preprocessed = configure_file(
input: 'foot.info',
output: 'foot.info.preprocessed',
configuration: conf_data,
)
custom_target( custom_target(
'terminfo', 'terminfo',
output: 'f', output: get_option('default-terminfo')[0],
input: 'foot.info', input: preprocessed,
command: [tic, '-x', '-o', '@OUTDIR@', '-e', 'foot,foot-direct', '@INPUT@'], command: [tic, '-x', '-o', '@OUTDIR@', '-e', '@0@,@0@-direct'.format(get_option('default-terminfo')), '@INPUT@'],
install: true, install: true,
install_dir: (terminfo_install_location != 'no' install_dir: terminfo_install_location
? terminfo_install_location
: default_terminfo_install_location)
) )
endif endif
@ -267,8 +274,9 @@ summary(
'IME': get_option('ime'), 'IME': get_option('ime'),
'Grapheme clustering': utf8proc.found(), 'Grapheme clustering': utf8proc.found(),
'Build terminfo': tic.found(), 'Build terminfo': tic.found(),
'Terminfo install location': terminfo_install_location,
'Default TERM': get_option('default-terminfo'), 'Default TERM': get_option('default-terminfo'),
'Terminfo custom install location': terminfo_install_location, 'Set TERMINFO': get_option('custom-terminfo-install-location') != '',
}, },
bool_yn: true bool_yn: true
) )

View file

@ -11,5 +11,5 @@ option('terminfo', type: 'feature', value: 'enabled', description: 'Build and in
option('default-terminfo', type: 'string', value: 'foot', option('default-terminfo', type: 'string', value: 'foot',
description: 'Default value of the "term" option in foot.ini.') description: 'Default value of the "term" option in foot.ini.')
option('custom-terminfo-install-location', type: 'string', option('custom-terminfo-install-location', type: 'string', value: '',
description: 'Path to foot\'s terminfo, relative to ${prefix}. If set to anything but “no“, foot will set TERMINFO to this value in the client process.') description: 'Path to foot\'s terminfo, relative to ${prefix}. If set, foot will set $TERMINFO to this value in the client process.')