Created
June 2, 2025 12:48
-
-
Save dol/31d247dd47e666eaffd62b2f0e3eba92 to your computer and use it in GitHub Desktop.
Download luarocks dependencies for offline usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -Eeuo pipefail | |
if [ -z "$1" ]; then | |
echo "No argument supplied" | |
fi | |
DEPENDENCIES_DIR="${PWD}/luarocks-dependencies" | |
mkdir -p "${DEPENDENCIES_DIR}" | |
# Pin the dependencies | |
luarocks build --only-deps --pin "$1" | |
mv luarocks.lock "${DEPENDENCIES_DIR}"/luarocks_lock.lua | |
cd "${DEPENDENCIES_DIR}" | |
echo "Dependencies in ${DEPENDENCIES_DIR}:" | |
while read -r line; do | |
if [ -z "$line" ]; then | |
continue | |
fi | |
IFS=" " read -r name version <<<"$line" | |
# If name is lua skip it | |
if [ "$name" = "lua" ]; then | |
continue | |
fi | |
echo "Downloading ${name} ${version}" | |
if ! luarocks search "${name}" "${version}" --porcelain | cut -f1,2,3 --output-delimiter " " | grep -q -F "${name} ${version} src"; then | |
luarocks download --rockspec "${name}" "${version}" | |
luarocks pack "${name}-${version}.rockspec" | |
else | |
luarocks download --source "${name}" "${version}" | |
fi | |
done <<<"$(lua -e "for name, version in pairs(require('luarocks_lock').dependencies) do print(name .. ' ' .. version) end")" | |
luarocks-admin make_manifest --local-tree "${PWD}" | |
cp manifest manifest-5.1 | |
cp manifest manifest-5.2 | |
cp manifest manifest-5.4 | |
# luarocks install --only-deps <name>.rockspec --only-server ./luarocks-dependencies |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment