From 2256d31b94f05870f0a9d86e65530bb9deab1b0b Mon Sep 17 00:00:00 2001 From: Jip-Hop <2871973+Jip-Hop@users.noreply.github.com> Date: Tue, 16 Jul 2024 16:12:12 +0200 Subject: [PATCH] Run jlmkr as zipapp --- .github/workflows/test.yml | 3 ++- .gitignore | 1 + jlmkr.py | 25 ------------------------- test/test-jlmkr | 6 +++--- test/test.sh | 4 ++-- 5 files changed, 8 insertions(+), 31 deletions(-) delete mode 100755 jlmkr.py diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9418aec..bc605d7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -87,6 +87,7 @@ jobs: env: PYTHONUNBUFFERED: 1 run: | - sudo chown -R 0:0 src jlmkr.py ./test/test-jlmkr + python3 -m zipapp src/jlmkr -p "/usr/bin/env python3" -o jlmkr + sudo chown 0:0 jlmkr ./test/test-jlmkr sudo bash ./test/test-jlmkr sudo ./test/test.sh diff --git a/.gitignore b/.gitignore index 6c6dbf4..0e3c632 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ dist/ # jail-specific /.lxc/ /jails/ +jlmkr # Mac-specific .DS_Store diff --git a/jlmkr.py b/jlmkr.py deleted file mode 100755 index 3554b0d..0000000 --- a/jlmkr.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers -# -# SPDX-License-Identifier: LGPL-3.0-only - -if __name__ == "__main__": - import subprocess - import sys - import os - - # Get the path of the currently running script - current_path = os.path.realpath(__file__) - - # Define the relative path you want to resolve - relative_path = "src/jlmkr" - - # Resolve the relative path - script_path = os.path.join(os.path.dirname(current_path), relative_path) - - # Get the arguments passed to the current script - args = sys.argv[1:] - - # Pass all arguments to the other script using subprocess - subprocess.run(["python3", script_path] + args, check=True) - diff --git a/test/test-jlmkr b/test/test-jlmkr index bc87295..f4c4bb8 100755 --- a/test/test-jlmkr +++ b/test/test-jlmkr @@ -13,9 +13,9 @@ if [[ -z "$JLMKR_PATH" && -n "$SCALE_POOL_ROOT" ]]; then elif [[ -z "$JLMKR_PATH" ]]; then JLMKR_PATH=${PWD:-.} fi -if [[ ! -r "$JLMKR_PATH/jlmkr.py" ]]; then +if [[ ! -r "$JLMKR_PATH/jlmkr" ]]; then >&2 printf "%s\n" \ - "couldn't find jlmkr.py. Are you running from the jailmaker directory?" \ + "couldn't find jlmkr. Are you running from the jailmaker directory?" \ "If not, setup either JLMKR_PATH or SCALE_POOL_ROOT" \ "" @@ -57,7 +57,7 @@ WAIT_FOR_JAIL=${WAIT_FOR_JAIL:-4s} #### Functions jlmkr () { - /usr/bin/env python3 "$JLMKR_PATH/jlmkr.py" "${@:---help}" + "$JLMKR_PATH/jlmkr" "${@:---help}" } iterate () { diff --git a/test/test.sh b/test/test.sh index 04a2aef..c9b3ec9 100755 --- a/test/test.sh +++ b/test/test.sh @@ -8,5 +8,5 @@ set -euo pipefail # TODO: test jlmkr.py from inside another working directory, with a relative path to a config file to test if it uses the config file (and doesn't look for it relative to the jlmkr.py file itself) -./jlmkr.py create --start --config=./templates/docker/config test -./jlmkr.py exec test docker run hello-world +./jlmkr create --start --config=./templates/docker/config test +./jlmkr exec test docker run hello-world