summaryrefslogtreecommitdiffstats
path: root/mkarchroot
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2007-10-11 14:36:04 +0200
committerDan McGee <dan@archlinux.org>2007-10-30 03:31:16 +0100
commit67dc59299a72d8165c4fef3a5cad213bcf34f78b (patch)
tree7d459d3a53c96726fcb400cf6ced29b0dc45c7a4 /mkarchroot
parenta104988329a23d8deb99a671e009e01c59e2f107 (diff)
downloaddevtools-67dc59299a72d8165c4fef3a5cad213bcf34f78b.tar.gz
devtools-67dc59299a72d8165c4fef3a5cad213bcf34f78b.tar.xz
mkarchroot: clean up/unify output messages
Also remove an extra EUID check, we do this at the beginning. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'mkarchroot')
-rwxr-xr-xmkarchroot32
1 files changed, 14 insertions, 18 deletions
diff --git a/mkarchroot b/mkarchroot
index 0ff2b80..be93209 100755
--- a/mkarchroot
+++ b/mkarchroot
@@ -16,19 +16,20 @@ working_dir=""
APPNAME=$(basename "${0}")
if [ "$EUID" != "0" ]; then
- echo "This script must be run as root."
+ echo "error: this script must be run as root."
exit 1
fi
+# usage: usage <exitvalue>
usage ()
{
echo "usage ${APPNAME} [options] working-dir [package-list | app]"
echo " options:"
- echo " -r <app> run 'app' within the context of the chroot"
- echo " -u update the chroot via pacman"
- echo " -f force overwrite of files in the working-dir"
- echo " -h this message."
- exit 1
+ echo " -r <app> Run 'app' within the context of the chroot"
+ echo " -u Update the chroot via pacman"
+ echo " -f Force overwrite of files in the working-dir"
+ echo " -h This message"
+ exit $1
}
while getopts 'r:ufh' arg; do
@@ -36,24 +37,24 @@ while getopts 'r:ufh' arg; do
r) RUN="$OPTARG" ;;
u) RUN="pacman -Syu" ;;
f) FORCE="y" ;;
- h|?) usage ;;
- *) echo "invalid argument '${arg}'"; usage ;;
+ h|?) usage 0 ;;
+ *) echo "invalid argument '${arg}'"; usage 1 ;;
esac
done
shift $(($OPTIND - 1))
if [ "$RUN" == "" -a $# -lt 2 ]; then
echo "you must specify a directory and one or more packages"
- usage
+ usage 1
elif [ $# -lt 1 ]; then
echo "you must specify a directory"
- usage
+ usage 1
fi
working_dir="$(readlink -f ${1})"
shift 1
-[ "${working_dir}" = "" ] && echo "error: please specify a working directory" && usage
+[ "${working_dir}" = "" ] && echo "error: please specify a working directory" && usage 1
# {{{ functions
@@ -90,14 +91,9 @@ function chroot_umount ()
if [ "$RUN" != "" ]; then
# run chroot {{{
- if [ "$EUID" != "0" ]; then
- echo "Running a chroot requires root privileges, aborting"
- exit 1
- fi
-
#Sanity check
if [ ! -f "${working_dir}/.arch-chroot" ]; then
- echo "'${working_dir}' does not appear to be a Arch chroot"
+ echo "error: '${working_dir}' does not appear to be a Arch chroot"
echo " please build the image using mkarchchroot"
exit 1
fi
@@ -111,7 +107,7 @@ if [ "$RUN" != "" ]; then
else
# {{{ build chroot
if [ -e "${working_dir}" -a "${FORCE}" = "n" ]; then
- echo "Working dir '${working_dir}' already exists - try using -f"
+ echo "error: working dir '${working_dir}' already exists - try using -f"
exit 1
fi