vbootstrap.sh.in 1.7 KB

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