1 #!/bin/sh 2 3 # Prepare a disk for booting a specific hardware device. 4 # 5 # Copyright (C) 2019 Paul Boddie <paul@boddie.org.uk> 6 # 7 # This program is free software; you can redistribute it and/or modify it under 8 # the terms of the GNU General Public License as published by the Free Software 9 # Foundation; either version 3 of the License, or (at your option) any later 10 # version. 11 # 12 # This program is distributed in the hope that it will be useful, but WITHOUT 13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 15 # details. 16 # 17 # You should have received a copy of the GNU General Public License along with 18 # this program. If not, see <http://www.gnu.org/licenses/>. 19 20 PROGNAME=`basename "$0"` 21 THISDIR=`dirname "$0"` 22 23 COMMON="$THISDIR/makesd-common" 24 DEFS="$THISDIR/makesd-defs" 25 EXPAND="$THISDIR/makesd-expand-def" 26 FILTER="$THISDIR/makesd-filter-def" 27 FORMAT="$THISDIR/makesd-format" 28 PARTITION="$THISDIR/makesd-partition" 29 30 . "$COMMON" 31 32 33 34 # Emit the help message if requested. 35 36 if [ "$1" = '--help' ] ; then 37 cat 1>&2 <<EOF 38 Usage: $PROGNAME [ --align ] <system> 39 $PROGNAME -a | --all | --defs 40 41 Partition, format, populate and initialise a device for use with a particular 42 kind of hardware. The given system name is used to search the database of 43 supported hardware devices and to configure the different preparation 44 activities. 45 46 $(show_definitions_description) 47 48 $(align_cylinder_description) 49 EOF 50 exit 0 51 fi 52 53 # Test for the definition output options. 54 55 if [ "$1" = '-a' ] || [ "$1" = '--all' ] || [ "$1" = '--defs' ] ; then 56 "$EXPAND" "$1" 57 exit 0 58 fi 59 60 # Obtain details of the selected device. 61 62 check_device 63 64 # Test for the cylinder alignment option. 65 66 if test_align_cylinder $* ; then shift 1 ; fi 67 68 # Obtain the definition name. 69 70 DEF="$1" 71 72 if [ ! "$DEF" ] ; then 73 cat 1>&2 <<EOF 74 No definition specified. 75 EOF 76 exit 1 77 fi 78 79 # Partition the given device, passing only partition details to the script. 80 81 "$EXPAND" "$DEF" \ 82 | "$FILTER" "partition" "position" "size" "type" \ 83 | "$PARTITION" $ALIGN_CYLINDER 84 85 # Format the given device, passing only partition types to the script. 86 87 "$EXPAND" "$DEF" \ 88 | "$FILTER" "partition" "type" \ 89 | "$FORMAT"