From 628dd97b2c347b7ba5877f2fb97baada8ba79f47 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Mon, 21 Jul 2014 13:52:24 -0400 Subject: installers/pc: Make partition and file system And install ProteanOS to the newly made file system. --- diff --git a/installers/pc.sh b/installers/pc.sh index a9f5898..435ad7c 100755 --- a/installers/pc.sh +++ b/installers/pc.sh @@ -19,6 +19,7 @@ main() local install_arch= local host_arch= local host_plat= + local mountpoint= while getopts 'm:' opt; do case ${opt} in @@ -30,11 +31,10 @@ main() esac done shift $(($OPTIND - 1)) - if [ ${#} -ne 1 ]; then + if [ ${#} -ne 0 ]; then print_usage >&2 exit 1 fi - root="${1}" install_arch="$(detect_arch)" printf '\nSelect a platorm' @@ -49,19 +49,25 @@ main() printf '\n=====================\n\n' dev="$(prompt_block_dev)" + printf '\nMaking partition table and file system' + printf '\n======================================\n\n' + make_partition_and_fs "${dev}" + printf '\nInstalling base system' printf '\n======================\n\n' + mountpoint="$(mount_fs "${dev}")" "${0%installers/pc.sh}./miniprokit.sh" install \ -a "${host_arch}" -P "${host_plat}" \ - ${mirror:+-m} ${mirror} "${root}" - "${0%installers/pc.sh}./miniprokit.sh" shell "${root}" \ + ${mirror:+-m} ${mirror} "${mountpoint}" + "${0%installers/pc.sh}./miniprokit.sh" shell "${mountpoint}" \ <"${0%pc.sh}data/pc.sh" + umount_fs "${mountpoint}" } print_usage() { - printf 'Usage: %s [-m ] \n' "${0}" + printf 'Usage: %s [-m ]\n' "${0}" } error() @@ -254,4 +260,31 @@ prompt_block_dev() EOF } +make_partition_and_fs() +{ + local dev="${1}" + + dd if=/dev/zero of="/dev/${dev}" bs=512 count=1 + printf 'n\np\n1\n\n\nt\n83\na\n1\nw\n' | fdisk "/dev/${dev}" + mke2fs -t ext4 "/dev/${dev}1" +} + +mount_fs() +{ + local dev="${1}" + local mountpoint= + + mountpoint="$(mktemp -d)" + mount "/dev/${dev}1" "${mountpoint}" + printf '%s\n' "${mountpoint}" +} + +umount_fs() +{ + local mountpoint="${1}" + + umount "${mountpoint}" + rmdir "${mountpoint}" +} + main "${@}" -- cgit v0.9.1