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.

80 lines
1.6 KiB

  1. #!/bin/sh
  2. if [ "$1" = -combo ] ; then
  3. combo=1
  4. elif [ "$#" != 0 ] ; then
  5. echo "usage: $0 [-combo]"
  6. exit 1
  7. fi
  8. tmpfile=`mktemp -p $PWD`
  9. tmpdir=$tmpfile.dir
  10. mkdir $tmpdir || exit 1
  11. rc=0
  12. tmpdev=""
  13. for x in /dev/loop/* ; do
  14. if losetup $x $tmpfile 2> /dev/null ; then
  15. tmpdev=$x ; break
  16. fi
  17. done
  18. if [ -z "$tmpdev" ] ; then
  19. echo "No free loopback device found!"
  20. rm -f $tmpfile ; rmdir $tmpdir
  21. exit 1
  22. fi
  23. echo "Using $tmpdev."
  24. for image in initrd boot_144 boot_288
  25. do
  26. echo "Creating ${image}.img ..."
  27. case ${image} in
  28. initrd)
  29. size=4096 ;;
  30. boot_144)
  31. size=1440 ;;
  32. boot_288)
  33. size=2880 ;;
  34. esac
  35. dd if=/dev/zero of=$tmpfile bs=1024 count=$size &> /dev/null
  36. losetup -d $tmpdev ; losetup $tmpdev $tmpfile || rc=1
  37. mke2fs -q $tmpdev &> /dev/null ; mount $tmpdev $tmpdir || rc=1
  38. case ${image} in
  39. initrd)
  40. cp -a initrd/* $tmpdir || rc=1
  41. ;;
  42. boot_144|boot_288)
  43. cp -a boot/{vmlinuz,lilo-help.txt} $tmpdir || rc=1
  44. if [ -f /boot/boot-text.b ]; then
  45. cp /boot/boot-text.b $tmpdir/boot.b || rc=1
  46. fi
  47. liloconf=lilo-conf-${image#boot_}
  48. if [ $image = boot_288 -o "$combo" = 1 ] ; then
  49. cp initrd.img $tmpdir || rc=1
  50. [ $image = boot_144 ] && liloconf=lilo-conf-1x2
  51. fi
  52. sed -e "s,/mnt/,$tmpdir/,g" \
  53. -e "s,/dev/floppy/0,$tmpdev,;" \
  54. < boot/$liloconf > $tmpdir/lilo.conf || rc=1
  55. lilo -C $tmpdir/lilo.conf > /dev/null || rc=1
  56. ;;
  57. esac
  58. umount $tmpdir
  59. case ${image} in
  60. initrd) gzip -9 < $tmpfile > $image.img || rc=1 ;;
  61. *) cp $tmpfile $image.img || rc=1 ;;
  62. esac
  63. done
  64. losetup -d $tmpdev
  65. rm -f $tmpfile
  66. rmdir $tmpdir
  67. exit $rc