paul@12 | 1 | #!/bin/sh |
paul@12 | 2 | |
paul@13 | 3 | # Prepare a disk for booting a specific hardware device. |
paul@12 | 4 | |
paul@12 | 5 | PROGNAME=`basename "$0"` |
paul@12 | 6 | THISDIR=`dirname "$0"` |
paul@12 | 7 | |
paul@12 | 8 | COMMON="$THISDIR/makesd-common" |
paul@14 | 9 | DEFS="$THISDIR/makesd-defs" |
paul@12 | 10 | EXPAND="$THISDIR/makesd-expand-def" |
paul@12 | 11 | FORMAT="$THISDIR/makesd-format" |
paul@12 | 12 | PARTSUMMARY="$THISDIR/makesd-partition-summary" |
paul@12 | 13 | PARTITION="$THISDIR/makesd-partition" |
paul@12 | 14 | |
paul@12 | 15 | . "$COMMON" |
paul@12 | 16 | |
paul@12 | 17 | |
paul@12 | 18 | |
paul@13 | 19 | # Emit the help message if requested. |
paul@13 | 20 | |
paul@13 | 21 | if [ "$1" = '--help' ] ; then |
paul@13 | 22 | cat 1>&2 <<EOF |
paul@13 | 23 | Usage: $PROGNAME [ --align ] <definition name> |
paul@14 | 24 | $PROGNAME -a | --all | --defs |
paul@13 | 25 | |
paul@13 | 26 | Partition, format, populate and initialise a device for use with a particular |
paul@13 | 27 | kind of hardware. The given definition name is used to search the database of |
paul@13 | 28 | supported hardware devices and to configure the different preparation |
paul@13 | 29 | activities. |
paul@13 | 30 | |
paul@14 | 31 | If the -a, --all or --defs options are specified, all hardware definitions are |
paul@14 | 32 | emitted and no further actions are taken. |
paul@14 | 33 | |
paul@13 | 34 | $(align_cylinder_description) |
paul@13 | 35 | EOF |
paul@13 | 36 | exit 0 |
paul@13 | 37 | fi |
paul@13 | 38 | |
paul@14 | 39 | # Test for the definition output options. |
paul@14 | 40 | |
paul@14 | 41 | if [ "$1" = '-a' ] || [ "$1" = '--all' ] || [ "$1" = '--defs' ] ; then |
paul@14 | 42 | grep '^[[:alpha:]]' "$DEFS" | cut -f1 | sort |
paul@14 | 43 | exit 0 |
paul@14 | 44 | fi |
paul@14 | 45 | |
paul@12 | 46 | # Obtain details of the selected device. |
paul@12 | 47 | |
paul@12 | 48 | check_device |
paul@12 | 49 | |
paul@12 | 50 | SUMMARY="`basename "$DEV"`.summary" |
paul@12 | 51 | |
paul@12 | 52 | # Test for the cylinder alignment option. |
paul@12 | 53 | |
paul@12 | 54 | if test_align_cylinder $* ; then shift 1 ; fi |
paul@12 | 55 | |
paul@12 | 56 | # Obtain the definition name. |
paul@12 | 57 | |
paul@12 | 58 | DEF="$1" |
paul@12 | 59 | |
paul@12 | 60 | if [ ! "$DEF" ] ; then |
paul@12 | 61 | cat 1>&2 <<EOF |
paul@12 | 62 | No definition specified. |
paul@12 | 63 | EOF |
paul@12 | 64 | exit 1 |
paul@12 | 65 | fi |
paul@12 | 66 | |
paul@12 | 67 | shift 1 |
paul@12 | 68 | |
paul@12 | 69 | # Expand the definition to partitioning options. |
paul@12 | 70 | |
paul@12 | 71 | if ! ARGS=`"$EXPAND" "$DEF"` ; then |
paul@12 | 72 | cat 1>&2 <<EOF |
paul@12 | 73 | Device definition not found: $DEF |
paul@12 | 74 | EOF |
paul@12 | 75 | exit 1 |
paul@12 | 76 | fi |
paul@12 | 77 | |
paul@12 | 78 | # Use the options to generate a partition summary. |
paul@12 | 79 | |
paul@12 | 80 | "$PARTSUMMARY" $ARGS \ |
paul@12 | 81 | > "$SUMMARY" |
paul@12 | 82 | |
paul@12 | 83 | # Partition the given device. |
paul@12 | 84 | |
paul@12 | 85 | "$PARTITION" $ALIGN_CYLINDER < "$SUMMARY" |
paul@12 | 86 | |
paul@12 | 87 | # Format the given device. |
paul@12 | 88 | |
paul@12 | 89 | "$FORMAT" < "$SUMMARY" |