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 1.6KB

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