CRUX-ARM : Home

Home :: Documentation :: Download :: Development :: Community :: Ports :: Packages :: Bugs :: Links :: About :: Donors
Synced changes with initramfs.git
[initrd.git] / filesystem / rc
index 2d023e17165dad7edacd4f7b892fa95ff6d192f4..5b19485074f12bd0241557687dfbffec0b4452d4 100755 (executable)
@@ -30,9 +30,8 @@ checkReturn() {
 # and prepare /newroot for switch_root at the end of the script
 find_and_mount_media() {
        echo -e " ${BOLD}${BLUE}*${NORM} Searching for the CRUX media..."
-       mkdir /media
-       CRUXMEDIA=""
-       MMC_DEVICES="`grep -E 'mmcblk' /proc/partitions | awk '{ print $4 }'`"
+       mkdir -p /media
+       MMC_DEVICES="`grep -E 'mmcblk0p' /proc/partitions | awk '{ print $4 }'`"
        BLOCK_DEVICES="`grep -E '[sh]d' /proc/partitions | awk '{ print $4 }'`"
        for DEV in $MMC_DEVICES $BLOCK_DEVICES
        do
@@ -44,7 +43,6 @@ find_and_mount_media() {
                        if [ -e /media/crux-media ]
                        then
                                echo ", CRUX media."
-                               CRUXMEDIA=$DEV
                                ln -s $DEV /dev/media
                                break
                        else
@@ -78,15 +76,19 @@ find_and_mount_media() {
                echo " found and installation will not continue."
                echo
        else
-               # configure for modules
-               MODULES_DIR="`find /media/crux/kernel -type d -name 'modules-*'`"
-               if [ ! -z "$MODULES_DIR" ]; then
-                       ln -sf $MODULES_DIR/lib/modules /lib
+               # configure modules
+               MODULES="`find /media/crux/kernel -type f -name 'modules-*.tar.*' 2>/dev/null`"
+               if [ ! -z "$MODULES" ]; then
+                       tar -C /tmp -xf $MODULES
+                       cd /lib && ln -s /tmp/lib/* .
                        depmod
                fi
-               # configure the setup script
-               if [ -e /media/crux/setup ]; then
-                       ln -sf /media/crux/setup /bin/setup
+               # configure pkgutils
+               PKGUTILS="`find /media/crux/core -type f -name 'pkgutils#*.pkg.tar.*' 2>/dev/null`"
+               if [ ! -z "$PKGUTILS" ]; then
+                       tar -C /tmp -xf $PKGUTILS
+                       cd /usr/bin && ln -s /tmp/usr/bin/* .
+                       cd /etc && ln -s /tmp/etc/* .
                fi
        fi
 }
@@ -96,13 +98,34 @@ find_and_mount_media() {
 #
 
 echo ""
-echo -e "${BOLD}CRUX-ARM 2.7 - ${BLUE}http://crux-arm.nu/${NORM}"
+echo -e "${BOLD}CRUX-ARM 3.0 - ${BLUE}http://crux-arm.nu/${NORM}"
 echo ""
 
 exec >/dev/console </dev/console 2>&1
 
+# premature mount /proc since we need some rw operations
+echo -e -n " ${BOLD}${BLUE}*${NORM} Mounting "
+echo -e -n "${BOLD}${GREEN}/proc${NORM}"
+mount -t proc proc /proc
+
+if grep -q "debug" /proc/cmdline
+then
+       DEBUG=1
+fi
+
+# dont show kernel printk messages
+PRINTK="`cat /proc/sys/kernel/printk`"
+if [ -z $DEBUG ]
+then
+       echo "0" > /proc/sys/kernel/printk
+fi
+
+echo -e ", ${BOLD}${GREEN}/sys${NORM}."
+mount -t sysfs sysfs /sys
+
 echo -e -n " ${BOLD}${BLUE}*${NORM} Mounting filesystems... "
-mount -v -a && mount -o remount,rw /
+mount -a && \
+mount -o remount,rw /
 checkReturn
 
 echo -e -n " ${BOLD}${BLUE}*${NORM} Populating /dev via mdev... "
@@ -127,10 +150,8 @@ hostname crux
 checkReturn
 
 echo -e -n " ${BOLD}${BLUE}*${NORM} Loading network loopback device... "
-ip addr add 127.0.0.1/8 dev lo broadcast + scope host
-checkReturn
-ip link set lo up
-checkReturn
+ip addr add 127.0.0.1/8 dev lo broadcast + scope host && \
+ip link set lo up && \
 echo "127.0.0.1 localhost crux" > /etc/hosts
 checkReturn
 
@@ -138,11 +159,28 @@ echo -e -n " ${BOLD}${BLUE}*${NORM} Saving boot messages... "
 dmesg > /var/log/boot
 checkReturn
 
-echo -e -n " ${BOLD}${BLUE}*${NORM} Trying to find and mount the media installer... "
+# run mdev again to fix issues with mmc devices. yeah, it is weird but worked
+mdev -s
+
+echo -e " ${BOLD}${BLUE}*${NORM} Trying to find and mount the media installer..."
 find_and_mount_media
 
+# debug could be necessary when are working with a new device and/or features
+# and for a weird reason you can't see any output message on the console.
+# You can create a debug.sh script at topdir of your install media and redirect
+# the output to a file to inspect later
+if [ ! -z $DEBUG ];
+then
+       echo -e -n " ${BOLD}${BLUE}*${NORM} Loading debug script..."
+       /media/debug.sh
+       checkReturn
+fi
+
 echo
 echo "The system is coming up. Please wait."
 echo
 
+# restore kernel printk status
+echo "$PRINTK" > /proc/sys/kernel/printk
+
 # End of file