Run jlmkr as zipapp
This commit is contained in:
parent
9bdcfedd1a
commit
2256d31b94
|
@ -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
|
||||
|
|
|
@ -7,6 +7,7 @@ dist/
|
|||
# jail-specific
|
||||
/.lxc/
|
||||
/jails/
|
||||
jlmkr
|
||||
|
||||
# Mac-specific
|
||||
.DS_Store
|
||||
|
|
25
jlmkr.py
25
jlmkr.py
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# SPDX-FileCopyrightText: © 2024 Jip-Hop and the Jailmakers <https://github.com/Jip-Hop/jailmaker>
|
||||
#
|
||||
# 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)
|
||||
|
|
@ -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 () {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue