gRPC-haskell/bin/install-macos-nix-grpc.sh
Joel Stanley 89a5547dc0 Add script for circumventing MacOS SIP and using nix-built grpc; upda… (#85)
* Add script for circumventing MacOS SIP and using nix-built grpc; update README.md

* Guard destructive /usr/local and brew updates with a user prompt
2016-12-20 11:37:46 -06:00

38 lines
962 B
Bash
Executable file

#!/bin/bash
set -e
function purge_grpc {
echo "Purging old grpc references in /usr/local..."
if brew list grpc; then
echo "Removing brew-installed grpc..."
brew uninstall grpc
else
echo "No brew-installed grpc detected."
fi
rm -rf /usr/local/include/grpc
rm -f /usr/local/lib/libgrpc.dylib
}
read -p "This script nukes brew-installed grpc libs and destructively updates /usr/local. Cool? [yN] " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
echo "Okay, aborting."
exit 1
fi
purge_grpc
echo "Building grpc from release.nix..."
grpc=$(nix-build release.nix -A grpc)
echo "Nix store path for grpc is ${grpc}."
echo "Creating symlinks into /usr/local/include and /usr/local/lib..."
ln -sf "${grpc}/include/grpc" /usr/local/include/grpc
ln -sf "${grpc}/lib/libgrpc.dylib" /usr/local/lib/libgrpc.dylib
echo "Creating the following symlinks:"
ls -ld /usr/local/include/grpc
ls -l /usr/local/lib/libgrpc.dylib
echo "All done."