Luanti AppImage creator bash script

Post Reply
User avatar
aiyu
New member
Posts: 1
Joined: Tue Dec 02, 2025 13:56

Luanti AppImage creator bash script

by aiyu » Post

So, I'm in the process of making a "PortableApps" style appimage menu for Linux, and I got bored and made this script to make a Luanti appimage.

This has only been tested on Debian 12, it may or may not work for you, it could probably use improvement.

NOTE: I'm tired, sleep deprived, and in a rush due to doctors appointment, so, there may be things overlooked.

Code: Select all

#!/bin/bash

## Exit if any errors
set -e

## Let's not waste the users time, if arch isn't supported by appimage, exit
ARCH=$(uname -m)

case "$ARCH" in
    x86_64)
        echo -e "\e[92mDetected x86_64\e[0m"
        ;;

    i686)
        echo -e "\e[92mDetected i686\e[0m"
        ;;

    armhf|armv7l)
        echo -e "\e[92mDetected armhf\e[0m"
        ;;

    aarch64|arm64)
        echo -e "\e[92mDetected aarch64\e[0m"
        ;;

    *)
        echo -e "\e[92mUnsupported architecture: $ARCH\e[0m"
        exit 1
        ;;
esac


## Let's see what distro we're on so we can install deps
echo -e "\e[92mInstalling deps\e[0m"
DISTRO=$( . /etc/os-release && echo "$ID" )

case "$DISTRO" in
    debian|ubuntu)
        echo "Detected Debian-based system"
        sudo apt update
        sudo apt install -y g++ make libc6-dev cmake libpng-dev libjpeg-dev \
            libgl1-mesa-dev libsqlite3-dev libogg-dev libvorbis-dev \
            libopenal-dev libcurl4-gnutls-dev libfreetype6-dev zlib1g-dev \
            libgmp-dev libjsoncpp-dev libzstd-dev libluajit-5.1-dev gettext \
            libsdl2-dev wget git
        ;;

    fedora|rhel|centos)
        echo "Detected RHEL-based system"
        sudo dnf install -y make automake gcc gcc-c++ kernel-devel cmake \
            libcurl-devel openal-soft-devel libpng-devel libjpeg-devel \
            libvorbis-devel libogg-devel freetype-devel mesa-libGL-devel \
            zlib-devel jsoncpp-devel gmp-devel sqlite-devel luajit-devel \
            leveldb-devel ncurses-devel spatialindex-devel libzstd-devel \
            gettext SDL2-devel git wget
        ;;

    arch)
        echo "Detected Arch-based system"
        sudo pacman -Syu --needed --noconfirm base-devel libcurl-gnutls cmake \
            libpng libjpeg-turbo sqlite libogg libvorbis openal freetype2 \
            jsoncpp gmp luajit leveldb ncurses zstd gettext sdl2 git wget
        ;;

    opensuse*|suse|sles)
        echo "Detected openSUSE / SUSE"
        sudo zypper refresh
        sudo zypper install -y gcc gcc-c++ cmake libjpeg8-devel libpng16-devel \
            openal-soft-devel libcurl-devel sqlite3-devel luajit-devel \
            libzstd-devel Mesa-libGL-devel libvorbis-devel freetype2-devel \
            SDL2-devel git wget
        ;;

    alpine)
        echo "Detected Alpine Linux"
        sudo apk add build-base cmake libpng-dev jpeg-dev mesa-dev sqlite-dev \
            libogg-dev libvorbis-dev openal-soft-dev curl-dev freetype-dev \
            zlib-dev gmp-dev jsoncpp-dev luajit-dev zstd-dev gettext \
            sdl2-dev git wget
        ;;

    void)
        echo "Detected Void Linux"
        sudo xbps-install -Sy cmake libpng-devel jpeg-devel mesa sqlite-devel \
            libogg-devel libvorbis-devel libopenal-devel libcurl-devel \
            freetype-devel zlib-devel gmp-devel jsoncpp-devel LuaJIT-devel \
            zstd libzstd-devel gettext SDL2-devel git wget
        ;;

    *)
        echo "Unsupported linux distribution: $DISTRO"
        exit 1
        ;;
esac

## Clone helper: clones if missing, auto-updates if exists
## Supports extra git args before the URL (e.g. --depth 1)
clone_repo() {
    local url="${@: -1}"        # last argument = URL
    local dir
    dir=$(basename "$url" .git)

    # Everything except last arg (the URL) is passed to git clone
    local clone_args=("${@:1:$#-1}")

    if [ -d "$dir/.git" ]; then
        echo "$dir exists, updating..."
        git -C "$dir" pull --ff-only
    else
        echo "Cloning $url"
        git clone "${clone_args[@]}" "$url"
    fi
}

## Fetch the luanti source
echo -e "\e[92mFetching and compiling Luanti\e[0m"
clone_repo --depth 1 https://github.com/luanti-org/luanti.git
cd luanti

## Let's build
cmake .
make -j"$(nproc)"

## AppImage time
mkdir -p luanti-appimage
cd luanti-appimage

## Fetch some popular games
mkdir -p games
cd games
clone_repo https://github.com/luanti-org/minetest_game.git
clone_repo https://git.minetest.land/VoxeLibre/VoxeLibre.git
clone_repo https://codeberg.org/mineclonia/mineclonia.git

## Move compiled Luanti files into the appimage folder
cd ..
cp -r ../bin/ ../builtin/ ../client/ ../clientmods/ ../doc/ ../fonts/ \
      ../lib/ ../locale/ ../po/ ../textures/ .

## Prep some files
echo -e "\e[92mPrepping some files\e[0m"
cat > AppRun << 'EOF'
#!/bin/bash

cd "$(dirname "$0")"

cat credits

vblank_mode=0 ./bin/luanti
EOF
chmod +x ./AppRun

cat > credits << 'EOF'
=(^_^)=
EOF

cat > luanti.desktop << 'EOF'
[Desktop Entry]
Name=Luanti
GenericName=Luanti
Comment=Block-based multiplayer game platform
Comment[de]=Blockbasierte Mehrspieler-Spieleplattform
Comment[fr]=Plate-forme de jeu multijoueurs à base de blocs
Exec=AppRun
Icon=luanti
Terminal=false
PrefersNonDefaultGPU=true
Type=Application
Categories=Game;Simulation;
StartupNotify=false
Keywords=sandbox;world;mining;crafting;blocks;nodes;multiplayer;roleplaying;minetest;
EOF

cat > readme.md << 'EOF'
# Luanti AppImages

### How to build
EOF

## Get Icon
wget -nc -O "luanti.svg" "https://upload.wikimedia.org/wikipedia/commons/a/a4/Minetest_logo.svg"

## Make the appimage
echo -e "\e[92mMaking the AppImage\e[0m"
cd ..

APPIMG_TOOL="appimagetool.appimage"

# Download appimagetool based on arch only if it does not exist
if [ ! -f "$APPIMG_TOOL" ]; then
    case "$ARCH" in
        x86_64)
            wget -O "$APPIMG_TOOL" \
                "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage"
            ;;

        i686)
            wget -O "$APPIMG_TOOL" \
                "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-i686.AppImage"
            ;;

        armhf|armv7l)
            wget -O "$APPIMG_TOOL" \
                "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-armhf.AppImage"
            ;;

        aarch64|arm64)
            wget -O "$APPIMG_TOOL" \
                "https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-aarch64.AppImage"
            ;;

        *)
            echo "Unsupported architecture for appimagetool: $ARCH"
            exit 1
            ;;
    esac
fi

chmod +x "$APPIMG_TOOL"

# Make it
./"$APPIMG_TOOL" ./luanti-appimage

echo -e "\e[92mAppImage has been made!\e[0m"

EDIT: Finally have an alpha level menu if anyone wants to try it. The luanti appimage maker script in the menu is different than this as its made specifically for use with the menu.
https://github.com/proboner/pyappimagemenu

bgstack15
Member
Posts: 47
Joined: Fri Feb 28, 2025 02:31

Re: Luanti AppImage creator bash script

by bgstack15 » Post

Thank you for sharing the AppImage build! That's a tech I have not gotten into yet, and this is a good working example. I know a little about building a Flatpak, but seeing this is great.

I also like its availability in your menu app you linked to.
cdb_5ea39b4225fd

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests