wok-6.x annotate busybox-boot/receipt @ rev 13883

busybox-boot: boot with loopfs= cmdline arg
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jan 17 16:09:53 2013 +0100 (2013-01-17)
parents be782e714030
children a0759293a0ca
rev   line source
pascal@13591 1 # SliTaz package receipt.
pascal@13591 2
pascal@13591 3 PACKAGE="busybox-boot"
pascal@13591 4 VERSION="1.20.2"
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@13591 8 DEPENDS="linux syslinux"
pascal@13591 9 WANTED="busybox"
pascal@13591 10 WEB_SITE="http://www.busybox.net/"
pascal@13591 11 CONFIG_FILES=""
pascal@13591 12
pascal@13591 13 # Rules to gen a SliTaz package suitable for Tazpkg.
pascal@13591 14 genpkg_rules()
pascal@13591 15 {
pascal@13591 16 jslinux=false
pascal@13879 17 mkdir -p $fs/bin $fs/sbin $fs/dev/pts $fs/proc $fs/sys $fs/tmp $fs/mnt
pascal@13591 18 cp -a $src/busybox-static $fs/bin/busybox
pascal@13591 19 mknod -m 660 $fs/dev/console c 5 1
pascal@13591 20 mknod -m 771 $fs/dev/null c 1 3
pascal@13591 21 mknod -m 660 $fs/dev/tty c 5 0
pascal@13879 22 mknod -m 660 $fs/dev/loop0 b 7 0
pascal@13879 23 mknod -m 660 $fs/dev/loop1 b 7 1
pascal@13879 24 while read name major minor ; do
pascal@13879 25 for i in '' 1 2 3 4 5 6 7 8 9 ; do
pascal@13879 26 mknod -m 644 $fs/dev/$name$i b $major $(($i + $minor))
pascal@13879 27 done
pascal@13879 28 done <<EOT
pascal@13879 29 hda 3 0
pascal@13879 30 hdb 3 64
pascal@13879 31 sda 8 0
pascal@13879 32 sdb 8 16
pascal@13879 33 EOT
pascal@13591 34 if $jslinux; then
pascal@13591 35 mknod -m 644 $fs/dev/clipboard c 10 231
pascal@13591 36 mknod -m 660 $fs/dev/ttyS0 c 4 64
pascal@13591 37 fi
pascal@13591 38 mknod -m 660 $fs/dev/tty1 c 4 1
pascal@13591 39 cat > $fs/init <<EOT
pascal@13591 40 #!/bin/busybox sh
pascal@13591 41
pascal@13591 42 for i in \$(busybox --list) ; do busybox ln /bin/busybox /bin/\$i; done
pascal@13591 43
pascal@13591 44 export PATH=/bin
pascal@13591 45 export HOME=/
pascal@13591 46 export TERM=vt100
pascal@13591 47
pascal@13591 48 mount -t proc none /proc
pascal@13879 49
pascal@13879 50 arg()
pascal@13879 51 {
pascal@13882 52 grep -q \$1= /proc/cmdline && root="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" </proc/cmdline)"
pascal@13879 53 }
pascal@13879 54
pascal@13882 55 arg mount && mount \$root /mnt
pascal@13882 56 arg loopfs && losetup /dev/loop0 /mnt/\$root && mount /dev/loop0 /mnt
pascal@13882 57 arg subroot && cp /bin/busybox /mnt/\$root/dev/shm &&
pascal@13882 58 exec switch_root mnt \$root/dev/shm/busybox chroot \$root /sbin/init
pascal@13883 59 arg loopfs && exec switch_root mnt /sbin/init
pascal@13879 60
pascal@13591 61 [ -d /proc/bus/usb ] && mount -t usbfs usbfs /proc/bus/usb
pascal@13591 62 mount -t sysfs none /sys
pascal@13591 63 mount -t devpts none /dev/pts
pascal@13591 64
pascal@13591 65 TTY=\$(tty 2>/dev/null)
pascal@13591 66 TTY=\${TTY:-/dev/tty1}
pascal@13591 67 EOT
pascal@13591 68 $jslinux && cat >> $fs/init <<EOT
pascal@13591 69 stty -F \$TTY rows 30 2>/dev/null
pascal@13591 70 EOT
pascal@13591 71 cat >> $fs/init <<EOT
pascal@13591 72
pascal@13591 73 busybox | sed '/Current/,\$!d'
pascal@13591 74 while true; do
pascal@13591 75 if [ -x /bin/setsid ]; then
pascal@13591 76 setsid sh -c "exec sh <\$TTY >\$TTY 2>&1"
pascal@13591 77 else
pascal@13591 78 sh <\$TTY >\$TTY 2>&1
pascal@13591 79 fi
pascal@13591 80 done
pascal@13591 81 EOT
pascal@13591 82 chmod +x $fs/init
pascal@13591 83 ln $fs/init $fs/sbin/init
pascal@13591 84 }
pascal@13591 85
pascal@13591 86 pre_install()
pascal@13591 87 {
pascal@13591 88 rm -rf $1/bin $1/sbin
pascal@13591 89 }
pascal@13591 90
pascal@13591 91 post_install()
pascal@13591 92 {
pascal@13591 93 rm -rf $1/lib $1/var $1/sbin $1/home $1/root $1/media
pascal@13591 94 }