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.

85 lines
1.8 KiB

  1. #!/bin/bash
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: misc/archive/iso2stick.sh
  6. # Copyright (C) 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. set -e
  16. usage()
  17. {
  18. echo "Usage iso2stick [ -fs file-system ] iso-image stick-device [ files ]"
  19. exit
  20. }
  21. fs="vfat -F 32"
  22. while [ "$1" ]; do
  23. case "$1" in
  24. -fs) fs="$2" ; shift ;;
  25. -*) usage ;;
  26. *) break ;;
  27. esac
  28. shift
  29. done
  30. if [ -z "$1" -o -z "$2" ]; then
  31. usage
  32. fi
  33. file="$1" ; shift
  34. dev="$1" ; shift
  35. # # ceate fresh image
  36. # size=`du --block-size=1000000 $1 | cut -f 1`
  37. # size=$(( size + 20 )) # just to be sure
  38. #
  39. # dd if=/dev/zero of=hd.img bs=1000000 count=$size
  40. # loop=`losetup -f`
  41. # losetup $loop hd.img
  42. case "$fs" in
  43. vfat*) ptype=b ;;
  44. *) ptype=83 ;;
  45. esac
  46. sfdisk $dev << EOT
  47. ,,$ptype
  48. EOT
  49. # losetup -d $loop
  50. mkfs.$fs ${dev}1
  51. # losetup /dev/loop0 -o 512 hd.img
  52. mkdir -p /mnt/source /mnt/target
  53. mount -o loop $file /mnt/source
  54. mount ${dev}1 /mnt/target
  55. rsync -arvH --inplace --exclude TRANS.TBL /mnt/source/ /mnt/target/
  56. # copy additional content specified in arguments
  57. for x ; do
  58. cp -arv $x /mnt/target/
  59. done
  60. sed -i 's/(cd)/(hd0,0)/g' /mnt/target/boot/grub/menu.lst
  61. umount /mnt/source
  62. umount /mnt/target
  63. echo -e "(hd0) /dev/sda" > device.map
  64. echo -e "root (hd0,0)\ninstall /boot/grub/stage1 (hd0) (hd0,0)/boot/grub/stage2 (hd0,0)/boot/grub/menu.lst\nquit" | grub --batch --device-map=./device.map
  65. rm ./device.map