summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xmkinitcpio14
1 files changed, 5 insertions, 9 deletions
diff --git a/mkinitcpio b/mkinitcpio
index ce40b22..0cf17fb 100755
--- a/mkinitcpio
+++ b/mkinitcpio
@@ -154,7 +154,10 @@ while :; do
SAVELIST=1 ;;
-g|--generate)
shift
- GENIMG=$1 ;;
+ [[ -d $1 ]] && die "Invalid image path -- must not be a directory"
+ if ! GENIMG=$(readlink -f "$1") || [[ ! -e ${GENIMG%/*} ]]; then
+ die "Unable to write to path: \`%s'" "$1"
+ fi ;;
-h|--help)
usage
cleanup 0 ;;
@@ -304,13 +307,6 @@ if [[ $PRESET ]]; then
fi
fi
-if [[ $GENIMG ]]; then
- IMGPATH=$(readlink -f "$GENIMG")
- if [[ -z $IMGPATH || ! -w ${IMGPATH%/*} ]]; then
- die "Unable to write to path: \`%s'" "$GENIMG"
- fi
-fi
-
if [[ ! -f $CONFIG ]]; then
die "Config file does not exist: \`%s'" "$CONFIG"
fi
@@ -441,7 +437,7 @@ if [[ $GENIMG ]]; then
pushd "$BUILDROOT" >/dev/null
find . -print0 |
bsdcpio $( (( QUIET )) && echo '--quiet' ) -R 0:0 -0oH newc |
- $COMPRESSION $COMPRESSION_OPTIONS > "$IMGPATH"
+ $COMPRESSION $COMPRESSION_OPTIONS > "$GENIMG"
pipesave=("${PIPESTATUS[@]}") # save immediately
popd >/dev/null