Issue #93: Improve help and add test for proot access

This commit is contained in:
Filippo Squillace 2015-07-05 14:20:07 +00:00
parent 438eeafb63
commit e2b14e9bff
4 changed files with 58 additions and 66 deletions

View file

@ -29,16 +29,23 @@ source "${JUNEST_BASE}/lib/core.sh"
usage() {
echo -e "$NAME: $DESCRIPTION"
echo -e "Usage: $CMD [options] [--] [command]"
echo -e "Options:"
echo
echo -e "Setup options:"
echo -e "-i, --setup-from-file <image> Setup the $NAME image in ${JUNEST_HOME}"
echo -e "-a, --arch <arch> $NAME architecture to download (x86_64, x86, arm)."
echo -e " Defaults to the host architecture ($ARCH)"
echo -e "-d, --delete Delete $NAME from ${JUNEST_HOME}"
echo
echo -e "Access options:"
echo -e "-f, --fakeroot Run $NAME with fakeroot privileges"
echo -e "-r, --root Run $NAME with root privileges"
echo -e "-p, --proot-args Proot arguments"
echo -e "-a, --arch $NAME architecture to use (x86_64, x86, arm)."
echo -e " Defaults to the host architecture ($ARCH)"
echo -e "-p, --proot-args <args> Proot arguments"
echo
echo -e "Building options:"
echo -e "-b, --build-image Build a $NAME image (must run in ArchLinux)"
echo -e "-n, --disable-validation Disable the $NAME image validation"
echo -e "-d, --delete Delete $NAME from ${JUNEST_HOME}"
echo
echo -e "General options:"
echo -e "-h, --help Show this help message"
echo -e "-v, --version Show the $NAME version"
}
@ -173,17 +180,21 @@ function execute_operation(){
setup_env_from_file $IMAGE_FILE
else
setup_env $ARCH_ARG
unset ARCH_ARG
fi
elif $OPT_SETUP_FROM_FILE; then
die "Error: The image cannot be installed since $JUNEST_HOME is not empty."
fi
[ -z "${ARCH_ARG}" ] || \
die "The option --arch cannot be specified since JuNest has already been downloaded in $JUNEST_HOME"
if $OPT_FAKEROOT; then
run_env_as_fakeroot "${ARCH_ARG}" "${PROOT_ARGS}" "${ARGS[@]}"
run_env_as_fakeroot "${PROOT_ARGS}" "${ARGS[@]}"
elif $OPT_ROOT; then
run_env_as_root "${ARGS[@]}"
else
run_env_as_user "${ARCH_ARG}" "${PROOT_ARGS}" "${ARGS[@]}"
run_env_as_user "${PROOT_ARGS}" "${ARGS[@]}"
fi
}