diff options
author | Aaron LI <aly@aaronly.me> | 2018-03-10 23:43:10 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2018-03-10 23:43:10 +0800 |
commit | f25d2060f4ed63585b9aae49e35794a0cba3643a (patch) | |
tree | ac0aa1d364a3f605998482137c7b4d58d1914ffb | |
parent | 5ccc0757901419acc3b2decdac86ac133eb9647c (diff) | |
download | dfly-update-f25d2060f4ed63585b9aae49e35794a0cba3643a.tar.bz2 |
Improve EC_NOFILE error a bit im checksum_image() and mount_image()
-rwxr-xr-x | dfly-update | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/dfly-update b/dfly-update index e4666eb..9c8f171 100755 --- a/dfly-update +++ b/dfly-update @@ -267,7 +267,8 @@ checksum_image() { local file="$1" local md5_match="$2" local md5 - [ -f "${file}" ] || error ${EC_NOFILE} "checksum_image: file not exists" + [ -f "${file}" ] || \ + error ${EC_NOFILE} "checksum_image: file not exists: ${file}" md5=$(md5 -q "${file}") if [ "${md5}" = "${md5_match}" ]; then return 0 @@ -642,20 +643,22 @@ cmd_download() { # Mount the given image file # # usage: -# cmd_mount <filepath> +# cmd_mount <file> cmd_mount() { [ $# -eq 1 ] || \ error ${EC_ARGS} "cmd_mount: invalid arguments: $@" - local filepath="$1" - case "${filepath}" in + local file="$1" + [ -f "${file}" ] || \ + error ${EC_NOFILE} "checksum_image: file not exists: ${file}" + case "${file}" in *.bz2) - echo -n "Decompressing file: ${filepath} ... " - bunzip2 "${filepath}" + echo -n "Decompressing file: ${file} ... " + bunzip2 "${file}" echo "DONE" - filepath="${filepath%.bz2}" + filepath="${file%.bz2}" ;; esac - mount_image "${filepath}" "${MNT_DIR}" + mount_image "${file}" "${MNT_DIR}" } # Back up the current kernel and world |