scripts/install-lua.sh: init script

Add a script that installs a Lua source archive into the Callisto
source tree. This will ease the pain of transitioning to Lua 5.4.7.

References: https://todo.sr.ht/~jeremy/callisto/8
This commit is contained in:
Jeremy Baxter 2024-06-13 10:40:07 +12:00
parent 00ea15b0b4
commit 90af5483fa

31
scripts/install-lua.sh Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env sh
# usage: scripts/install-lua.sh lua-x.x.x.tar.gz
# Install a Lua release into the Callisto source tree.
set -e
[ -z "$1" ] && (echo "usage: $0 lua-x.x.x.tar.gz"; exit 1)
! [ -d external/lua ] && (echo "not in Callisto source tree"; exit 1) || true
# clear out existing Lua sources
cd external/lua/
for file in $(ls -A | sed -Ee 's/^(patches|.gitignore)$//'); do
rm -fr "$file"
done
cd ../../
# install new Lua sources
luadir="$(tar -tf "$1" | head -n1)"
rm -rf "$luadir"
tar -xf "$1"
ls "$luadir"
mv "$luadir"/README "$luadir"/src/
cp -R "$luadir"/src/* external/lua/
rm -r "$luadir"
# patch the sources
cd external/lua
for patch in $(ls patches/); do
patch -p0 -i patches/"$patch"
done
cd ../../