1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/qi-emdebian-postsetup Wed Sep 05 00:25:27 2012 +0200
1.3 @@ -0,0 +1,101 @@
1.4 +#!/bin/sh
1.5 +
1.6 +PROGNAME=`basename $0`
1.7 +ROOTDIR=$1
1.8 +KERNEL=$2
1.9 +BUILD=$3
1.10 +
1.11 +if [ ! "$1" ] || [ "$1" = '--help' ]; then
1.12 + cat 1>&2 <<EOF
1.13 +Usage: $PROGNAME <root filesystem path> <kernel image> <system files path>
1.14 +
1.15 +Example: $PROGNAME rootfs openwrt-xburst-qi_lb60-uImage.bin configfiles
1.16 +
1.17 +This program copies the given kernel image into the indicated root filesystem,
1.18 +together with files from the given system files directory hierarchy. It also
1.19 +copies two initial configuration files (preinit and preinit-config) from the
1.20 +current working directory.
1.21 +
1.22 +A root filesystem can be constructed using the multistrap tool as well as
1.23 +other tools such as debootstrap. The preinit and preinit-config files are
1.24 +intended to perform work on the target system to make the root filesystem
1.25 +usable and bootable.
1.26 +EOF
1.27 + exit 1
1.28 +fi
1.29 +
1.30 +if [ ! "$KERNEL" ]; then
1.31 + cat 1>&2 <<EOF
1.32 +$PROGNAME: Need a path to a kernel image.
1.33 +
1.34 +The image filename will be something like openwrt-xburst-qi_lb60-uImage.bin
1.35 +EOF
1.36 + exit 1
1.37 +fi
1.38 +
1.39 +if [ ! "$BUILD" ]; then
1.40 + echo "$PROGNAME: Need a path to a filesystem containing kernel modules and configuration files." 1>&2
1.41 + exit 1
1.42 +fi
1.43 +
1.44 +if [ ! -e preinit ] || [ ! -e preinit-config ]; then
1.45 + echo "$PROGNAME: Need preinit and preinit-config files to deploy in the root filesystem." 1>&2
1.46 + exit 1
1.47 +fi
1.48 +
1.49 +# Make a link to the busybox binary acting as a shell.
1.50 +
1.51 +if [ ! -e "$ROOTDIR/usr/lib/busybox" ]; then
1.52 + mkdir -p "$ROOTDIR/usr/lib/busybox"
1.53 + ln -s /bin/busybox "$ROOTDIR/usr/lib/busybox/sh"
1.54 +fi
1.55 +
1.56 +# The first boot involves a special configuration script.
1.57 +
1.58 +cp preinit preinit-config "$ROOTDIR/etc/"
1.59 +
1.60 +# Copy the kernel image and any modules.
1.61 +
1.62 +cp "$KERNEL" "$ROOTDIR/boot/uImage"
1.63 +
1.64 +if [ -e "$BUILD/lib/modules" ]; then
1.65 + if [ ! -e "$ROOTDIR/lib/modules" ]; then
1.66 + mkdir -p "$ROOTDIR/lib/modules"
1.67 + fi
1.68 + cp -R "$BUILD/lib/modules/"* "$ROOTDIR/lib/modules/"
1.69 + cp "$BUILD/etc/modules" "$ROOTDIR/etc/"
1.70 +fi
1.71 +
1.72 +# Copy configuration files.
1.73 +
1.74 +cp "$BUILD/etc/fstab" "$ROOTDIR/etc/"
1.75 +cp "$BUILD/etc/network/interfaces" "$ROOTDIR/etc/network/"
1.76 +
1.77 +# Also required for a "first boot" script:
1.78 +# /etc/hostname
1.79 +# /etc/resolv.conf
1.80 +
1.81 +# Make devices.
1.82 +
1.83 +mknod -m 0600 "$ROOTDIR/dev/console" c 5 1
1.84 +mknod -m 0660 "$ROOTDIR/dev/full" c 1 7
1.85 +mknod -m 0640 "$ROOTDIR/dev/kmem" c 1 2
1.86 +mknod -m 0660 "$ROOTDIR/dev/loop0" b 7 0
1.87 +mknod -m 0640 "$ROOTDIR/dev/mem" c 1 1
1.88 +mknod -m 0666 "$ROOTDIR/dev/null" c 1 3
1.89 +mknod -m 0640 "$ROOTDIR/dev/port" c 1 4
1.90 +mknod -m 0666 "$ROOTDIR/dev/random" c 1 8
1.91 +mknod -m 0660 "$ROOTDIR/dev/tty" c 5 0
1.92 +mknod -m 0666 "$ROOTDIR/dev/urandom" c 1 9
1.93 +mknod -m 0666 "$ROOTDIR/dev/zero" c 1 5
1.94 +
1.95 +for N in `seq 0 5` ; do
1.96 + mknod -m 0660 "$ROOTDIR/dev/tty$N" c 4 $N
1.97 +done
1.98 +
1.99 +for N in `seq 0 15` ; do
1.100 + mknod -m 0660 "$ROOTDIR/dev/ram$N" b 1 $N
1.101 +done
1.102 +
1.103 +ln -s /dev/ram1 "$ROOTDIR/dev/ram"
1.104 +ln -s /proc/kcore "$ROOTDIR/dev/core"