Updated QEMU script

Hans Bezemer thebeez at xs4all.nl
Mon Sep 17 12:24:33 EDT 2012


On Monday 17 September 2012, discussion-request at lists.en.qi-hardware.com 
wrote:

> I haven't actually tested this script (yet?), but noticed something
> while reading it. I suspect these two lines:
>
> mkdir /dev/pts
> mknod -m 0666 "$ROOTDIR/ptmx"         c 5 2
>
> should be replaced with these two:
>
> mkdir "$ROOTDIR/dev/pts"
> mknod -m 0666 "$ROOTDIR/dev/ptmx"     c 5 2

Thx! I'd already caught the first one. I fixed the other as well. The package 
has been updated, so is the script.

Hans Bezemer

---8<---
#!/bin/sh
# set -x

# Ben NanoNote QEMU patch script v0.2 - Copyright 2012 J.L. Bezemer
# You can redistribute this file and/or modify it under
# the terms of the GNU General Public License

# 1. Mount the EXT2 image as a loop device;
# 2. Unpack the Ben NanoNote openwrt-xburst-qi_lb60-rootfstar.gz package
#    in it;
# 3. Start this script. Usage: makeqemu.sh <mount-point>;
# 4. Unmount the loopdevice;
# 5. Startup QEMU;
# 6. qemu-system-mipsel -m 32 -kernel <kernel-image> -hda <disk-image>
#    -append "root=/dev/sda1 rw console=tty0" -no-reboot
#    -net user,net=192.168.254.0/24,host=192.168.254.100 -net nic
#    -redir tcp:<port>:192.168.254.101:22

# NOTE THAT THIS SCRIPT HAS NOT BEEN PROPERLY TESTED YET!
# *** USE AT YOUR OWN RISK ***

PROGNAME=`basename $0`
ROOTDIR=$1

if [ -z $ROOTDIR ]; then
   echo "Cannot apply changes to your root directory!"
   exit 1
fi

#
# Populate /dev
#

mkdir "$ROOTDIR/dev/pts"
mknod -m 0666 "$ROOTDIR/dev/ptmx"     c 5 2
mknod -m 0600 "$ROOTDIR/dev/console"  c 5 1
mknod -m 0660 "$ROOTDIR/dev/full"     c 1 7
mknod -m 0640 "$ROOTDIR/dev/kmem"     c 1 2
mknod -m 0660 "$ROOTDIR/dev/loop0"    b 7 0
mknod -m 0640 "$ROOTDIR/dev/mem"      c 1 1
mknod -m 0666 "$ROOTDIR/dev/null"     c 1 3
mknod -m 0640 "$ROOTDIR/dev/port"     c 1 4
mknod -m 0666 "$ROOTDIR/dev/random"   c 1 8
mknod -m 0660 "$ROOTDIR/dev/tty"      c 5 0
mknod -m 0666 "$ROOTDIR/dev/urandom"  c 1 9
mknod -m 0666 "$ROOTDIR/dev/zero"     c 1 5
mknod -m 0666 "$ROOTDIR/dev/fb0"      c 29 0
mknod -m 0666 "$ROOTDIR/dev/sda"      b 8 0
mknod -m 0666 "$ROOTDIR/dev/sda1"     b 8 1

ln -s /proc/kcore "$ROOTDIR/dev/core"
ln -s /dev/ram1 "$ROOTDIR/dev/ram"
ln -s /dev/sda1 "$ROOTDIR/dev/root"

for N in `seq 0 5` ; do
    mknod -m 0660 "$ROOTDIR/dev/tty$N" c 4 $N
done

for N in `seq 0 15` ; do
    mknod -m 0660 "$ROOTDIR/dev/ram$N" b 1 $N
done

#
# Add missing mount point
#

mkdir "$ROOTDIR/sys/kernel"
mkdir "$ROOTDIR/sys/kernel/debug"

#
# Correct /etc/inittab
#

cat << 'EOF' > "$ROOTDIR/etc/inittab"
::sysinit:/etc/init.d/rcS S boot
::shutdown:/etc/init.d/rcS K stop
::askfirst:/bin/sh /usr/bin/gmenu2x
EOF

#
# Create rcS compliant QEMU procedure
#

cat << 'EOF' > "$ROOTDIR/etc/init.d/qemu"
#!/bin/sh /etc/rc.common

START=09
STOP=09

start () {
	mount -t proc none /proc
	mount -t devpts devpts /dev/pts

	if [ -f /var/run/dbus.pid ]; then
		rm /var/run/dbus.pid
	fi

	setfont /usr/share/kbd/consolefonts/kernel-6x11-font
	return 0
}

stop() {
	killall gmenu2x.bin
	return 0
}
EOF

#
# Patch rcS boot procedure
#

cd "$ROOTDIR/etc/rc.d"
ln -s ../init.d/qemu S09qemu
ln -s ../init.d/qemu K09qemu
rm K01ben-nanonote
rm S01ben-nanonote
rm S93triggerhappy
cd -

#
# Patch networking configuration
#

cat << 'EOF' > "$ROOTDIR/etc/config/network"
# Copyright (C) 2006 OpenWrt.org

config interface loopback
        option ifname   lo
        option proto    static
        option ipaddr   127.0.0.1
        option netmask  255.0.0.0

config interface lan
        option ifname   eth0
        option proto    static
        option ipaddr   192.168.254.101
        option netmask  255.255.255.0
        option gateway  192.168.254.100
        option dns      "8.8.8.8 8.8.4.4"
        option hostname BenNanoNote
EOF

#
# Patch /etc/uci-defaults
#

cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/01-optimization-for-ben-nanonote"
#!/bin/sh

# no need in NanoNote
/etc/init.d/atd disable
/etc/init.d/led disable
/etc/init.d/telnet disable

# generate fontconfig cache
/usr/bin/fc-cache

exit 0
EOF

cat << 'EOF' > "$ROOTDIR/etc/uci-defaults/99-set-time"
#!/bin/sh 
date --set 201207072133
EOF

#
# Patch and install startup scripts
#

cat << EOF > "$ROOTDIR/usr/bin/backgammon.sh"
#!/bin/sh
setfont /usr/share/kbd/consolefonts/kernel-6x11-font
exec /usr/bin/backgammon
EOF

chmod +x "$ROOTDIR/usr/bin/backgammon.sh"

cat << EOF > "$ROOTDIR/usr/bin/alfilemplayer.sh"
#!/bin/sh
FILE=$(dialog --stdout --title "MPlayer: Select Video" --fselect $HOME/ 15 70)
if [ -f "$FILE" ]; then
   mplayer -vo fbdev2 -framedrop -nosound "$FILE"
fi
EOF

chmod +x "$ROOTDIR/usr/bin/alfilemplayer.sh"

cat << EOF > "$ROOTDIR/usr/bin/alfilenupdf.sh"
#!/bin/sh
FILE=$(dialog --stdout --title "NuPDF: Select File" --fselect $HOME/ 15 70)
if [ -f "$FILE" ]; then
   nupdf "$FILE"
fi
EOF

chmod +x "$ROOTDIR/usr/bin/alfilenupdf.sh"

#
# Patch gmenu2x entries
#

cat << EOF > "$ROOTDIR/usr/share/gmenu2x/sections/applications/mplayer"
title=MPlayer
icon=skin:icons/mplayer.png
exec=/usr/bin/alfilemplayer.sh
EOF

cat << EOF > "$ROOTDIR/usr/share/gmenu2x/sections/applications/nupdf"
title=NuPDF
icon=skin:icons/editor.png
exec=/usr/bin/alfilenupdf.sh
EOF

cat << EOF > "$ROOTDIR/usr/share/gmenu2x/sections/terminals/ash-default"
title=ash(Default)
icon=skin:icons/utilities-terminal.png
exec=/usr/bin/setfont
params=/usr/share/kbd/consolefonts/kernel-6x11-font; /bin/ash --login
EOF

cat << EOF > "$ROOTDIR/usr/share/gmenu2x/sections/games/tetris"
title=tetris
icon=skin:icons/tetris.png
exec=/usr/bin/setfont
params=/usr/share/kbd/consolefonts/kernel-6x11-font; /usr/bin/tetris
EOF
---8<---


-- 
Absolutely no trees were killed to produce this sig. Well, OK, we had to tie 
one up and torture it. That's it.

Visit our website! http://thebeez.home.xs4all.nl/4tH/

*** Home of the 4tH compiler! ***




More information about the discussion mailing list


interactive