vbootstrap.sh.in 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. VERSION=@@VBOOTSTRAP_VERSION@@
  3. ##
  4. VBOOTSTRAPDIR="/usr/share/vbootstrap"
  5. SUPPORTED_VERSION="$(ls $VBOOTSTRAPDIR/scripts/)"
  6. ##
  7. usage()
  8. {
  9. echo "Usage: vbootstrap <version> <targetdir>"
  10. echo " supported version:"
  11. for ver in $SUPPORTED_VERSION
  12. do
  13. echo " $ver"
  14. done
  15. }
  16. ##
  17. if [ "$(id -u)" != "0" ]
  18. then
  19. usage
  20. echo "E: You should run vbooststrap as super user."
  21. exit 0
  22. fi
  23. if ! [ $# -eq 2 ]
  24. then
  25. usage
  26. echo "E: You must specify a vine version and target."
  27. exit 0
  28. fi
  29. INSTVER=$1
  30. shift
  31. if [ -f "$VBOOTSTRAPDIR/scripts/$INSTVER" ]
  32. then
  33. source $VBOOTSTRAPDIR/scripts/$INSTVER
  34. else
  35. usage
  36. echo "E: $INSTVER is not supported."
  37. exit 0
  38. fi
  39. INSTDIR=$1
  40. shift
  41. if [ -d "$INSTDIR" ]
  42. then
  43. echo "E: Specified directory \"$INSTDIR\" is already exists."
  44. usage
  45. exit 0
  46. fi
  47. ##
  48. APT_OPTS="$APT_LINE -o RPM::RootDir=$INSTDIR
  49. -o Dir::Etc::sourceparts=$INSTDIR/etc/apt/sources.list.d
  50. -o Dir::State=$INSTDIR/var/lib/apt
  51. -o Dir::Cache=$INSTDIR/var/cache/apt "
  52. ##
  53. # initialize rpm database
  54. echo "Initializing RPM database in $INSTDIR."
  55. mkdir -p $INSTDIR/var/lib/rpm
  56. rpm --initdb --root $INSTDIR
  57. # update apt database
  58. echo "update apt database."
  59. mkdir -p $INSTDIR/var/lib/apt/lists/partial
  60. mkdir -p $INSTDIR/var/cache/apt/archives/partial
  61. apt-get -qq $APT_OPTS update
  62. # misc setup files
  63. mkdir -p $INSTDIR/etc
  64. touch $INSTDIR/etc/mtab
  65. # create some device files
  66. mkdir $INSTDIR/dev
  67. mknod $INSTDIR/dev/null c 1 3
  68. mknod $INSTDIR/dev/console c 5 1
  69. # install base vine linux system.
  70. echo "Installing basesystem."
  71. for i in $BASE_PKGS
  72. do
  73. apt-get -y -qq $APT_OPTS install $i
  74. done
  75. # run post install script
  76. vbootstrap_post
  77. echo "vboostrap done."