diff options
author | P. J. McDermott <pj@pehjota.net> | 2014-07-21 13:52:24 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2014-07-21 13:52:24 (EDT) |
commit | 628dd97b2c347b7ba5877f2fb97baada8ba79f47 (patch) | |
tree | 36f754d1f0ce1668bc607ec8a874df598b33da81 /installers | |
parent | 354b24ff32c66e2f4a6e989ccaf1a035f85c129a (diff) |
installers/pc: Make partition and file system
And install ProteanOS to the newly made file system.
Diffstat (limited to 'installers')
-rwxr-xr-x | installers/pc.sh | 43 |
1 files changed, 38 insertions, 5 deletions
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 <mirror>] <root>\n' "${0}" + printf 'Usage: %s [-m <mirror>]\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 "${@}" |