[PATCH 8/8] Many thanks to Jos for his comments: * introduced transformation to lower case for environment variables * the partition table is now written in all cases
Steffen Moeller
steffen_moeller at gmx.de
Sun Feb 15 23:14:47 UTC 2009
---
install.sh | 76 +++++++++++++++++++++++++++++++++++++++--------------------
1 files changed, 50 insertions(+), 26 deletions(-)
diff --git a/install.sh b/install.sh
index 0fb5063..d28b56b 100755
--- a/install.sh
+++ b/install.sh
@@ -22,6 +22,18 @@
set -e
+# This function expects names of a variables as its argument
+# and converts them all to lower case
+lc () {
+ # chosing a rarely seen variable name to avoid masking
+ for i_____i in $*
+ do
+ cmd="$i_____i=\$(echo \$$i_____i|tr 'A-Z' 'a-z')"
+ #echo $cmd
+ eval $cmd
+ done
+}
+
#
# INSTALLER CONFIGURATION
#
@@ -44,6 +56,17 @@ QI_VERBOSE_BOOT=${QI_VERBOSE_BOOT:-false}
SINGLE_PART=${SINGLE_PART:-$QI}
WINDOW_MANAGER=${WINDOW_MANAGER:-zhone}
+# hardening for the case that a user uses capitals
+lc SD_PART1_FS SD_PART2_FS APT_RECOMMENDS QI QI_VERBOSE_BOOT WINDOW_MANAGER FSO_DEVICE
+
+### sanity check until the GTA01 installer will be merged
+if [ "${FSO_DEVICE}" != gta02 ]; then
+ echo "Installing on anything different than the Openmoko"
+ echo "GTA02 Neo FreeRunner is not supported yet."
+ exit 1
+fi
+
+
# general variables
VERSION=1.1
TESTHOST=www.debian.org
@@ -435,6 +458,7 @@ if [ "vfat" = "$SD_PART1_FS" ]; then
fi
if [ "$SINGLE_PART" = "true" ]; then
+ echo "Preparing SD as a single Linux device."
fdisk $SD_DEVICE <<__END__
n
p
@@ -460,32 +484,39 @@ $bootfstypeno
EOBOOTCONF
lastcylinder=$(($cylinders-($cylinders*$SD_SWAP_SIZE/$mb)))
- if [ 0 -lt "$SD_SWAP_SIZE" ]; then
- cat <<EOROOTCONF >> /tmp/argsToFdisk$$
+ cat <<EOROOTCONF >> /tmp/argsToFdisk$$
n
p
2
$lastcylinder
t
+2
83
EOROOTCONF
- fi
-
- cat <<EOSWAPCONF >> /tmp/argsToFdisk$$
+ if [ 0 -lt "$SD_SWAP_SIZE" ]; then
+ cat <<EOSWAPCONF >> /tmp/argsToFdisk$$
n
p
3
t
+3
82
-w
+p
EOSWAPCONF
+echo "w" >> /tmp/argsToFdisk$$
+
+ fi
if fdisk $SD_DEVICE < /tmp/argsToFdisk$$; then
echo "Partitioning was successful."
+ if [ -n "$verbose" ]; then
+ echo "The following partitions have been created:"
+ echo "pq" | fdisk $SD_DEVICE
+ fi
#rm /tmp/argsToFdisk$$
else
echo "Partitioning failed, could not execute with fdisk:"
@@ -979,10 +1010,10 @@ do
if [ -z "$assignVariablename" ]; then
case "$i" in
"-h"|"--help"|"What's up, doc?")
- showHelp="yes"
+ showHelp="true"
;;
"--verbose")
- verbose="yes"
+ verbose="true"
;;
"-v")
echo "$VERSION"
@@ -998,12 +1029,12 @@ do
;;
"--part1-size")
assignParametername="$i"
- assignNumeric="yes"
+ assignNumeric="true"
assignVariablename="SD_PART1_SIZE"
;;
"--swap-size")
assignParametername="$i"
- assignNumeric="yes"
+ assignNumeric="true"
assignVariablename="SD_SWAP_SIZE"
;;
"all")
@@ -1021,25 +1052,27 @@ do
action_unmount
;;
"testing"|"time"|"partition"|"format"|"mount"|"debian"|"apt"|"fso"|"configuration"|"kernel"|"unmount"|"uboot")
- echo "Running stage $i"
- action_$i
- echo "I: Done with stage $i"
+ if [ -z "$showHelp" ]; then
+ echo "Running stage $i"
+ action_$i
+ echo "I: Done with stage $i"
+ fi
;;
*)
echo "Unknown option '$i'."
echo
- showHelp="yes"
+ showHelp="true"
;;
esac
else
eval $assignVariablename="$i"
- if [ "yes" = "$assignNumeric" ]; then
+ if [ "true" = "$assignNumeric" ]; then
# Testing if argument is indeed numerical
if ! echo $i | egrep -q '^[0-9]+$'; then
echo
echo "Usage error: argument '$assignParametername' needs a numerical argument, not something like '$i'."
echo
- showHelp="yes"
+ showHelp="true"
fi
fi
assignVariablename=""
@@ -1050,7 +1083,7 @@ done
if [ -n "$assignParametername" ]; then
echo "Error: expected value for parameter '$assignParametername'."
- showHelp="yes"
+ showHelp="true"
fi
if [ -n "$showHelp" ]; then
@@ -1058,13 +1091,4 @@ if [ -n "$showHelp" ]; then
fi
-### sanity check until the GTA01 installer will be merged
-if [ "${FSO_DEVICE}" != gta02 ]; then
- echo "Installing on anything different than the Openmoko"
- echo "GTA02 Neo FreeRunner is not supported yet."
- exit 1
-fi
-
-
-
exit 0
--
1.6.1.3
--------------030607060002090207040000--
More information about the pkg-fso-maint
mailing list