diff options
author | P. J. McDermott <pj@pehjota.net> | 2016-01-23 18:44:51 (EST) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2016-01-23 18:44:51 (EST) |
commit | 9b9f917e5da9d26a06a93e0bc4275f353069bdd7 (patch) | |
tree | fa01cd503f30e15e4a69dc5c44236a7cb50bbf65 /src | |
parent | 0e5897958196a6d5748973e0cce5c6e2cef9dbd5 (diff) |
cmd/installer-pc: Only print dd/(s)fdisk/mke2fs output on error
Diffstat (limited to 'src')
-rw-r--r-- | src/cmd/installer-pc.sh | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh index c0162cc..1d43793 100644 --- a/src/cmd/installer-pc.sh +++ b/src/cmd/installer-pc.sh @@ -105,33 +105,51 @@ cmd_installer_pc_main() cmd_installer_pc_make_partition_and_fs() { local dev="${1}" + local log= - if ! dd if=/dev/zero of="${dev}" bs=512 count=1; then + if ! log="$(dd if=/dev/zero of="${dev}" bs=512 count=1 2>&1)"; then error "$(get_msg 'cmd_installer_pc_dd_fail')" + cmd_installer_pc_log_print 'dd' "${log}" return 1 fi if ${HAVE_SFDISK}; then - if ! printf ',,83,*\n' | ${SFDISK} "${dev}"; then + if ! log="$(printf ',,83,*\n' | ${SFDISK} "${dev}" 2>&1)"; then error "$(get_msg 'cmd_installer_pc_fdisk_fail')" + cmd_installer_pc_log_print 'sfdisk' "${log}" return 1 fi elif ${HAVE_FDISK}; then - if ! printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | ${FDISK} "${dev}" - then + if ! log="$(printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | + ${FDISK} "${dev}" 2>&1)"; then error "$(get_msg 'cmd_installer_pc_fdisk_fail')" + cmd_installer_pc_log_print 'fdisk' "${log}" return 1 fi fi - if ! ${MKE2FS} -t ext4 "${dev}1"; then + if ! log="$(${MKE2FS} -t ext4 "${dev}1" 2>&1)"; then error "$(get_msg 'cmd_installer_pc_mkfs_fail')" + cmd_installer_pc_log_print 'mke2fs' "${log}" return 1 fi return 0 } +cmd_installer_pc_log_print() +{ + local prefix="${1}" + local log="${2}" + local line= + + IFS="${LF}" + for line in ${log}; do + error '%s: %s' "${prefix}" "${line}" + done + unset IFS +} + cmd_installer_pc_register() { register_cmd 'installer-pc' |