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.

make-base-vm 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #!/bin/sh
  2. set -e
  3. SUITE=lucid
  4. ARCH=amd64
  5. MIRROR=http://${MIRROR_HOST:-127.0.0.1}:3142/archive.ubuntu.com/ubuntu
  6. SECURITY_MIRROR=http://${MIRROR_HOST:-127.0.0.1}:3142/security.ubuntu.com/ubuntu
  7. LXC=0
  8. usage() {
  9. echo "Usage: ${0##*/} [OPTION]..."
  10. echo "Make a base client."
  11. echo
  12. cat << EOF
  13. --help display this help and exit
  14. --suite U build suite U instead of lucid
  15. --arch A build architecture A (e.g. i386) instead of amd64
  16. --lxc use lxc instead of kvm
  17. The MIRROR_HOST environment variable can be used to change the
  18. apt-cacher host. It should be something that the target VM can
  19. resolve. It may be set to 127.0.0.1, in which case it will be
  20. changed to 10.0.2.2 on the guest. 10.0.2.2 is the host IP as visible
  21. from the guest under qemu networking.
  22. EOF
  23. }
  24. if [ $# != 0 ] ; then
  25. while true ; do
  26. case "$1" in
  27. --help|-h)
  28. usage
  29. exit 0
  30. ;;
  31. --suite|-s)
  32. SUITE="$2"
  33. shift 2
  34. ;;
  35. --arch|-a)
  36. ARCH="$2"
  37. shift 2
  38. ;;
  39. --lxc)
  40. LXC=1
  41. shift 1
  42. ;;
  43. --*)
  44. echo "unrecognized option $1"
  45. exit 1
  46. ;;
  47. *)
  48. break
  49. ;;
  50. esac
  51. done
  52. fi
  53. mkdir -p var
  54. if [ ! -e var/id_dsa ]; then
  55. ssh-keygen -t dsa -f var/id_dsa -N ""
  56. fi
  57. OUT=base-$SUITE-$ARCH
  58. FLAVOUR=virtual
  59. if [ $ARCH = "amd64" -a $SUITE = "hardy" ]; then
  60. FLAVOUR=server
  61. fi
  62. addpkg=openssh-server,pciutils,build-essential,git-core,subversion
  63. if [ $LXC = "0" ]; then
  64. if [ -e $OUT.qcow2 ]; then
  65. echo $OUT.qcow2 already exists, please remove it first
  66. exit 1
  67. fi
  68. rm -rf $OUT
  69. sudo vmbuilder kvm ubuntu --arch=$ARCH --suite=$SUITE --addpkg=$addpkg --ssh-key=var/id_dsa.pub --ssh-user-key=var/id_dsa.pub --mirror=$MIRROR --security-mirror=$SECURITY_MIRROR --dest=$OUT --flavour=$FLAVOUR --firstboot=`pwd`/target-bin/bootstrap-fixup
  70. mv $OUT/*.qcow2 $OUT.qcow2
  71. rm -rf $OUT
  72. else
  73. if [ -e $OUT ]; then
  74. echo $OUT already exists, please remove it first
  75. exit 1
  76. fi
  77. rm -rf $OUT-root
  78. sudo debootstrap --include=$addpkg --arch=$ARCH $SUITE $OUT-root $MIRROR
  79. sudo target-bin/bootstrap-fixup $OUT-root
  80. fi