2019-09-06 06:02:18 +04:00
#!/bin/sh
set -e
2019-06-08 23:03:53 +04:00
# This script installs opam for the user. It should NOT be included in any makefiles/etc.
2019-06-08 23:13:06 +04:00
if [ -n "`which opam`" ]
2019-06-08 23:03:53 +04:00
then
2020-04-14 13:51:24 +04:00
if [ -n "`opam --version | grep -P " 2\. .\. ."`" ]
2019-06-08 23:03:53 +04:00
then
2020-04-14 13:51:24 +04:00
echo "Opam 2.x seems to already exist, exiting..."
exit 1
2019-06-09 01:19:07 +04:00
else
2020-04-14 13:51:24 +04:00
read -p "This script will upgrade opam to the 2.x series, are you okay with that? (y/n)" choice1
case " $choice1 " in
y| Y ) : ; ;
n| N ) exit ; ;
esac
2019-06-08 23:03:53 +04:00
fi
fi
2019-10-24 17:04:16 +04:00
echo "Installing dependencies.."
if [ -n "`uname -a | grep -i arch`" ]
then
sudo pacman -Sy --noconfirm \
2020-03-04 17:51:13 +04:00
rakudo \
2019-10-24 17:04:16 +04:00
make \
m4 \
patch \
bubblewrap \
rsync \
2020-02-11 21:51:58 +04:00
curl
2019-10-24 17:04:16 +04:00
fi
if [ -n "`uname -a | grep -i ubuntu`" ]
then
2019-06-08 09:01:23 +04:00
sudo apt-get install -y make \
2020-03-04 17:51:13 +04:00
perl6 \
2020-02-11 21:55:31 +04:00
make \
2019-06-08 09:01:23 +04:00
m4 \
patch \
bubblewrap \
rsync \
2020-02-11 21:51:58 +04:00
curl
2019-10-24 17:04:16 +04:00
fi
2020-02-11 21:51:58 +04:00
2019-06-08 09:01:23 +04:00
if [ -n "`uname -a | grep -i ubuntu`" ]
then
2019-10-24 17:04:16 +04:00
echo "ubuntu"
2019-06-08 09:01:23 +04:00
sudo add-apt-repository -y ppa:avsm/ppa
sudo apt-get update
2019-06-08 23:03:53 +04:00
sudo apt-get install opam
2019-06-08 09:01:23 +04:00
else
2019-10-24 17:04:16 +04:00
if [ -n "`uname -a | grep -i arch`" ]
2019-06-08 09:01:23 +04:00
then
2019-10-24 17:04:16 +04:00
echo "arch"
sudo pacman -Sy --noconfirm opam
2019-06-08 09:01:23 +04:00
else
2019-10-24 17:04:16 +04:00
echo "unknown distro"
#I'm going to assume here that we're on x86_64, 32-bit users should be basically
#extinct at this point right?
curl -L https://github.com/ocaml/opam/releases/download/2.0.4/opam-2.0.4-x86_64-linux \
--output opam_temp_version_2_0_4.bin
if [ "`openssl sha256 -r opam_temp_version_2_0_4.bin`" = "373e34f92f282273d482537f8103caad0d17b6f2699ff504bed77f474cb0c951 *opam_temp_version_2_0_4.bin" ]
then
# Stay paranoid, in case other checks fail don't want to overrwrite
# user's opam on accident
chmod +x opam_temp_version_2_0_4.bin # Set execute so we can get version
if [ -e /usr/local/bin/opam ]
then
opam_old_v = ` /usr/local/bin/opam --version`
opam_new_v = ` opam_temp_version_2_0_4.bin --version`
read -p " This will overrwrite the opam you have in /usr/local/bin (version $opam_old_v ) with version $opam_new_v , do you actually want to do that? Type yes. (yes/n) " choice2
else
choice2 = "yes"
fi
if [ $choice2 = "yes" ]
then
sudo mv opam_temp_version_2_0_4.bin /usr/local/bin/opam
else
rm opam_temp_version_2_0_4.bin
exit
fi
else
echo "opam file hash doesn't match what was recorded at time of signature verification!"
echo "(If you actually get this message, you should probably file an issue)"
echo "https://gitlab.com/ligolang/ligo/issues"
exit 1
2020-04-14 13:51:24 +04:00
fi
2019-10-24 17:04:16 +04:00
fi
2019-06-08 09:01:23 +04:00
fi
opam init -a --bare