From d5122f833a5801ccb9c05b60f8a79836a9e25124 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Mon, 18 Sep 2023 00:05:03 +1000 Subject: [PATCH] packaging: Let eris install on Fedora distributions --- README.md | 9 ++++----- eris/eris/__main__.py | 16 ++++++++++++---- eris/eris/tools.py | 2 +- eris/eris/tools.toml | 6 +++--- install | 9 ++------- packaging/Dockerfile | 2 +- packaging/Dockerfile.fedora | 15 +++++++++++++++ packaging/make-readme.py | 9 ++++----- 8 files changed, 42 insertions(+), 26 deletions(-) create mode 100644 packaging/Dockerfile.fedora diff --git a/README.md b/README.md index 81cb5f2..ae1d42a 100644 --- a/README.md +++ b/README.md @@ -6,13 +6,12 @@ Eris maintains an up-to-date set of reports for every file in a codebase. ## Installation -#### Debian / Ubuntu +#### Debian / Ubuntu / Fedora -Install eris directly using pipx, and apt install the tools eris relies on: +Install eris with pipx, then install all the tools eris uses: - sudo apt install pipx pipx install --system-site-packages git+https://gitlab.com/ahamilton/eris@v2023.09.11#subdirectory=eris - eris --apt-install-tools + eris --install-all-tools Or install from source: (including tools) @@ -22,7 +21,7 @@ Or install from source: (including tools) Then to run: - eris -h + eris eris-webserver # Or a simple web interface. ## Tools diff --git a/eris/eris/__main__.py b/eris/eris/__main__.py index c270172..7a39a49 100755 --- a/eris/eris/__main__.py +++ b/eris/eris/__main__.py @@ -51,7 +51,7 @@ Usage: eris [options] eris -h | --help eris -i | --info - eris -a | --apt-install-tools + eris -a | --install-all-tools eris --version Example: @@ -60,7 +60,7 @@ Example: Options: -h, --help Show the full help. -i, --info Show information about the available tools. - -a, --apt-install-tools Install all tools. Ubuntu only. + -a, --install-all-tools Install all tools. -w COUNT, --workers=COUNT The number of processes working in parallel. By default it is the number of cpus minus 1. -e "COMMAND", --editor="COMMAND" The command used to start the editor, in @@ -1142,9 +1142,17 @@ def check_arguments(): sys.exit(1) os.environ["ERIS_CONFIG"] = config_path import eris.tools as tools - if arguments["--apt-install-tools"]: + if arguments["--install-all-tools"]: print("Installing all tools… (requires sudo)") - subprocess.run(["sudo", "apt", "-y", "install"] + sorted(tools.dependencies()), check=True) + tools_ = tools.dependencies() + package_manager = "apt" + if "ID=fedora\n" in open("/etc/os-release"): + tools_.remove("lua-check") + fedora_rename = {"lua5.3": "lua", "python3-bandit": "bandit", + "ruby3.1": "ruby", "xz-utils": "xz"} + tools_ = [fedora_rename.get(tool, tool) for tool in tools_] + package_manager = "dnf" + subprocess.run(["sudo", package_manager, "-y", "install"] + sorted(tools_), check=True) print("Done.") sys.exit(0) if arguments["--info"]: diff --git a/eris/eris/tools.py b/eris/eris/tools.py index 727e3d1..72dfe20 100755 --- a/eris/eris/tools.py +++ b/eris/eris/tools.py @@ -379,7 +379,7 @@ MAX_IMAGE_SIZE = 200 def _resize_image(image, new_width): - import PIL.Image # Here to avoid 'Segmentation Fault' in apt-install-tools + import PIL.Image # Here to avoid 'Segmentation Fault' in install-all-tools scale = new_width / image.width return image.resize((int(image.width * scale), int(image.height * scale)), PIL.Image.LANCZOS) diff --git a/eris/eris/tools.toml b/eris/eris/tools.toml index 7c4b56b..f4bc649 100644 --- a/eris/eris/tools.toml +++ b/eris/eris/tools.toml @@ -148,12 +148,12 @@ tools_for_extensions = [ [unrar] dependencies = ["unrar"] url = "http://www.rarlabs.com/" - command = "unrar-nonfree l" + command = "unrar l" [7z] dependencies = ["p7zip"] url = "http://p7zip.sourceforge.net/" - command = "7zr l" + command = "7za l" [unxz] dependencies = ["xz-utils"] @@ -237,7 +237,7 @@ tools_for_extensions = [ [lua_syntax] dependencies = ["lua5.3"] url = "http://www.lua.org" - command = "luac5.3 -p" + command = "luac -p" [js_syntax] dependencies = ["nodejs"] diff --git a/install b/install index 750d10c..abcfaa2 100755 --- a/install +++ b/install @@ -2,13 +2,8 @@ set -e +set -x -sudo apt install -y python3.11 pipx pipx install --system-site-packages $1 ./eris -eris --apt-install-tools -# When developing... -# python3.11 -m pip install -e ./eris -# python3.11 -m pip install -e ./fill3 -# python3.11 -m pip install -e ./termstr -# python3.11 -m pip install -e ./lscolors +eris --install-all-tools diff --git a/packaging/Dockerfile b/packaging/Dockerfile index b1f028f..7e94402 100644 --- a/packaging/Dockerfile +++ b/packaging/Dockerfile @@ -8,7 +8,7 @@ COPY . eris RUN PIPX_BIN_DIR=/bin pipx install --system-site-packages ./eris/eris RUN chmod a+rwx -R /root RUN apt-get install -y sudo -RUN eris --apt-install-tools +RUN eris --install-all-tools ENTRYPOINT ["eris"] diff --git a/packaging/Dockerfile.fedora b/packaging/Dockerfile.fedora new file mode 100644 index 0000000..26159c1 --- /dev/null +++ b/packaging/Dockerfile.fedora @@ -0,0 +1,15 @@ + + +FROM fedora + +RUN dnf -y install python3.11 python3-pip pipx gcc python3.11-devel +COPY . eris +RUN PIPX_BIN_DIR=/bin pipx install --system-site-packages ./eris/eris +RUN chmod a+rwx -R /root +RUN dnf -y install sudo +RUN eris --install-all-tools + +ENTRYPOINT ["eris"] + + +# docker build -t eris -f packaging/Dockerfile.fedora . diff --git a/packaging/make-readme.py b/packaging/make-readme.py index a69af2c..525b386 100755 --- a/packaging/make-readme.py +++ b/packaging/make-readme.py @@ -22,13 +22,12 @@ Eris maintains an up-to-date set of reports for every file in a codebase. ## Installation -#### Debian / Ubuntu +#### Debian / Ubuntu / Fedora -Install eris directly using pipx, and apt install the tools eris relies on: +Install eris with pipx, then install all the tools eris uses: - sudo apt install pipx pipx install --system-site-packages git+https://gitlab.com/ahamilton/eris@v2023.09.11#subdirectory=eris - eris --apt-install-tools + eris --install-all-tools Or install from source: (including tools) @@ -38,7 +37,7 @@ Or install from source: (including tools) Then to run: - eris -h + eris eris-webserver # Or a simple web interface. ## Tools