altboot: Sources are now managed by OE's mt database.
authorMatthias Hentges <oe@hentges.net>
Thu, 4 Aug 2005 18:07:53 +0000 (18:07 +0000)
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>
Thu, 4 Aug 2005 18:07:53 +0000 (18:07 +0000)
25 files changed:
packages/altboot/altboot.bb [new file with mode: 0644]
packages/altboot/altboot_20050727.bb [deleted file]
packages/altboot/altboot_cvs.bb [deleted file]
packages/altboot/files/altboot-menu/.mtn2git_empty [new file with mode: 0644]
packages/altboot/files/altboot-menu/00-Default [new file with mode: 0644]
packages/altboot/files/altboot-menu/10-noGui [new file with mode: 0644]
packages/altboot/files/altboot-menu/15-bootSD [new file with mode: 0644]
packages/altboot/files/altboot-menu/20-bootCF [new file with mode: 0644]
packages/altboot/files/altboot-menu/99-ownScripts-example [new file with mode: 0644]
packages/altboot/files/altboot-menu/Advanced/.mtn2git_empty [new file with mode: 0644]
packages/altboot/files/altboot-menu/Advanced/40-bootNFS [new file with mode: 0644]
packages/altboot/files/altboot-menu/Advanced/55-bin-sh [new file with mode: 0644]
packages/altboot/files/altboot.func [new file with mode: 0644]
packages/altboot/files/init.altboot [new file with mode: 0644]
packages/altboot/files/spitz/.mtn2git_empty [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/.mtn2git_empty [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/00-Default [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/10-noGui [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/15-bootSD [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/20-bootCF [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/99-ownScripts-example [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/Advanced/.mtn2git_empty [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/Advanced/40-bootNFS [new file with mode: 0644]
packages/altboot/files/spitz/altboot-menu/Advanced/55-bin-sh [new file with mode: 0644]
packages/altboot/files/spitz/altboot.cfg [new file with mode: 0644]

diff --git a/packages/altboot/altboot.bb b/packages/altboot/altboot.bb
new file mode 100644 (file)
index 0000000..c02f1c6
--- /dev/null
@@ -0,0 +1,64 @@
+DESCRIPTION = "A text-based bootmanager allowing a Zaurus to boot from SD or CF. \
+Tested machines: Collie, Poodle, Akita, Spitz"
+SECTION = "base"
+PRIORITY = "optional"
+MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
+LICENSE = "GPL"
+
+PV = "0.0.1+cvs-${CVSDATE}"
+PR = "r3"
+
+
+SRC_URI = "file://altboot-menu \
+          file://altboot.rc \
+          file://altboot.func \         
+          file://init.altboot \
+          file://altboot.cfg"
+
+# S = "${WORKDIR}/files"
+do_install() {
+       install -d ${D}/sbin
+       install -d ${D}/etc/altboot-menu
+       install -d ${D}/etc/altboot-menu/Advanced
+       install -d ${D}/etc/altboot.rc
+       install -d ${D}/usr/share/doc/altboot
+       
+       install -m 0644 ${WORKDIR}/altboot.cfg ${D}/etc
+       install -m 0644 ${WORKDIR}/altboot.func ${D}/etc
+#      install -m 0644 ${WORKDIR}/docs/altboot/*.txt ${D}/usr/share/doc/altboot
+       install -m 0755 ${WORKDIR}/init.altboot ${D}/sbin       
+       install -m 0755 ${WORKDIR}/altboot-menu/*-* ${D}/etc/altboot-menu
+       install -m 0755 ${WORKDIR}/altboot-menu/Advanced/*-* ${D}/etc/altboot-menu/Advanced
+}              
+
+
+
+pkg_postinst() {
+       update-alternatives --install /sbin/init init /sbin/init.altboot 55
+}
+
+pkg_postinst_spitz() {
+       
+       # Note: Spitz support is a royal pain in the ass.
+       #       Since Spitz pivot_roots by default, there is no real way
+       #       a user can install an altboot.ipk into the flash FS.
+       #       So we need to do that manually (*SIGH*)
+       
+       # /l/m only exists on the HDD on spitz
+       if test -d /lib/modules
+       then
+               # FIXME: Do be written
+               a=a # do nothing
+       fi                                      
+}
+
+pkg_postrm() {
+       update-alternatives --remove init /sbin/init.altboot
+}
+
+pkg_postrm_spitz() {
+       # FIXME: To be written
+       a=a # do nothing
+}
diff --git a/packages/altboot/altboot_20050727.bb b/packages/altboot/altboot_20050727.bb
deleted file mode 100644 (file)
index f2635e0..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-SECTION = "base"
-DESCRIPTION = "A text-based bootmanager allowing a Zaurus to boot from SD or CF. \
-Tested machines: Collie"
-PRIORITY = "optional"
-MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
-LICENSE = "GPL"
-
-
-PR = "r1"
-
-CVSDATE = "${PV}"
-
-SRC_URI = "cvs://anonymous@hentges.net/hentgescvs;module=hentgescvs/hentges-utils/files;method=pserver \
-          file://altboot.cfg"
-S = "${WORKDIR}/files"
-
-do_install() {
-       install -d ${D}/sbin
-       install -d ${D}/etc/altboot-menu
-       install -d ${D}/etc/altboot-menu/Advanced
-       install -d ${D}/usr/share/doc/altboot
-       
-       install -m 0644 ${WORKDIR}/altboot.cfg ${D}/etc
-       install -m 0644 ${WORKDIR}/files/altboot.func ${D}/etc
-       install -m 0644 docs/altboot/*.txt ${D}/usr/share/doc/altboot
-       install -m 0755 init.altboot ${D}/sbin  
-       install -m 0755 altboot-menu/*-* ${D}/etc/altboot-menu
-       install -m 0755 altboot-menu/Advanced/*-* ${D}/etc/altboot-menu/Advanced
-}              
-
-
-
-pkg_postinst() {
-       update-alternatives --install /sbin/init init /sbin/init.altboot 55
-}
-
-pkg_postrm() {
-       update-alternatives --remove init /sbin/init.altboot
-}
diff --git a/packages/altboot/altboot_cvs.bb b/packages/altboot/altboot_cvs.bb
deleted file mode 100644 (file)
index 3b8bb73..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-DESCRIPTION = "A text-based bootmanager allowing a Zaurus to boot from SD or CF. \
-Tested machines: Collie"
-SECTION = "base"
-PRIORITY = "optional"
-MAINTAINER = "Matthias 'CoreDump' Hentges  <oe@hentges.net>"
-LICENSE = "GPL"
-
-PV = "0.0.1+cvs-${CVSDATE}"
-PR = "r3"
-
-
-SRC_URI = "cvs://anonymous@hentges.net/hentgescvs;module=hentgescvs/hentges-utils/files;method=pserver \
-          file://altboot.cfg"
-S = "${WORKDIR}/files"
-do_install() {
-       install -d ${D}/sbin
-       install -d ${D}/etc/altboot-menu
-       install -d ${D}/etc/altboot-menu/Advanced
-       install -d ${D}/usr/share/doc/altboot
-       
-       install -m 0644 ${WORKDIR}/altboot.cfg ${D}/etc
-       install -m 0644 ${WORKDIR}/files/altboot.func ${D}/etc
-       install -m 0644 docs/altboot/*.txt ${D}/usr/share/doc/altboot
-       install -m 0755 init.altboot ${D}/sbin  
-       install -m 0755 altboot-menu/*-* ${D}/etc/altboot-menu
-       install -m 0755 altboot-menu/Advanced/*-* ${D}/etc/altboot-menu/Advanced
-}              
-
-
-
-pkg_postinst() {
-       update-alternatives --install /sbin/init init /sbin/init.altboot 55
-}
-
-pkg_postrm() {
-       update-alternatives --remove init /sbin/init.altboot
-}
diff --git a/packages/altboot/files/altboot-menu/.mtn2git_empty b/packages/altboot/files/altboot-menu/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/altboot/files/altboot-menu/00-Default b/packages/altboot/files/altboot-menu/00-Default
new file mode 100644 (file)
index 0000000..9d29fda
--- /dev/null
@@ -0,0 +1,14 @@
+# !/bin/sh
+M_TITLE="Normal Boot"
+
+
+run_module() {
+       exec $REAL_INIT "$INIT_RUNLEVEL"
+       exit 0
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/10-noGui b/packages/altboot/files/altboot-menu/10-noGui
new file mode 100644 (file)
index 0000000..57141d4
--- /dev/null
@@ -0,0 +1,14 @@
+# !/bin/sh
+M_TITLE="Don't launch GUI"
+
+
+run_module() {
+       clear ; exec $REAL_INIT "$NO_GUI_RL"
+       exit 0
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/15-bootSD b/packages/altboot/files/altboot-menu/15-bootSD
new file mode 100644 (file)
index 0000000..60d9da4
--- /dev/null
@@ -0,0 +1,48 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+M_TITLE="Boot SD card"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+
+       echo -n "Loading SD kernel module..."
+       /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
+
+       echo -n "Mounting $SD_MOUNTPOINT..."  >/dev/tty0
+       /bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT >/dev/null 2>&1 && echo ok  >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       
+       # Check for a real fs and loop-images.
+       check_target "$SD_MOUNTPOINT" >/dev/tty0
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/20-bootCF b/packages/altboot/files/altboot-menu/20-bootCF
new file mode 100644 (file)
index 0000000..931e469
--- /dev/null
@@ -0,0 +1,47 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+M_TITLE="Boot CF card"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+               
+       echo -n "Mounting /proc..." >/dev/tty0
+       mount /proc >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount /proc failed!"
+               
+       /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       
+       # Check for a real fs and loop-images.
+       check_target "$CF_MOUNTPOINT"
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/99-ownScripts-example b/packages/altboot/files/altboot-menu/99-ownScripts-example
new file mode 100644 (file)
index 0000000..61c0645
--- /dev/null
@@ -0,0 +1,81 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+# This file will teach you how to implement your own scripts while using existing altboot
+# code.
+
+# /sbin/init.altboot searches /etc/altboot-menu for scripts. It will only list scripts which
+# return a title when run with the "title" parameter. 
+# Script which do not return a title will never be shown in the boot menu!
+# 
+M_TITLE="altboot sample"
+
+# We can use that to deactivate certain scripts:
+exit 0
+
+# The "title" parameter is implemented at the end of this script so it will never be reached
+# and the script will simply be ignored by altboot.
+
+
+# The die() function aborts the boot if something goes wrong and sets STDIN / STDERR / STDOUT
+# correctly.
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+
+       # altboot.func contains re-useable code. If you intend to use check_target (see below)
+       # you must keep this line. If not, delete it.
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"  
+
+
+       # The only thing you'll have to do is get your medium mounted.
+       # The following lines mount a SD card on 2.4-series kernels on a Zaurus
+       
+       ##########################################
+       
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+
+       echo -n "Loading SD kernel module..."
+       /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
+
+       echo -n "Mounting $SD_MOUNTPOINT..."  >/dev/tty0
+       /bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT >/dev/null 2>&1 && echo ok  >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       ##########################################      
+       
+       # Once the medium (be it a CF or SD card, or even a NFS drive) is mounted somewhere,
+       # just call check_target with the mountpoint as parameter.
+       # check_target searches the medium for a real filesystem and loop-images and
+       # asks the user what to boot if there are several choices.
+       
+       # Check for a real fs and loop-images.
+       check_target "$SD_MOUNTPOINT" >/dev/tty0
+       
+       # Done :)
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/Advanced/.mtn2git_empty b/packages/altboot/files/altboot-menu/Advanced/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/altboot/files/altboot-menu/Advanced/40-bootNFS b/packages/altboot/files/altboot-menu/Advanced/40-bootNFS
new file mode 100644 (file)
index 0000000..feedfc7
--- /dev/null
@@ -0,0 +1,95 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+M_TITLE="Boot from NFS"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED" 
+
+       echo -n "Mounting /proc..." >/dev/tty0
+       mount /proc >/dev/tty0 2>&1 && echo ok  >/dev/tty0 || echo failed
+
+       # Needed for NFS
+       /etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
+       
+       # For some reason NFS mounts hang if /e/i/networking is not run.
+       # For the time beeing I'm to lazy to investigate ;)
+       /etc/init.d/networking start || die "/etc/init.d/networking start failed!"
+       
+       sleep 2
+       
+       # After the PCMCIA service is started, an inserted WLAN card should automatically
+       # activate itself.
+       /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+       
+       # Give WLAN time to login into the network
+       echo "Waiting for WLAN..."
+       sleep 8
+                
+       nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
+       nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"   
+       
+       if test "` echo "$nfs_mountpoints" |wc -l | tr -d " "`" -gt 1
+       then
+               echo -e "Please select your NFS root:\n"
+
+               cnt=1
+               for nfs_mount in $nfs_mountpoints
+               do
+                       echo -e "\t[$cnt] $nfs_mount"
+                       let cnt=$cnt+1
+               done
+               
+               echo ""
+               
+               while test -z "$selection"
+               do
+                       echo -n "Boot NFS root: "
+                       read junk < /dev/tty1
+                       
+                       cnt=1
+                       for nfs_mount in $nfs_mounts
+                       do
+                               if test "$junk" = "$cnt"
+                               then
+                                       selection="$nfs_mount"
+                               fi
+                               let cnt=$cnt+1
+                       done                    
+                       
+               done
+       else
+               test -z "$nfs_mounts" && die "No NFS mounts configured in /etc/fstab!"  
+               selection="$nfs_mounts"
+       fi
+       
+       mkdir -p /media/nfsroot || die "mkdir -p /media/nfsroot failed!"
+       
+       echo -n "Mounting NFS root..."
+       mount -t nfs "$selection" /media/nfsroot && echo ok || die "mount -t nfs "$selection" /media/nfsroot failed!"
+       
+       check_target "/media/nfsroot"
+       
+}      
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
new file mode 100644 (file)
index 0000000..6db4ada
--- /dev/null
@@ -0,0 +1,23 @@
+# !/bin/sh
+M_TITLE="init=/bin/sh"
+
+
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/tty0
+       
+       echo -e "\nBoot system with 'exec /sbin/init 5'\n"
+       while true
+       do
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+               echo "WARNING: Shell was killed!"
+       done
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/altboot.func b/packages/altboot/files/altboot.func
new file mode 100644 (file)
index 0000000..761c51f
--- /dev/null
@@ -0,0 +1,261 @@
+#! /bin/sh
+# This function checks for the presence of a real filesystem and loop-images on the target
+# $1 = folder of rootfs, $2 = runlevel (defaults to 5)
+check_target() {
+       # Check if there is a /sbin/init or /sbin/init.sysvinit on the card
+       if test -x $1/sbin/init -o -x $1/$REAL_INIT
+       then
+               real_fs_found=1
+       else
+               echo -e "Note: No INIT [$REAL_INIT] found on target"
+       fi
+       
+       # Check for loop-images
+       if (ls $1/$IMAGE_PATH/*rootfs.bin) >/dev/null 2>&1
+       then
+               image_found=1
+       else
+               echo "Note: No boot-images found in [$1/$IMAGE_PATH]"
+       fi
+       
+       # Check if we have both, a real fs and boot-images. If so, ask the user what to boot
+       if test "$real_fs_found" = 1 -a "$image_found" = 1
+       then
+               echo -e "\nI have found a real filesystem and boot-images on the target"
+               echo -e "What do you want to boot?\n"
+               
+               echo -e "\t[1] The real filesystem"
+               echo -e "\t[2] A loop-image"
+               echo ""
+               
+               while test -z "$ans"
+               do
+                       echo -n "Your choice: "
+                       read junk < /dev/tty1
+                       
+                       if test "$junk" = 1 -o "$junk" = 2
+                       then
+                               ans="$junk"
+                       fi
+               done
+               
+               case "$ans" in
+               1)      pivot_realfs "$1" "$2">/dev/tty0;;
+               2)      pivot_image "$1" "$2">/dev/tty0;;
+               esac
+                               
+               exit 0
+       fi
+
+       # Boot a real filesystem        
+       test "$real_fs_found" = 1 && pivot_realfs "$1" >/dev/tty0
+       
+       # Boot a loop-image
+       test "$image_found" = 1 && pivot_image "$1" >/dev/tty0
+               
+       if test "$real_fs_found" != 1 -a "$image_found" != 1
+       then
+               die "Nothing to do!"
+       fi
+}
+
+# This function pivot_root's into a real filesystem calling $newrootfs/sbin/init
+# $1 = The new rootfs
+pivot_realfs() {
+       test -z "$2" && RL="5" || RL="$2"
+       mkdir -p $1/media/ROM || die "mkdir -p $1/media/ROM failed"
+
+       mount -o remount,ro /
+
+       echo -n "Pivoting root..."
+       if (/sbin/pivot_root $1 $1/media/ROM) 
+       then
+               echo "Success"
+
+               # Interestingly, this doesn't work with the "real" mount
+               # Without this command, /dev would be mounted under /media/ROM/dev after pivoting root
+               /bin/busybox mount -o move /media/ROM/dev /dev
+
+               cd /
+
+               # Boot init.sysvinit if it is available or use /sbin/init instead
+               if test -x $REAL_INIT
+               then
+                       echo "Calling INIT [$REAL_INIT $RL]"
+                       exec /usr/sbin/chroot . $REAL_INIT $RL >/dev/tty0 2>&1                  
+               else
+                       echo "Calling INIT [/sbin/init $RL]"                    
+                       exec /usr/sbin/chroot . /sbin/init $RL >/dev/tty0 2>&1                  
+               fi
+       else
+               echo "FAILED"
+               die "* * * pivot_root failed! * * *" 
+       fi
+}
+
+# This function loop-mounts an image-file and pivot_root's into it
+# $1: The new rootfs
+pivot_image() {
+       test -z "$2" && RL="5" || RL="$2"
+       cd $1/$IMAGE_PATH
+
+       # Check for rootfs images on the card
+       if test "`ls *rootfs.bin | wc -l | tr -d " "`" -gt 1
+       then
+               echo -e "\n\nPlease select a rootfs:\n"
+
+               # Show all available images
+               x=0
+               for file in `ls *rootfs.bin`
+               do
+                       let x=$x+1
+                       echo -e "\t\t[$x] $file"
+               done
+
+               echo ""                 
+
+               IMAGE_NAME=""
+               while test -z "$IMAGE_NAME"
+               do
+                       echo -en "Please choose one of the above: "
+                       read junk < /dev/tty1
+
+                       x=0
+                       for file in `ls *rootfs.bin`
+                       do
+                               let x=$x+1
+                               if test "$x" = "$junk"
+                               then
+                                       IMAGE_NAME="$file"                                              
+                               fi
+                       done    
+               done
+       else
+               IMAGE_NAME="`ls *rootfs.bin`"           
+               test -z "$IMAGE_NAME" && die "No rootfs found (*rootfs.bin) in $1/$IMAGE_PATH"
+       fi
+
+       echo "Using [$IMAGE_NAME]"
+
+       mkdir -p /media/image || die "mkdir -p /media/image failed"
+
+
+       if test "$FSCK_IMAGES" = yes
+       then
+               echo "Checking file system on [$IMAGE_NAME]"
+               losetup /dev/loop0 $1/$IMAGE_PATH/$IMAGE_NAME || die "losetup /dev/loop0 $1/$IMAGE_PATH/$IMAGE_NAME failed!"
+               fsck.ext3 -p /dev/loop0 || sleep 2
+               losetup -d /dev/loop0
+       fi                                              
+
+       echo -e "\n* * * Booting rootfs image * * *\n"
+
+
+       # Busybox's "mount" doesn't seem to like "-o loop" for some reason
+       # It works on collie and b0rks on poodle.
+       losetup /dev/loop1 $1/$IMAGE_PATH/$IMAGE_NAME || die "losetup /dev/loop1 $1/$IMAGE_PATH/$IMAGE_NAME failed!"
+       mount /dev/loop1 /media/image || die "mount /dev/loop1 /media/image failed!"
+
+
+       mkdir -p /media/image/media/ROM || die "mkdir -p /media/image/media/ROM failed"
+
+       echo -n "Pivoting root..."
+       if (/sbin/pivot_root /media/image /media/image/media/ROM) 
+       then
+               echo "Success"
+
+               cd /
+
+               /bin/busybox mount -o move /media/ROM$1 $1
+               /bin/busybox mount -o move /media/ROM/dev /dev
+               /bin/busybox mount -o move /media/ROM/proc /proc >/dev/null 2>&1
+
+               echo "Calling INIT"
+               exec /usr/sbin/chroot . /sbin/init $RL >/dev/tty0 2>&1
+       else
+               echo "FAILED"
+               die "* * * pivot_root failed! * * *" 
+       fi
+
+
+}
+
+# This functions configures the master password for altboot if none is set
+set_password() {
+       mount -o remount,rw /
+       if test -z "$MASTER_PASSWORD"
+       then
+               echo -e "\nAltboot is a boot-manager which allows to boot from SD, CF and NFS\n\n"
+               echo -e "\nFor security reasons altboot requires a password\nto boot into single-user mode or init=/bin/sh"
+               echo -e "\nThis is *not* your root password! It is used by altboot alone!"
+               echo -e "Please enter a new master password:\n"
+
+               while true
+               do
+                       echo -en "New password: "
+                       read junk1 < /dev/tty0
+                       if ! test -z "$junk1"
+                       then
+                               echo -n "Repeat: "
+                               read junk2  < /dev/tty0
+                               
+                               if test "$junk1" = "$junk2"
+                               then
+                                       crypt_pw="`echo "$junk1" | md5sum | awk '{print $1}'`"
+                                       
+                                       if test -e /etc/hutils.conf
+                                       then
+                                               sed "/^MASTER_PASSWORD/s/\(.*\=\).*/\1\"$crypt_pw\"/" /etc/hutils.conf > /etc/hutils.conf_
+                                               mv /etc/hutils.conf_ /etc/hutils.conf
+                                               echo "Password changed."
+                                       fi
+                                       if test -e /etc/altboot.cfg
+                                       then
+                                               sed "/^MASTER_PASSWORD/s/\(.*\=\).*/\1\"$crypt_pw\"/" /etc/altboot.cfg > /etc/altboot.cfg_
+                                               mv /etc/altboot.cfg_ /etc/altboot.cfg
+                                               MASTER_PASSWORD="$crypt_pw"
+                                               echo "Password changed."
+                                       fi
+                                       
+                                       break
+                               else
+                                       echo -e "Passwords didn't match, try again\n"
+                               fi
+                       fi      
+               done
+       fi
+       
+}
+
+# This function asks for altboots master password. It only returns if the correct password was supplied
+verify_master_pw() {
+       if ! test -z "$MASTER_PASSWORD"
+       then
+               auth_timeout="3"
+
+               echo "Please enter your altboot master password"
+
+               cnt=0
+               while true
+               do
+                       let cnt=$cnt+$auth_timeout
+                       echo -n "Password: "
+                       read junk < /dev/tty0
+
+                       if test "`echo "$junk" | md5sum | awk '{print $1}'`" = "$MASTER_PASSWORD"
+                       then
+                               break
+                       else
+                               echo "[`echo "$junk" | md5sum | awk '{print $1}'`]"
+                               echo "[$MASTER_PASSWORD]"
+                               echo "Wrong password, sleeping $cnt seconds..."
+                               sleep $cnt
+
+#                              if test "$cnt" -gt 10
+#                              then
+#                                      break
+#                              fi
+                       fi
+               done
+       fi
+}
diff --git a/packages/altboot/files/init.altboot b/packages/altboot/files/init.altboot
new file mode 100644 (file)
index 0000000..28ae7b7
--- /dev/null
@@ -0,0 +1,324 @@
+#!/bin/sh
+#
+# altboot provides a simple bootmenu before init is beeing run.
+# There are two default menu entries: "Normal boot" and "Single user mode"
+# New menu entries can be created be putting files into /etc/altboot-menu.
+#
+
+test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+
+CURRENT_ENV="`set`"
+VERSION="0.0.2"
+
+# Set some defaults in case hutils.conf is missing
+REAL_INIT="/sbin/init.sysvinit"
+
+# Read default runlevel from inittab
+INIT_RUNLEVEL="`cat /etc/inittab | sed -n "/^id\:/s/id\:\([0-9]\)\:.*$/\1/p"`"
+test -z "$INIT_RUNLEVEL" && INIT_RUNLEVEL=5
+
+test -e /etc/altboot.cfg && . /etc/altboot.cfg || echo "No altboot.cfg" > /dev/tty1
+test -e /etc/hutils.conf && . /etc/hutils.conf || echo "No hutils.conf" > /dev/tty1
+
+C_RED="\033[31m"
+C_BLUE="\033[34m"
+C_WHITE="\033[37m"
+C_RESET="\033[0m"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+
+# This function prints the boot-menu
+# $1: Directory containing the scripts for the menu-items
+show_menu() {
+       test -z "$1" && die "DEBUG: Parameter 1 is empty in show_menu"
+       echo "" 
+       echo -e "altboot v$VERSION\n" 
+
+       cnt=0
+       m_entry=""
+       if test -d $1
+       then
+               # Build "m_entry" for scripts in /etc/altboot-menu
+               cd $1
+               for file in `ls -1`
+               do      
+                       if ! test -d "$1/$file"
+                       then                    
+                               M_TITLE="`$1/$file title`"
+                               if ! test -z "$M_TITLE"
+                               then
+                                       let cnt=$cnt+1
+                                       # Keep a list of existing "modules" together with an index number
+                                       # This sure is ugly, but Busybox sh doesn't do arrays....
+                                       m_entry="`echo -e "$m_entry\n$cnt:$file\n"`"
+                                       echo -e "\t\t[$cnt] $M_TITLE"                                   
+                               fi
+                               M_TITLE=""
+                       fi
+               done
+
+               # Display directories below /etc/altboot-menu as menu-item
+               # and add all scripts inside the directory to m_entry
+               for dir in `ls -1`
+               do      
+                       if test -d "$1/$dir"
+                       then                    
+                               M_TITLE="`basename "$1/$dir"`"
+                               if ! test -z "$M_TITLE"
+                               then
+                                       let cnt=$cnt+1
+                                       # Keep a list of existing "modules" together with an index number
+                                       # This sure is ugly, but Busybox sh doesn't do arrays....
+                                       m_entry="`echo -e "$m_entry\n$cnt:$dir:DIR\n"`"
+                                       echo -e "\t\t[$cnt] $M_TITLE"                                   
+                                       
+                                       OLD_PWD="$PWD"
+                                       cd "$1/$dir"
+                                       for file in `ls -1`
+                                       do      
+                                               if ! test -d "$1/$dir/$file"
+                                               then                    
+                                                       M_TITLE="`$1/$dir/$file title`"
+                                                       if ! test -z "$M_TITLE"
+                                                       then
+                                                               let cnt=$cnt+1
+                                                               # Keep a list of existing "modules" together with an index number
+                                                               # This sure is ugly, but Busybox sh doesn't do arrays....
+                                                               m_entry="`echo -e "$m_entry\n$cnt:$dir/$file\n"`"
+                                                               #echo -e "\t\t[$cnt] $M_TITLE"                                  
+                                                       fi
+                                                       M_TITLE=""
+                                               fi
+                                       done
+                                       cd "$OLD_PWD"
+
+                               fi
+                               M_TITLE=""
+                       fi
+               done
+               
+               
+               echo ""
+       else
+               echo "WARNING: $1 not found"
+       fi
+       
+}
+
+# This function is used to display the content of directories below
+# /etc/altboot-menu as menu-items
+show_sub_menu() {
+       dirname="`basename "$1"`"
+               
+       d_entries="`echo "$m_entry"|grep "$dirname/"`"
+       
+#      echo "[$d_entries]"
+       
+       echo -e "\naltboot v$VERSION: $dirname menu\n" 
+       
+       
+       for d_entry in $d_entries
+       do
+               d_entry_number="`echo "$d_entry"| sed -n "s/\(.*\)\:\(.*\)/\1/p"`"
+               d_entry_file="`echo "$d_entry"| sed -n "s/\(.*\)\:\(.*\)/\2/p"`"
+               d_entry_title="`$d_entry_file title`"
+               
+#              echo "number: [$d_entry_number]"
+#              echo "file: [$d_entry_file]"
+#              echo "title: [$d_entry_title]"
+               
+               echo -e "\t\t[$d_entry_number] $d_entry_title"
+       done
+               
+       echo ""
+       
+}
+
+# Shows the timer and sets $launch_altboot to yes if a keypress was detected
+run_timer() {
+       if test "$TIMEOUT" != 0
+       then
+               test -x /opt/QtPalmtop/bin/zgreeter.sh && /opt/QtPalmtop/bin/zgreeter.sh
+                       
+               mount -t proc proc /proc >/dev/null 2>&1
+               key_ints="`cat /proc/interrupts | grep keyboard | awk '{print $2}'`"
+       
+               echo -en "\n\nPlease press any key to launch altboot." > /dev/tty1
+               
+               test -z "$TIMEOUT" && TIMEOUT="3"
+
+               cnt=0
+               while test "$cnt" != "$TIMEOUT"
+               do
+                       sleep 1
+                       if test "`cat /proc/interrupts | grep keyboard | awk '{print $2}'`" != "$key_ints" 
+                       then                            
+                               launch_altboot=yes                              
+                               break
+                       fi
+                       echo -n "." >/dev/tty1
+                       let cnt=$cnt+1
+               done
+               #umount /proc
+       else
+               launch_altboot=yes
+       fi
+} 
+
+# This function launches the selected menu item / script
+# $1: Directory containing the scripts for the menu-items
+launch_selection() {
+       test -z "$1" && die "Parameter 1 of launch_selection is empty!"
+       
+       case "$junk" in
+       *)      file="`echo "$m_entry"| sed -n "/$junk\:/s/^.*\:\(.*\)/\1/p"`"
+               
+               # The selected menu-item points to a directory
+               if test "$file" = DIR
+               then
+                       dir="`echo "$m_entry"| sed -n "/$junk\:/s/^.*\:\(.*\)\:\(.*\)/\1/p"`"
+                       show_sub_menu /etc/altboot-menu/$dir >/dev/tty0
+                       wait_for_input >/dev/tty0                       
+                       launch_selection /etc/altboot-menu >/dev/tty0                                           
+               fi
+               
+               if test "$file" = MAIN
+               then
+                       show_sub_menu /etc/altboot-menu >/dev/tty0
+                       wait_for_input >/dev/tty0                       
+                       launch_selection /etc/altboot-menu >/dev/tty0                                           
+               fi      
+               
+               #echo "[$file]"
+                               
+               . $1/$file run "$file" >/dev/tty0       
+               echo "WARNING: Using failsafe shell" >/dev/tty0 
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1                               
+               
+               ;;      
+       esac
+}
+
+
+wait_for_input() {
+       while true
+       do
+               echo -n "Please choose one of the above [$last_selection]: " </dev/tty0 > /dev/tty0 2>&1
+               read junk < /dev/tty0 2>&1
+
+               # This is required to work around an annoying busybox bug.
+               # Every key you press while this script runs will be
+               # picked up by the next "read $junk". And there's no goddamn way
+               # to prevent it. So the next read would pick up the "any" key the user pressed
+               # above to launch the altboot menu.             
+               junk="`echo "$junk" |  sed -n "s/.*\([0-9]\)/\1/p"`"
+               
+               
+               if test "$junk" -lt "$cnt" -o "$junk" -eq "$cnt" 
+               then
+                       if test ! -z "$junk"
+                       then
+                               # Don't remount rw if the drive is already mounted rw
+                               # Only helpful for testing / debugging
+                               if test "`mount|sed -n "/\/dev\/root/s/.*(\(.*\))/\1/p"`" != "rw"
+                               then
+                                       
+                                       mount -o remount,rw / >/dev/null 2>&1
+                                       echo "$junk" > /etc/altboot.conf
+                                       mount -o remount,ro / >/dev/null 2>&1   
+                               else
+                                       echo "$junk" > /etc/altboot.conf
+                               fi
+                       else
+                               junk="$last_selection"
+                               break
+                       fi
+                       break
+               fi
+       done
+}
+
+# * * * * * * This is the main function * * * * * *
+
+if ! test -z "$*" 
+then
+       echo "altboot: Using real init [$REAL_INIT] [$*] *" >/dev/tty1
+       exec $REAL_INIT $*
+       exit 0
+else   
+
+       # Execute scripts in /etc/altboot.rc before doing anything else.
+       # Required for special situations, like booting spitz
+       for file in `ls -1 /etc/altboot.rc/*.sh`
+       do
+                . $file >/dev/tty1 2>&1 || echo "/etc/altboot.rc/$file failed!"
+       done
+       
+       if test "$ENABLE_ALTBOOT" != "yes" 
+       then    
+               echo "altboot: Using real init [$REAL_INIT] **" >/dev/tty1
+               exec $REAL_INIT $INIT_RUNLEVEL
+               exit 0
+       fi
+       
+       # Make sure altboots master password is set
+       set_password >/dev/tty0 
+       
+       test "$ASK_PW_ON_BOOT" = "yes" && verify_master_pw >/dev/tty0 
+       
+       # This timeout works by reading /proc/interrupts to see if the keyboard interrupt
+       # increases while the timer is running. A TIMEOUT of 0 will always launch altboot.      
+       run_timer >/dev/tty1 2>&1
+               
+       echo "" >/dev/tty0
+       
+       
+       if test "$launch_altboot" != yes
+       then
+               # last_selection is the previously selected menu item by the user
+               last_selection="`cat /etc/altboot.conf`" >/dev/null 2>&1
+               test -z "$last_selection" && last_selection="1" 
+               
+               echo "Booting last selection: [$last_selection]" >/dev/tty0
+               
+               # Set up the wanna-be array of available menu entries and their numbers
+               show_menu /etc/altboot-menu >/dev/null
+               junk="$last_selection"
+               launch_selection /etc/altboot-menu >/dev/tty0
+
+       fi
+       # Anything after this point will never be reached if $launch_altboot != yes
+       
+       # Show the altboot menu
+       show_menu /etc/altboot-menu >/dev/tty0
+
+       # Load last selection for use as default if <ENTER> is pressed at the prompt
+       last_selection="`cat /etc/altboot.conf`" >/dev/null 2>&1
+       test -z "$last_selection" && last_selection="1" 
+
+       # Ask the user which menu-item to use
+       wait_for_input >/dev/tty0 
+       
+       # This should _never_ happen.
+       if test -z "$junk"
+       then
+               echo "WARNING: Trying failsafe mode" >/dev/tty0
+               mount -o remount,rw / >/dev/tty0 2>&1
+               echo "Dumping environment to /altboot.env"
+               echo "$CURRENT_ENV" > /altboot.env
+               mount -o remount,ro / >/dev/tty0 2>&1
+               junk=1
+       fi
+
+       launch_selection /etc/altboot-menu >/dev/tty0   
+       
+       # Uhoh, something went terribly wrong if we reach this point!
+       die "WARNING: Failsafe fall-through activated. Spawning emergency shell"        
+
+fi
+
+
diff --git a/packages/altboot/files/spitz/.mtn2git_empty b/packages/altboot/files/spitz/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/altboot/files/spitz/altboot-menu/.mtn2git_empty b/packages/altboot/files/spitz/altboot-menu/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/altboot/files/spitz/altboot-menu/00-Default b/packages/altboot/files/spitz/altboot-menu/00-Default
new file mode 100644 (file)
index 0000000..c18633a
--- /dev/null
@@ -0,0 +1,49 @@
+# !/bin/sh
+M_TITLE="Normal Boot"
+
+# Note for Spitz: The HDD has already been mounted in /media/hdd from
+# /etc/altboot.rc/00-Default.sh
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"  
+       
+       test -z "$SPITZ_HDD_PART" && SPITZ_HDD_PART="/dev/hda1"
+       echo "Spitz: Mounting [$SPITZ_HDD_PART] as /media/hdd"
+       mount -t proc proc /proc || echo "Mounting /proc failed!"
+
+       mount -o remount,rw / 
+
+       # Note: Redirecting STDIN & STDOUT is required, cardmg will die otherwise
+       cardmgr -o < /dev/tty0 > /dev/tty0 2>&1 || echo "cardmgr -o failed!"
+       
+       # I've seen busybox die a horrible death on "!"...
+       if (mount -t auto $SPITZ_HDD_PART /media/hdd)
+       then
+               a=a
+       else
+               echo "ERROR: mount -t ext3 $SPITZ_HDD_PART /media/hdd failed!"
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+       fi
+
+       # There are no device files on Spitz yet, requires HDD (bad for testing
+       # with CF)
+       for n in 1 2 3 4 5
+       do
+               mknod /dev/loop$n b 7 $n
+       done
+       
+       # Check for /sbin/init and / or loop-images     
+       check_target "/media/hdd" 5
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/10-noGui b/packages/altboot/files/spitz/altboot-menu/10-noGui
new file mode 100644 (file)
index 0000000..3f1ce81
--- /dev/null
@@ -0,0 +1,47 @@
+# !/bin/sh
+M_TITLE="Don't launch GUI"
+
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"  
+       
+       test -z "$SPITZ_HDD_PART" && SPITZ_HDD_PART="/dev/hda1"
+       echo "Spitz: Mounting [$SPITZ_HDD_PART] as /media/hdd"
+       mount -t proc proc /proc || echo "Mounting /proc failed!"
+
+       mount -o remount,rw / 
+
+       # Note: Redirecting STDIN & STDOUT is required, cardmg will die otherwise
+       cardmgr -o < /dev/tty0 > /dev/tty0 2>&1 || echo "cardmgr -o failed!"
+       
+       # I've seen busybox die a horrible death on "!"...
+       if (mount -t auto $SPITZ_HDD_PART /media/hdd)
+       then
+               a=a
+       else
+               echo "ERROR: mount -t ext3 $SPITZ_HDD_PART /media/hdd failed!"
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+       fi
+
+       # There are no device files on Spitz yet, requires HDD (bad for testing
+       # with CF)
+       for n in 1 2 3 4 5
+       do
+               mknod /dev/loop$n b 7 $n
+       done
+       
+       # Check for /sbin/init and / or loop-images     
+       check_target "/media/hdd" 2
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/15-bootSD b/packages/altboot/files/spitz/altboot-menu/15-bootSD
new file mode 100644 (file)
index 0000000..d223160
--- /dev/null
@@ -0,0 +1,64 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+M_TITLE="Boot SD card"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       test -z "$SPITZ_HDD_PART" && SPITZ_HDD_PART="/dev/hda1" 
+       mount -t proc proc /proc || echo "Mounting /proc failed!"
+
+       # Note: Redirecting STDIN & STDOUT is required, cardmg will die otherwise
+       cardmgr -o < /dev/tty0 > /dev/tty0 2>&1 || echo "cardmgr -o failed!"
+       
+       # I've seen busybox die a horrible death on "!"...
+       if (mount -t auto $SPITZ_HDD_PART /media/hdd)
+       then
+               a=a
+       else
+               echo "ERROR: mount -t auto $SPITZ_HDD_PART /media/hdd failed!"
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+       fi
+
+#      echo -n "Generating device files..." >/dev/tty0
+#      /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+# FIXME: generate device-files 
+
+       echo -n "Loading SD kernel module..."
+       /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
+
+       echo -n "Mounting $SD_MOUNTPOINT..."  >/dev/tty0
+       /bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT >/dev/null 2>&1 && echo ok  >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       
+       # Check for a real fs and loop-images.
+       check_target "$SD_MOUNTPOINT" >/dev/tty0
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/20-bootCF b/packages/altboot/files/spitz/altboot-menu/20-bootCF
new file mode 100644 (file)
index 0000000..3f19b4e
--- /dev/null
@@ -0,0 +1,49 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+# FXIME: boot CF on spitz (hdb??)
+exit 0
+
+M_TITLE="Boot CF card"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+               
+       echo -n "Mounting /proc..." >/dev/tty0
+       mount /proc >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount /proc failed!"
+               
+       /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       
+       # Check for a real fs and loop-images.
+       check_target "$CF_MOUNTPOINT"
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/99-ownScripts-example b/packages/altboot/files/spitz/altboot-menu/99-ownScripts-example
new file mode 100644 (file)
index 0000000..61c0645
--- /dev/null
@@ -0,0 +1,81 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+
+# This file will teach you how to implement your own scripts while using existing altboot
+# code.
+
+# /sbin/init.altboot searches /etc/altboot-menu for scripts. It will only list scripts which
+# return a title when run with the "title" parameter. 
+# Script which do not return a title will never be shown in the boot menu!
+# 
+M_TITLE="altboot sample"
+
+# We can use that to deactivate certain scripts:
+exit 0
+
+# The "title" parameter is implemented at the end of this script so it will never be reached
+# and the script will simply be ignored by altboot.
+
+
+# The die() function aborts the boot if something goes wrong and sets STDIN / STDERR / STDOUT
+# correctly.
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+
+       # altboot.func contains re-useable code. If you intend to use check_target (see below)
+       # you must keep this line. If not, delete it.
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"  
+
+
+       # The only thing you'll have to do is get your medium mounted.
+       # The following lines mount a SD card on 2.4-series kernels on a Zaurus
+       
+       ##########################################
+       
+       
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED"
+
+
+       echo -n "Loading SD kernel module..."
+       /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
+
+       echo -n "Mounting $SD_MOUNTPOINT..."  >/dev/tty0
+       /bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT >/dev/null 2>&1 && echo ok  >/dev/tty0|| die "/bin/mount -t auto -o defaults,noatime $SD_DEVICE $SD_MOUNTPOINT failed"
+               
+       echo ""
+
+       # Give the SD and CF mounting some time. This is a must for SD                  
+       sleep 2
+       ##########################################      
+       
+       # Once the medium (be it a CF or SD card, or even a NFS drive) is mounted somewhere,
+       # just call check_target with the mountpoint as parameter.
+       # check_target searches the medium for a real filesystem and loop-images and
+       # asks the user what to boot if there are several choices.
+       
+       # Check for a real fs and loop-images.
+       check_target "$SD_MOUNTPOINT" >/dev/tty0
+       
+       # Done :)
+               
+}
+
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/Advanced/.mtn2git_empty b/packages/altboot/files/spitz/altboot-menu/Advanced/.mtn2git_empty
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/packages/altboot/files/spitz/altboot-menu/Advanced/40-bootNFS b/packages/altboot/files/spitz/altboot-menu/Advanced/40-bootNFS
new file mode 100644 (file)
index 0000000..6cac410
--- /dev/null
@@ -0,0 +1,97 @@
+# !/bin/sh
+#
+# Copyright Matthias Hentges (c) 2005
+#
+# License: GPL (see http://www.gnu.org/licenses/gpl.txt for a copy of the GPL)
+
+# FIXME: Make this work
+
+M_TITLE="Boot from NFS"
+
+die() {
+       echo "ERROR: $1" >/dev/tty0
+       exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+}
+
+# This function is activated by init.altboot by calling this script with the "run" option
+run_module() {
+
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+
+       echo -n "Mounting rootfs rw..." >/dev/tty0
+       mount -o remount,rw / >/dev/tty0 2>&1 && echo ok  >/dev/tty0|| die "mount -o remount,rw / failed"
+
+       echo -n "Generating device files..." >/dev/tty0
+       /etc/init.d/devices start && echo ok  >/dev/tty0|| die "FAILED" 
+
+       echo -n "Mounting /proc..." >/dev/tty0
+       mount /proc >/dev/tty0 2>&1 && echo ok  >/dev/tty0 || echo failed
+
+       # Needed for NFS
+       /etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
+       
+       # For some reason NFS mounts hang if /e/i/networking is not run.
+       # For the time beeing I'm to lazy to investigate ;)
+       /etc/init.d/networking start || die "/etc/init.d/networking start failed!"
+       
+       sleep 2
+       
+       # After the PCMCIA service is started, an inserted WLAN card should automatically
+       # activate itself.
+       /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+       
+       # Give WLAN time to login into the network
+       echo "Waiting for WLAN..."
+       sleep 8
+                
+       nfs_mounts="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $1}'`"
+       nfs_mountpoints="`cat /etc/fstab | grep -v ^# | grep nfs | awk '{print $2}'`"   
+       
+       if test "` echo "$nfs_mountpoints" |wc -l | tr -d " "`" -gt 1
+       then
+               echo -e "Please select your NFS root:\n"
+
+               cnt=1
+               for nfs_mount in $nfs_mountpoints
+               do
+                       echo -e "\t[$cnt] $nfs_mount"
+                       let cnt=$cnt+1
+               done
+               
+               echo ""
+               
+               while test -z "$selection"
+               do
+                       echo -n "Boot NFS root: "
+                       read junk < /dev/tty1
+                       
+                       cnt=1
+                       for nfs_mount in $nfs_mounts
+                       do
+                               if test "$junk" = "$cnt"
+                               then
+                                       selection="$nfs_mount"
+                               fi
+                               let cnt=$cnt+1
+                       done                    
+                       
+               done
+       else
+               test -z "$nfs_mounts" && die "No NFS mounts configured in /etc/fstab!"  
+               selection="$nfs_mounts"
+       fi
+       
+       mkdir -p /media/nfsroot || die "mkdir -p /media/nfsroot failed!"
+       
+       echo -n "Mounting NFS root..."
+       mount -t nfs "$selection" /media/nfsroot && echo ok || die "mount -t nfs "$selection" /media/nfsroot failed!"
+       
+       check_target "/media/nfsroot"
+       
+}      
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module "$2";;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot-menu/Advanced/55-bin-sh b/packages/altboot/files/spitz/altboot-menu/Advanced/55-bin-sh
new file mode 100644 (file)
index 0000000..6db4ada
--- /dev/null
@@ -0,0 +1,23 @@
+# !/bin/sh
+M_TITLE="init=/bin/sh"
+
+
+run_module() {
+       
+       test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!"
+       
+       test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/tty0
+       
+       echo -e "\nBoot system with 'exec /sbin/init 5'\n"
+       while true
+       do
+               exec $SH_SHELL </dev/tty0 >/dev/tty0 2>&1
+               echo "WARNING: Shell was killed!"
+       done
+}
+
+case "$1" in
+title) echo "$M_TITLE";;
+run)   run_module;;
+esac
+
diff --git a/packages/altboot/files/spitz/altboot.cfg b/packages/altboot/files/spitz/altboot.cfg
new file mode 100644 (file)
index 0000000..7ae0770
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# Handled by /sbin/init.altboot
+# Allow booting images from SD, CF or RAM instead of booting
+# the ROM. This is currently broken.
+ENABLE_ALTBOOT="yes"
+TIMEOUT="3"
+REAL_INIT="/sbin/init.sysvinit"
+SH_SHELL="/bin/sh"
+IMAGE_PATH="boot-images"
+FSCK_IMAGES="yes"
+SD_DEVICE="/dev/mmcda1"
+SD_KERNEL_MODULE="/media/hdd/lib/modules/2.4.20/kernel/drivers/block/sharp_mmcsd_m.o"
+INIT_RUNLEVEL="5"
+NO_GUI_RL="2"
+MASTER_PASSWORD=""
+ASK_PW_ON_BOOT="no"
+SPITZ_HDD_PART="/dev/hda1"
+
+SD_MOUNTPOINT="/media/card"
+CF_MOUNTPOINT="/media/cf"
+