Make creating a linux package even easier

This commit is contained in:
Kovid Goyal 2017-01-09 10:37:10 +05:30
parent d507208e3f
commit 445579942c
2 changed files with 39 additions and 22 deletions

View File

@ -261,22 +261,18 @@ Instead run,
python3 setup.py linux-package
```
This will create the directory `linux-package` containing all the files need to run kitty. kitty can be run using
This will install kitty into the directory `linux-package`. You can run kitty
with `linux-package/bin/kitty`. All the files needed to run kitty will be in
`linux-package/lib/kitty`. The terminfo file will be installed into
`linux-package/share/terminfo`. Simply copy these files into `/usr` to install
kitty. In other words, `linux-package` is the staging area into which kitty is
installed. You can choose a different staging area, by passing the `--prefix`
argument to `setup.py`.
```
python3 linux-package
```
The `linux-package` directory can be renamed and moved anywhere on the
filesystem, it is self contained. So simply create a launcher script named
`/usr/bin/kitty` that calls `python3 /path/to/the/installed/linux-package/directory`.
You should also create a second package named kitty-terminfo that installs the
file `linux-package/terminfo/x/xterm-kitty` into `/usr/share/terminfo` (or
whatever location your distribution uses for terminfo files). Make the main
kitty package depend on `kitty-terminfo`. This allows users to install the
terminfo file on servers into which they ssh, without needing to install all of
kitty.
You should probably split kitty into two packages, `kitty-terminfo` that
installs the terminfo file and `kitty` that installs the main program.
This allows users to install the terminfo file on servers into which they ssh,
without needing to install all of kitty.
== Resources on terminal behavior

View File

@ -146,6 +146,7 @@ def option_parser():
p.add_argument('--asan', default=False, action='store_true',
help='Turn on address sanitization to detect memory access errors. Note that if you do turn it on,'
' you have to run kitty with the environment variable LD_PRELOAD=/usr/lib/libasan.so')
p.add_argument('--prefix', default='./linux-package', help='Where to create the linux package')
return p
@ -165,26 +166,46 @@ def build(args):
compile_c_extension('kitty/fast_data_types', *find_c_files())
def safe_makedirs(path):
try:
os.makedirs(path)
except FileExistsError:
pass
def package(args):
ddir = 'linux-package'
if os.path.exists(ddir):
shutil.rmtree(ddir)
os.makedirs(ddir + '/terminfo/x')
shutil.copy2('__main__.py', ddir)
shutil.copy2('terminfo/x/xterm-kitty', ddir + '/terminfo/x')
ddir = args.prefix
libdir = os.path.join(ddir, 'lib', 'kitty')
terminfo_dir = os.path.join(ddir, 'share/terminfo/x')
if os.path.exists(libdir):
shutil.rmtree(libdir)
os.makedirs(os.path.join(libdir, 'terminfo/x'))
safe_makedirs(terminfo_dir)
shutil.copy2('__main__.py', libdir)
shutil.copy2('terminfo/x/xterm-kitty', terminfo_dir)
shutil.copy2('terminfo/x/xterm-kitty', os.path.join(libdir, 'terminfo/x'))
def src_ignore(parent, entries):
return [x for x in entries if '.' in x and x.rpartition('.')[2] not in ('py', 'so', 'conf')]
shutil.copytree('kitty', ddir + '/kitty', ignore=src_ignore)
shutil.copytree('kitty', os.path.join(libdir, 'kitty'), ignore=src_ignore)
import compileall
compileall.compile_dir(ddir, quiet=1, workers=4)
for root, dirs, files in os.walk(ddir):
for f in files:
path = os.path.join(root, f)
os.chmod(path, 0o755 if f.endswith('.so') else 0o644)
launcher_dir = os.path.join(ddir, 'bin')
safe_makedirs(launcher_dir)
run_tool([cc, '-ggdb', 'linux-launcher.c', '-o', os.path.join(launcher_dir, 'kitty')])
def main():
if sys.version_info < (3, 5):
raise SystemExit('python >= 3.5 required')
args = option_parser().parse_args()
args.prefix = os.path.abspath(args.prefix)
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if args.action == 'build':
build(args)
elif args.action == 'test':