summaryrefslogtreecommitdiff
path: root/packages/altboot
diff options
context:
space:
mode:
authorRod Whitby <rod@whitby.id.au>2006-02-06 00:46:35 +0000
committerOpenEmbedded Project <openembedded-devel@lists.openembedded.org>2006-02-06 00:46:35 +0000
commit9b188ea2600bce6ed35559b21677bd8b7223f5a8 (patch)
tree40e9328ce853279c0eae8ecc851d514ef01c26d1 /packages/altboot
parent76107d774ec7a96b7788d2f2b98b5621a04cfe71 (diff)
parent1be31761f3449cd4f92508fd2c2c41968039c918 (diff)
merge of 1133a2f6d7624f04cdda9771f28e1502680e7213
and 59438d13db19ded8e22646fb8cddf849804f3a90
Diffstat (limited to 'packages/altboot')
-rw-r--r--packages/altboot/altboot.bb2
-rw-r--r--packages/altboot/files/altboot-menu/15-bootSD38
-rw-r--r--packages/altboot/files/altboot-menu/20-bootCF18
-rw-r--r--packages/altboot/files/altboot-menu/99-ownScripts-example11
-rw-r--r--packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick7
-rw-r--r--packages/altboot/files/altboot-menu/Advanced/40-bootNFS10
-rw-r--r--packages/altboot/files/altboot-menu/Advanced/55-bin-sh3
-rw-r--r--packages/altboot/files/altboot-menu/Advanced/70-install-tgz229
-rw-r--r--packages/altboot/files/altboot.func85
-rw-r--r--packages/altboot/files/altboot.rc/disable_printk.sh4
-rw-r--r--packages/altboot/files/init.altboot1
11 files changed, 335 insertions, 73 deletions
diff --git a/packages/altboot/altboot.bb b/packages/altboot/altboot.bb
index a6b2bcb524..b0639e9251 100644
--- a/packages/altboot/altboot.bb
+++ b/packages/altboot/altboot.bb
@@ -6,7 +6,7 @@ MAINTAINER = "Matthias 'CoreDump' Hentges <oe@hentges.net>"
LICENSE = "GPL"
IGNORE_STRIP_ERRORS = "1"
-PR = "r16"
+PR = "r18"
SRC_URI = "file://altboot-menu \
diff --git a/packages/altboot/files/altboot-menu/15-bootSD b/packages/altboot/files/altboot-menu/15-bootSD
index d086cde344..7123491000 100644
--- a/packages/altboot/files/altboot-menu/15-bootSD
+++ b/packages/altboot/files/altboot-menu/15-bootSD
@@ -15,43 +15,13 @@ die() {
# 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!"
+ 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"
+ # Mount /proc, etc
+ init_rootfs
- echo -n "Generating device files..." >/dev/tty0
- /etc/init.d/devices start && echo ok >/dev/tty0|| die "FAILED"
+ mount_sd
- # We can't trust that the SD device file is there when running kernel 2.6 w/ udev
- # and starting udev at this point may not be the best idea...
-
- if `uname -r | grep -q "2.6"`
- then
- #Let's just assume the device file name never changes...
- dev_no="`echo "$SD_DEVICE" | sed -n "s/\/dev\/mmcblk\(.*\)p\(.*\)/\1/p"`"
- part_no="`echo "/dev/mmcblk0p1" | sed -n "s/\/dev\/mmcblk\(.*\)p\(.*\)/\2/p"`"
- ! test -e /dev/mmcblk${dev_no} && mknod /dev/mmcblk${dev_no} b 254 0
- ! test -e /dev/mmcblk${dev_no}p${part_no} && mknod /dev/mmcblk${dev_no}p${part_no} b 254 $part_no
- fi
-
- # Kernel 2.6 has the SD driver compiled into the kernel
- if test -n "$SD_KERNEL_MODULE"
- then
- echo -n "Loading SD kernel module..."
- /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
- else
- echo "No SD kernel module, configured, assuming it's build-in"
- fi
-
- 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
diff --git a/packages/altboot/files/altboot-menu/20-bootCF b/packages/altboot/files/altboot-menu/20-bootCF
index 931e46995c..3a3f4fbafe 100644
--- a/packages/altboot/files/altboot-menu/20-bootCF
+++ b/packages/altboot/files/altboot-menu/20-bootCF
@@ -17,23 +17,11 @@ 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!"
+ # Mount /proc, etc
+ init_rootfs
- /etc/init.d/pcmcia start || die "/etc/init.d/pcmcia/start failed!"
+ mount_cf
- 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"
diff --git a/packages/altboot/files/altboot-menu/99-ownScripts-example b/packages/altboot/files/altboot-menu/99-ownScripts-example
index 61c0645176..b1b444f2d1 100644
--- a/packages/altboot/files/altboot-menu/99-ownScripts-example
+++ b/packages/altboot/files/altboot-menu/99-ownScripts-example
@@ -40,14 +40,9 @@ run_module() {
# 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"
-
+
+ # Mount /proc, etc
+ init_rootfs
echo -n "Loading SD kernel module..."
/sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
diff --git a/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick b/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick
index 5a1d049976..3ef17764d0 100644
--- a/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick
+++ b/packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick
@@ -17,11 +17,8 @@ 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"
+ # Mount /proc, etc
+ init_rootfs
echo "Starting USB..."
diff --git a/packages/altboot/files/altboot-menu/Advanced/40-bootNFS b/packages/altboot/files/altboot-menu/Advanced/40-bootNFS
index e83a2867c5..818a93943d 100644
--- a/packages/altboot/files/altboot-menu/Advanced/40-bootNFS
+++ b/packages/altboot/files/altboot-menu/Advanced/40-bootNFS
@@ -16,14 +16,8 @@ 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
+ # Mount /proc, etc
+ init_rootfs
# Needed for NFS
/etc/init.d/portmap start >/dev/tty1 2>&1 || die "/etc/init.d/portmap start failed!"
diff --git a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
index 6db4adaf3a..4619e51ce7 100644
--- a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
+++ b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh
@@ -8,6 +8,9 @@ run_module() {
test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/tty0
+ # Mount /proc, etc
+ init_rootfs
+
echo -e "\nBoot system with 'exec /sbin/init 5'\n"
while true
do
diff --git a/packages/altboot/files/altboot-menu/Advanced/70-install-tgz b/packages/altboot/files/altboot-menu/Advanced/70-install-tgz
new file mode 100644
index 0000000000..acf148efb3
--- /dev/null
+++ b/packages/altboot/files/altboot-menu/Advanced/70-install-tgz
@@ -0,0 +1,229 @@
+#!/bin/sh
+
+M_TITLE="Install RootFS from tar.gz"
+
+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!"
+
+ # Mount /proc, etc
+ init_rootfs
+
+ # Mount
+ mount_sd
+ mount_cf
+ mount_home
+
+ for source in /home /media/card /media/cf
+ do
+ #echo "source: [$source]"
+ rootfs_files="`ls -1 $source | grep "rootfs.tar.gz"`"
+
+ #echo "rootfs_file: [$rootfs_files]"
+ if test "`echo "$rootfs_files" | wc -l | tr -d " "`" -gt 1
+ then
+ echo "Multiple rootfs files not supported, yet"
+ else
+ if test -n "$rootfs_files"
+ then
+ rootfs_source="$source/$rootfs_files"
+ echo "Using [$rootfs_source]"
+ break
+ fi
+ fi
+ done
+
+ test -z "$rootfs_source" && die "No rootfs.tar.gz found"
+
+ echo -e "\nPlease choose the target of this installation:\n"
+
+ echo -e "\t [1] SD / MMC"
+ echo -e "\t [2] Compact Flash"
+
+ echo ""
+ while true
+ do
+ echo -n "Your target: "
+ read junk
+
+ case "$junk" in
+ 1) rootfs_target="/media/card"; break ;;
+ 2) rootfs_target="/media/cf" ; break ;;
+ esac
+ done
+
+ echo -e "\nPlease choose the method of this installation:\n"
+
+ echo -e "\t [1] ImageFile (loopfile)"
+ echo -e "\t [2] Direct Install"
+
+ echo ""
+ while true
+ do
+ echo -n "Install type: "
+ read junk
+
+ case "$junk" in
+ 1) rootfs_type="image"; break ;;
+ 2) rootfs_type="direct" ; break ;;
+ esac
+ done
+
+ case "$rootfs_type" in
+ image) install_rootfs_image "$rootfs_target";;
+ direct) install_rootfs_direct "$rootfs_target";;
+ esac
+}
+
+clear_directories(){
+ test "$1" = "/" -o "$1" = "/ " && die "clear_directories(): You don't want to do that."
+
+ ! test -d "$1" && die "clear_directories(): [$1] not found."
+
+ for d in bin dev media proc sys usr boot etc lib mnt sbin tmp var
+ do
+ echo "Removing [$1/$d]..."
+ rm -rf "$1/$d"
+ done
+
+}
+
+
+install_rootfs_direct(){
+
+ echo -e "Do you want to remove existing directories from [$1]\n before installing the new rootfs?"
+ echo ""
+
+ while true
+ do
+ echo -n "Remove old directories? [Y|n] "
+ read junk </dev/tty0 >/dev/tty0 2>&1
+
+ case "$junk" in
+ Y|y|"") clear_directories "$1"; break ;;
+ esac
+ done
+
+ echo "Please press <ENTER> to begin the installation"
+ read junk </dev/tty0 >/dev/tty0 2>&1
+
+ mount | grep -q "$1 " || die "Installation target [$1] not mounted"
+ test -d "$1" || die "Directory [$1] not found"
+
+ echo -n "Installing rootfs, please wait..."
+ tar -xzf "$rootfs_source" -C "$1" >/dev/null 2>&1 && echo ok || die "tar -xzf \"$rootfs_source\" -C \"$1\" failed!"
+
+ echo -n "Syncing drives..."
+ sync
+ echo "done"
+
+ umount "$1"
+
+ echo "Press <ENTER> to bring up the altboot menu"
+ read junk </dev/tty0 >/dev/tty0 2>&1
+ exec /sbin/init.altboot -force
+
+}
+
+install_rootfs_image(){
+
+ mount | grep -q "$1 " || die "Installation target [$1] not mounted"
+
+ echo ""
+ echo "Please enter a name for the image file."
+ echo "Do not use the <space> character"
+ echo ""
+
+
+ while true
+ do
+ echo -n "Image name: "
+ read junk
+
+ if test -n "$junk"
+ then
+ echo -n "Use [$junk] as name? [Y|n] "
+ read junk2
+
+ case "$junk2" in
+ "Y"|"y"|"") rootfs_image_name="${junk}-rootfs.bin"
+ break ;;
+ *) echo "err ]$junk]";;
+ esac
+ fi
+ done
+
+ echo ""
+ echo "Please enter the image size in MegaBytes"
+ echo "Must be at least 50Mb"
+ echo ""
+
+ while true
+ do
+ echo -n "Image size: "
+ read junk
+
+ junk="`echo "$junk" | sed "s/[a-zA-Z]//g"`"
+
+ if test -n "$junk"
+ then
+ if test "$junk" -gt 1
+ then
+ echo -n "Is [${junk}Mb] correct? [Y|n] "
+ read junk2
+
+ case "$junk2" in
+ Y|y|"") rootfs_image_size="$junk"
+ break ;;
+ esac
+
+ else
+ echo "Image size of [${junk}Mb] is too small!"
+ fi
+ fi
+ done
+
+ test -z "$rootfs_image_name" -o -z "$rootfs_image_size" && die "DEBUG: Empty VAR in install_rootfs_image()"
+
+ echo ""
+ echo "Creating [$rootfs_image_name] (${rootfs_image_size}Mb) on [$1]"
+ echo "Please wait..."
+ mkdir -p "$1/boot-images"
+
+ ! test -e "$1/boot-images/$rootfs_image_name" && dd if=/dev/zero of="$1/boot-images/$rootfs_image_name" bs=1024k count=$rootfs_image_size >/dev/null
+
+ echo -n "Creating an ext2 filesystem on $rootfs_image_name..."
+ losetup /dev/loop0 "$1/boot-images/$rootfs_image_name" || die "losetup /dev/loop0 \"$1/boot-images/$rootfs_image_name\" failed!"
+ mkfs.ext2 -m0 /dev/loop0 >/dev/null 2>&1 && echo done || die "mkfs.ext2 -m0 /dev/loop0 failed!"
+
+ echo -n "Mounting loopfile..."
+ mkdir -p /media/image
+ mount /dev/loop0 /media/image && echo ok || die "mount /dev/loop0 /media/image failed!"
+
+ echo -n "Installing rootfs, please wait..."
+ tar -xzf "$rootfs_source" -C "/media/image" >/dev/null 2>&1 && echo ok || die "tar -xzf \"$rootfs_source\" -C \"$1\" failed!"
+
+ echo -n "Syncing drives..."
+ sync
+ echo "done"
+
+ umount "/media/image" && losetup -d /dev/loop0
+
+ echo "Press <ENTER> to bring up the altboot menu"
+ read junk </dev/tty0 >/dev/tty0 2>&1
+ exec /sbin/init.altboot -force
+
+}
+
+
+
+#run_module
+
+case "$1" in
+title) echo "$M_TITLE";;
+run) run_module "$2";;
+esac
diff --git a/packages/altboot/files/altboot.func b/packages/altboot/files/altboot.func
index ceee6abae2..5651ef9f9d 100644
--- a/packages/altboot/files/altboot.func
+++ b/packages/altboot/files/altboot.func
@@ -295,3 +295,88 @@ check_fs() {
fi
fi
}
+
+# Make the initial rootfs a bit more usable
+init_rootfs(){
+ 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"
+
+ mount | grep -q "/proc " >/dev/null 2>&1 && echo "Note: /proc is already mounted" || mount proc -t proc /proc >/dev/tty0 2>&1
+
+ if ( uname -r | grep -q "2.6." )
+ then
+ mount | grep -q "/sys " >/dev/null 2>&1 && echo "Note: /sys is already mounted" || mount sys -t sysfs /sys >/dev/tty0 2>&1
+ fi
+
+ echo -n "Generating device files..." >/dev/tty0
+ /etc/init.d/devices start && echo ok >/dev/tty0|| die "FAILED"
+}
+
+mount_sd(){
+ if mount | grep -q "/media/card "
+ then
+ echo "Note: /media/card is already mounted"
+ else
+ # We can't trust that the SD device file is there when running kernel 2.6 w/ udev
+ # and starting udev at this point may not be the best idea...
+ if `uname -r | grep -q "2.6"`
+ then
+ #Let's just assume the device file name never changes...
+ dev_no="`echo "$SD_DEVICE" | sed -n "s/\/dev\/mmcblk\(.*\)p\(.*\)/\1/p"`"
+ part_no="`echo "$SD_DEVICE" | sed -n "s/\/dev\/mmcblk\(.*\)p\(.*\)/\2/p"`"
+ ! test -e /dev/mmcblk${dev_no} && mknod /dev/mmcblk${dev_no} b 254 0
+ ! test -e /dev/mmcblk${dev_no}p${part_no} && mknod /dev/mmcblk${dev_no}p${part_no} b 254 $part_no
+ fi
+
+ # Kernel 2.6 has the SD driver compiled into the kernel
+ if test -n "$SD_KERNEL_MODULE"
+ then
+ echo -n "Loading SD kernel module..."
+ /sbin/insmod $SD_KERNEL_MODULE >/dev/null 2>&1 && echo ok || die "insmod failed"
+ else
+ echo "No SD kernel module configured, assuming it's build-in"
+ fi
+
+ check_fs "$SD_DEVICE"
+
+ 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"
+ fi
+ echo ""
+
+ # Give the SD and CF mounting some time. This is a must for SD
+ sleep 2
+}
+
+mount_cf(){
+ if mount | grep -q "/media/cf "
+ then
+ echo "Note: /media/cf is already mounted"
+ else
+ /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
+ fi
+}
+
+mount_home(){
+ if mount | grep -q "/home "
+ then
+ echo "Note: /home is already mounted"
+ else
+
+ if ( grep -q "/home " /etc/fstab )
+ then
+ echo "Mounting /home"
+ home_fstab="`grep "/home " /etc/fstab`"
+ home_dev="`echo "$home_fstab" | awk '{print $1}'`"
+ home_fs="`echo "$home_fstab" | awk '{print $3}'`"
+ home_options="`echo "$home_fstab" | awk '{print $4}'`"
+
+ mount -t "$home_fs" -o $home_options "$home_dev" /home
+ fi
+ fi
+}
diff --git a/packages/altboot/files/altboot.rc/disable_printk.sh b/packages/altboot/files/altboot.rc/disable_printk.sh
index 9d5f918c1e..af15adec44 100644
--- a/packages/altboot/files/altboot.rc/disable_printk.sh
+++ b/packages/altboot/files/altboot.rc/disable_printk.sh
@@ -1,4 +1,6 @@
-#!/bin/bash
+#!/bin/sh
+
+mount proc -t proc /proc >/dev/null 2>&1
echo 0 > /proc/sys/kernel/printk
diff --git a/packages/altboot/files/init.altboot b/packages/altboot/files/init.altboot
index cd8b6b8929..2ef804d99c 100644
--- a/packages/altboot/files/init.altboot
+++ b/packages/altboot/files/init.altboot
@@ -24,7 +24,6 @@ case "`uname -r`" in
ALTBOOT_CFG_FILE="/etc/altboot-2.6.cfg";;
esac
-echo "Using [${ALTBOOT_CFG_FILE}]"
test -e "$ALTBOOT_CFG_FILE" && . "$ALTBOOT_CFG_FILE" || echo "WARNING: No $ALTBOOT_CFG_FILE found! Check your installation of Altboot!" > /dev/tty1
C_RED="\033[31m"