paul@6 | 1 | #!/bin/sh |
paul@6 | 2 | |
paul@9 | 3 | # Support partitioning of a device using sfdisk. This program accepts a |
paul@9 | 4 | # partitioning summary on standard input. |
paul@6 | 5 | # |
paul@6 | 6 | # Important tasks: |
paul@6 | 7 | # |
paul@6 | 8 | # Erase bootloader blocks. |
paul@6 | 9 | # Perform partitioning using sfdisk. |
paul@6 | 10 | |
paul@6 | 11 | PROGNAME=`basename "$0"` |
paul@6 | 12 | THISDIR=`dirname "$0"` |
paul@6 | 13 | |
paul@7 | 14 | COMMON="$THISDIR/makesd-common" |
paul@6 | 15 | PARTTABLE="$THISDIR/makesd-partition-table" |
paul@6 | 16 | SFDISK="/sbin/sfdisk" |
paul@6 | 17 | |
paul@7 | 18 | . "$COMMON" |
paul@7 | 19 | |
paul@6 | 20 | |
paul@6 | 21 | |
paul@6 | 22 | # Test sfdisk behaviour and obtain useful information. |
paul@6 | 23 | |
paul@6 | 24 | init_sfdisk() |
paul@6 | 25 | { |
paul@6 | 26 | if "$SFDISK" -uS -s "$1" > /dev/null 2>&1 ; then |
paul@6 | 27 | SFDISK_OPTIONS="-uS -L" |
paul@6 | 28 | else |
paul@6 | 29 | SFDISK_OPTIONS= |
paul@6 | 30 | fi |
paul@6 | 31 | } |
paul@6 | 32 | |
paul@6 | 33 | |
paul@6 | 34 | |
paul@6 | 35 | # Obtain details of the selected device. |
paul@6 | 36 | |
paul@7 | 37 | check_device |
paul@6 | 38 | |
paul@6 | 39 | # Initialise sfdisk usage. |
paul@6 | 40 | |
paul@6 | 41 | init_sfdisk "$DEV" |
paul@6 | 42 | |
paul@9 | 43 | # Convert the partitioning summary into a partition table description. |
paul@6 | 44 | # Present the table to sfdisk. |
paul@6 | 45 | |
paul@9 | 46 | "$PARTTABLE" $* \ |
paul@6 | 47 | | "$SFDISK" $SFDISK_OPTIONS "$DEV" |