snap: Start snap support.

- Create a snapcraft.yaml file in snap directory.
  Couldn't put this in packaging directory.
- Use make-snapcraft.py to generate the snapcraft file.
- Use make-snap to make the snap from the snapcraft file.
- Eris is confined to only access projects in home.
- os.setpriority doesn't work in snaps.
- eris-webserver is run as "eris.webserver".
This commit is contained in:
Andrew Hamilton 2021-12-05 18:33:42 +10:00
parent abb9633e97
commit 0331a9da1e
5 changed files with 195 additions and 4 deletions

19
packaging/make-snap Executable file
View file

@ -0,0 +1,19 @@
#!/bin/bash
# Run this script from the project root.
# i.e. ./packaging/make-snap
set -e
set -x
# snap install lxd
# lxd init # Use defaults. Set size of loop device to at least 3GB.
snapcraft clean --use-lxd
snapcraft --use-lxd --debug
sudo snap remove eris
sudo snap install --dangerous eris_*_amd64.snap
/snap/bin/eris -h

70
packaging/make-snapcraft.py Executable file
View file

@ -0,0 +1,70 @@
#!/usr/bin/env python3.9
# -*- coding: utf-8 -*-
import textwrap
import eris.__main__
import eris.tools as tools
def main():
lines = eris.__main__.__doc__.splitlines()
summary = lines[2]
description = textwrap.indent("\n".join(lines[2:]), " ")
print(f"""\
name: eris
base: core20
version: 2021.11.29
summary: {summary}
description: |
{description}
grade: devel
confinement: strict
apps:
eris:
command: bin/eris
environment:
PYTHONPATH: $SNAP/lib/python3.9/site-packages:$SNAP/lib/python3.9/dist-packages:$PYTHONPATH
plugs:
- home
webserver:
command: bin/eris-webserver
environment:
PYTHONPATH: $SNAP/lib/python3.9/site-packages:$SNAP/lib/python3.9/dist-packages:$PYTHONPATH
plugs:
- home
- network-bind
passthrough:
layout:
$SNAP/usr/bin/php:
symlink: $SNAP/usr/bin/php7.4
parts:
eris:
plugin: python
source: .
python-packages:
- ./termstr
- ./lscolors
- ./fill3
- ./eris
requirements:
- ./termstr/requirements.txt
- ./fill3/requirements.txt
- ./eris/requirements.txt
build-environment:
- SNAPCRAFT_PYTHON_INTERPRETER: python3.9
stage-packages:
- python3.9-venv
- python3-distutils
- python3-pkg-resources
- """, end="")
print("\n - ".join(sorted(tools.dependencies())))
if __name__ == "__main__":
main()