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-clean-vm 1.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/bin/sh
  2. set -e
  3. SUITE=lucid
  4. ARCH=amd64
  5. VMSW=KVM
  6. if [ -n "$USE_LXC" ]; then
  7. VMSW=LXC
  8. elif [ -n "$USE_VBOX" ]; then
  9. VMSW=VBOX
  10. fi
  11. usage() {
  12. echo "Usage: ${0##*/} [OPTION]..."
  13. echo "Make a clean copy of the base client."
  14. echo
  15. cat << EOF
  16. --help display this help and exit
  17. --suite U build suite U instead of lucid
  18. --arch A build architecture A (e.g. i386) instead of amd64
  19. EOF
  20. }
  21. if [ $# != 0 ] ; then
  22. while true ; do
  23. case "$1" in
  24. --help|-h)
  25. usage
  26. exit 0
  27. ;;
  28. --suite|-s)
  29. SUITE="$2"
  30. shift 2
  31. ;;
  32. --arch|-a)
  33. ARCH="$2"
  34. shift 2
  35. ;;
  36. --*)
  37. echo "unrecognized option $1"
  38. exit 1
  39. ;;
  40. *)
  41. break
  42. ;;
  43. esac
  44. done
  45. fi
  46. export LXC_SUITE=$SUITE
  47. export LXC_ARCH=$ARCH
  48. BASE=base-$SUITE-$ARCH
  49. OUT=target-$SUITE-$ARCH
  50. case $VMSW in
  51. KVM)
  52. qemu-img create -f qcow2 -o backing_file="$BASE.qcow2" "$OUT.qcow2"
  53. ;;
  54. LXC)
  55. cp -a --sparse=always $BASE $OUT
  56. libexec/config-bootstrap-fixup
  57. on-target -u root bash < target-bin/bootstrap-fixup
  58. ;;
  59. VBOX)
  60. VBoxManage snapshot "Gitian-${SUITE}-${ARCH}" restore "Gitian-Clean"
  61. ;;
  62. esac