1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/makesd-common Sat May 25 01:19:21 2019 +0200
1.3 @@ -0,0 +1,33 @@
1.4 +#!/bin/sh
1.5 +
1.6 +# Common routines.
1.7 +
1.8 +# Test for a selected device.
1.9 +
1.10 +check_device()
1.11 +{
1.12 + if [ ! "$DEV" ] ; then
1.13 + cat 1>&2 <<EOF
1.14 +No device specified. Use the DEV environment variable to indicate a device.
1.15 +EOF
1.16 + exit 1
1.17 + fi
1.18 +
1.19 + if [ ! -e "$DEV" ] ; then
1.20 + cat 1>&2 <<EOF
1.21 +Device not found: $DEV
1.22 +EOF
1.23 + exit 1
1.24 + fi
1.25 +}
1.26 +
1.27 +# Process partition field values in summary tables.
1.28 +
1.29 +read_fields()
1.30 +{
1.31 + OLDIFS=$IFS
1.32 + IFS=`echo -n '\t'` read START SIZE TYPE
1.33 + STATUS=$?
1.34 + IFS=$OLDIFS
1.35 + return $STATUS
1.36 +}
2.1 --- a/makesd-partition Fri May 24 23:17:38 2019 +0200
2.2 +++ b/makesd-partition Sat May 25 01:19:21 2019 +0200
2.3 @@ -10,11 +10,14 @@
2.4 PROGNAME=`basename "$0"`
2.5 THISDIR=`dirname "$0"`
2.6
2.7 +COMMON="$THISDIR/makesd-common"
2.8 EXPAND="$THISDIR/makesd-expand-def"
2.9 PARTSUMMARY="$THISDIR/makesd-partition-summary"
2.10 PARTTABLE="$THISDIR/makesd-partition-table"
2.11 SFDISK="/sbin/sfdisk"
2.12
2.13 +. "$COMMON"
2.14 +
2.15
2.16
2.17 # Test sfdisk behaviour and obtain useful information.
2.18 @@ -32,19 +35,7 @@
2.19
2.20 # Obtain details of the selected device.
2.21
2.22 -if [ ! "$DEV" ] ; then
2.23 - cat 1>&2 <<EOF
2.24 -No device specified. Use the DEV environment variable to indicate a device.
2.25 -EOF
2.26 - exit 1
2.27 -fi
2.28 -
2.29 -if [ ! -e "$DEV" ] ; then
2.30 - cat 1>&2 <<EOF
2.31 -Device not found: $DEV
2.32 -EOF
2.33 - exit 1
2.34 -fi
2.35 +check_device
2.36
2.37 # Test for the cylinder alignment option.
2.38
3.1 --- a/makesd-partition-table Fri May 24 23:17:38 2019 +0200
3.2 +++ b/makesd-partition-table Sat May 25 01:19:21 2019 +0200
3.3 @@ -6,8 +6,11 @@
3.4 PROGNAME=`basename "$0"`
3.5 THISDIR=`dirname "$0"`
3.6
3.7 +COMMON="$THISDIR/makesd-common"
3.8 SFDISK="/sbin/sfdisk"
3.9
3.10 +. "$COMMON"
3.11 +
3.12
3.13
3.14 # Cylinder size in sectors for alignment purposes.
3.15 @@ -119,10 +122,10 @@
3.16 partition_type()
3.17 {
3.18 case "$1" in
3.19 - ( ext[2-4]? ) echo "0x83" ;;
3.20 - ( swap ) echo "0x82" ;;
3.21 - ( fat ) echo "0x0c" ;;
3.22 - ( * ) echo "0x83" ;;
3.23 + ( ext* ) echo "0x83" ;;
3.24 + ( swap ) echo "0x82" ;;
3.25 + ( fat ) echo "0x0c" ;;
3.26 + ( * ) echo "0x83" ;;
3.27 esac
3.28 }
3.29
3.30 @@ -175,19 +178,6 @@
3.31
3.32
3.33
3.34 -# Process the arguments, building a partition description.
3.35 -
3.36 -read_fields()
3.37 -{
3.38 - OLDIFS=$IFS
3.39 - IFS=`echo -n '\t'` read START SIZE TYPE
3.40 - STATUS=$?
3.41 - IFS=$OLDIFS
3.42 - return $STATUS
3.43 -}
3.44 -
3.45 -
3.46 -
3.47 # Emit the help message if requested.
3.48
3.49 if [ "$1" = '--help' ] ; then
3.50 @@ -224,19 +214,7 @@
3.51
3.52 # Obtain details of the selected device.
3.53
3.54 -if [ ! "$DEV" ] ; then
3.55 - cat 1>&2 <<EOF
3.56 -No device specified. Use the DEV environment variable to indicate a device.
3.57 -EOF
3.58 - exit 1
3.59 -fi
3.60 -
3.61 -if [ ! -e "$DEV" ] ; then
3.62 - cat 1>&2 <<EOF
3.63 -Device not found: $DEV
3.64 -EOF
3.65 - exit 1
3.66 -fi
3.67 +check_device
3.68
3.69 # Initialise sfdisk usage.
3.70