mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
4.1 KiB

  1. pkgloop
  2. echo_header "Creating the router ramdisk..."
  3. echo_status "Creating the directory structure."
  4. outdir="$build_rock/router"
  5. rm -rf $outdir
  6. mkdir -p $outdir/initrd/bin
  7. mkdir -p $outdir/initrd/lib
  8. mkdir -p $outdir/initrd/etc
  9. mkdir -p $outdir/initrd/tmp
  10. mkdir -p $outdir/initrd/dev
  11. mkdir -p $outdir/initrd/proc
  12. mkdir -p $outdir/initrd/share
  13. mkdir -p $outdir/initrd.mnt
  14. ln -s . $outdir/initrd/usr
  15. ln -s bin $outdir/initrd/sbin
  16. chmod 700 $outdir
  17. cd $outdir
  18. echo_status "Copying program binaries."
  19. for x in bash modprobe lsmod uname gawk lspci find openvpn killall sync dhclient \
  20. sysctl mount umount sshd ssh-keygen agetty sleep cat ls ps ln strace \
  21. swapon swapoff mkdir killall5 reboot sed sort dhclient-script ifconfig \
  22. expr hostname route nvi ez-ipupdate pptp rm scp
  23. do
  24. for y in bin sbin usr/bin usr/sbin; do
  25. [ -f $build_root/$y/$x ] && cp $build_root/$y/$x initrd/bin/
  26. done
  27. [ ! -f initrd/bin/$x ] &&
  28. echo_error "Did not find program binary for '$x'."
  29. done
  30. for x in iproute2 iptables grub ppp
  31. do
  32. echo_status "Copy entire $x package."
  33. while read dummy fn
  34. do
  35. mkdir -p $( dirname initrd/$fn )
  36. cp $build_root/$fn initrd/$fn
  37. done < $build_root/var/adm/flists/$x
  38. done
  39. echo_status "Copying library files."
  40. for x in $( ls initrd/bin/ )
  41. do
  42. while read a b c d
  43. do
  44. [ "$b" = "=>" ] && [ -n "$d" ] && \
  45. cp $build_root/${c#/} initrd/lib/
  46. done < <( chroot $build_root /bin/bash -c \
  47. "cd /; ldd \`type -p $x\`"; )
  48. done
  49. echo_status "Copying shutdown script."
  50. cp $base/target/$target/shutdown initrd/bin/
  51. chmod +x initrd/bin/shutdown
  52. echo_status "Copying rocknet scripts."
  53. cp -r $build_root/etc/network initrd/etc/
  54. cp -r $build_root/etc/services initrd/etc/
  55. cp $build_root/sbin/if{up,down} initrd/bin/
  56. echo_status "Copying some terminfo database entries."
  57. mkdir -p initrd/share/terminfo/{v,x,l}
  58. cp -r $build_root/usr/share/terminfo/v/vt100 initrd/share/terminfo/v/
  59. cp -r $build_root/usr/share/terminfo/l/linux initrd/share/terminfo/l/
  60. cp -r $build_root/usr/share/terminfo/x/xterm initrd/share/terminfo/x/
  61. echo_status "deleting manpages and other stuff."
  62. rm -rf initrd/share/man
  63. rm -rf initrd/var/adm
  64. echo_status "Copying kernel modules."
  65. cp -a $build_root/lib/modules initrd/lib/
  66. cd initrd/lib/modules/*/
  67. rm -rf pcmcia kernel/fs kernel/drivers/{bluetooth,cdrom,pcmcia,scsi,sound,usb}
  68. rm -rf kernel/sound
  69. rm -rf kernel/net/{8021q,appletalk,bluetooth,irda,khttpd,decnet,econet,ipx}
  70. rm -rf kernel/drivers/{video,telephony,mtd,message,media,md,input,ide,i2c,ieee1394}
  71. rm -rf kernel/drivers/{hotplug,char,block}
  72. cd $outdir
  73. echo_status "Create init script."
  74. echo -e '#!/bin/bash\ncd; exec /bin/bash --login' > initrd/bin/login-shell
  75. cp $base/target/$target/init.sh initrd/bin/init
  76. chmod +x initrd/bin/login-shell initrd/bin/init
  77. cp $build_root/sbin/{hwscan,dumpnetcfg} initrd/bin/
  78. cp $build_root/usr/share/pci.ids initrd/share/
  79. ln -s bash initrd/bin/sh
  80. SIZE=$(( 1024 * $ROCKCFG_T_ROUTER_INITRD_SIZE ))
  81. REALSIZE=`du -sk initrd | cut -d' ' -f1`
  82. if [ $REALSIZE -gt $SIZE ] ; then
  83. echo_error "Initrd too small!"
  84. echo_status "$REALSIZE kb are needed, but you only want $SIZE kb."
  85. echo_status "please re-run ./scripts/Config and increase the initrd size!"
  86. exit 1
  87. fi
  88. echo_status "Creating initrd image ($SIZE kb)."
  89. dd if=/dev/zero of=initrd.img count=$SIZE bs=1024 2>/dev/null
  90. mke2fs -qF initrd.img 2>/dev/null
  91. mount -o loop initrd.img initrd.mnt
  92. cp -a initrd/* initrd.mnt/
  93. umount -d initrd.mnt/
  94. gzip -9 initrd.img
  95. mv initrd.img.gz initrd.img
  96. echo_status "Copy kernel image."
  97. cp $build_root/boot/vmlinuz .
  98. echo_status "Create isolinux setup."
  99. tar --use-compress-program=bzip2 \
  100. -xOf $base/download/mirror/s/syslinux-3.07.tar.bz2 \
  101. syslinux-3.07/isolinux.bin > isolinux.bin
  102. sed -e "s,@INITRD_SIZE@,$SIZE," -e "s,@SERIAL_BAUD@,$ROCKCFG_T_ROUTER_SERIAL_BAUD," \
  103. $base/target/$target/isolinux.cfg > ./isolinux.cfg
  104. echo_status "Create iso description."
  105. cat > ../isofs.txt <<- EOT
  106. BOOT -b isolinux.bin -c boot.catalog
  107. BOOTx -no-emul-boot -boot-load-size 4 -boot-info-table
  108. DISK1 build/${ROCKCFG_ID}/ROCK/router /
  109. EOT
  110. if [ "$ROCK_DEBUG_ROUTER_NOCLEANUP" != 1 ]; then
  111. echo_status "Cleaning up."
  112. rm -rf initrd.mnt/ initrd
  113. fi