wok view busybox-boot/receipt @ rev 17836

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