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