From: Matthias Hentges Date: Mon, 8 Aug 2005 14:48:34 +0000 (+0000) Subject: altboot: Add 'Copy rootfs to SD/CF' menuitem. *NEEDS DEBUGGING*. Deactivated for... X-Git-Tag: Release-2010-05/1~9453^2~3946^2~18^2~1 X-Git-Url: https://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9fb2641bccd42f1000029d6829c8233de5233fe4;p=openembedded.git altboot: Add 'Copy rootfs to SD/CF' menuitem. *NEEDS DEBUGGING*. Deactivated for now. --- diff --git a/packages/altboot/files/altboot-menu/Advanced/80-copyrootfs b/packages/altboot/files/altboot-menu/Advanced/80-copyrootfs new file mode 100644 index 0000000000..bac366303c --- /dev/null +++ b/packages/altboot/files/altboot-menu/Advanced/80-copyrootfs @@ -0,0 +1,325 @@ +# !/bin/sh +M_TITLE="Copy rootfs to SD/CF" + +exit 0 + +die() { + echo "ERROR: $1" >/dev/tty0 + exec $SH_SHELL /dev/tty0 2>&1 +} + +ask_target() { + available_disks="`mount | grep "/media" | grep -v ram | awk '{print $3}'`" + + if test -z "$available_disks" + then + die "No mounted targets found!" + fi + + cnt=1 + for d in $available_disks + do + echo -e "\t[$cnt] $d" + let cnt=$cnt+1 + done + + while test -z "$ROOTFS_TARGET" + do + echo -n "Target: " + read junk /dev/null 2>&1 + then + echo -n "Use [$junk]MB? [y|n] " + read junk2 + if test "$junk2" = y + then + ROOTFS_IMAGE_SIZE="$junk" + fi + fi + done + + echo -e "\nPlease enter a name for the image file." + echo "The name must _not_ contain whitespaces or the '-' sign." + + while test -z "$ROOTFS_IMAGE_NAME" + do + echo -n "File name: " + read junk + + if ! test -z "$junk" + then + echo -n "Use [$junk] as image name? [y|n] " + read junk2 + + if test "$junk2" = y + then + ROOTFS_IMAGE_NAME="$junk" + fi + fi + done + + echo -e "\nDo you want to format [$ROOTFS_TARGET_DEV] to the ext2 filesystem?" + + while true + do + echo -n "Format to ext2? [y|n] " + read junk + case "$junk" in + y) format_target + break ;; + n) break ;; + esac + done + + /etc/init.d/devices start + + echo -en "\nCreating image file [$ROOTFS_TARGET/$IMAGE_PATH/$ROOTFS_IMAGE_NAME-rootfs.bin] (${ROOTFS_IMAGE_SIZE}MB)..." + mkdir -p "$ROOTFS_TARGET/$IMAGE_PATH" + + dd if=/dev/zero of="$ROOTFS_TARGET/$IMAGE_PATH/$ROOTFS_IMAGE_NAME-rootfs.bin" bs=1024k count=$ROOTFS_IMAGE_SIZE >/dev/null 2>&1 && echo ok || die "FAILED" + losetup /dev/loop1 "$ROOTFS_TARGET/$IMAGE_PATH/$ROOTFS_IMAGE_NAME-rootfs.bin" + + echo -n "Creating filesystem..." + mkfs.ext2 -m0 /dev/loop1 >/dev/null 2>&1 && echo ok || die FAILED + + mkdir -p /media/temp + mount /dev/loop1 /media/temp || die "mount /dev/loop1 /media/temo FAILED!" + + copy_files + +} + +copy_files() { + echo -e "\nCopying files..." + + exclude_list="tmp sys proc var dev media root" + mkdir_list="var proc sys dev media/card media/cf /media/hdd" + + if (cat /etc/fstab | grep -q "/home") + then + echo "Note: /home appears to be mounted on a different flash partition: not copying /home" + exclude_list="$exclude_list home" + mkdir_list="$mkdir_list home/root" + + fi + + + + source_dirs="`ls -1 /`" + + echo -n "Excluding [" + for d in $exclude_list + do + echo -n "$d " + source_dirs="`echo "$source_dirs" | grep -v "$d"`" + done + echo "] from copy" + + + cd / + for dir in $source_dirs + do + if test -d "$dir" + then + echo -n "Copying [$dir]..." + cp -a $dir /media/temp && echo ok || echo FAILED + fi + done + + for dir in $mkdir_list + do + mkdir -p /media/temp/$dir + done + + rm /media/temp/etc/rcS.s/S39sd + +} +run_module() { + + test -e /etc/altboot.func && . /etc/altboot.func || die "ERROR: /etc/altboot.func not found. Check your installation!" + + echo -e "${C_RED}* * * * * WARNING * * * * *${C_RESET}" + echo -e "${C_RED}Continueing will delete the content of the selected target device.\nTHIS IS NO JOKE. If you do now know what this menu-item does, exit NOW${C_RESET}" + + mount -o remount,rw / + + while true + do + echo -en "\nContinue? [y|n] " + read junk /dev/null 2>&1 && echo ok || echo "FAILED" +# +# echo -n "Trying to mount SD card..." +# /etc/init.d/sd start >/dev/null 2>&1 +# sleep 3 +# /etc/sdcontrol insert >/dev/null 2>&1 && echo ok || echo "FAILED" + + #exit 0 + echo -e "\nPlease select the target device:" + + # Sets ROOTFS_TARGET* + ask_target + + # Sets ROOTFS_TARGET_TYPE ([direct | image] + ask_format + + # Ask confirmation + ask_confirm + + case "$ROOTFS_TARGET_TYPE" in + direct) direct_install;; + image) image_install;; + esac +} + +case "$1" in +title) echo "$M_TITLE";; +run) run_module;; +esac diff --git a/packages/altboot/files/init.altboot b/packages/altboot/files/init.altboot index d9443c568e..57560b8326 100644 --- a/packages/altboot/files/init.altboot +++ b/packages/altboot/files/init.altboot @@ -252,7 +252,7 @@ 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` + for file in `ls -1 /etc/altboot.rc/*.sh` >/dev/null 2>&1 do . $file >/dev/tty1 2>&1 || echo "/etc/altboot.rc/$file failed!" done