mirror of
https://github.com/fsquillace/junest.git
synced 2026-01-23 02:34:30 +00:00
Add tests for wrappers
This commit is contained in:
parent
3d16ee2583
commit
2aeb23b882
4 changed files with 74 additions and 43 deletions
46
bin/junest
46
bin/junest
|
|
@ -68,12 +68,6 @@ usage() {
|
|||
echo -e " b[uild] Build a $NAME image (must run in ArchLinux)"
|
||||
echo -e " -n, --disable-check Disable the $NAME image check"
|
||||
echo
|
||||
echo -e " c[reate-wrappers] Create wrappers in ${JUNEST_HOME}/usr/bin_wrappers of the executables under"
|
||||
echo -e " ${JUNEST_HOME}/usr/bin to be run directly from the host."
|
||||
echo -e " Use the variable JUNEST_ARGS to define how the wrapper will call $NAME (default "ns --fakeroot")."
|
||||
echo -e " Use PATH variable to point directly to the bin_wrappers directory from the host."
|
||||
echo -e " -r, --recreate-existing Instead of skipping existing wrappers recreate them"
|
||||
echo
|
||||
}
|
||||
|
||||
version() {
|
||||
|
|
@ -87,7 +81,6 @@ function parse_arguments(){
|
|||
ACT_NAMESPACE=false
|
||||
ACT_PROOT=false
|
||||
ACT_GROOT=false
|
||||
ACT_WRAPPERS=false
|
||||
ACT_ROOT=false
|
||||
ACT_HELP=false
|
||||
ACT_VERSION=false
|
||||
|
|
@ -99,7 +92,6 @@ function parse_arguments(){
|
|||
p|proot) ACT_PROOT=true ; shift ;;
|
||||
g|groot) ACT_GROOT=true ; shift ;;
|
||||
r|root) ACT_ROOT=true ; shift ;;
|
||||
c|create-wrappers) ACT_WRAPPERS=true ; shift ;;
|
||||
-h|--help) ACT_HELP=true ; shift ;;
|
||||
-V|--version) ACT_VERSION=true ; shift ;;
|
||||
*) ACT_NAMESPACE=true ;;
|
||||
|
|
@ -123,33 +115,9 @@ function parse_arguments(){
|
|||
elif $ACT_ROOT
|
||||
then
|
||||
_parse_root_opts "$@"
|
||||
elif $ACT_WRAPPERS
|
||||
then
|
||||
_parse_wrappers_opts "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
function _parse_wrappers_opts() {
|
||||
# Options:
|
||||
OPT_RECREATE_EXISTING=false
|
||||
|
||||
while [[ -n "$1" ]]
|
||||
do
|
||||
case "$1" in
|
||||
-r|--recreate-existing) OPT_RECREATE_EXISTING=true ; shift ;;
|
||||
--) shift ; break ;;
|
||||
-*) die "Invalid option $1" ;;
|
||||
*) break ;;
|
||||
esac
|
||||
done
|
||||
|
||||
ARGS=()
|
||||
for arg in "$@"
|
||||
do
|
||||
ARGS+=("$arg")
|
||||
done
|
||||
}
|
||||
|
||||
function _parse_root_opts() {
|
||||
# Options:
|
||||
BACKEND_ARGS=""
|
||||
|
|
@ -280,7 +248,7 @@ function execute_operation() {
|
|||
else
|
||||
setup_env $ARCH_ARG
|
||||
fi
|
||||
create_wrappers false
|
||||
create_wrappers
|
||||
fi
|
||||
|
||||
return
|
||||
|
|
@ -292,11 +260,6 @@ function execute_operation() {
|
|||
die "Error: The image is still not installed in $JUNEST_HOME. Run this first: $CMD setup"
|
||||
fi
|
||||
|
||||
if $ACT_WRAPPERS; then
|
||||
create_wrappers $OPT_RECREATE_EXISTING
|
||||
return
|
||||
fi
|
||||
|
||||
local run_env
|
||||
if $ACT_NAMESPACE; then
|
||||
if $OPT_FAKEROOT; then
|
||||
|
|
@ -316,12 +279,9 @@ function execute_operation() {
|
|||
run_env=run_env_as_chroot
|
||||
fi
|
||||
|
||||
$run_env "$BACKEND_COMMAND" "${BACKEND_ARGS}" $OPT_NO_COPY_FILES "${ARGS[@]}"
|
||||
|
||||
# TODO use the run_env exit status
|
||||
|
||||
# Call create_wrappers in case new bin files have been created
|
||||
create_wrappers false
|
||||
trap "create_wrappers" EXIT QUIT TERM KILL
|
||||
$run_env "$BACKEND_COMMAND" "${BACKEND_ARGS}" $OPT_NO_COPY_FILES "${ARGS[@]}"
|
||||
}
|
||||
|
||||
function main() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue