diff options
-rw-r--r-- | packages/altboot/altboot.bb | 2 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/15-bootSD | 38 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/20-bootCF | 18 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/99-ownScripts-example | 11 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/Advanced/30-bootUSB-Stick | 7 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/Advanced/40-bootNFS | 10 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/Advanced/55-bin-sh | 6 | ||||
-rw-r--r-- | packages/altboot/files/altboot-menu/Advanced/70-install-tgz | 229 | ||||
-rw-r--r-- | packages/altboot/files/altboot.func | 85 |
9 files changed, 330 insertions, 76 deletions
diff --git a/packages/altboot/altboot.bb b/packages/altboot/altboot.bb index 0a349c62d8..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 = "r17" +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 baa85a7cf7..7123491000 100644 --- a/packages/altboot/files/altboot-menu/15-bootSD +++ b/packages/altboot/files/altboot-menu/15-bootSD @@ -17,43 +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" + # Mount /proc, etc + init_rootfs - mount proc -t proc /proc >/dev/tty0 2>&1 + mount_sd - echo -n "Generating device files..." >/dev/tty0 - /etc/init.d/devices start && echo ok >/dev/tty0|| die "FAILED" - - # 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 7279ba66ee..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 >/dev/null 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 90a6f37ff5..4619e51ce7 100644 --- a/packages/altboot/files/altboot-menu/Advanced/55-bin-sh +++ b/packages/altboot/files/altboot-menu/Advanced/55-bin-sh @@ -8,10 +8,8 @@ run_module() { test "$ASK_PW_ON_BOOT" != "yes" && verify_master_pw >/dev/tty0 - # Make the system a little bit more usable than a standard init=/bin/sh boot - mount -t proc proc /proc >/dev/null 2>&1 - uname -r | grep -q "2.6." && mount sys -t sysfs /sys - mount -o remount,rw / + # Mount /proc, etc + init_rootfs echo -e "\nBoot system with 'exec /sbin/init 5'\n" while true 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..612d875a9a 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_fstan" | awk '{print $4}'`" + + mount -t "$home_fs" -o $home_options "$home_dev" /home + fi + fi +} |