-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added install.sh
script
#625
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
# Copyright (c) 2020, The Pallene Developers | ||
# Pallene is licensed under the MIT license. | ||
# Please refer to the LICENSE and AUTHORS files for details | ||
# SPDX-License-Identifier: MIT | ||
|
||
#### | ||
# One script to rule them all, one script to find them, | ||
# one script to bring them all and in the ease-of-use bind them. | ||
#### | ||
|
||
# Versions | ||
LUA_VERSION=5.4.7 | ||
LUAROCKS_VERSION=3.9.1 | ||
PT_VERSION=0.5.0a | ||
|
||
# Where we will clone | ||
CLONE_DIR="/tmp/pallene" | ||
mkdir -p $CLONE_DIR | ||
|
||
# Current working directory | ||
CURR_DIR=$(pwd) | ||
|
||
# Whether to install Pallene locally | ||
SUPERUSER=sudo | ||
LOCAL_FLAG= | ||
if [ "${PALLENE_LOCAL:-0}" -eq 1 ]; then | ||
SUPERUSER= | ||
LOCAL_FLAG=--local | ||
fi | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest if-else |
||
|
||
# Function to display usage | ||
usage() { | ||
echo "Usage: $0 { world | lua | rocks | ptracer | pallene }" | ||
echo " world - Install all components" | ||
echo " lua - Install Lua Internals" | ||
echo " pallene - Install Pallene" | ||
echo " rocks - Install LuaRocks" | ||
echo " ptracer - Install Pallene Tracer" | ||
echo | ||
echo "Use MYCFLAGS environment variable to pass flags to Lua Internals:" | ||
echo " MYCFLAGS=-DLUAI_ASSERT ./install.sh lua" | ||
echo | ||
echo "Use PALLENE_TRACER_TESTS=1 to run Pallene Tracer tests after installation:" | ||
echo " PALLENE_TRACER_TESTS=1 ./install.sh ptracer" | ||
echo | ||
echo "Use PALLENE_LOCAL=1 to install Pallene locally with '--local' flag in LuaRocks:" | ||
echo " PALLENE_LOCAL=1 ./install.sh pallene" | ||
echo | ||
echo "Use PALLENE_TESTS=1 to run Pallene tests after installation:" | ||
echo " PALLENE_TESTS=1 ./install.sh pallene" | ||
exit $1 | ||
} | ||
|
||
# Install Lua Internals | ||
install_lua_internals() { | ||
cd $CLONE_DIR | ||
wget -O - https://github.com/pallene-lang/lua-internals/archive/refs/tags/$LUA_VERSION.tar.gz | tar xzf - | ||
cd lua-internals-$LUA_VERSION | ||
make linux MYCFLAGS=$MYCFLAGS -j$(nproc) | ||
sudo make install | ||
cd $CURR_DIR | ||
} | ||
|
||
# Install Luarocks | ||
install_luarocks() { | ||
cd $CLONE_DIR | ||
wget -O - https://luarocks.org/releases/luarocks-$LUAROCKS_VERSION.tar.gz | tar xzf - | ||
cd luarocks-$LUAROCKS_VERSION | ||
./configure --with-lua=/usr/local | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big fan of hardcoded paths in an installation script. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But Lua internals will always be installed in /usr/local prefix. If there is a valid, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nevermind. Now |
||
make -j$(nproc) | ||
sudo make install | ||
cd $CURR_DIR | ||
} | ||
|
||
# Install Pallene Tracer | ||
install_ptracer() { | ||
cd $CLONE_DIR | ||
git clone --depth 1 https://github.com/pallene-lang/pallene-tracer --branch $PT_VERSION | ||
cd pallene-tracer | ||
make LUA_PREFIX=/usr/local | ||
sudo make install | ||
|
||
if [ "${PALLENE_TRACER_TESTS:-0}" -eq 1 ]; then | ||
./run-tests | ||
fi | ||
|
||
cd $CURR_DIR | ||
} | ||
|
||
# Install Pallene | ||
install_pallene() { | ||
eval "$(luarocks path)" | ||
$SUPERUSER luarocks $LOCAL_FLAG make | ||
|
||
# Run tests | ||
if [ "${PALLENE_TESTS:-0}" -eq 1 ]; then | ||
./run-tests | ||
fi | ||
} | ||
|
||
# Install everything | ||
install_world() { | ||
install_lua_internals | ||
install_luarocks | ||
install_ptracer | ||
install_pallene | ||
} | ||
|
||
# Process arguments | ||
case "$1" in | ||
world) | ||
install_world | ||
;; | ||
lua) | ||
install_lua_internals | ||
;; | ||
rocks) | ||
install_luarocks | ||
;; | ||
ptracer) | ||
install_ptracer | ||
;; | ||
pallene) | ||
install_pallene | ||
;; | ||
--help) | ||
usage 0 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Put the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May I ask why? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Readability; make the function only do one thing. |
||
;; | ||
-h) | ||
usage 0 | ||
;; | ||
*) | ||
usage 1 | ||
;; | ||
esac | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if there is a way to make the script smarter, and only install the things that have a new version. |
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike the LUA_VERSION and PT_VERSION, the LUAROCKS_VERSION is only there because our CI needs a Lua version. In theory we could always go with a more recent version. (And in fact, it's probably about time we bump this to a newer Luarocks...)