More robust copying of terminfo

Dont use symlinks in the tarball, instead create them
in the bootstrap scripts, only if needed.
This commit is contained in:
Kovid Goyal 2022-03-10 21:08:20 +05:30
parent a9de91087a
commit f774841ee0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
5 changed files with 15 additions and 10 deletions

View File

@ -11,7 +11,7 @@ import sys
import tempfile
def compile_terminfo(base, add_other_versions=False):
def compile_terminfo(base):
with tempfile.TemporaryDirectory() as tdir:
proc = subprocess.run(['tic', '-x', f'-o{tdir}', 'terminfo/kitty.terminfo'], check=True, stderr=subprocess.PIPE)
regex = '^"terminfo/kitty.terminfo", line [0-9]+, col [0-9]+, terminal \'xterm-kitty\': older tic versions may treat the description field as an alias$'
@ -29,13 +29,6 @@ def compile_terminfo(base, add_other_versions=False):
os.makedirs(odir, exist_ok=True)
ofile = os.path.join(odir, xterm_kitty)
shutil.move(tfile, ofile)
if add_other_versions:
shutil.copy2('terminfo/kitty.terminfo', base)
for x in os.listdir('terminfo'):
if x == 'kitty.terminfo':
continue
if not os.path.exists(os.path.join(base, x)):
os.symlink(directory, os.path.join(base, x))
def generate_terminfo():

View File

@ -3,6 +3,7 @@
import atexit
import fnmatch
import glob
import io
import json
import os
@ -131,7 +132,8 @@ def make_tarfile(ssh_opts: SSHOptions, base_env: Dict[str, str], compression: st
f'{arcname}/ssh/*', # bootstrap files are sent as command line args
f'{arcname}/zsh/kitty.zsh', # present for legacy compat not needed by ssh kitten
))
tf.add(terminfo_dir, arcname='home/.terminfo', filter=normalize_tarinfo)
tf.add(f'{terminfo_dir}/kitty.terminfo', arcname='home/.terminfo/kitty.terminfo', filter=normalize_tarinfo)
tf.add(glob.glob(f'{terminfo_dir}/*/xterm-kitty')[0], arcname='home/.terminfo/x/xterm-kitty', filter=normalize_tarinfo)
return buf.getvalue()

View File

@ -1258,7 +1258,7 @@ def package(args: Options, bundle_type: str) -> None:
for x in (libdir, os.path.join(ddir, 'share')):
odir = os.path.join(x, 'terminfo')
safe_makedirs(odir)
build_terminfo['compile_terminfo'](odir, add_other_versions=True)
build_terminfo['compile_terminfo'](odir)
shutil.copy2('__main__.py', libdir)
shutil.copy2('logo/kitty-128.png', os.path.join(libdir, 'logo'))
shutil.copy2('logo/kitty.png', os.path.join(libdir, 'logo'))

View File

@ -121,6 +121,10 @@ def compile_terminfo(base):
if cp.returncode != 0:
sys.stderr.buffer.write(cp.stdout)
raise SystemExit('Failed to compile the terminfo database')
q = os.path.join(base, tname, '78', 'xterm-kitty')
if not os.path.exists(q):
os.makedirs(os.path.dirname(q), exist_ok=True)
os.symlink("../x/xterm-kitty", q)
def get_data():

View File

@ -201,6 +201,12 @@ compile_terminfo() {
tic_out=$(command tic -x -o "$1/$tname" "$1/.terminfo/kitty.terminfo" 2>&1)
[ $? = 0 ] || die "Failed to compile terminfo with err: $tic_out";
fi
# Ensure the 78 dir is present
if [ ! -f "$1/$tname/78/xterm-kitty" ]; then
command mkdir -p "$1/$tname/78"
command ln -sf "../x/xterm-kitty" "$1/$tname/78/xterm-kitty"
fi
}
untar_and_read_env() {