summaryrefslogtreecommitdiffstats
path: root/src/cmd
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2019-04-26 00:27:12 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2019-04-26 00:28:20 (EDT)
commit5295b41e5fe90db9f2af91a0ba6d9e7b662e346d (patch)
tree7e745bc0492ff121edb4a2e7a7698a904c578ba6 /src/cmd
parent4020f12ff37dfdaf9cb8c2c372a85b68daa7ac71 (diff)
src/cmd/installer-pc.sh: Define functions before references
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/installer-pc.sh102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/cmd/installer-pc.sh b/src/cmd/installer-pc.sh
index 33b2e7c..b41402a 100644
--- a/src/cmd/installer-pc.sh
+++ b/src/cmd/installer-pc.sh
@@ -20,6 +20,57 @@
cmd_installer_pc_optstring='a:p:m:'
+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_make_partition_and_fs()
+{
+ local dev="${1}"
+ local log=
+
+ info "$(get_msg 'cmd_installer_pc_dd')"
+ 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
+
+ info "$(get_msg 'cmd_installer_pc_fdisk')"
+ if ${HAVE_SFDISK}; 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 ! 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
+
+ info "$(get_msg 'cmd_installer_pc_mkfs')"
+ 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_main()
{
local suite=
@@ -87,57 +138,6 @@ cmd_installer_pc_main()
return 0
}
-cmd_installer_pc_make_partition_and_fs()
-{
- local dev="${1}"
- local log=
-
- info "$(get_msg 'cmd_installer_pc_dd')"
- 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
-
- info "$(get_msg 'cmd_installer_pc_fdisk')"
- if ${HAVE_SFDISK}; 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 ! 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
-
- info "$(get_msg 'cmd_installer_pc_mkfs')"
- 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'