wok-current annotate busybox-boot/receipt @ rev 15782

busybox-boot: bump
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Jan 13 00:14:46 2014 +0100 (2014-01-13)
parents 8b2948ea66be
children bf783a1bf96f
rev   line source
pascal@13591 1 # SliTaz package receipt.
pascal@13591 2
pascal@13591 3 PACKAGE="busybox-boot"
pascal@15734 4 VERSION="1.22.0"
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@15782 18 mkdir -p $fs/usr/share/boot/bin $fs/usr/share/boot/dev
pascal@13591 19 jslinux=false
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@15760 47 if [ -d /etc ]; then
pascal@15760 48 [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
pascal@15760 49 for i in \$dns ; do echo nameserver \$i; done >> /etc/resolv.conf
pascal@15527 50 [ -n "\$broadcast" ] && BROADCAST="broadcast \$broadcast"
pascal@15527 51 [ -n "\$subnet" ] && NETMASK="netmask \$subnet"
pascal@15760 52 if ifconfig \$interface \${ip:-0.0.0.0} \$BROADCAST \$NETMASK ; then
pascal@15760 53 while route del default gw 0.0.0.0 dev \$interface ; do : ; done
pascal@15760 54 for i in \$router ; do route add default gw \$i dev \$interface; done
pascal@15760 55 fi
pascal@15760 56 exit
pascal@15527 57 fi
pascal@15527 58
pascal@15527 59 mkdir /tmp /mnt /proc /etc
pascal@13591 60 mount -t proc none /proc
pascal@13895 61 while read name major minor ; do
pascal@13895 62 for i in '' 1 2 3 4 5 6 7 8 9 ; do
pascal@13895 63 mknod -m 644 /dev/\$name\$i b \$major \$((\$i + \$minor))
pascal@13895 64 done
pascal@13895 65 done <<EOM
pascal@13895 66 loop 7 0
pascal@13895 67 hda 3 0
pascal@13895 68 hdb 3 64
pascal@15531 69 hdc 22 0
pascal@15531 70 hdd 22 64
pascal@13895 71 sda 8 0
pascal@13895 72 sdb 8 16
pascal@15531 73 sdc 8 32
pascal@15531 74 sdd 8 48
pascal@13895 75 EOM
pascal@13879 76
pascal@13879 77 arg()
pascal@13879 78 {
pascal@15527 79 root="\$(sed "s/^/ /;s/\$/ /;/ \$1=/!d;s/.* \$1=\\([^ ]*\\).*/\\1/" </proc/cmdline)"
pascal@15527 80 busybox [ -n "\$root" ]
pascal@13879 81 }
pascal@13879 82
pascal@15527 83 arg init
pascal@15527 84 init=\${root:-/sbin/init}
pascal@15530 85 [ -n "\$(sed 's/\$/ /;s/^/ /;/ ro /!d' /proc/cmdline)" ] && ro="-o ro"
pascal@15530 86 [ -n "\$(sed 's/\$/ /;s/^/ /;/ rw /!d' /proc/cmdline)" ] && ro="-o rw"
pascal@15527 87 arg root && root="\$(echo \$root | sed 's|/|\\\\/|g')" &&
pascal@15530 88 mount \$ro \$(busybox blkid | sed "s/\"//g;/\$root/!d;s/:.*//;q") /mnt
pascal@15527 89 arg loopfs && busybox losetup /dev/loop /mnt/\$root && mount /dev/loop /mnt
pascal@13882 90 arg subroot && cp /bin/busybox /mnt/\$root/dev/shm &&
pascal@15527 91 chroot="\$root/dev/shm/busybox chroot \$root"
pascal@15527 92 busybox [ -x /mnt/\$root\$init ] && exec busybox switch_root mnt \$chroot \$init
pascal@15527 93
pascal@15530 94 for i in \$(busybox --list) ; do ln /bin/busybox /bin/\$i 2> /dev/null ; done
pascal@13879 95
pascal@13591 96 [ -d /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb
pascal@13895 97 while read type dir ; do
pascal@15531 98 grep -qs \$type /proc/filesystems || continue
pascal@15531 99 mkdir \$dir
pascal@15531 100 mount -t \$type none \$dir
pascal@13895 101 done <<EOM
pascal@15531 102 sysfs /sys
pascal@15531 103 devtmpfs /dev
pascal@15531 104 devpts /dev/pts
pascal@13895 105 EOM
pascal@13591 106
pascal@13591 107 TTY=\$(tty 2>/dev/null)
pascal@13591 108 TTY=\${TTY:-/dev/tty1}
pascal@13591 109 EOT
pascal@14753 110 $jslinux && echo 'stty -F $TTY rows 30 2>/dev/null' >> $fs/usr/share/boot/init
pascal@14753 111 cat >> $fs/usr/share/boot/init <<EOT
pascal@13591 112
pascal@15527 113 [ -x /bin/udhcpc ] && udhcpc -b -s /init
pascal@13591 114 while true; do
pascal@14756 115 busybox | sed '/Current/,\$!d'
pascal@13591 116 if [ -x /bin/setsid ]; then
pascal@13591 117 setsid sh -c "exec sh <\$TTY >\$TTY 2>&1"
pascal@13591 118 else
pascal@13591 119 sh <\$TTY >\$TTY 2>&1
pascal@13591 120 fi
pascal@13591 121 done
pascal@13591 122 EOT
pascal@14751 123 chmod +x $fs/usr/share/boot/init
pascal@14753 124 ( cd $fs/usr/share/boot ; find bin dev init | cpio -o -H newc > initrd )
pascal@14751 125 rm -rf $fs/usr/share/boot/bin $fs/usr/share/boot/dev $fs/usr/share/boot/init
pascal@13591 126 }