#!/bin/sh
# Get kernel from:
# http://downloads.openmoko.org/distro/unstable/daily/om-gta02/20090404/
# ==> latest andy-tracking + modules
# or get this kernel from my site:
# http://users.telenet.be/liedekef/uImage-2.6.28-andy-tracking+gitr6+9c4451ff31b937a478f3d3eabef30b71cbe12b12-r3-om-gta02.bin
# Get fso-console-image from:
# http://downloads.openmoko.org/distro/unstable/daily/om-gta02/20090404/
# Modules: on request

# OR

# get kernel and rootfs from:
# http://downloads.freesmartphone.org/fso-stable/milestone5.1/om-gta02/
# download fso-console-image-om-gta02.jffs2
# and uImage-2.6.28-oe1+gitr34240a1c06ae36180dee695aa25bbae869b2aa26-r3-om-gta02.bin

#
# ./dfu-util -a kernel -R -D  uImage-2.6.28-...
# ./dfu-util -a rootfs -R -D fso-image-...
#
# after that reboot twice (first to let the new kernel boot and create
# all devices, second time you will have usb)

# create the qtopia dir
mkdir -p /opt/Trolltech/Qtopia
cd /opt/Trolltech/Qtopia

# get the files
wget http://users.telenet.be/liedekef/qte_20090425.tgz
# unzip, install
gzip -dc qte_20090425.tgz|tar xvf -
rm qte_20090425.tgz

cd /home/root
# better, simple keyboard
wget http://users.telenet.be/liedekef/libqkeyboard.so
cp /opt/Trolltech/Qtopia/plugins/inputmethods/libqkeyboard.so /opt/Trolltech/Qtopia/plugins/inputmethods/libqkeyboard.so.orig
cp libqkeyboard.so /opt/Trolltech/Qtopia/plugins/inputmethods/libqkeyboard.so
# remove some predictiveness
rm /opt/Trolltech/Qtopia/etc/dict/en_US/*

# better ringtones
cd /opt/Trolltech/Qtopia/etc/SystemRingTones/
mv alarm.wav alarm.wav.orig
wget http://users.telenet.be/liedekef/alarm.wav

# get other QtE startup script for now (bluetooth issues)
cd /home/root
wget http://users.telenet.be/liedekef/qpe.sh
chmod 755 qpe.sh
cp qpe.sh /etc/init.d
rm qpe.sh
cd /etc/rc5.d
ln -s ../init.d/qpe.sh S98qpe.sh

cd /home/root
# get working asound.conf for voicenotes
wget http://users.telenet.be/liedekef/asound.conf
cp asound.conf /etc
rm asound.conf
#cd /usr/share/openmoko/scenarios; cp capturehandset.state capturehandset.state.orig; cp voip-handset.state capturehandset.state

# do we need avahi???
#mv S21avahi-daemon _S21avahi-daemon

# Do something about eth0, at unsuspend it can't be dhcp by default, otherwise
# the wireless lan always becomes active
cd /etc/network
cp interfaces interfaces.orig
cat interfaces.orig |sed "s/iface eth0 inet dhcp/iface eth0 inet manual/" >interfaces

# if the console image is used, some fso stuff needs to be disabled
opkg remove -recursive frameworkd
#mv S35fso-monitord _S35fso-monitord
#mv S35fso-gpsd _S35fso-gpsd
#mv S29frameworkd _S29frameworkd

# remove non existent feed
rm /etc/opkg/armv4-feed.conf

opkg update
# bluetooth daemon needs to be downgraded to bluez3
##opkg install hal
opkg remove -recursive bluez4
opkg install bluez-audio
opkg install bluez-utils
opkg install bluez-utils-alsa
opkg install bluez-utils-compat
### the bluetooth init script needs to be changed
### replace DAEMON_NAME=bluetoothd with DAEMON_NAME=hcid
echo "check that DAEMON_NAME=hcid in /etc/init.d/bluetooth"
# also the poweron/off scripts get a lift
cd /opt/Trolltech/Qtopia/bin
mv bt-poweron.sh bt-poweron.sh.orig
mv bt-poweroff.sh bt-poweroff.sh.orig
wget http://users.telenet.be/liedekef/bt-poweron.sh
wget http://users.telenet.be/liedekef/bt-poweroff.sh
chmod 755 bt-poweron.sh bt-poweroff.sh
# and the dbus config
#cd /etc/dbus-1/system.d/
#mv bluetooth.conf bluetooth.conf.orig
#wget http://users.telenet.be/liedekef/bluetooth.conf

# if the MS5.1 version is used, libts and libstdc++ are not installed
# for others: it doesn't hurt
opkg install libts-1.0-0
opkg install libstdc++6
# obex is needed for bluetooth
opkg install libopenobex1

# atd needed for alarms
# maybe we should use atd from the qtopia distro (rtc based), more lightweight
# that one can be compiled using:
# export QTOPIA_DEPOT_PATH=/opt/QtExtended/qt-extended-improved
# export QPEDIR=/opt/QtExtended/build/
# export PATH=/opt/toolchains/arm920t-eabi/bin/:$QPEDIR/bin:$PATH
# cd /opt/QtExtended/qt-extended-improved/src/3rdparty/tools/atd/
# /opt/QtExtended/build/bin/qbuild
# result is in /opt/QtExtended/build/src/3rdparty/tools/atd/
# copy it, use init script and done
wget http://www.angstrom-distribution.org/unstable/armv4t/base/atd_0.70-r4_armv4t.ipk
# some have own versions, but have issues ..., so we remove the opkg cache
/bin/rm /var/lib/opkg/*
opkg install atd_0.70-r4_armv4t.ipk

#reboot

# List of issues:
# See http://users.telenet.be/liedekef/qt-issues.txt
