Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r4786 - in developers/werner: . myroot myroot/restricted_bin
      ([EMAIL PROTECTED])
   2. r4787 - developers/werner/myroot ([EMAIL PROTECTED])
--- Begin Message ---
Author: werner
Date: 2008-11-14 11:29:34 +0100 (Fri, 14 Nov 2008)
New Revision: 4786

Added:
   developers/werner/myroot/
   developers/werner/myroot/README
   developers/werner/myroot/mkjffs2
   developers/werner/myroot/myroot
   developers/werner/myroot/restricted_bin/
   developers/werner/myroot/restricted_bin/update-alternatives
   developers/werner/myroot/werner.init
Log:
Customized rootfs image builder. (For development and such.)



Added: developers/werner/myroot/README
===================================================================
--- developers/werner/myroot/README                             (rev 0)
+++ developers/werner/myroot/README     2008-11-14 10:29:34 UTC (rev 4786)
@@ -0,0 +1,125 @@
+*** WORK IN PROGRESS - USE AT YOUR OWN PERIL ! ***
+
+
+What does it do ?
+=================
+
+This root filesystem construction system builds a root filesystem from
+pre-compiled packages from the Openmoko feed. The goal is to be able to
+make highly customized systems with as little effort as possible.
+
+A high degree of customization is required in case like system
+development, where complex user space often interferes with tests and
+may alter the system's state in inexpected ways.
+
+Also, "dumbing down" an existing rootfs and then augmenting it with the
+special tools used during development is often very time-consuming, and
+since it usually takes the form of an ad-hoc job, most of the work has
+to be repeated when switching to a new base rootfs.
+
+
+How to use this
+===============
+
+Customization
+-------------
+
+The customization script is a shell script that specifies which packages
+get installed, sets up the system initialization process, and performs a
+number of adaptations and corrections.
+
+The script "werner" is an example of a relatively complex customization.
+It installs many development tools not normally part of a rootfs and
+reduces the system setup to the bare minimum, so that once can interact
+with a pristine system.
+
+The execution environment of this script is as follows:
+
+- the environment variable SVN points to the root of the Openmoko SVN
+  repository
+
+- the command "pkg" is equivalent to "opkg-target install ..."
+
+- the command "root" changes the current directory to the root of the
+  file system being populated
+
+- when using path names, be careful to avoid absolute paths for
+  destinations, e.g.,
+  echo 'user:...' >>/etc/passwd
+  will add it to the host's /etc/passwd, not the one in the rootfs.
+
+
+Plugging the holes
+------------------
+
+Some executables are currently missing. They are crudely provided by
+copying items from an existing rootfs image:
+
+wget 
http://downloads.openmoko.org/releases/Om2008.9/Om2008.9-gta02-20080916.rootfs.tar.gz
+mkdir rootfs
+tar xCfz rootfs Om2008.9-gta02-20080916.rootfs.tar.gz
+
+
+Making the filesystem hierarchy
+-------------------------------
+
+Just run
+
+./myroot <customization_script>
+
+myroot will print out a flurry of errors at the end when trying to run
+the postinstall scripts, but that's the way things are for now.
+
+The result is a directory "root" with contains the root filesystem
+hierarchy.
+
+myroot also has an interactive mode that can be invoked by setting the
+variable (in the myroot script) interactive=true. In interactive mode,
+which runs after the customization script is processed, all shell
+commands entered are interpreted as if they were part of the
+customization script.
+
+
+Making a filesystem image
+-------------------------
+
+A GTA02 JFFS2 image can be generated with
+
+./mkjffs2
+
+The result is a file root.jffs2 which can be copied to the GTA02 with
+the usual
+
+dfu-util -a rootfs -D root.jffs2 
+
+
+Bugs and future improvements
+============================
+
+Excessive downloads
+-------------------
+
+myroot currently refreshes the package database and downloads all the
+packages it installs over and over again in each run, which wastes quite
+a bit of time. Work is underway to make opkg cache this data.
+
+
+Missing files and packages
+--------------------------
+
+For some programs, we only have a busybox version, either because the
+packge with the regular version is not in our feed or because the
+program in question seems to be missing from the package.
+
+
+Postinstall scripts
+-------------------
+
+Postinstall scripts are run in a rather crude "sandbox" that only
+provides the update-alternatives command. As a consequence, the scripts
+produce lots of errors, some packages need further post-processing, and
+there's the risk of scripts still modifying files outside the "sandbox".
+
+Ideally, myroot would run a proper chroot'ed environment for the
+post-processing script, and maybe even enlist the help of something like
+qmu to run ARM binaries.

Added: developers/werner/myroot/mkjffs2
===================================================================
--- developers/werner/myroot/mkjffs2                            (rev 0)
+++ developers/werner/myroot/mkjffs2    2008-11-14 10:29:34 UTC (rev 4786)
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+# GTA02 !
+#
+
+dir=${1:-root}
+name="`basename $dir`"
+
+if [ ! -d "$dir" ]; then
+    echo "usage: $0 [dirname]" 1>&2
+    exit 1
+fi
+
+mkfs.jffs2 --eraseblock=0x20000 --pagesize=0x800 --no-cleanmarkers \
+  --little-endian --pad -o _tmp -d $dir
+sumtool --eraseblock=0x20000 --no-cleanmarkers \
+  --littleendian --pad -i _tmp -o $name.jffs2
+rm -f _tmp


Property changes on: developers/werner/myroot/mkjffs2
___________________________________________________________________
Name: svn:executable
   + *

Added: developers/werner/myroot/myroot
===================================================================
--- developers/werner/myroot/myroot                             (rev 0)
+++ developers/werner/myroot/myroot     2008-11-14 10:29:34 UTC (rev 4786)
@@ -0,0 +1,206 @@
+#!/bin/sh
+
+#
+# Builds upon the Openmoko toolchain:
+# http://wiki.openmoko.org/wiki/Toolchain
+#
+
+PREFIX=/usr/local/openmoko/arm
+ARCH=arm-angstrom-linux-gnueabi
+CONF=$PREFIX/$ARCH/etc/opkg.conf
+LIB=$PREFIX/lib
+OPKG_CL=$PREFIX/bin/opkg-cl
+
+MAKE="`which make`"
+INSTALL="`which install`"
+
+CWD=$PWD
+restricted_bin=$PWD/restricted_bin
+root=$PWD/root
+
+remove_root=true
+interactive=false
+
+
+# ----- Find the Openmoko SVN repository --------------------------------------
+
+
+for base in $PWD $HOME /home; do
+    for dir in "" openmoko moko om; do
+       for svn in svn.openmoko.org svn.openmoko svn ""; do
+           try=$base/$dir/$svn
+           if [ -d $try/developers/werner ]; then
+               SVN=$try
+               break 3
+           fi
+       done
+    done
+done
+
+echo "SVN=$SVN"
+if [ -z "$SVN" ]; then
+    echo svn checkout http://svn.openmoko.org/
+    exit 1
+fi
+
+
+# ----- Special commands in the build script ----------------------------------
+
+
+opkg()
+{
+    LD_LIBRARY_PATH=$LIB $OPKG_CL -f $CONF -o "$root" "$@"
+}
+
+
+pkg()
+{
+    LD_LIBRARY_PATH=$LIB $OPKG_CL -f $CONF -o "$root" -V 0 install "$@"
+}
+
+
+make()
+{
+    PATH=$PATH:$PREFIX/bin $MAKE -s CC=$ARCH-gcc "$@"
+}
+
+
+install()
+{
+    [ -e "$1" ]
+    [ -d "$2" ]
+    cp "$1" "$root/$2/"
+}
+
+
+root()
+{
+    cd $root
+}
+
+
+# ----- Set up the root directory ---------------------------------------------
+
+
+if [ "$root" = "${root#/}" ]; then
+    root="$PWD/$root"
+fi
+
+root="`echo \"$root\" | sed 's|/$||'`"
+root_base="`dirname \"$root\"`"
+
+if [ -d "$root" ]; then
+    if $remove_root; then
+       rm -rf "$root"
+    else
+       echo "$root: output directory already exists" 1>&2
+       exit 1
+    fi
+fi
+
+if [ -e "$root" ]; then
+    echo "$root: something is in the way" 1>&2
+    exit 1
+fi
+
+if [ ! -d "$root_base" ]; then
+    echo "$root: no parent directory" 1>&2
+    exit 1
+fi
+
+echo "Creating $root"
+mkdir "$root"
+
+
+# ----- set up the bare essentials --------------------------------------------
+
+
+mkdir -p "$root/dev"
+mkdir -p "$root/proc"
+mkdir -p "$root/sys"
+
+mknod "$root/dev/null" c 1 3
+mknod "$root/dev/tty" c 5 0
+mknod "$root/dev/console" c 5 1
+mknod "$root/dev/ttySAC2" c 204 66
+
+mkdir -p "$root/sbin"
+mkdir -p "$root/bin"
+mkdir -p "$root/etc"
+mkdir -p "$root/tmp"
+mkdir -p "$root/usr/local/bin"
+mkdir -p "$root/usr/lib/opkg"
+
+mkdir -p "$root/home/root"
+chmod 755 "$root/home" "$root/home/root"
+
+echo "root::0:0:root:/home/root:/bin/sh" >"$root/etc/passwd"
+
+cp $CONF "$root/etc"
+
+
+# ----- opkg environment ------------------------------------------------------
+
+
+PKG_CONFIG_SYSROOT_DIR="$root"
+PKG_CONFIG_PATH="/usr/lib/pkgconfig"
+CONFIG_SITE=/usr/local/openmoko/arm/site-config
+
+export PKG_CONFIG_SYSROOT_DIR PKG_CONFIG_PATH CONFIG_SITE
+
+
+# ----- opkg package database -------------------------------------------------
+
+# @@@ cache lists and packages
+
+update_cache()
+{
+    mkdir -p $PWD/cache
+    root=$PWD/cache opkg update
+}
+
+
+
+# -----
+
+
+
+opkg update
+custom=$1
+if [ ! -z "$custom" ]; then
+    if [ "${custom#/}" = "$custom" ]; then
+       custom="$PWD/$custom"
+    fi
+    . "$custom"
+fi
+
+
+if $interactive; then
+    while read -e -p "mkroot> " l; do
+       eval "$l"
+    done
+fi
+
+
+# ----- run postinstall scripts -----------------------------------------------
+
+
+#
+# The only thing we really need our post-install scripts to do is to rename the
+# alternatives. We accomplish this by executing them on the host, but giving
+# them a very limited PATH, containing only update-alternatives.
+#
+
+cd "$root/usr/lib/opkg/info"
+MYROOT_ROOT="$root"
+export MYROOT_ROOT
+for n in *.postinst; do
+    PATH=$restricted_bin ./$n
+done
+rm *.postinst
+
+
+# ----- Done ------------------------------------------------------------------
+
+
+exit


Property changes on: developers/werner/myroot/myroot
___________________________________________________________________
Name: svn:executable
   + *

Added: developers/werner/myroot/restricted_bin/update-alternatives
===================================================================
--- developers/werner/myroot/restricted_bin/update-alternatives                 
        (rev 0)
+++ developers/werner/myroot/restricted_bin/update-alternatives 2008-11-14 
10:29:34 UTC (rev 4786)
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+#
+# Invocation example:
+#
+# update-alternatives --install /bin/more more more.util-linux 100
+#
+# $1 is always --install
+# $2 is the absolute path under which the file will be used
+# $3 seems to be the file's canonical name (basename $2 ?)
+# $4 is the relative or absolute (!) path to the file installed by opkg so far
+# $5 is a priority value, in case there are alternatives
+#
+
+PATH=/bin:/usr/bin
+
+if [ "$1" != "--install" ]; then
+    echo "expected --install" 1>&2
+    exit 1
+fi
+
+if [ -e "$MYROOT_ROOT/$2" ]; then
+    echo "$2: exists" 1>&2
+    exit 1
+fi
+
+if [ "${4#/}" = "$4" ]; then
+    src="`dirname \"$2\"`/$4"
+else
+    src="$4"
+fi
+
+if [ ! -e "$MYROOT_ROOT/$src" ]; then
+    echo "$src: not found" 1>&2
+    exit 1
+fi
+
+ln -sf "$4" "$MYROOT_ROOT/$2"


Property changes on: developers/werner/myroot/restricted_bin/update-alternatives
___________________________________________________________________
Name: svn:executable
   + *

Added: developers/werner/myroot/werner.init
===================================================================
--- developers/werner/myroot/werner.init                                (rev 0)
+++ developers/werner/myroot/werner.init        2008-11-14 10:29:34 UTC (rev 
4786)
@@ -0,0 +1,37 @@
+#!/bin/sh
+PATH=/sbin:/bin/:/usr/bin:/usr/local/bin
+
+ldconfig
+mod_dir=/lib/modules/`uname -r`
+mkdir -p $mod_dir
+touch $mod_dir/modules.dep
+
+# mounts
+>/etc/fstab
+mount -t proc none /proc
+mount -t sysfs none /sys
+mount -t tmpfs none /tmp
+
+# devices and sshd
+mount -t tmpfs none /dev
+mknod /dev/null c 1 3
+mknod /dev/tty c 5 0
+mknod /dev/ttySAC2 c 204 66
+mkdir /dev/pts
+mount -t devpts none /dev/pts
+( udevd --daemon; udevtrigger && udevsettle && /usr/sbin/sshd ) &
+
+# network
+ifconfig usb0 192.168.0.202 up
+route add default gw 192.168.0.200
+
+# X
+TSLIB_TSDEVICE=/dev/input/touchscreen0
+export TSLIB_TSDEVICE
+
+# shell
+PS1='con:\w\$ '
+HOME=/home/root
+cd $HOME
+export PS1 HOME
+exec setsid /bin/bash -l </dev/ttySAC2 >/dev/ttySAC2 2>&1


Property changes on: developers/werner/myroot/werner.init
___________________________________________________________________
Name: svn:executable
   + *




--- End Message ---
--- Begin Message ---
Author: werner
Date: 2008-11-14 11:37:34 +0100 (Fri, 14 Nov 2008)
New Revision: 4787

Added:
   developers/werner/myroot/werner
Log:
My customization script.



Added: developers/werner/myroot/werner
===================================================================
--- developers/werner/myroot/werner                             (rev 0)
+++ developers/werner/myroot/werner     2008-11-14 10:37:34 UTC (rev 4787)
@@ -0,0 +1,203 @@
+#
+# Werner's customized development root FS.
+#
+# Highlights:
+# - no GUI or fancy system daemons
+# - has lots of exploration tools used (only) for system-level development
+# - wherever possible, installs full versions of programs, not busybox
+#
+
+# ----- paths -----------------------------------------------------------------
+
+
+root
+calypso=http://people.openmoko.org/joerg/calypso_moko_FW/
+my=$SVN/developers/werner
+wmiconfig=$SVN/trunk/src/target/AR6kSDK.build_sw.18/host/tools/wmiconfig/
+
+
+# ----- basic setup -----------------------------------------------------------
+
+
+pkg udev procps module-init-tools
+pkg coreutils grep sed gawk util-linux bash findutils
+pkg mtd-utils sysfsutils apm
+pkg net-tools iproute openssh ntpdate
+pkg dhcp-client wireless-tools wpa-supplicant
+pkg portmap ppp rsync
+pkg alsa-state alsa-utils-alsamixer alsa-utils-alsactl alsa-utils-aplay
+pkg vim diffutils patch file
+pkg opkg gzip tar
+pkg perl python make
+pkg xserver-kdrive-glamo xset xhost xdpyinfo
+
+
+# ----- general exploration tools ---------------------------------------------
+
+
+pkg s3c24xx-gpio
+pkg gdb strace ldd
+
+make -C $my/poke clean all
+cp $my/poke/poke usr/bin
+
+make -C $my/pmu clean all
+cp $my/pmu/pmu usr/bin
+
+ln -s /usr/sbin/s3c24xx-gpio usr/bin/gpio
+
+
+# ----- fun with GSM ----------------------------------------------------------
+
+
+pkg $calypso/fluid_0.0+svn20070817-r2_armv4t_eabi.ipk
+pkg cu
+
+#echo "uucp:*:2:2:uucp:/:/bin/true" >>etc/passwd
+#chown 2 dev/ttySAC0
+
+
+# ----- network testing -------------------------------------------------------
+
+
+pkg tcpdump
+pkg traceroute
+
+make -C $my/ttcp clean all
+cp $my/ttcp/ttcp-1.12/ttcp usr/bin
+
+make -C $my/owping clean all
+cp $my/owping/owping usr/bin
+
+cp $my/bin/wlanscan usr/bin
+
+make -C $wmiconfig
+cp $wmiconfig/wmiconfig usr/bin
+
+
+# ----- for u-boot ------------------------------------------------------------
+
+
+make -C $SVN/trunk/src/host/envedit clean all
+cp  $SVN/trunk/src/host/envedit/envedit usr/bin
+
+cp $my/neobin/envi usr/bin
+
+
+# ----- create /sbin/init -----------------------------------------------------
+
+
+# inspired by kboot's scripts/kboot
+
+cp $my/myroot/werner.init sbin/init
+
+
+# ----- set up sshd -----------------------------------------------------------
+
+# @@@ cache the keys ?
+
+mkdir -p etc/ssh
+ssh-keygen -t rsa1 -f etc/ssh/ssh_host_key -N ""
+ssh-keygen -t dsa -f etc/ssh/ssh_host_dsa_key -N "" 
+ssh-keygen -t rsa -f etc/ssh/ssh_host_rsa_key -N "" 
+
+echo "sshd:*:1:1:SSH:/:/bin/true" >>etc/passwd
+
+mkdir -p var/run/sshd
+
+
+# ----- enable passwordless SSH entry -----------------------------------------
+
+
+cd home/root
+mkdir .ssh
+chmod 700 .ssh
+cp $HOME/.ssh/id_rsa.pub .ssh/authorized_keys
+root
+
+
+# ----- install things we don't have in the feed yet --------------------------
+
+
+# crudely install busybox
+
+cp $CWD/rootfs/bin/busybox bin
+ln -s /bin/busybox sbin/ifconfig
+ln -s /bin/busybox sbin/route
+ln -s /bin/busybox bin/ip
+ln -s /bin/busybox bin/ping
+ln -s /bin/busybox bin/tar
+ln -s /bin/busybox bin/df
+ln -s /bin/busybox bin/env
+ln -s /bin/busybox usr/bin/killall
+ln -s /bin/busybox usr/bin/which
+
+
+# ----- copy configuration files from the host --------------------------------
+
+
+cp /etc/hosts etc/hosts
+cp /etc/services etc/services
+
+# cp /etc/resolv.conf etc/resolv.conf
+
+# prefer to hard-code it here
+
+cat <<EOF >>etc/resolv.conf
+# opendns
+nameserver 208.67.222.222
+nameserver 208.67.220.220
+EOF
+# prevent DHCP from messing with it
+chmod 444 etc/resolv.conf
+
+
+# ----- shell init ------------------------------------------------------------
+
+
+sed -i 's|/bin/sh|/bin/bash|' etc/passwd
+
+cat <<EOF >home/root/.bash_profile
+[ "\${PS1#con}" = "\$PS1" ] && PS1='ssh:\w\\\$ '
+export PS1
+EOF
+
+
+# ----- save some space -------------------------------------------------------
+
+
+rm usr/lib/opkg/lists/*
+rm -rf usr/share/vim
+
+ln -sf uptime.procps usr/bin/uptime
+
+
+# ----- miscellaneous ---------------------------------------------------------
+
+
+ln -s bash bin/sh
+
+# vim gets a little confused on the console. Fortunately, this is easy to fix:
+# see http://vt100.net/docs/vt102-ug/chapter5.html
+# restore cursor, reset scrolling region, restore cursor
+
+cat <<EOF >usr/bin/vi
+#!/bin/sh
+/usr/bin/vim "\$@"
+code=\$?
+echo -ne '\e7\e[;r\e8'
+exit \$?
+EOF
+chmod 755 usr/bin/vi
+
+
+# seems that we've reached the limits of the update-alternatives hack ;-)
+
+for n in sbin/*.26; do
+    mv $n sbin/`basename $n .26`
+done
+
+echo "audio:*:10:" >>etc/group
+
+
+# -----------------------------------------------------------------------------


Property changes on: developers/werner/myroot/werner
___________________________________________________________________
Name: svn:executable
   + *




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to