foot/PKGBUILD
Daniel Eklöf 7639186865
terminfo: install to $datadir/foot/terminfo by default, append to TERMINFO_DIRS
As of 2021-07-31, ncurses ships its own version of foot’s terminfo.

Since:

* It doesn’t have the non-standard Sync,Tc,setrgbf,setrgbb
  capabilities.
* It doesn’t set hs,fsl,dsl (statusbar).
* We want to be able to update our termminfo without waiting for an
  ncurses release.
* Foot should be installable and usable on Linux systems that doesn’t
  have the latest ncurses.

we still want to ship our own version. We can however not install it
to the default terminfo location (e.g. /usr/share/terminfo), since it
will collide with the ncurses provided files.

Our options are to either rename our terminfo to something else, or to
keep the name, but install our terminfo files somewhere else.

The first option would be the easy one. However, I think it makes
sense to use the same name. For example, a user that SSH’s into a
remote system that does *not* have our own version installed,
but *does* have the ncurses one, will gracefully fall back to that
one, which is better than manually having to set
e.g. TERM=xterm-256color.

Now, if we want to use the same name, we need to install it somewhere
else. But where? And how do we ensure our version is preferred over
the ncurses one?

I opted to $datadir/foot/terminfo (e.g. /usr/share/foot/terminfo) by
default. It makes it namespaced to foot (i.e. we’re not introducing a
new “standard” terminfo location), thus guaranteeing it wont collide
with ncurses.

To enable applications to find it, we export TERMINFO_DIRS. This is a
list of *additional* directories to search for terminfo files. If it’s
already defined, we *append* to it.

The nice thing with this is, if there’s no terminfo in that
location (e.g. when you SSH into a remote), the default terminfo
location is *also* searched. But only *after* having searched through
TERMINFO_DIRS.

In short: our version is preferred, but the ncurses one (or an older
version of our terminfo package!) will be used if ours cannot be
found.

To enable packagers full control over the new behavior, the existing
meson command line options have been modified, and a new option added:

-Dterminfo=disabled|enabled|auto: *build* and *install* the terminfo
files.

-Dcustom-terminfo-install-location=<path>: *where* the terminfo files
are expected to be found.

This *needs* to be set *even* if -Dterminfo=disabled. For example, if
the packaging script builds and packages the terminfo files separate
from the regular foot build. The path is *relative to $prefix*, and
defaults to $datadir/foot/terminfo.

This is the value that will be appended to TERMINFO_DIRS. Note that
you can set it to ‘no’, in which case foot will *not* set/modify
TERMINFO_DIRS. Only do this if you don’t intend to package foot’s
terminfo files at all (i.e. you plan on using the ncurses ones only).

-Ddefault-terminfo=foot. Allows overriding the default TERM
value. This should only be changed if the target platform doesn’t
support terminfo files.

Closes #671
2021-08-17 21:04:30 +02:00

112 lines
2.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

pkgname=('foot-git' 'foot-terminfo-git')
pkgver=1.8.2
pkgrel=1
arch=('x86_64' 'aarch64')
url=https://codeberg.org/dnkl/foot
license=(mit)
depends=('libxkbcommon' 'wayland' 'pixman' 'fontconfig' 'libutf8proc' 'fcft>=2.4.0')
makedepends=('meson' 'ninja' 'scdoc' 'python' 'ncurses' 'wayland-protocols' 'tllist>=1.0.4')
source=()
pkgver() {
cd ../.git &> /dev/null && git describe --tags --long | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' ||
head -3 ../meson.build | grep version | cut -d "'" -f 2
}
build() {
local compiler=other
local do_pgo=no
# makepkg uses -O2 by default, but we *really* want -O3
CFLAGS+=" -O3"
# Figure out which compiler we're using, and whether or not to do PGO
case $(${CC-cc} --version) in
*GCC*)
compiler=gcc
do_pgo=yes
;;
*clang*)
compiler=clang
# We need llvm to be able to manage the profiling data
if command -v llvm-profdata > /dev/null; then
do_pgo=yes
# Meson adds -fprofile-correction, which Clang doesn't
# understand
CFLAGS+=" -Wno-ignored-optimization-argument"
fi
;;
esac
meson --prefix=/usr --buildtype=release --wrap-mode=nofallback -Db_lto=true ..
if [[ ${do_pgo} == yes ]]; then
find -name "*.gcda" -delete
meson configure -Db_pgo=generate
ninja
# If fcft/tllist are subprojects, we need to ensure their tests
# have been executed, or well get “profile count data file not
# found” errors.
ninja test
local script_options="--scroll --scroll-region --colors-regular --colors-bright --colors-256 --colors-rgb --attr-bold --attr-italic --attr-underline --sixel"
tmp_file=$(mktemp)
if [[ -v WAYLAND_DISPLAY ]]; then
./footclient --version
./foot \
--config /dev/null \
--term=xterm \
sh -c "../scripts/generate-alt-random-writes.py ${script_options} ${tmp_file} && cat ${tmp_file}"
else
./footclient --version
./foot --version
../scripts/generate-alt-random-writes.py \
--rows=67 \
--cols=135 \
${script_options} \
${tmp_file}
./pgo ${tmp_file} ${tmp_file} ${tmp_file}
fi
rm "${tmp_file}"
if [[ ${compiler} == clang ]]; then
llvm-profdata merge default_*profraw --output=default.profdata
fi
meson configure -Db_pgo=use
fi
ninja
}
check() {
ninja test
}
package_foot-git() {
pkgdesc="A wayland native terminal emulator"
changelog=CHANGELOG.md
depends+=('foot-terminfo')
conflicts=('foot')
provides=('foot')
DESTDIR="${pkgdir}/" ninja install
rm -rf "${pkgdir}/usr/share/foot/terminfo"
}
package_foot-terminfo-git() {
pkgdesc="Terminfo files for the foot terminal emulator"
depends=('ncurses')
conflicts=('foot-terminfo')
provides=('foot-terminfo')
install -dm 755 "${pkgdir}/usr/share/foot/terminfo/f/"
cp f/* "${pkgdir}/usr/share/foot/terminfo/f/"
}