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