Nokia N900 >> Easy Debian

架設環境(Debian 5)


參考資訊:
1. debian-m5-v3e.img.ext2.lzma

感謝Pali以及社群的協助下,讓N900可以chroot到Debian下,該chroot跟Android chroot的最大差別在於,N900的chroot是使用Xephyr進行GUI操作;而Android的chroot則是使用vncserver的操作方式,加上N900的觸控螢幕是電阻觸控,因此,整體的體驗,N900還是比Android來的好,雖然Pali已經有幫使用者建立EasyDebian套件,不過該EasyDebian套件將本機/home/user也綁定到chroot下,加上目前使用的Desktop Environment是LXDE,使用者如要更改成XFCE4時,則需要到更改到EasyDebian腳本,但是EasyDebian的腳本寫的有點複雜,因此,司徒基於EasyDebian腳本,改寫一個比較適合、容易瞭解的腳本,並且列出一些常用的套件供使用者參考。

司徒習慣將Image放到內部Flash,用以加快存取速度,而且不是用單一檔案的方式(xxx.ext2.img),因為單一檔案需要預留空間,除了浪費空間以外,遇到空間不足時,更是相當麻煩,因此建議使用者可以將/home分區加大,用來存放該Image資料。

接著到該Image資料夾下,建立chroot腳本

$ vim login
#!/bin/sh
CHMODE=$1
CHUSER=$2
CHROOT=`dirname $0`

_usage(){
 echo "Usage: login [cli|lxde|xfce4] [root|user]"
}

_mount(){
 sudo mount -o bind /sys           "$CHROOT/sys"
 sudo mount -o bind /proc          "$CHROOT/proc"
 sudo mount -o bind /dev           "$CHROOT/dev"
 sudo mount -t devpts none         "$CHROOT/dev/pts"
 sudo mount -o bind /dev/shm       "$CHROOT/dev/shm"
 sudo mount -o bind /var/tmp       "$CHROOT/var/tmp"
 sudo mount -o bind /var/run/pulse "$CHROOT/var/run/pulse"
 sudo mount -o bind /var/run/dbus  "$CHROOT/var/run/dbus"
 sudo mount -o bind /var/lib/dbus  "$CHROOT/var/lib/dbus"
 sudo mount /dev/mmcblk0p1         "$CHROOT/home/user/MyDocs"
}

_umount(){
 sudo umount "$CHROOT/var/lib/dbus"
 sudo umount "$CHROOT/var/run/dbus"
 sudo umount "$CHROOT/var/run/pulse"
 sudo umount "$CHROOT/var/tmp"
 sudo umount "$CHROOT/dev/shm"
 sudo umount "$CHROOT/dev/pts"
 sudo umount "$CHROOT/dev" &> /dev/null
 sudo mount -o bind /dev "$CHROOT/dev"
 sudo umount "$CHROOT/dev"
 sudo umount "$CHROOT/proc"
 sudo umount "$CHROOT/sys"
 sudo umount "$CHROOT/home/user/MyDocs"
}

if [ `whoami` == "root" ] ; then
 echo "Run me as user"
 exit 1
fi

if [ "$CHMODE" != "cli" ] && [ "$CHMODE" != "lxde" ] && [ "$CHMODE" != "xfce4" ] ; then
 _usage
 exit 2
fi

if [ "$CHUSER" != "root" ] && [ "$CHUSER" != "user" ] ; then
 _usage
 exit 
fi

_umount &> /dev/null
_mount

export GTK_MODULES=libgtkstylus.so
if [ "x$DISPLAY" = x ] ; then
 export DISPLAY=:0.0
fi

if [ "x$GTK_MODULES" = x ] ; then
 export GTK_MODULES=libgtkstylus.so
fi

if [ "$CHMODE" = "cli" ] ; then
 sudo chroot $CHROOT su - "$CHUSER"
 _umount
 exit 0
fi

if [ "$CHMODE" = "lxde" ] ; then
 if [ ! -f "$CHROOT/usr/bin/startlxde1" ] ; then
  echo "Not found LXDE installed"
  exit 4
 fi
fi

if [ "$CHMODE" = "xfce4" ] ; then
 if [ ! -f "$CHROOT/usr/bin/startxfce41" ] ; then
  echo "Not found XFCE4 installed"
  exit 4
 fi
fi

export DISPLAY=:0
sudo chroot $CHROOT su - "$CHUSER" -c 'echo "chroot is now open"'
sudo chroot $CHROOT su - "$CHUSER" -c '/usr/bin/Xephyr :1 -screen 800x480 -br -ac' &
while [ "x$PARWIN" = "x" ] ; do
 export PARWIN=`wmctrl -l | grep -i "N/A Xephyr" | awk '{print $1}'`
done
DISPLAY=:1 ; sudo chroot $CHROOT su - "$CHUSER" -c "habak -mf /usr/share/fonts/truetype/DroidSans-Bold.ttf -ht 'Welcome to Debian5'"
DISPLAY=:0 ; sudo wmctrl -i -r $PARWIN -T 'Debian5'
sudo wmctrl -i -r $PARWIN -b toggle,fullscreen
zenity --display=:0 --info --title="Information" --text="Welcome to Debian5. This window is needed to gain keyboard focus in LXDE." &
while [ "x$TWOWIN" = "x" ] ; do
 export TWOWIN=`wmctrl -l | grep -i Information | awk '{print $1}'`
done
sudo chroot $CHROOT su root -c "/sbin/qobi-wmhint-fix $PARWIN"
sudo chroot $CHROOT su "$CHUSER" -c "/usr/bin/xbindkeys"
if [ "$CHMODE" = "xfce4" ] ; then
 sudo chroot $CHROOT su - "$CHUSER" -c "/usr/bin/startxfce41"
else
 sudo chroot $CHROOT su - "$CHUSER" -c "/usr/bin/startlxde1"
fi
sudo killall Xephyr
export DISPLAY=:0
_umount
exit 0

接著修改repository清單

$ sudo vim etc/apt/sources.list
deb http://archive.debian.org/debian lenny main contrib non-free
deb http://archive.debian.org/debian-backports lenny-backports main contrib non-free
deb http://http.us.debian.org/debian squeeze main contrib non-free
deb http://archive.debian.org/debian-security lenny/updates main contrib non-free
deb http://security.us.debian.org/ squeeze/updates main contrib non-free
deb ftp://ftp.deb-multimedia.org lenny main
deb http://www.deb-multimedia.org squeeze main
deb-src http://archive.debian.org/debian lenny main contrib non-free
deb-src http://http.us.debian.org/debian squeeze main contrib non-free

由於N900的觸控只能模擬滑鼠左鍵,因此,司徒使用xbindkeys和xdotool套件,製作出可以模擬滑鼠移動(Ctrl + 鍵盤方向鍵)、滑鼠左鍵(Shift + 鍵盤左鍵)、滑鼠右鍵(Shift + 鍵盤右鍵)

$ vim home/user/.xbindkeysrc
"wmctrl -r :ACTIVE: -b toggle,fullscreen"
 m:0x81 + c:33

"xdotool click 3"
 Shift + Right
"xdotool click 1"
 Shift + Left
"xdotool click 4"
 Shift + Up
"xdotool click 5"
 Shift + Down

"xdotool key Tab"
 Control + Up

"xdotool mousemove_relative 50 0"
 Control + Right
"xdotool mousemove_relative -- -50 0"
 Control + Left
#"xdotool mousemove_relative 0 -50"
# Control + Up
#"xdotool mousemove_relative 0 50"
# Control + Down

至於鍵盤對映鍵的設定,可以參考N900的鍵盤設定,請參考司徒的教學文章。

完成後,就可以開始使用chroot腳本,首先使用如下指令切到CLI介面:

$ sudo sh login cli user



如要切到LXDE介面,可以使用如下指令:

$ sudo sh login lxde user



由於LXDE是屬於另一個Display,一般情況下是無法取得鍵盤的控制權,因此可以透過zenity視窗,讓使用者點選按鈕,藉此方式取得鍵盤控制權


用過N810的chroot使用者,對此畫面應該很熟悉


Terminator:司徒最愛使用的Terminal


KiCAD:必備的PCB繪圖軟體


Evince:PDF閲讀軟體
Wings3D:模型繪圖軟體
FreeCAD:模型繪圖軟體
GIMP:超好用的圖片編輯軟體


Iceweasel:開源的FireFox瀏覽器


OpenOffice:好用的Office軟體


LXTerminal:LXDE附屬的Terminal


MonoDevelop:C#開發工具
Bluefish:好用的網頁編輯軟體
Qt Creator:相當不錯的Qt開發環境
Anjuta IDE:相當不錯的IDE開發環境


不建議在chroot中播放音樂


PCManFM:好用的File Manager軟體


SCIM:司徒常用的scim-pinyin輸入法


登出畫面


由於司徒同時安裝LXDE和XFCE4,而且腳本也有針對XFCE4改寫,因此,可以使用如下指令進入XFCE4

$ sudo sh login xfce4 user



XFCE4的開始列是位於上面


登出畫面


返回上一頁