Install debian from OM 2008.12 (bash read -t/-n workarround)

Michael Tomschitz michael.tomschitz at gmx.de
Sat Mar 6 14:49:41 CET 2010


Hi,

i'm trying to install debian from Om2008.12 using install.sh

install.sh requires /bin/bash which is onboard in Om2008.12, but has a
buggy read built-in, which only works the first time. Timeout ("-t 5")
doesn't time out at all the second time, so typing anything stops
install.sh in function five_seconds_to_quit().

root at om-gta02:~# /bin/bash --version
GNU bash, version 3.2.39(1)-release (arm-angstrom-linux-gnueabi)
Copyright (C) 2007 Free Software Foundation, Inc.


One workaround is to install a working debian-bash and start "install.sh"
using "/home/root/bin/bash install.sh"

root at om-gta02:~# cd /home/root
root at om-gta02:~# wget -q http://ftp.debian.org/debian/pool/main/b/bash/bash_3.2-4_armel.deb
root at om-gta02:~# ar xv bash_3.2-4_armel.deb data.tar.gz
rw-r--r-- 0/0 580414 May 13 16:51 2008 data.tar.gz
root at om-gta02:~# tar -xzvf data.tar.gz ./bin/bash
./bin/bash
root at om-gta02:~# ls -l $PWD/bin/bash
-rwxr-xr-x    1 root     root       700184 May 13  2008 /home/root/bin/bash


another solution would be to let the user always type "yes" or never type
anything if ALWAYS_SAY_YES=yes:

root at om-gta02:~# diff -u old new
--- old/install.sh      Sat Mar  6 12:18:55 2010
+++ new/install.sh      Sat Mar  6 12:46:57 2010
@@ -40,6 +40,7 @@
 #

 # user variables
+ALWAYS_SAY_YES=${ALWAYS_SAY_YES:-}
 APT_OPTIONS=${APT_OPTIONS:- --yes}
 APT_RECOMMENDS=${APT_RECOMMENDS:-false}
 BOOTSTRAPPER=${BOOTSTRAPPER:-cdebootstrap}
@@ -65,7 +66,7 @@
 ZHONE=${ZHONE:-true}

 # hardening for the case that a user uses capitals
-lc APT_RECOMMENDS BOOTSTRAPPER FSO_DEVICE QI QI_VERBOSE_BOOT SD_PART1_FS SD_PART2_FS
+lc ALWAYS_SAY_YES APT_RECOMMENDS BOOTSTRAPPER FSO_DEVICE QI QI_VERBOSE_BOOT SD_PART1_FS SD_PART2_FS

 # device autodetection if the user has not set FSO_DEVICE
 FSO_DEVICE_AUTODETECTED=`grep GTA /proc/cpuinfo | awk '{print $3}' | tr "[:upper:]" "[:lower:]"`
@@ -225,10 +226,16 @@
 }

 five_seconds_to_quit () {
-       # since dash doesn't support 'read' -t and -n options, this script
-       # should be executed only by /bin/bash.  However, all official
-       # Openmoko images use busybox, which doesn't provide /bin/bash
-       read -t 5 -n 1 intern_var || intern_var=continue
+       if [ -n "$ALWAYS_SAY_YES" ]; then
+               intern_var=$ALWAYS_SAY_YES
+       else
+               echo "I: type \"yes\" to continue"
+               read intern_var
+       fi
+       case $intern_var in
+               yes) intern_var=continue;;
+               *)intern_var=stop;;
+       esac
        if [ "$intern_var" != "continue" ]; then
                echo "E: aborting on user request"
                exit 1


But "five_seconds_to_quit" should then be renamed to something appropriate.

Regards,

Michael



More information about the Smartphones-userland mailing list