vbootstrap.sh.in 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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> <url> <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 3 ]
  26. then
  27. usage
  28. echo "E: You must specify a vine version, location 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. FETCHURL=$1
  42. shift
  43. INSTDIR=$1
  44. shift
  45. if [ -d "$INSTDIR" ]
  46. then
  47. echo "E: Specified directory \"$INSTDIR\" is already exists."
  48. usage
  49. exit 0
  50. fi
  51. ##
  52. APT_OPTS="
  53. -o Dir::Etc::sourcelist=$INSTDIR/etc/vbootstrap/sources.list.d/$INSTVER
  54. -o RPM::RootDir=$INSTDIR
  55. -o Dir::Etc::sourceparts=$INSTDIR/etc/apt/sources.list.d
  56. -o Dir::State=$INSTDIR/var/lib/apt
  57. -o Dir::Cache=$INSTDIR/var/cache/apt
  58. -o RPM::PM=\"external\"
  59. -o RPM::Install-Options::=--force
  60. -o RPM::Install-Options::=--nosignature "
  61. ##
  62. # generate source.list of $INSTVER
  63. mkdir -p $INSTDIR/etc/vbootstrap/sources.list.d
  64. sed -e "s,@@FETCHURL@@,${FETCHURL}," $VBOOTSTRAPDIR/sources.list.d/$INSTVER > $INSTDIR/etc/vbootstrap/sources.list.d/$INSTVER || exit 1
  65. # initialize rpm database
  66. echo $"Initializing RPM database in $INSTDIR."
  67. mkdir -p $INSTDIR/var/lib/rpm
  68. rpm --initdb --root $INSTDIR
  69. # update apt database
  70. echo $"update apt database."
  71. mkdir -p $INSTDIR/var/lib/apt/lists/partial
  72. mkdir -p $INSTDIR/var/cache/apt/archives/partial
  73. apt-get -qq $APT_OPTS update
  74. # misc setup files
  75. mkdir -p $INSTDIR/etc
  76. touch $INSTDIR/etc/mtab
  77. # create some device files
  78. mkdir $INSTDIR/dev
  79. mknod $INSTDIR/dev/null c 1 3
  80. mknod $INSTDIR/dev/console c 5 1
  81. mknod $INSTDIR/dev/urandom c 1 9
  82. # install base vine linux system.
  83. echo $"Installing basesystem."
  84. for i in $BASE_PKGS
  85. do
  86. apt-get -y -qq $APT_OPTS install $i
  87. done
  88. # run post install script
  89. vbootstrap_post
  90. echo $"vbootstrap done."