Move packaging scripts for docker and appimage into subdirectory.

- De-clutter the project root directory.
This commit is contained in:
Andrew Hamilton 2021-11-03 21:23:15 +10:00
parent 0f59e43395
commit 58b78e9ce4
10 changed files with 6 additions and 6 deletions

14
packaging/Dockerfile Normal file
View file

@ -0,0 +1,14 @@
# Copyright (C) 2020 Andrew Hamilton. All rights reserved.
# Licensed under the Artistic License 2.0.
FROM ubuntu:impish
RUN apt update && apt install -y git sudo
RUN git clone https://github.com/ahamilton/eris
RUN cd eris && git checkout 0f59e4339548de8bcccc3ebf85be9b2b49fd10f0
RUN rm -rf eris/.git
RUN DEBIAN_FRONTEND=noninteractive apt install -y tzdata
RUN cd eris && ./install
ENTRYPOINT ["eris"]

25
packaging/RELEASES Normal file
View file

@ -0,0 +1,25 @@
18 October 2021
- Moved to Ubuntu 21.10.
- Fixed slow loading of large summaries.
- Gave the summary and listing panes different widths.
- Removed distinction between normal and okay statuses.
- Displaying wide characters correctly.
- Dropped flatpak releases.
24 September 2020
- Follow changes to the filesystem more efficiently. No pauses with large projects.
- Quick startup for large projects. Load them incrementally after startup.
- Added docker support.
- Added tool info report. See 'eris -i'
- Can be run without a tty, to produce a log.
- Moved to Ubuntu 20.04.
- Always use bundled LS_COLORS to color files.
- Clear all results when the tools.toml file is changed.
- Added installation instructions to Readme.
- Only use tools whose executables are available.

26
packaging/appimage/AppRun Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
# This is a modified version of the AppRun made by AppImage's meta/Recipe.
set -e
HERE="$(dirname "$(readlink -f "${0}")")"
export APPDIR="${HERE}"
export PATH="${HERE}"/usr/bin/:"${HERE}"/usr/local/bin/:"${PATH}"
export UNION_PRELOAD="${HERE}"
export LD_PRELOAD="${HERE}/libunionpreload.so"
export LD_LIBRARY_PATH="${HERE}"/usr/lib/:"${HERE}"/usr/lib/i386-linux-gnu/:"${HERE}"/usr/lib/x86_64-linux-gnu/:"${HERE}"/usr/lib32/:"${HERE}"/usr/lib64/:"${HERE}"/lib/:"${HERE}"/lib/i386-linux-gnu/:"${HERE}"/lib/x86_64-linux-gnu/:"${HERE}"/lib32/:"${HERE}"/lib64/:"${LD_LIBRARY_PATH}"
export PYTHONPATH=/usr/local/lib/python3.9/dist-packages:"${PYTHONPATH}"
if [ -z $APPIMAGE_ENTER ]; then
EXEC=$(grep -e '^Exec=.*' "${HERE}"/*.desktop | head -n 1 | cut -d "=" -f 2- | sed -e 's|%.||g')
exec ${EXEC} $@
else
if [ -z "$@" ]; then
exec /bin/bash
else
$@
fi
fi

View file

@ -0,0 +1,8 @@
[Desktop Entry]
Type=Application
Name=Eris
Comment=
Exec=eris
Terminal=true
Icon=eris
Categories=Application;

BIN
packaging/appimage/eris.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 701 B

Binary file not shown.

23
packaging/eris-docker Executable file
View file

@ -0,0 +1,23 @@
#!/bin/bash
set -e
DOCKER_IMAGE=eris
ARGS=( $(getopt -u -o hiw:e:t:c: --long help,info,workers:,editor:,theme:,compression: -- "$@") )
if [ "${ARGS[-1]}" == "--" ]; then
OPTION_ARGS="${ARGS[@]:0:${#ARGS[@]}-1}" # ARGS[:-1]
DOCKER_ARGS="$DOCKER_IMAGE $OPTION_ARGS"
elif [ "${ARGS[-2]}" == "--" ]; then
OPTION_ARGS="${ARGS[@]:0:${#ARGS[@]}-2}" # ARGS[:-2]
REAL_PATH=$(realpath "${ARGS[-1]}")
PROJECT=$(basename "$REAL_PATH")
DOCKER_ARGS="-v $REAL_PATH:/tmp/$PROJECT $DOCKER_IMAGE $OPTION_ARGS /tmp/$PROJECT"
else
echo "Usage:
eris [options] <directory>
eris -h | --help"
exit 1
fi
exec docker run -v /etc/passwd:/etc/passwd -u ${UID}:$(id -g) -it --rm $DOCKER_ARGS

111
packaging/make-appimage.py Executable file
View file

@ -0,0 +1,111 @@
#!/usr/bin/env python3.9
import os
import pickle
import subprocess
import sys
import tempfile
ERIS_PATH = os.path.realpath(os.path.dirname(__file__))
def cmd(command):
subprocess.run(command, shell=True, check=True)
def all_paths(path):
for entry in os.scandir(path):
if entry.is_dir(follow_symlinks=False):
yield from all_paths(entry.path)
else:
yield entry.path
def relative_paths(root_path, paths):
root_len = len(root_path)
for path in paths:
yield "." + path[root_len:]
def make_sub_container(src_root, dest_root, paths):
for path in paths:
dest_path = os.path.join(dest_root, path)
os.makedirs(os.path.dirname(dest_path), exist_ok=True)
os.link(os.path.join(src_root, path), dest_path)
def filter_paths(paths, exclusions):
return [path for path in paths
if all(excluded not in path for excluded in exclusions)]
def run_in_container(container, command):
option = "--directory" if os.path.isdir(container) else "--image"
cmd(f"sudo systemd-nspawn --quiet --chdir=/eris --overlay={ERIS_PATH}:"
f'/eris {option}={container} /bin/bash --login -c "{command}"')
def build_ubuntu():
cmd("sudo debootstrap --components=main,restricted,universe,multiverse "
"impish ubuntu.part http://au.archive.ubuntu.com/ubuntu/")
run_in_container("ubuntu.part",
"ln -sf /lib/systemd/resolv.conf /etc/resolv.conf")
os.rename("ubuntu.part", "ubuntu")
def make_ubuntu_base():
if os.path.exists("base_paths"):
with open("base_paths", "rb") as file_:
base_paths = pickle.load(file_)
else:
build_ubuntu()
base_paths = relative_paths("ubuntu", all_paths("ubuntu"))
base_paths = filter_paths(base_paths, ["python3"])
with open("base_paths", "wb") as file_:
pickle.dump(base_paths, file_)
return base_paths
def make_app_dir(app_dir, new_paths):
os.mkdir(app_dir)
make_sub_container("ubuntu", app_dir, new_paths)
cmd(f"cp -a {ERIS_PATH}/tests {app_dir}")
cmd(f"cp -a {ERIS_PATH}/test-all {app_dir}")
cmd(f"cp {ERIS_PATH}/packaging/appimage/* {app_dir}")
def cleanup_app_dir(app_dir):
cmd(f"rm -rf {app_dir}/usr/share/go*")
cmd(f"rm -rf {app_dir}/usr/lib/go*")
cmd(f"rm -rf {app_dir}/root")
def make_appimage(app_dir):
cmd("wget --continue https://github.com/AppImage/AppImageKit/releases/"
"download/13/appimagetool-x86_64.AppImage")
cmd("chmod +x appimagetool-x86_64.AppImage")
cmd("ARCH=x86_64 ./appimagetool-x86_64.AppImage --comp xz " + app_dir)
def main(work_path):
assert os.getuid() == 0 and os.getgid() == 0, "Need to be root."
os.chdir(work_path)
base_paths = make_ubuntu_base()
run_in_container("ubuntu", "./install")
post_install_paths = relative_paths("ubuntu", all_paths("ubuntu"))
new_paths = set(post_install_paths) - set(base_paths)
new_paths = filter_paths(new_paths, ["/var/cache/apt/archives", "lto1"])
app_dir = "eris.AppDir"
if os.path.exists(app_dir):
cmd("sudo rm -rf " + app_dir)
make_app_dir(app_dir, new_paths)
cleanup_app_dir(app_dir)
make_appimage(app_dir)
if __name__ == "__main__":
work_path = (tempfile.mkdtemp(prefix="make-appimage-")
if len(sys.argv) == 1 else sys.argv[1])
main(work_path)

60
packaging/make-readme.py Executable file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env python3.9
# -*- coding: utf-8 -*-
import eris.tools as tools
def main():
all_tools = ([(["*"], tools.generic_tools() +
[tools.git_diff, tools.git_blame, tools.git_log])] +
tools.TOOLS_FOR_EXTENSIONS)
tool_set = set()
extension_set = set()
for extensions, tools_ in all_tools:
tool_set.update(tools_)
extension_set.update(extensions)
print(f"""\
# Eris Codebase Monitor
## Summary
Eris maintains an up-to-date set of reports for every file in a codebase.
## Installation
### Ubuntu (21.10)
# git clone https://github.com/ahamilton/eris
# cd eris
# ./install
# eris -h
### Docker
# git clone https://github.com/ahamilton/eris
# cd eris
# sudo docker build -t eris -f packaging/Dockerfile .
# cp packaging/eris-docker ~/bin/eris # e.g. Put wrapper script in your PATH
# eris -h
### AppImage
# Download AppImage file from github releases page:
https://github.com/ahamilton/eris/releases
# chmod +x eris-2020-09-24.AppImage
# mv eris-2020-09-24.AppImage ~/bin/eris # e.g. Put appimage in your PATH
# eris -h
## Tools
File types({len(extension_set)-1}) | Tools({len(tool_set)})
----------:| -----""")
for extensions, tools_ in all_tools:
print("%s | %s" % (
" ".join("." + extension for extension in extensions),
"".join(f"[{tool.__name__}]({tool.url})" for tool in tools_)))
if __name__ == "__main__":
main()