mirror of
https://github.com/digital-asset/daml.git
synced 2024-09-20 01:07:18 +03:00
98 lines
2.7 KiB
Bash
Executable File
98 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
set -eu
|
|
|
|
# Make sure they are in the right repo
|
|
readonly REPO_ROOT=$(bazel info workspace)
|
|
if [[ "${REPO_ROOT}/dev-env/bin/daml-sdk-head" != "${BASH_SOURCE}" ]];
|
|
then
|
|
echo "Repo root does not match the script being run."
|
|
echo "Make sure you run this script from a directory within the 'daml' repository "
|
|
exit 1
|
|
fi
|
|
|
|
# get rid of old .daml-head installation
|
|
if [ -d "$HOME/.daml-head" ] ; then
|
|
chmod -R u+w "$HOME/.daml-head"
|
|
rm -rf "$HOME/.daml-head"
|
|
fi
|
|
|
|
|
|
NUKE=0
|
|
PROFILING=0
|
|
for opt in "$@" ; do
|
|
case $opt in
|
|
"--nuke")
|
|
NUKE=1
|
|
;;
|
|
"--profiling")
|
|
PROFILING=1
|
|
;;
|
|
*)
|
|
echo "Unknown option: $opt"
|
|
echo "Available options:"
|
|
echo " --nuke Remove existing daml installation before installing daml-head."
|
|
echo " --profiling Build Haskell executables with profiling enabled."
|
|
exit 1
|
|
esac
|
|
done
|
|
|
|
BAZEL_MODE_FLAG=""
|
|
|
|
if [ "$PROFILING" -ne "0" ] ; then
|
|
BAZEL_MODE_FLAG="-c dbg"
|
|
fi
|
|
|
|
readonly DAML_HOME="$HOME/.daml"
|
|
if [ -d $DAML_HOME ] && [ "$NUKE" -ne "0" ] ; then
|
|
echo "$(tput setaf 3)Removing existing daml installation.$(tput sgr 0)"
|
|
chmod -R u+w $DAML_HOME
|
|
rm -rf $DAML_HOME
|
|
fi
|
|
|
|
readonly DAML_HEAD_SDK="$DAML_HOME/sdk/0.0.0"
|
|
if [ -d $DAML_HEAD_SDK ] ; then
|
|
echo "$(tput setaf 3)Removing existing daml-head installation.$(tput sgr 0)"
|
|
rm -f $DAML_HOME/bin/daml-head
|
|
chmod -R u+w $DAML_HEAD_SDK
|
|
rm -rf $DAML_HEAD_SDK
|
|
fi
|
|
|
|
|
|
echo "$(tput setaf 3)Building version 0.0.0 - this may take a while ...$(tput sgr 0)"
|
|
echo ""
|
|
|
|
function cleanup() {
|
|
echo "SDK 0.0.0 failed to build/install - if you need help ask on #product-daml"
|
|
echo "$(tput setaf 3)FAILED TO INSTALL! $(tput sgr 0)"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
# Building here separately so the user can see the build process which could take a while
|
|
bazel build $BAZEL_MODE_FLAG //release:sdk-head-tarball.tar.gz
|
|
|
|
readonly TARBALL=$(bazel info bazel-genfiles $BAZEL_MODE_FLAG)/release/sdk-head-tarball.tar.gz
|
|
readonly TMPDIR=$(mktemp -d)
|
|
mkdir -p $TMPDIR/sdk-head
|
|
|
|
tar xzf $TARBALL -C $TMPDIR/sdk-head --strip-components 1
|
|
|
|
readonly DAML_CMD="$(which daml)"
|
|
if [ -x "$DAML_CMD" ] && [ "$DAML_CMD" == "$DAML_HOME/bin/daml" ] ; then
|
|
# A daml installation already exists, so just install SDK version 0.0.0.
|
|
$DAML_HOME/bin/daml install $TMPDIR/sdk-head --force
|
|
else
|
|
# No daml installation detected, so install the tarball normally but disable auto-install.
|
|
$TMPDIR/sdk-head/install.sh --force
|
|
echo "auto-install: false" > $DAML_HOME/daml-config.yaml
|
|
fi
|
|
|
|
cat > $DAML_HOME/bin/daml-head << EOF
|
|
#!/bin/bash
|
|
exec env DAML_SDK_VERSION=0.0.0 $DAML_HEAD_SDK/daml/daml "\$@"
|
|
EOF
|
|
chmod +x $DAML_HOME/bin/daml-head
|
|
|
|
trap - EXIT
|
|
echo "$(tput setaf 3)Successfully installed daml-head command.$(tput sgr 0)"
|
|
|