OpenSDE Framework (without history before r20070)
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.

105 lines
2.5 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: architecture/x86/boot/makeimages.sh
  6. # Copyright (C) 2004 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. if [ "$1" = -reroot ] ; then
  16. echo "Old PATH: $PATH"
  17. PATH="../../sbin:../../bin:../../../sbin:../usr/bin:$PATH"
  18. echo "New PATH: $PATH"
  19. echo "Old LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
  20. export LD_LIBRARY_PATH="../../lib:../../usr/lib:$LD_LIBRARY_PATH"
  21. LD_LIBRARY_PATH=${LD_LIBRARY_PATH%:}
  22. echo "New LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
  23. shift
  24. fi
  25. if [ "$1" = -combo ] ; then
  26. combo=1
  27. elif [ "$#" != 0 ] ; then
  28. echo "usage: $0 [-reroot] [-combo]"
  29. exit 1
  30. fi
  31. tmpfile=`mktemp -p $PWD`
  32. tmpdir=$tmpfile.dir
  33. mkdir $tmpdir || exit 1
  34. rc=0
  35. tmpdev=""
  36. for x in /dev/loop/* ; do
  37. if losetup $x $tmpfile 2> /dev/null ; then
  38. tmpdev=$x ; break
  39. fi
  40. done
  41. if [ -z "$tmpdev" ] ; then
  42. echo "No free loopback device found!"
  43. rm -f $tmpfile ; rmdir $tmpdir
  44. exit 1
  45. fi
  46. echo "Using $tmpdev."
  47. for image in initrd boot_144 boot_288
  48. do
  49. case ${image} in
  50. initrd)
  51. echo "Creating ${image}.gz ..."
  52. size=4096 ;;
  53. boot_144)
  54. echo "Creating ${image}.img ..."
  55. size=1440 ;;
  56. boot_288)
  57. echo "Creating ${image}.img ..."
  58. size=2880 ;;
  59. esac
  60. dd if=/dev/zero of=$tmpfile bs=1024 count=$size &> /dev/null
  61. losetup -d $tmpdev ; losetup $tmpdev $tmpfile || rc=1
  62. mke2fs -q $tmpdev &> /dev/null ; mount $tmpdev $tmpdir || rc=1
  63. case ${image} in
  64. initrd)
  65. cp -a initrd/* $tmpdir || rc=1
  66. ;;
  67. boot_144|boot_288)
  68. cp -a boot/{vmlinuz,lilo-help.txt} $tmpdir || rc=1
  69. if [ -f /boot/boot-text.b ]; then
  70. cp /boot/boot-text.b $tmpdir/boot.b || rc=1
  71. fi
  72. liloconf=lilo-conf-${image#boot_}
  73. if [ $image = boot_288 -o "$combo" = 1 ] ; then
  74. cp initrd.gz $tmpdir || rc=1
  75. [ $image = boot_144 ] && liloconf=lilo-conf-1x2
  76. fi
  77. sed -e "s,/mnt/,$tmpdir/,g" \
  78. -e "s,/dev/floppy/0,$tmpdev,;" \
  79. < boot/$liloconf > $tmpdir/lilo.conf || rc=1
  80. lilo -C $tmpdir/lilo.conf > /dev/null || rc=1
  81. ;;
  82. esac
  83. umount $tmpdir
  84. case ${image} in
  85. initrd) gzip -9 < $tmpfile > $image.gz || rc=1 ;;
  86. *) cp $tmpfile $image.img || rc=1 ;;
  87. esac
  88. done
  89. losetup -d $tmpdev
  90. rm -f $tmpfile
  91. rmdir $tmpdir
  92. exit $rc