Copy vpnkit from Docker Desktop instead of compiling on M1 Macs

This commit is contained in:
Micah Lee 2021-11-18 16:25:03 -08:00
parent f1cbbdf43c
commit 8248d58f21
No known key found for this signature in database
GPG key ID: 403C2657CD994F73
2 changed files with 19 additions and 10 deletions

View file

@ -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
```

View file

@ -5,15 +5,23 @@ cd vendor/hyperkit/
make || { echo 'Failed to compile hyperkit' ; exit 1; }
cd ../..
# Compile vpnkit
# 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
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