Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 8 additions & 39 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,17 @@ on:
pull_request:
branches: [ master ]

env:
LUA_VERSION: 5.4.7
LUAROCKS_VERSION: 3.9.0
PT_VERSION: 0.5.0a

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Install Lua
run: |
wget -O - https://github.com/pallene-lang/lua-internals/archive/refs/tags/${{env.LUA_VERSION}}.tar.gz | tar xzf -
cd lua-internals-${{env.LUA_VERSION}}
make linux
sudo make install

- name: Install Luarocks
- name: Install Lua and LuaRocks
run: |
wget -O - https://luarocks.org/releases/luarocks-${{env.LUAROCKS_VERSION}}.tar.gz | tar xzf -
cd luarocks-${{env.LUAROCKS_VERSION}}
./configure --with-lua=/usr/local
make
sudo make install
./install.sh lua
./install.sh rocks

- name: Install Luacheck
run: luarocks install --local luacheck
Expand All @@ -63,30 +48,14 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Install Lua
run: |
wget -O - https://github.com/pallene-lang/lua-internals/archive/refs/tags/${{env.LUA_VERSION}}.tar.gz | tar xzf -
cd lua-internals-${{env.LUA_VERSION}}
make linux
sudo make install

- name: Install Luarocks
run: |
wget -O - https://luarocks.org/releases/luarocks-${{env.LUAROCKS_VERSION}}.tar.gz | tar xzf -
cd luarocks-${{env.LUAROCKS_VERSION}}
./configure --with-lua=/usr/local
make
sudo make install

- name: Install Pallene Tracer
- name: Install Lua, LuaRocks and Pallene Tracer
run: |
git clone --depth 1 https://github.com/pallene-lang/pallene-tracer --branch ${{env.PT_VERSION}}
cd pallene-tracer
make LUA_PREFIX=/usr/local
sudo make install
./install.sh lua
./install.sh rocks
./install.sh ptracer

- name: Build
run: luarocks --local make
run: PALLENE_LOCAL=1 ./install.sh pallene

- name: Install Busted
run: luarocks --local install busted
Expand Down
152 changes: 152 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
# 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
Copy link
Member

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...)

PT_VERSION=0.5.0a

# Where we will clone
CLONE_DIR="/tmp/pallene"
mkdir -p $CLONE_DIR

# Current working directory
CURR_DIR=$(pwd)

# Where to install/locate Lua
LUA_PREFIX=${LUA_PREFIX:-/usr/local}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please initialize everything that has a default value here on top. That way it's easier to see what all the configuration options are. (For example, PALLENE_LOCAL, etc)


# 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 "Lua Internals:"
echo " Use LUA_CFLAGS, LUA_LDFLAGS, LUA_LIBS and LUA_OBJS to pass flags:"
echo " LUA_MYCFLAGS=-DLUAI_ASSERT ./install.sh lua; or"
echo " LUA_CFLAGS=-fsanitize=address LUA_LDFLAGS=-lasan ./install.sh lua; to enable Address Sanitization"
echo
echo " Use LUA_PLAT to define Lua platform. Defualt is 'linux'."
echo " Available platforms: guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris"
echo " e.g. LUA_PLAT=linux-readline ./install.sh lua"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default plat should be "guess"
In the documentation, we should encourage users to use linux-readline option.

echo
echo " Use LUA_PREFIX to provide Lua install prefix. Default is '/usr/local'."
echo " e.g. LUA_PREFIX=/usr/local ./install.sh lua"
echo
echo "Pallene Tracer:"
echo " Use PT_TESTS=1 to run Pallene Tracer tests after installation, e.g."
echo " PT_TESTS=1 ./install.sh ptracer"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the PT_TESTS functionality? I would rather have the CI run those in a separate step than integrate them into the installation script. It complicates the script, and also introduces a dependency on busted.

echo
echo " Use PT_LDFLAGS to pass LDFLAGS to Pallene Tracer Makefile, e.g."
echo " PT_LDFLAGS=-lasan ./install.sh ptracer; if Lua is built with Address Sanitizer"
echo
echo "Pallene:"
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"
}

# 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 clean
make ${LUA_PLAT:-linux} MYCFLAGS="$LUA_CFLAGS" MYLDFLAGS="$LUA_LDFLAGS" MYLIBS="$LUA_LIBS" MYOBJS="$LUA_OBJS" -j$(nproc)
sudo make install INSTALL_TOP=$LUA_PREFIX
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=$LUA_PREFIX
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 clean
sudo make install LUA_PREFIX=$LUA_PREFIX LDFLAGS="$PT_LDFLAGS"

if [ "${PT_TESTS:-0}" -eq 1 ]; then
./run-tests
fi

cd $CURR_DIR
}

# Install Pallene
install_pallene() {
eval "$(luarocks path)"

# Local installation
if [ "${PALLENE_LOCAL:-0}" -eq 1 ]; then
luarocks --local make
else
sudo luarocks make
fi

# 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
;;
-h)
usage
;;
*)
usage
exit 1
;;
esac
Copy link
Member

Choose a reason for hiding this comment

The 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.


Loading