slitaz-arm rev 216
piboot: berryboot compatible
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Mon Feb 06 18:44:20 2017 +0100 (2017-02-06) |
parents | 4e7726c49011 |
children | 3d01fa704e91 |
files | rpi/piboot |
line diff
1.1 --- a/rpi/piboot Fri Jan 27 11:50:44 2017 +0100 1.2 +++ b/rpi/piboot Mon Feb 06 18:44:20 2017 +0100 1.3 @@ -2,7 +2,7 @@ 1.4 # 1.5 # /sbin/piboot: SliTaz Raspberry Pi bootloader and web boot! 1.6 # 1.7 -# (C) 2014-2016 SliTaz GNU/Linux - ... 1.8 +# (C) 2014-2017 SliTaz GNU/Linux - ... 1.9 # 1.10 # usage: insert 'rdinit=/sbin/piboot' (if you load an initramfs) 1.11 # or 'init=/sbin/piboot' in the kernel command line /boot/cmdline.txt 1.12 @@ -119,7 +119,9 @@ 1.13 for url in ${webpath//,/ }; do 1.14 wget -O /root/webboot.sh "$url?mac=$(cat \ 1.15 /sys/class/net/eth0/address /sys/class/net/*/address \ 1.16 - | sed q)" 2>&1 > /dev/null 1.17 + | sed q)&serial=$(sed '/Serial/!d;s/.*: //' \ 1.18 + /proc/cpuinfo)&cpu=$(sed '/Hardware/!d;s/.*: //' \ 1.19 + /proc/cpuinfo)" 2>&1 > /dev/null 1.20 [ -s /root/webboot.sh ] || continue 1.21 . /root/webboot.sh 1.22 webprefix=$(dirname $url) 1.23 @@ -161,11 +163,14 @@ 1.24 1.25 mount -t proc proc /proc 1.26 mount -t sysfs sys /sys 1.27 -BOOTDEV=$(cmdlinearg bootdev) 1.28 -mnt=/mnt 1.29 -mount -t devtmpfs /dev /dev 1.30 -mount -r /dev/${BOOTDEV:-mmcblk0p1} $mnt 1.31 -umount /dev 1.32 +mnt=$PWD 1.33 +if [ ! -s "$mnt/menu.txt" ]; then 1.34 + BOOTDEV=$(cmdlinearg bootdev) 1.35 + mnt=/mnt 1.36 + mount -t devtmpfs /dev /dev 1.37 + mount -r /dev/${BOOTDEV:-mmcblk0p1} $mnt 1.38 + umount /dev 1.39 +fi 1.40 1.41 1.42 # Get global variables 1.43 @@ -311,13 +316,13 @@ 1.44 ( cd /media ; cpio -idmu ) 1.45 rm -f /rootfs 1.46 else 1.47 - n=$(stat -c %s /rootfs) 1.48 - n=$(($n % 4)) 1.49 + n=$(($(ls -l /rootfs | awk '{ print $5 }') % 4)) 1.50 [ $n -ne 0 ] && 1.51 dd if=/dev/zero bs=1 count=$((4 - $n)) >> /rootfs 1.52 fi 2> /dev/null 1.53 done 1.54 1.55 + cd / 1.56 if ! kexec -u 2> /dev/null; then 1.57 umount $mnt 1.58 ROOTDIR=$(cmdvararg "subroot") 1.59 @@ -338,7 +343,7 @@ 1.60 INIT=${RDINIT:-/init} 1.61 mnt=/media 1.62 for i in $(seq 2 5); do 1.63 - mount -r /dev/mmcblk0p$i /tmp || continue 1.64 + mount -r /dev/mmcblk0p$i /tmp 2> /dev/null || continue 1.65 echo "Get modules from /dev/mmcblk0p$i" 1.66 cp -a /tmp/lib/modules /tmp/lib/firmware \ 1.67 $mnt/$ROOTDIR/lib || 1.68 @@ -359,7 +364,7 @@ 1.69 export LD_LIBRARY_PATH=/$TMPDIR:/lib 1.70 KEXEC="exec /sbin/switch_root $mnt $CHROOT $ROOTDIR/ $INIT" 1.71 fi 1.72 - stat $mnt/$ROOTDIR/$INIT > /dev/null || KEXEC="echo 'No $ROOTDIR/$INIT'" 1.73 + [ -s $mnt/$ROOTDIR/$INIT ] || KEXEC="echo 'No $ROOTDIR/$INIT'" 1.74 else 1.75 echo "Loading $(basename $KERNEL)" 1.76 web_get $KEYWORD/$KERNEL /vmlinuz