Split partitioning logic to either run sfdisk or sgdisk 11/7711/7
authorPatrick McCarty <patrick.mccarty@linux.intel.com>
Thu, 1 Aug 2013 17:59:20 +0000 (10:59 -0700)
committerPatrick McCarty <patrick.mccarty@linux.intel.com>
Mon, 5 Aug 2013 17:00:53 +0000 (10:00 -0700)
Using the input string generated in the appropriate *_options function,
now partition the device using either sfdisk or sgdisk.

Only MBR and GPT are supported, so any other partition table formats are
ignored.

Change-Id: I78ee6bb7fd6077725b30fa5f8622c4ab3c6dcdfc

scripts/system-installer

index 68d2ecc..2159017 100644 (file)
@@ -151,14 +151,22 @@ function gpt_partition_options {
     [ -n "$typeid" ] && params=$(printf "${params}%s" " --typecode=${partnum}:${typeid}")
 }
 
-function partition_device {
-    /usr/sbin/sfdisk -uM $TARGET_DEV << EOF
-,2000,82
-,,83,*;
+function partition_msdos {
+    # make sure there is a newline in the heredoc,
+    # or else sfdisk fails to parse the input
+    /usr/sbin/sfdisk --in-order -uM ${TARGET_DEV} << EOF
+${1}
+
 EOF
     sync
 }
 
+function partition_gpt {
+    /usr/sbin/sgdisk -Z ${TARGET_DEV}
+    /usr/sbin/sgdisk ${1} ${TARGET_DEV}
+    sync
+}
+
 function format_device {
     /usr/sbin/mkswap ${TARGET_DEV}1
 
@@ -285,6 +293,7 @@ find_devices
 message "Installing on to the hard disk now, this will take a few minutes..."
 
 pnum=0
+# first, generate the option list to pass to either 'sfdisk' or 'sgdisk'
 while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
     if [ "$INSTALLERFW_PTABLE_FORMAT" = "msdos" ]; then
         msdos_partition_options $pnum
@@ -294,7 +303,13 @@ while [ "$pnum" -lt "$INSTALLERFW_PART_COUNT" ]; do
     pnum="$((pnum+1))"
 done
 
-partition_device
+# now, do the partitioning
+if [ "$INSTALLERFW_PTABLE_FORMAT" = "msdos" ]; then
+    partition_msdos "$params"
+elif [ "$INSTALLERFW_PTABLE_FORMAT" = "gpt" ]; then
+    partition_gpt "$params"
+fi
+
 format_device
 mount_devices
 install_os