wok view busybox-boot/receipt @ rev 16182

Add gweled
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Mar 30 16:56:33 2014 +0000 (2014-03-30)
parents a248ba6ee79d
children 6bc472de003f
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/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 while read name major minor ; do
62 for i in '' 1 2 3 4 5 6 7 8 9 ; do
63 mknod -m 644 /dev/\$name\$i b \$major \$((\$i + \$minor))
64 done
65 done <<EOM
66 loop 7 0
67 hda 3 0
68 hdb 3 64
69 hdc 22 0
70 hdd 22 64
71 sda 8 0
72 sdb 8 16
73 sdc 8 32
74 sdd 8 48
75 EOM
77 arg()
78 {
79 root="\$(sed "s/^/ /;s/\$/ /;/ \$1=/!d;s/.* \$1=\\([^ ]*\\).*/\\1/" </proc/cmdline)"
80 busybox [ -n "\$root" ]
81 }
83 arg init
84 init=\${root:-/sbin/init}
85 [ -n "\$(sed 's/\$/ /;s/^/ /;/ ro /!d' /proc/cmdline)" ] && ro="-o ro"
86 [ -n "\$(sed 's/\$/ /;s/^/ /;/ rw /!d' /proc/cmdline)" ] && ro="-o rw"
87 arg root && root="\$(echo \$root | sed 's|/|\\\\/|g')" &&
88 mount \$ro \$(busybox blkid | sed "s/\"//g;/\$root/!d;s/:.*//;q") /mnt
89 arg loopfs && busybox losetup /dev/loop /mnt/\$root && mount /dev/loop /mnt
90 arg subroot && cp /bin/busybox /mnt/\$root/dev/shm &&
91 chroot="\$root/dev/shm/busybox chroot \$root"
92 busybox [ -x /mnt/\$root\$init ] && exec busybox switch_root mnt \$chroot \$init
94 for i in \$(busybox --list) ; do ln /bin/busybox /bin/\$i 2> /dev/null ; done
96 [ -d /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb
97 while read type dir ; do
98 grep -qs \$type /proc/filesystems || continue
99 mkdir \$dir
100 mount -t \$type none \$dir
101 done <<EOM
102 sysfs /sys
103 devtmpfs /dev
104 devpts /dev/pts
105 EOM
107 TTY=\$(tty 2>/dev/null)
108 TTY=\${TTY:-/dev/tty1}
109 EOT
110 $jslinux && echo 'stty -F $TTY rows 30 2>/dev/null' >> $fs/usr/share/boot/init
111 cat >> $fs/usr/share/boot/init <<EOT
113 [ -x /bin/udhcpc ] && udhcpc -b -s /init
114 while true; do
115 busybox | sed '/Current/,\$!d'
116 if [ -x /bin/setsid ]; then
117 setsid sh -c "exec sh <\$TTY >\$TTY 2>&1"
118 else
119 sh <\$TTY >\$TTY 2>&1
120 fi
121 done
122 EOT
123 chmod +x $fs/usr/share/boot/init
124 ( cd $fs/usr/share/boot ; find bin dev init | cpio -o -H newc > initrd )
125 rm -rf $fs/usr/share/boot/bin $fs/usr/share/boot/dev $fs/usr/share/boot/init
126 }