wok view busybox-boot/receipt @ rev 17049

busyboot-boot: use devtmpfs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 20 16:27:39 2014 +0200 (2014-08-20)
parents 6bc472de003f
children d303e26dcea3
line source
1 # SliTaz package receipt.
3 PACKAGE="busybox-boot"
4 VERSION="1.22.1"
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 for i in sed mount mknod mkdir sh cp ln ; do
30 ln $fs/usr/share/boot/bin/busybox $fs/usr/share/boot/bin/$i
31 done
32 mknod -m 660 $fs/usr/share/boot/dev/console c 5 1
33 mknod -m 771 $fs/usr/share/boot/dev/null c 1 3
34 mknod -m 660 $fs/usr/share/boot/dev/tty c 5 0
35 mknod -m 660 $fs/usr/share/boot/dev/tty1 c 4 1
36 if $jslinux; then
37 mknod -m 644 $fs/usr/share/boot/dev/clipboard c 10 231
38 mknod -m 660 $fs/usr/share/boot/dev/ttyS0 c 4 64
39 fi
40 cat > $fs/usr/share/boot/init <<EOT
41 #!/bin/busybox sh
43 export PATH=/bin
44 export HOME=/
45 export TERM=vt100
47 if [ -d /etc ]; then
48 [ -n "\$domain" ] && echo search \$domain > /etc/resolv.conf
49 for i in \$dns ; do echo nameserver \$i; done >> /etc/resolv.conf
50 [ -n "\$broadcast" ] && BROADCAST="broadcast \$broadcast"
51 [ -n "\$subnet" ] && NETMASK="netmask \$subnet"
52 if ifconfig \$interface \${ip:-0.0.0.0} \$BROADCAST \$NETMASK ; then
53 while route del default gw 0.0.0.0 dev \$interface ; do : ; done
54 for i in \$router ; do route add default gw \$i dev \$interface; done
55 fi
56 exit
57 fi
59 mkdir /tmp /mnt /proc /etc
60 mount -t proc none /proc
61 mount -t devtmpfs none /dev
63 arg()
64 {
65 root="\$(sed "s/^/ /;s/\$/ /;/ \$1=/!d;s/.* \$1=\\([^ ]*\\).*/\\1/" </proc/cmdline)"
66 busybox [ -n "\$root" ]
67 }
69 arg init
70 init=\${root:-/sbin/init}
71 [ -n "\$(sed 's/\$/ /;s/^/ /;/ ro /!d' /proc/cmdline)" ] && ro="-o ro"
72 [ -n "\$(sed 's/\$/ /;s/^/ /;/ rw /!d' /proc/cmdline)" ] && ro="-o rw"
73 arg root && root="\$(echo \$root | sed 's|/|\\\\/|g')" &&
74 root="\$(busybox blkid | sed "s/\"//g;/\$root/!d;s/:.*//;q")" &&
75 [ -n "\$root" ] && mount \$ro \$root /mnt
76 arg loopfs && busybox losetup /dev/loop0 /mnt/\$root && mount /dev/loop0 /mnt
77 arg subroot && cp /bin/busybox /mnt/\$root/dev/shm &&
78 chroot="\$root/dev/shm/busybox chroot \$root"
79 busybox [ -x /mnt/\$root/\$init ] && umount /dev && umount /proc && exec busybox switch_root mnt \$chroot \$init
81 [ -d /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb
82 while read type dir ; do
83 grep -qs \$type /proc/filesystems || continue
84 [ -d "\$dir" ] || mkdir \$dir
85 mount -t \$type none \$dir
86 done <<EOM
87 sysfs /sys
88 devpts /dev/pts
89 EOM
91 TTY=\$(tty 2>/dev/null)
92 TTY=\${TTY:-/dev/tty1}
93 EOT
94 $jslinux && echo 'stty -F $TTY rows 30 2>/dev/null' >> $fs/usr/share/boot/init
95 cat >> $fs/usr/share/boot/init <<EOT
97 udhcpc -b -s /init
98 while true; do
99 busybox | sed '/Current/,\$!d'
100 setsid sh -c "exec sh <\$TTY >\$TTY 2>&1"
101 done
102 EOT
103 chmod +x $fs/usr/share/boot/init
104 ( cd $fs/usr/share/boot ; find bin dev init | cpio -o -H newc > initrd )
105 rm -rf $fs/usr/share/boot/bin $fs/usr/share/boot/dev $fs/usr/share/boot/init
106 }