commit: b66b35e438437f20aeb2e0f24e2ec06654b33b8b
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Wed May 7 01:26:50 2014 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Wed May 7 01:26:50 2014 +0000
URL:
http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=b66b35e4
bin/: add roverlay-others
Runs roverlay with ROVERLAY_TARGET_TYPE=foreign
---
bin/invoke_pyscript.bash | 39 +++++++++++++++++++++++++++++++++++----
bin/roverlay | 25 +------------------------
bin/roverlay.others | 1 +
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
deleted file mode 100755
index 3c385b8..0000000
--- a/bin/roverlay
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/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
diff --git a/bin/roverlay b/bin/roverlay
new file mode 120000
index 0000000..3f5df48
--- /dev/null
+++ b/bin/roverlay
@@ -0,0 +1 @@
+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