diff options
author | André Erdmann <dywi@mailerd.de> | 2014-05-07 03:26:50 +0200 |
---|---|---|
committer | André Erdmann <dywi@mailerd.de> | 2014-05-07 03:26:50 +0200 |
commit | b66b35e438437f20aeb2e0f24e2ec06654b33b8b (patch) | |
tree | e5ebb9964333914d0283d2e60dbe55b55f9b6e8d | |
parent | fix deprule (diff) | |
download | R_overlay-b66b35e438437f20aeb2e0f24e2ec06654b33b8b.tar.gz R_overlay-b66b35e438437f20aeb2e0f24e2ec06654b33b8b.tar.bz2 R_overlay-b66b35e438437f20aeb2e0f24e2ec06654b33b8b.zip |
bin/: add roverlay-others
Runs roverlay with ROVERLAY_TARGET_TYPE=foreign
-rwxr-xr-x | bin/invoke_pyscript.bash | 39 | ||||
l---------[-rwxr-xr-x] | bin/roverlay | 25 | ||||
l--------- | bin/roverlay.others | 1 | ||||
l--------- | roverlay-others.py | 1 |
4 files changed, 38 insertions, 28 deletions
diff --git a/bin/invoke_pyscript.bash b/bin/invoke_pyscript.bash index 41af30d..574405e 100755 --- a/bin/invoke_pyscript.bash +++ b/bin/invoke_pyscript.bash @@ -1,10 +1,41 @@ #!/bin/bash -readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") -readonly SCRIPT_NAME="${BASH_SOURCE[0]##*/}" +readonly SCRIPT="$(readlink -f "${BASH_SOURCE[0]?}")" +readonly SCRIPT_FILENAME="${BASH_SOURCE[0]##*/}" readonly SCRIPT_DIR="${SCRIPT%/*}" - readonly PRJROOT="${SCRIPT_DIR%/*}" -readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" + +extra_args=() + +SCRIPT_NAME="${SCRIPT_FILENAME%.py}" +case "${SCRIPT_NAME}" in + *[-_.]others) + export ROVERLAY_TARGET_TYPE="foreign" + SCRIPT_NAME="${SCRIPT_NAME%[-_.]*}" + ;; + *) + : ${ROVERLAY_TARGET_TYPE:=gentoo} + SCRIPT_NAME="${SCRIPT_NAME}" + ;; +esac + +case "${SCRIPT_NAME}" in + 'roverlay') SCRIPT_NAME="main" ;; +esac +readonly SCRIPT_NAME + +if [[ "${ROVERLAY_TARGET_TYPE}" == "foreign" ]]; then + case "${SCRIPT_NAME#roverlay[_-]}" in + 'setup') + extra_args+=( '--target-type' 'foreign' "$@" ) + ;; + 'main'|'query'[-_]'config'|'status') + extra_args+=( '-c' "${PRJROOT}/R-overlay.conf.others" "$@" ) + ;; + esac +fi + +readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME}.py" +[ ${#extra_args[@]} -eq 0 ] || set -- "${extra_args[@]}" "$@" export ROVERLAY_PRJROOT="${PRJROOT}" export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" diff --git a/bin/roverlay b/bin/roverlay index 3c385b8..3f5df48 100755..120000 --- a/bin/roverlay +++ b/bin/roverlay @@ -1,24 +1 @@ -#!/bin/bash -# similar to invoke_pyscript.bash, but uses a fixed SCRIPT_NAME -# -readonly SCRIPT=$(readlink -f "${BASH_SOURCE[0]?}") -readonly SCRIPT_NAME="main" -readonly SCRIPT_DIR="${SCRIPT%/*}" - -readonly PRJROOT="${SCRIPT_DIR%/*}" -readonly PYSCRIPT="${SCRIPT_DIR}/py/${SCRIPT_NAME%.*}.py" - -export ROVERLAY_PRJROOT="${PRJROOT}" -export PYTHONPATH="${PRJROOT}${PYTHONPATH:+:}${PYTHONPATH}" - - -cd "${PRJROOT}" || exit - -if [[ -z "${PYTHON-}" ]] && [[ -x "${PYSCRIPT}" ]]; then - exec ${PYSCRIPT} "$@" -elif [[ -f "${PYSCRIPT}" ]]; then - exec ${PYTHON:-python} ${PYSCRIPT} "$@" -else - echo "script not found: ${PYSCRIPT}" 1>&2 - exit 9 -fi +invoke_pyscript.bash
\ No newline at end of file diff --git a/bin/roverlay.others b/bin/roverlay.others new file mode 120000 index 0000000..3f5df48 --- /dev/null +++ b/bin/roverlay.others @@ -0,0 +1 @@ +invoke_pyscript.bash
\ No newline at end of file diff --git a/roverlay-others.py b/roverlay-others.py new file mode 120000 index 0000000..466a6fb --- /dev/null +++ b/roverlay-others.py @@ -0,0 +1 @@ +bin/invoke_pyscript.bash
\ No newline at end of file |