[pkg-fso-commits] [SCM] Various non-packaged files branch, master, updated. fbcc696c651387637f16b277be5d4b6aad36edd0
Steffen Moeller
steffen_moeller at gmx.de
Thu Feb 19 23:43:44 UTC 2009
The following commit has been merged in the master branch:
commit 88b768540592addf50a327cdf8f0af2bb61d9a22
Author: Steffen Moeller <moeller at debian.org>
Date: Fri Feb 13 16:51:06 2009 +0100
Allowing options to override settings of environment variables.
diff --git a/install.sh b/install.sh
index 030ea51..8a20ed5 100755
--- a/install.sh
+++ b/install.sh
@@ -19,14 +19,6 @@
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-# This file is maintained in the pkg-fso git repository. To contribute,
-# check it out with
-# git clone git://git.debian.org/pkg-fso/files.git
-# perform your changes and prepare patches with
-# git format-patch origin/master
-# to send to the authors or to the pkg-fso mailing list
-# pkg-fso-maint at lists.alioth.debian.org .
-
set -e
@@ -39,6 +31,7 @@ HOSTNAME=${HOSTNAME:-debian-gta02}
SD_DEVICE=${SD_DEVICE:-/dev/mmcblk0}
SD_PART1_FS=${SD_PART1_FS:-ext2}
SD_PART1_SIZE=${SD_PART1_SIZE:-8}
+SD_PART2_FS=${SD_PART2_FS:-ext3}
SD_SWAP_SIZE=${SD_SWAP_SIZE:-0}
INST_DIR=${INST_DIR:-/mnt/debian}
INST_MIRROR=${INST_MIRROR:-http://ftp2.de.debian.org/debian}
@@ -51,13 +44,6 @@ QI_VERBOSE_BOOT=${QI_VERBOSE_BOOT:-false}
SINGLE_PART=${SINGLE_PART:-$QI}
WINDOW_MANAGER=${WINDOW_MANAGER:-zhone}
-### 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
@@ -94,16 +80,26 @@ TAR_PACKAGE=$INST_MIRROR/pool/main/t/tar/tar_1.20-1_armel.deb
# fight against auto-mounting
umount_all () {
+ if [ -n "$verbose" ]; then echo "Now unmounting all SD devices."; fi
for I in $(seq 0 9); do
- if mount | grep -q ^${SD_DEVICE}p$I; then
- echo "W: ${SD_DEVICE}p$I is mounted, unmounting"
- umount ${SD_DEVICE}p$I
- if mount | grep -q ^${SD_DEVICE}p$I; then
- echo "E: Unmount failed"
- exit 1
+ cmd="mount | grep -q '^${SD_DEVICE}p$I'"
+ if [ -n "$verbose" ]; then echo -n " testing #$I ($cmd)"; fi
+ if mount | grep -q "^${SD_DEVICE}p$I" ; then
+ if [ -n "$verbose" ]; then
+ echo " unmounting"
+ else
+ echo "W: ${SD_DEVICE}p$I is mounted, unmounting"
fi
+ umount ${SD_DEVICE}p$I
+ # if mount | grep -q ^${SD_DEVICE}p$I; then
+ # echo "E: Unmount failed"
+ # exit 1
+ # fi
+ elif [ -n "$verbose" ]; then
+ echo 'not mounted'
fi
done
+ if [ -n "$verbose" ]; then echo "All SD devices unmounted."; fi
}
five_seconds_to_quit () {
@@ -118,6 +114,7 @@ five_seconds_to_quit () {
}
card_data_warning () {
+
cat <<__END__
Starting to $1 the microSD card
@@ -129,112 +126,141 @@ This will destroy all the data on the microSD card!!!
Press any key within 5 seconds to quit
__END__
+
five_seconds_to_quit
+
}
-if [ $# -eq 0 ]; then
-#
-# Usage
-#
+usage () {
cat <<__END__
-Auto-Installer for Debian on the Openmoko FreeRunner (GTA02) v$VERSION
------------------------------------------------------------------
-
-Copyright 2008 Joachim Breitner <nomeata at debian.org>
-Copyright 2008 Luca Capello <luca at pca.it>
-
-This program is licensed under the terms of GNU General Public
-License either version 2, or (at your option) any later version.
-
-Usage: [variable1 variable2 ...] $0 stage1 [stage2 ...]
-
-Variables:
- HOSTNAME the name of the machine (default to debian-gta02)
- SD_DEVICE the character device to access the microSD card
- (default to /dev/mmcblk0)
- SD_PART1_FS the filesystem for the first microSD card partition,
- i.e. the one containing the uImage.bin (default to
- ext2, possible values are ext2/vfat)
- SD_PART1_SIZE number of megabytes for first partition (default $SD_PART1_SIZE)
- SD_SWAP_SIZE number of megabytes of swap partition (default $SD_SWAP_SIZE)
- INST_DIR the directory where the microSD card partitions
- will be mounted to (default to /mnt/debian)
- INST_MIRROR the Debian mirror used during installation, it
- should be set to a mirror nearby that carries armel
- binaries for unstable and experimental (default to
- http://ftp2.de.debian.org/debian)
- APT_RECOMMENDS control if APT should install recommends by default
- (default to false, possible values are false/true)
- DASH_BINSH configure dash as default /bin/sh (default to true,
- possible values are true/false)
- FSO_MIRROR the Debian FSO repository (default to
- http://pkg-fso.alioth.debian.org/debian)
- FSO_DEVICE the device the installation is being performed on
- (default to gta02, possible value is gta02 only)
- QI if you use Qi bootloader set this to true
- (default to false)
- QI_VERBOSE_BOOT set this to true if you want to see the kernel messages
- do this only when QI=true (default to false)
- SINGLE_PART set this to true if only one partition should be created
- this is true by default for QI=true and false if SD_PART1_FS=vfat
- WINDOW_MANAGER the presentation of the phone to the user. The default is
- to just use the 'zhone' (phone) application. Alternatively,
- 'fbpanel' is a tiny but usable window manager.
-
-
-Stages:
- all Runs all the stages in the following order:
- testing time partition format mount debian apt fso configuration kernel unmount
- testing Verifys that everything is in place for this
- installer to work
- time Fetches the current time from $RDATEHOST via rdate
- partition Partitions the microSD card found in $SD_DEVICE
- (WARNING, this will destroy all the data on the
- microSD card unless the partioning is the same as
- used before; this can be used to recover a broken
- partiton table due to the suspend/resume problem)
- format Formats the microSD card found in $SD_DEVICE
- (WARNING, this will destroy all the data on the
- microSD card)
- mount Mounts microSD card partitions under $INST_DIR
- debian Installs a basic Debian system, including an SSH
- server
- apt Configure APT
- fso Installs packages required to use the Zhone GUI
- configuration Configures various parts of the system, such as
- the X server
- kernel Downloads and installs the Debian kernel package
- (only when $SD_PART1_FS is set to ext2)
- unmount Unmounts the Debian filesystem mounted at $INST_DIR
-
-Unsupported or buggy stages, use at your own risk:
- uboot Configures the U-Boot environment to boot Debian
- (it needs to run between the debian and the unmount
- stage, only when $SD_PART1_FS is set to ext2)
-
-For more information, go to http://wiki.debian.org/DebianOnFreeRunner
+NAME
+ install.sh - Auto-Installer for Debian on the Openmoko FreeRunner (GTA02) v$VERSION
+
+SYNOPSIS
+ [variable1=value1 variable2 ...] `dirname $0` [options] all
+ [variable1=value1 variable2 ...] `dirname $0` [options] <stages>
+
+DESCRIPTION
+
+ This script is to be executed on an OpenMoko FreeRunner, an openly
+ designed telephone, to install the Debian operating system on
+ an SD card. The system goes through multiple stages, and can
+ be modified to adapt to local preferences.
+
+ The individual stages are described below. The script uses
+ cdebootstrap to prepare a directory to which it can chroot(8)
+ and complete the configuration.
+
+ Variables:
+
+ HOSTNAME the name of the machine (default to debian-gta02)
+ SD_DEVICE the character device to access the microSD card
+ (default to /dev/mmcblk0)
+ SD_PART1_FS the filesystem for the first microSD card partition,
+ i.e. the one containing the uImage.bin (default to
+ ext2, possible values are ext2/vfat)
+ SD_PART1_SIZE number of megabytes for first partition (default $SD_PART1_SIZE)
+ SD_SWAP_SIZE number of megabytes of swap partition (default $SD_SWAP_SIZE)
+ INST_DIR the directory where the microSD card partitions
+ will be mounted to (default to /mnt/debian)
+ INST_MIRROR the Debian mirror used during installation, it
+ should be set to a mirror nearby that carries armel
+ binaries for unstable and experimental (default to
+ http://ftp2.de.debian.org/debian)
+ APT_RECOMMENDS control if APT should install recommends by default
+ (default to false, possible values are false/true)
+ DASH_BINSH configure dash as default /bin/sh (default to true,
+ possible values are true/false)
+ FSO_MIRROR the Debian FSO repository (default to
+ http://pkg-fso.alioth.debian.org/debian)
+ FSO_DEVICE the device the installation is being performed on
+ (default to gta02, possible value is gta02 only)
+ QI if you use Qi bootloader set this to true
+ (default to false)
+ QI_VERBOSE_BOOT set this to true if you want to see the kernel messages
+ do this only when QI=true (default to false)
+ SINGLE_PART set this to true if only one partition should be created
+ this is true by default for QI=true and false if SD_PART1_FS=vfat
+ WINDOW_MANAGER the presentation of the phone to the user. The default is
+ to just use the 'zhone' (phone) application. Alternatively,
+ 'fbpanel' is a tiny but usable window manager.
+
+ Stages:
+
+ all Runs all the stages in the following order:
+ testing time partition format mount debian
+ apt fso configuration kernel unmount
+ testing Verifys that everything is in place for this
+ installer to work
+ time Fetches the current time from $RDATEHOST via rdate
+ partition Partitions the microSD card found in $SD_DEVICE
+ (WARNING, this will destroy all the data on the
+ microSD card unless the partioning is the same as
+ used before; this can be used to recover a broken
+ partiton table due to the suspend/resume problem)
+ format Formats the microSD card found in $SD_DEVICE
+ (WARNING, this will destroy all the data on the
+ microSD card)
+ mount Mounts microSD card partitions under $INST_DIR
+ debian Installs a basic Debian system, including an SSH server
+ apt Configure APT
+ fso Installs packages required to use the Zhone GUI
+ configuration Configures various parts of the system, such as
+ the X server
+ kernel Downloads and installs the Debian kernel package
+ (only when $SD_PART1_FS is set to ext2)
+ unmount Unmounts the Debian filesystem mounted at $INST_DIR
+
+ Unsupported or buggy stages, use at your own risk:
+ uboot Configures the U-Boot environment to boot Debian
+ (it needs to run between the debian and the unmount
+ stage, only when $SD_PART1_FS is set to ext2)
+
+OPTIONS
+ For users uncomfortable with setting environment variables, the following
+ options have been implemented to be set as arguments:
+
+ -h|--help shows this information
+ --hostname <name>
+ sets the HOSTNAME variable
+ --part1-fs sets the SD_PART1_FS variable
+ --part1-size sets the SD_PART1_SIZE variable
+ --swap-size sets the SD_SWAP_SIZE variable
+
+BUGS
+ Only the current (second) generation of devices is supported.
+
+ For comments or contributions, you can directly send emails
+ to the list mentioned below. However, please be aware of the
+ pkg-fso git repository that helps orchestrating our efforts. You
+ can check it out with
+ git clone git://git.debian.org/pkg-fso/files.git
+ perform your changes and prepare patches with
+ git format-patch origin/master
+ to send to the authors or to the pkg-fso mailing list
+ pkg-fso-maint at lists.alioth.debian.org .
+
+AUTHORS
+ Copyright 2008 Joachim Breitner <nomeata at debian.org>
+ Copyright 2008 Luca Capello <luca at pca.it>
+
+ This program is licensed under the terms of GNU General Public
+ License either version 2, or (at your option) any later version.
+
+SEE ALSO
+ This project's homepage: http://wiki.debian.org/DebianOnFreeRunner
+ The OpenMoko project: http://www.openmoko.org
__END__
- exit 0
-fi
-
-if [ $# -gt 1 ]; then
-#
-# Call itself for all arguments
-#
- $0 $1
- shift
- while [ $# -gt 0 ]; do
- $0 $1
- shift
- done
exit 0
-fi
+}
+
+vfat_check () {
# /boot on vfat is no more supported (http://bugs.debian.org/315493)
# http://lists.linuxtogo.org/pipermail/smartphones-userland/2008-November/000502.html
if [ "$SD_PART1_FS" = "vfat" ]; then
@@ -260,16 +286,13 @@ __END__
five_seconds_to_quit
SINGLE_PART="false"
fi
+}
-# let the fun start!
-echo "Running stage $1"
-
-case $1 in
-all)
#
# Stage all
#
+action_all () {
cat <<__END__
I: Running all stages with these settings:
I: hostname set to $HOSTNAME
@@ -282,7 +305,11 @@ I: dash as default /bin/sh se to $DASH_BINSH
__END__
-$0 testing time partition format mount debian apt fso configuration kernel unmount
+for f in testing time partition format mount debian apt fso configuration kernel unmount
+do
+ if [ -n "$verbose" ]; then echo calling '$f'; fi
+ action_$f
+done
cat <<__END__
I: All done!
@@ -297,13 +324,13 @@ else
fi
echo
exit 0
-;;
+}
-testing)
#
# Stage test
#
+action_testing () {
echo "Testing system setup"
if ! test -e $SD_DEVICE; then
@@ -312,7 +339,7 @@ if ! test -e $SD_DEVICE; then
fi
echo " * microSD card device: $SD_DEVICE present"
-for BINARY in wget ping fdisk mount umount mkfs.ext2 gunzip dd sed rdate; do
+for BINARY in wget ping fdisk mount umount mkfs.$SD_PART1_FS mkfs.$SD_PART2_FS gunzip dd sed rdate; do
if ! which $BINARY > /dev/null; then
echo "E: Could not find $BINARY binary"
exit 1
@@ -372,23 +399,24 @@ if ps -C qpe >/dev/null; then
fi
echo "I: System setup looks good"
-;;
+}
-time)
#
# Stage time
#
+
+action_time () {
echo "Fetching time from $RDATEHOST with rdate"
rdate -s "$RDATEHOST"
echo "I: Time is now `date`"
-;;
-
+}
-partition)
#
# Stage partitioning
#
+
+action_partition () {
card_data_warning partition
umount_all
@@ -483,12 +511,12 @@ while ! $DEVTEST; do
SLEEP_SECONDS=`expr $SLEEP_SECONDS + 3`
done
echo " * Partition table created"
-;;
+}
-format)
#
# Stage format
#
+action_format () {
echo
card_data_warning format
umount_all
@@ -498,35 +526,44 @@ if [ "$SINGLE_PART" = "true" ]; then
mkfs.ext2 ${SD_DEVICE}p1
else
mkfs.$SD_PART1_FS ${SD_DEVICE}p1
- mkfs.ext2 ${SD_DEVICE}p2
+ mkfs.$SD_PART2_FS ${SD_DEVICE}p2
fi
echo "I: microSD card ready"
-;;
-
+}
-mount)
#
# Stage mount
#
+action_mount () {
echo "Mounting the newly created system"
-mkdir -p $INST_DIR
+if [ -d "$INST_DIR" ]; then
+ mkdir -p $INST_DIR;
+elif [ -n "$verbose" ]; then
+ echo "Not creating directory '$INST_DIR', it is already existing."
+fi
if [ "$SINGLE_PART" = "true" ]; then
- mount -t ext2 ${SD_DEVICE}p1 $INST_DIR
+ if [ -n "$verbose" ]; then echo "Preparing single ext2 device."; fi
+ mount -t auto ${SD_DEVICE}p1 $INST_DIR
mkdir -p $INST_DIR/boot
else
- mount -t ext2 ${SD_DEVICE}p2 $INST_DIR
- mkdir -p $INST_DIR/boot
- mount -t $SD_PART1_FS ${SD_DEVICE}p1 $INST_DIR/boot
+ if [ -n "$verbose" ]; then echo "Mounting root partition to '$INST_DIR'."; fi
+ mount -t auto ${SD_DEVICE}p2 $INST_DIR
+ if [ "vfat" = "$SD_PART1_FS" ]; then
+ echo "You have a vfat boot filesystem. This is not mounted to /boot."
+ else
+ if [ ! -d "$INST_DIR/boot" ]; then mkdir $INST_DIR/boot; fi
+ mount -t auto ${SD_DEVICE}p1 $INST_DIR/boot
+ fi
fi
echo "I: microSD card partitions mounted"
-;;
+}
-debian)
#
# Stage debian
#
+action_debian () {
echo "Install a basic Debian system"
echo " * Downloading cdebootstrap package"
@@ -540,13 +577,13 @@ echo " * Running cdebootstrap to install the system (might take a while)"
cdebootstrap-static --allow-unauthenticated --flavour minimal --include=$CDEBOOTSTRAP_EXTRA_PACKAGES --exclude=$CDEBOOTSTRAP_EXCLUDE_PACKAGES sid $INST_DIR $INST_MIRROR
echo "I: basic Debian system installed"
-;;
+}
-apt)
#
# Stage apt
#
+action_apt () {
echo "Configuring APT"
echo " * Creating /etc/apt/sources.list"
@@ -573,13 +610,13 @@ apt-get clean
__END_CHROOT__
echo "I: APT configured"
-;;
+}
-fso)
#
# Stage fso
#
+action_fso () {
# TODO
echo "Installing FSO-specific packages"
chroot $INST_DIR /bin/sh -e <<__END_CHROOT__
@@ -587,13 +624,13 @@ apt-get --yes install $FSO_PACKAGES
apt-get clean
__END_CHROOT__
echo "I: FSO packages installed"
-;;
+}
-configuration)
#
# Stage configuration
#
+action_configuration () {
echo "Configuring system files for ${FSO_DEVICE}"
echo " * Installing the fso-config-${FSO_DEVICE} package"
@@ -667,7 +704,7 @@ rootfs / auto defaults,errors=remount-ro,noatime 0 1
__END__
if [ "$SINGLE_PART" != "true" ]; then
- if [ "ext2" = "$SD_PART1_FS" ]; then
+ if [ "ext2" = "$SD_PART1_FS" -o "ext3" = "$SD_PART1_FS" ]; then
cat >> $INST_DIR/etc/fstab <<__END__
/dev/mmcblk0p1 /boot auto defaults,noatime 0 2
__END__
@@ -769,13 +806,12 @@ EOZHONE
fi
echo "I: System configured"
-;;
-
+}
-kernel)
#
# Stage kernel
#
+action_kernel () {
echo "Installing kernel package"
if [ "$SD_PART1_FS" = "vfat" ]; then
@@ -815,13 +851,13 @@ if [ "$QI" = "true" ]; then
echo "root=$ROOT_PART rootdelay=1" >$BOOT_DIR/append-GTA02
fi
fi
-;;
+}
-uboot)
#
# Stage uboot
#
+action_uboot () {
echo "Modifying U-Boot bootloader menu"
if [ "$SD_PART1_FS" = "vfat" ]; then
@@ -904,30 +940,131 @@ echo " * Unmounting /dev"
umount $INST_DIR/dev
echo "I: U-Boot environment modified"
-;;
-
+}
-unmount)
#
# Stage unmount
#
+action_unmount () {
echo "Unmounting microSD card partitions"
if [ "$SINGLE_PART" != "true" ]; then
umount $INST_DIR/boot
fi
umount $INST_DIR
echo "I: microSD card partitions unmounted"
-;;
+}
+#
+# MAIN PROGRAM
+#
+
+if [ $# -eq 0 ]; then
+ usage
+fi
-*)
-echo "E: Unknown stage $1"
-exit 1
-;;
+# internal variable
+verbose=""
+showHelp=""
+
+# parse options
+
+assignVariablename=""
+assignParametername=""
+
+vfat_check
+
+for i in $*
+do
+ if [ -z "$assignVariablename" ]; then
+ case "$i" in
+ "-h"|"--help"|"What's up, doc?")
+ showHelp="yes"
+ ;;
+ "--verbose")
+ verbose="yes"
+ ;;
+ "-v")
+ echo "$VERSION"
+ exit 0
+ ;;
+ "--hostname")
+ assignParametername="$i"
+ assignVariablename="HOSTNAME"
+ ;;
+ "--part1-fs")
+ assignParametername="$i"
+ assignVariablename="SD_PART1_FS"
+ ;;
+ "--part1-size")
+ assignParametername="$i"
+ assignNumeric="yes"
+ assignVariablename="SD_PART1_SIZE"
+ ;;
+ "--swap-size")
+ assignParametername="$i"
+ assignNumeric="yes"
+ assignVariablename="SD_SWAP_SIZE"
+ ;;
+ "all")
+ action_testing
+ action_time
+ action_partition
+ action_format
+ action_mount
+ action_debian
+ action_apt
+ action_fso
+ action_configuration
+ action_kernel
+ action_uboot
+ 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"
+ ;;
+ *)
+ echo "Unknown option '$i'."
+ echo
+ showHelp="yes"
+ ;;
+ esac
+ else
+ eval $assignVariablename="$i"
+ if [ "yes" = "$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"
+ fi
+ fi
+ assignVariablename=""
+ assignParametername=""
+ assignNumeric=""
+ fi
+done
+
+if [ -n "$assignParametername" ]; then
+ echo "Error: expected value for parameter '$assignParametername'."
+ showHelp="yes"
+fi
+
+if [ -n "$showHelp" ]; then
+ usage
+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
-esac
-echo "I: Done with stage $1"
exit 0
--
Various non-packaged files
More information about the pkg-fso-commits
mailing list