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