From 8248d58f218a7f2844d306015a644d6313a8ae0d Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Thu, 18 Nov 2021 16:25:03 -0800 Subject: [PATCH] Copy vpnkit from Docker Desktop instead of compiling on M1 Macs --- BUILD.md | 9 +++++---- install/macos/make-vm.sh | 20 ++++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/BUILD.md b/BUILD.md index be071d6..36be7aa 100644 --- a/BUILD.md +++ b/BUILD.md @@ -54,8 +54,6 @@ Create a .rpm: ## macOS -_Note for Apple Silicon users:_ Unfortunately the build process requires using a Mac with an Intel chip for now. Building the container image uses Vagrant, which requires VMs, and for now the M1 chip can only run M1 VMs, VirtualBox isn't supported, etc. - Ensure you have the git submodules checked out: ``` @@ -65,6 +63,8 @@ git submodule update Install Xcode from the App Store. +Install [Docker Desktop](https://www.docker.com/products/docker-desktop). Make sure to choose your correct CPU, either Intel Chip or Apple Chip. + Install Python 3.9.9 [[from python.org])(https://www.python.org/downloads/release/python-399/). Install Python dependencies: @@ -77,12 +77,13 @@ poetry install Install [Homebrew](https://brew.sh/) dependencies: ```sh -brew install create-dmg wget pkg-config opam dune ocaml +brew install create-dmg wget pkg-config ``` -Install opam dependencies: +Install opam dependencies (you can skip this step if you are using an Apple M1 chip Mac): ``` +brew install opam dune ocaml opam init -y opam install -y alcotest astring base64 bigarray-compat charrua-client-mirage charrua-core cmdliner cohttp-lwt cstruct cstruct-lwt datakit-server datakit-server-9p duration ezjsonm fd-send-recv fmt hvsock io-page io-page-unix ipaddr logs lwt lwt-dllist mirage-channel mirage-channel-lwt mirage-clock-lwt mirage-clock-unix mirage-flow-lwt mirage-kv-lwt mirage-profile mirage-protocols-lwt mirage-random mirage-stack-lwt mirage-time-lwt mirage-vnetif oUnit pcap-format ppx_cstruct ppx_sexp_conv protocol-9p re rresult sexplib sha tar tcpip uri uuidm uwt ``` diff --git a/install/macos/make-vm.sh b/install/macos/make-vm.sh index e906be8..17850d9 100755 --- a/install/macos/make-vm.sh +++ b/install/macos/make-vm.sh @@ -5,15 +5,23 @@ cd vendor/hyperkit/ make || { echo 'Failed to compile hyperkit' ; exit 1; } cd ../.. -# Compile vpnkit -cd vendor/vpnkit/ -make -f Makefile.darwin || { echo 'Failed to compile vpnkit' ; exit 1; } -cd ../.. +# Compile vpnkit (on Intel chips, it's too hard to compile in Apple chips) +ARCH=$(/usr/bin/arch) +if [ "$ARCH" == "i386" ]; then + cd vendor/vpnkit/ + make -f Makefile.darwin || { echo 'Failed to compile vpnkit' ; exit 1; } + cd ../.. +fi # Copy binaries to share mkdir -p share/bin cp vendor/hyperkit/build/hyperkit share/bin/hyperkit -cp vendor/vpnkit/_build/install/default/bin/vpnkit share/bin/vpnkit +if [ "$ARCH" == "i386" ]; then + cp vendor/vpnkit/_build/install/default/bin/vpnkit share/bin/vpnkit +elif [ "$ARCH" == "arm64" ]; then + # On Apple chips we copy the binary from Docker Desktop + cp /Applications/Docker.app/Contents/Resources/bin/com.docker.vpnkit share/bin/vpnkit +fi # Build the dangerzone-converter image echo "Building dangerzone-converter image" @@ -21,7 +29,7 @@ docker build dangerzone-converter --tag dangerzone.rocks/dangerzone echo "Saving dangerzone-converter image" docker save dangerzone.rocks/dangerzone -o vm-builder/dangerzone-converter.tar echo "Compressing dangerzone-converter image" -gzip vm-builder/dangerzone-converter.tar +gzip -f vm-builder/dangerzone-converter.tar # Build the ISO docker run -v $(pwd)/vm-builder:/vm-builder alpine:latest /vm-builder/build-iso.sh