diff --git a/build.sh b/build.sh index 25bd025..a8e70ac 100644 --- a/build.sh +++ b/build.sh @@ -1,25 +1,23 @@ #!/bin/bash -e # run this script on an aarch64 computer, running modern debian or -# something similar, otherwise it's not going to work... +# something similar, otherwise it's not going to work... -VERSION="5.16.1" -SDL_VERSION="2.32.10" +VERSION="5.15.1" -BOLD="\x1b[1m" -RED="\x1b[31m" -GREEN="\x1b[32m" -RESET="\x1b[0m" +BOLD="\033[1m" +RED="\033[31m" +GREEN="\033[32m" +RESET="\033[0m" # make sure we are root -if [ "$(id -u)" != "0" ]; then +if [ "$(id -u)" != 0 ]; then echo -e "${BOLD}${RED}This script must be run as root!${RESET}" exit 1 fi # install deps echo -e "${BOLD}Downloading deps...${RESET}" - apt-get install -y --no-install-recommends \ git \ g++ \ @@ -48,19 +46,12 @@ apt-get install -y --no-install-recommends \ ca-certificates \ file -# download luajit, SDL2, and luanti source code -echo -e "${BOLD}Downloading LuaJIT, SDL2, and Luanti source code...${RESET}" -git clone --depth=1 https://github.com/LuaJIT/LuaJIT.git luajit +# download source code +echo -e "${BOLD}Downloading LuaJIT and Luanti source code...${RESET}" +git clone --depth 1 https://github.com/LuaJIT/LuaJIT.git luajit curl -Lo luanti.zip https://github.com/luanti-org/luanti/archive/refs/tags/${VERSION}.zip -curl -Lo sdl2.zip https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/SDL2-${SDL_VERSION}.zip - unzip luanti.zip mv luanti-${VERSION} luanti/ -rm luanti.zip - -unzip sdl2.zip -mv SDL2-${SDL_VERSION} sdl2 -rm sdl2.zip # compile luajit echo -e "${BOLD}Compiling LuaJIT...${RESET}" @@ -68,26 +59,6 @@ cd luajit make amalg -j$(nproc) cd .. -# compile sdl2 -echo -e "${BOLD}Compiling SDL2...${RESET}" -cd sdl2 - -mkdir build -cd build - -cmake .. -G Ninja \ - -DSDL_INSTALL_CMAKEDIR=usr/lib/cmake/SDL2 \ - -DCMAKE_BUILD_TYPE=Release \ - -DCMAKE_INSTALL_PREFIX=/ \ - -DCMAKE_C_FLAGS="-DSDL_LEAN_AND_MEAN=1" \ - -DSDL_{AUDIO,RENDER,VULKAN,TEST,STATIC}=OFF - -ninja -j$(nproc) -strip -s *.so -DESTDIR="../../" ninja install -j$(nproc) - -cd ../.. - # prepare to compile luanti cd luanti mkdir -p build @@ -97,7 +68,7 @@ echo -e "${BOLD}Downloading AppImageTool${RESET}" curl -Lo appimagetool https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-aarch64.AppImage chmod +x appimagetool -# compile luanti +# compile and install into AppDir echo -e "${BOLD}Compiling Luanti...${RESET}" cmake .. -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ @@ -107,14 +78,13 @@ cmake .. -G Ninja \ -DLUA_INCLUDE_DIR=../../luajit/src/ \ -DLUA_LIBRARY=../../luajit/src/libluajit.a -# install into the AppDir folder ninja install -j$(nproc) # build the appimage itself cd AppDir echo -e "${BOLD}Building AppImage...${RESET}" -# put desktop and icon at root of AppDir +# put desktop and icon at root ln -sf usr/share/applications/org.luanti.luanti.desktop luanti.desktop ln -sf usr/share/icons/hicolor/128x128/apps/luanti.png luanti.png ln -sf luanti.png .DirIcon @@ -122,40 +92,37 @@ ln -sf luanti.png .DirIcon # fix locales mv usr/share/locale usr/share/luanti -cat > AppRun <<'EOF' -#!/bin/bash +cat > AppRun <<'APPRUN' +#!/bin/sh APP_PATH="$(dirname "$(readlink -f "${0}")")" export LD_LIBRARY_PATH="${APP_PATH}"/usr/lib/:"${LD_LIBRARY_PATH}" exec "${APP_PATH}/usr/bin/luanti" "$@" -EOF - +APPRUN chmod +x AppRun # bundle the libraries INCLUDE_LIBS=( libopenal.so.1 - libsndio.so.7.0 - libbsd.so.0 - libmd.so.0 + libSDL2-2.0.so.0 + libsndio.so.7.0 + libbsd.so.0 + libmd.so.0 libjpeg.so.62 libpng16.so.16 libvorbisfile.so.3 - libogg.so.0 - libvorbis.so.0 + libogg.so.0 + libvorbis.so.0 libzstd.so.1 libsqlite3.so.0 libleveldb.so.1d - libsnappy.so.1 + libsnappy.so.1 ) mkdir -p usr/lib/ for i in "${INCLUDE_LIBS[@]}"; do - cp /usr/lib/aarch64-linux-gnu/${i} usr/lib/ + cp /usr/lib/aarch64-linux-gnu/$i usr/lib/ done -# copy our SDL2 into place -cp ../../../usr/lib/libSDL2-2.0.so.0 usr/lib/ - # finally make the appimage cd .. ARCH=aarch64 ./appimagetool --appimage-extract-and-run AppDir/ @@ -166,9 +133,7 @@ mv Luanti-aarch64.AppImage ../../luanti-${VERSION}-aarch64.AppImage # clean up cd ../.. -rm -rf luanti/ -rm -rf sdl2/ -rm -rf usr/ +rm -rf luanti{,.zip} rm -rf luajit/ # done :D diff --git a/test.sh b/test.sh index 9e2638d..a5619df 100644 --- a/test.sh +++ b/test.sh @@ -3,12 +3,12 @@ # test the AppImage built with build.sh # again, this only works on aarch64 -VERSION="5.16.1" +VERSION="5.15.1" -BOLD="\x1b[1m" -RED="\x1b[31m" -GREEN="\x1b[32m" -RESET="\x1b[0m" +BOLD="\033[1m" +RED="\033[31m" +GREEN="\033[32m" +RESET="\033[0m" # make sure we are root if [ "$(id -u)" != 0 ]; then @@ -21,7 +21,6 @@ if [ "$(ps aux | grep luanti | wc -l)" != 1 ]; then echo -e "${BOLD}${RED}No Luanti processes may be running while this script is run.${RESET}" exit 1 fi - # check if the AppImage even exists echo -e "${BOLD}Checking if AppImage exists...${RESET}" @@ -64,7 +63,7 @@ DEPS=( echo -e "${BOLD}Removing dependencies...${RESET}" for d in "${DEPS[@]}"; do - apt remove ${d} -y + apt remove $d -y done # test the AppImage @@ -88,7 +87,7 @@ echo -e "${BOLD}Reinstalling dependencies...${RESET}" # reinstall the dependencies for d in "${DEPS[@]}"; do - apt-get install -y ${d} + apt-get install -y $d done exit 0