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.3KB

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