wok-6.x annotate busybox-boot/receipt @ rev 15527
busybox-root: fix root=device|UUID|LABEL cmdline
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Nov 21 11:34:23 2013 +0000 (2013-11-21) |
parents | a4254bd509cd |
children | 2ecc1cd5a9a4 |
rev | line source |
---|---|
pascal@13591 | 1 # SliTaz package receipt. |
pascal@13591 | 2 |
pascal@13591 | 3 PACKAGE="busybox-boot" |
pascal@14770 | 4 VERSION="1.21.1" |
pascal@13591 | 5 CATEGORY="base-system" |
pascal@13591 | 6 SHORT_DESC="Many common UNIX utilities for core-5in1/boot flavor." |
pascal@13591 | 7 MAINTAINER="pascal.bellard@slitaz.org" |
pascal@14657 | 8 LICENSE="GPL2" |
pascal@13591 | 9 DEPENDS="linux syslinux" |
pascal@13591 | 10 WANTED="busybox" |
pascal@13591 | 11 WEB_SITE="http://www.busybox.net/" |
pascal@13591 | 12 CONFIG_FILES="" |
pascal@13591 | 13 |
pascal@13591 | 14 # Rules to gen a SliTaz package suitable for Tazpkg. |
pascal@13591 | 15 genpkg_rules() |
pascal@13591 | 16 { |
pascal@13591 | 17 jslinux=false |
pascal@14752 | 18 mkdir -p $fs/usr/share/boot/bin $fs/usr/share/boot/dev |
pascal@14750 | 19 CHOICE=static |
pascal@14750 | 20 for i in uclibc musl diet ; do |
pascal@14750 | 21 [ -x $src/busybox-$i ] || continue |
pascal@14750 | 22 [ $(stat -c %s $src/busybox-$i) -lt \ |
pascal@14750 | 23 $(stat -c %s $src/busybox-$CHOICE) ] && |
pascal@14750 | 24 CHOICE=$i |
pascal@14750 | 25 done |
pascal@14751 | 26 cp -a $src/busybox-$CHOICE $fs/usr/share/boot/bin/busybox |
pascal@14751 | 27 chmod 4755 $fs/usr/share/boot/bin/busybox |
pascal@15527 | 28 for i in sed mount mknod mkdir sh cp ln ; do |
pascal@15527 | 29 ln $fs/usr/share/boot/bin/busybox $fs/usr/share/boot/bin/$i |
pascal@15527 | 30 done |
pascal@14751 | 31 mknod -m 660 $fs/usr/share/boot/dev/console c 5 1 |
pascal@14751 | 32 mknod -m 771 $fs/usr/share/boot/dev/null c 1 3 |
pascal@14751 | 33 mknod -m 660 $fs/usr/share/boot/dev/tty c 5 0 |
pascal@14751 | 34 mknod -m 660 $fs/usr/share/boot/dev/tty1 c 4 1 |
pascal@13591 | 35 if $jslinux; then |
pascal@14751 | 36 mknod -m 644 $fs/usr/share/boot/dev/clipboard c 10 231 |
pascal@14751 | 37 mknod -m 660 $fs/usr/share/boot/dev/ttyS0 c 4 64 |
pascal@13591 | 38 fi |
pascal@14751 | 39 cat > $fs/usr/share/boot/init <<EOT |
pascal@15527 | 40 #!/bin/sh |
pascal@13591 | 41 |
pascal@13591 | 42 export PATH=/bin |
pascal@13591 | 43 export HOME=/ |
pascal@13591 | 44 export TERM=vt100 |
pascal@13591 | 45 |
pascal@15527 | 46 if [ -n "\$1" ]; then |
pascal@15527 | 47 [ -n "\$broadcast" ] && BROADCAST="broadcast \$broadcast" |
pascal@15527 | 48 [ -n "\$subnet" ] && NETMASK="netmask \$subnet" |
pascal@15527 | 49 ifconfig \$interface \${ip:-0.0.0.0} \$BROADCAST \$NETMASK |
pascal@15527 | 50 while route del default gw 0.0.0.0 dev \$interface ; do : ; done |
pascal@15527 | 51 for i in \$router ; do route add default gw \$i dev \$interface; done |
pascal@15527 | 52 [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf |
pascal@15527 | 53 for i in \$dns ; do echo nameserver \$i; done >> /etc/resolv.conf |
pascal@15527 | 54 exit 0 |
pascal@15527 | 55 fi |
pascal@15527 | 56 |
pascal@15527 | 57 mkdir /tmp /mnt /proc /etc |
pascal@13591 | 58 mount -t proc none /proc |
pascal@13895 | 59 while read name major minor ; do |
pascal@13895 | 60 for i in '' 1 2 3 4 5 6 7 8 9 ; do |
pascal@13895 | 61 mknod -m 644 /dev/\$name\$i b \$major \$((\$i + \$minor)) |
pascal@13895 | 62 done |
pascal@13895 | 63 done <<EOM |
pascal@13895 | 64 loop 7 0 |
pascal@13895 | 65 hda 3 0 |
pascal@13895 | 66 hdb 3 64 |
pascal@13895 | 67 sda 8 0 |
pascal@13895 | 68 sdb 8 16 |
pascal@13895 | 69 EOM |
pascal@13879 | 70 |
pascal@13879 | 71 arg() |
pascal@13879 | 72 { |
pascal@15527 | 73 root="\$(sed "s/^/ /;s/\$/ /;/ \$1=/!d;s/.* \$1=\\([^ ]*\\).*/\\1/" </proc/cmdline)" |
pascal@15527 | 74 busybox [ -n "\$root" ] |
pascal@13879 | 75 } |
pascal@13879 | 76 |
pascal@15527 | 77 arg init |
pascal@15527 | 78 init=\${root:-/sbin/init} |
pascal@15527 | 79 arg root && root="\$(echo \$root | sed 's|/|\\\\/|g')" && |
pascal@15527 | 80 mount \$(busybox blkid | sed "s/\"//g;/\$root/!d;s/:.*//;q") /mnt |
pascal@15527 | 81 arg loopfs && busybox losetup /dev/loop /mnt/\$root && mount /dev/loop /mnt |
pascal@13882 | 82 arg subroot && cp /bin/busybox /mnt/\$root/dev/shm && |
pascal@15527 | 83 chroot="\$root/dev/shm/busybox chroot \$root" |
pascal@15527 | 84 busybox [ -x /mnt/\$root\$init ] && exec busybox switch_root mnt \$chroot \$init |
pascal@15527 | 85 |
pascal@15527 | 86 for i in \$(busybox --list) ; do busybox ln /bin/busybox /bin/\$i; done |
pascal@13879 | 87 |
pascal@13591 | 88 [ -d /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb |
pascal@13895 | 89 while read type dir ; do |
pascal@13895 | 90 grep -qs \$type /proc/filesystems && |
pascal@13895 | 91 mkdir \$dir && mount -t \$type none \$dir |
pascal@13895 | 92 done <<EOM |
pascal@13895 | 93 sysfs /sys |
pascal@13895 | 94 devpts /dev/pts |
pascal@13895 | 95 EOM |
pascal@13591 | 96 |
pascal@13591 | 97 TTY=\$(tty 2>/dev/null) |
pascal@13591 | 98 TTY=\${TTY:-/dev/tty1} |
pascal@13591 | 99 EOT |
pascal@14753 | 100 $jslinux && echo 'stty -F $TTY rows 30 2>/dev/null' >> $fs/usr/share/boot/init |
pascal@14753 | 101 cat >> $fs/usr/share/boot/init <<EOT |
pascal@13591 | 102 |
pascal@15527 | 103 [ -x /bin/udhcpc ] && udhcpc -b -s /init |
pascal@13591 | 104 while true; do |
pascal@14756 | 105 busybox | sed '/Current/,\$!d' |
pascal@13591 | 106 if [ -x /bin/setsid ]; then |
pascal@13591 | 107 setsid sh -c "exec sh <\$TTY >\$TTY 2>&1" |
pascal@13591 | 108 else |
pascal@13591 | 109 sh <\$TTY >\$TTY 2>&1 |
pascal@13591 | 110 fi |
pascal@13591 | 111 done |
pascal@13591 | 112 EOT |
pascal@14751 | 113 chmod +x $fs/usr/share/boot/init |
pascal@14753 | 114 ( cd $fs/usr/share/boot ; find bin dev init | cpio -o -H newc > initrd ) |
pascal@14751 | 115 rm -rf $fs/usr/share/boot/bin $fs/usr/share/boot/dev $fs/usr/share/boot/init |
pascal@13591 | 116 } |