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