[provisioning] Add Elixir

This commit is contained in:
Correl Roush 2020-06-24 21:31:00 -04:00
parent fc944d75ee
commit 40ca82570d
2 changed files with 42 additions and 3 deletions

View file

@ -5,8 +5,7 @@ function _apt {
local pkg=$1 local pkg=$1
if ! dpkg -s $pkg >/dev/null 2>&1; then if ! dpkg -s $pkg >/dev/null 2>&1; then
if [ -z "$__apt_updated" ]; then if [ -z "$__apt_updated" ]; then
_run "Update APT cache" sudo apt-get update _apt_update
__apt_updated=yes
fi fi
_run "[apt] Install $pkg" sudo apt-get install -y $1 _run "[apt] Install $pkg" sudo apt-get install -y $1
else else
@ -14,8 +13,30 @@ function _apt {
fi fi
} }
function _apt_update {
_run "Update APT cache" sudo apt-get update
__apt_updated=yes
}
function _apt_source {
_run "[apt] Add Source: $1" sudo add-apt-repository -u -y "$1"
}
function _dpkg {
local pkg=$1
local url=$2
if ! dpkg -s $pkg >/dev/null 2>&1; then
local download=$(mktemp -d)
_run "[dpkg] Downloading $pkg" curl -q -o "$download/$pkg.deb" "$url"
_run "[dpkg] Installing $pkg" sudo dpkg -i "$download/$pkg.deb"
rm -rf "$download"
else
echo "[dpkg] $pkg is already installed, skipping."
fi
}
_apt software-properties-common _apt software-properties-common
function _ppa { function _ppa {
_run "[apt] Add PPA: $1" sudo add-apt-repository -u -y ppa:$1 _apt_source ppa:$1
} }

18
recipes/elixir Normal file
View file

@ -0,0 +1,18 @@
#!/bin/bash
# Description: The Elixir programming language
set -e
case $_PLATFORM in
darwin)
_brew elixir
;;
*)
_recipe _apt
_apt_source "deb https://packages.erlang-solutions.com/ubuntu $(lsb_release -cs) contrib"
_apt esl-erlang
_apt elixir
;;
esac
_run "[elixir] Installing / updating hex" mix local.hex --force