diff --git a/.github/workflows/appimage.yml b/.github/workflows/appimage.yml new file mode 100644 index 000000000..976034dad --- /dev/null +++ b/.github/workflows/appimage.yml @@ -0,0 +1,75 @@ +name: Build MG AppImage +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }} + cancel-in-progress: true + +on: + workflow_dispatch: + inputs: + version: + description: 'version number' + required: false + type: string + push: + branches: develop + pull_request: + branches: develop + +jobs: + build-mg-appimage: + runs-on: ${{ matrix.os }} + env: + VERSION: ${{ inputs.version }} + strategy: + matrix: + os: + - ubuntu-24.04-arm + - ubuntu-24.04 + + steps: + - name: Checkout MegaGlest + uses: actions/checkout@v4 + + - name: Checkout Data + uses: actions/checkout@v4 + with: + repository: "megaglest/megaglest-data" + path: "data/glest_game" + + - name: Build AppImage + run: | + export HOSTUID=$(id -u) HOSTGID=$(id -g) + docker compose -f mk/linux/docker/docker-compose.yml run --rm build + + - name: Create sha256sum + run: | + for file in *.AppImage; do + sha256sum "$file" > "$file.sha256sum"; + done + + - name: Artifact Filename + run: | + PLATFORM=$(uname -m) + echo "ARTIFACT_NAME=AppImages-${PLATFORM//\//-}" >> $GITHUB_ENV + + - if: ${{ github.ref != 'refs/heads/develop' }} + name: Upload AppImage + uses: actions/upload-artifact@v4 + with: + name: ${{ env.ARTIFACT_NAME }} + path: ./*AppImage* + if-no-files-found: error + + - if: ${{ github.ref == 'refs/heads/develop' }} + name: 'Prerelease' + uses: ncipollo/release-action@v1 + with: + artifacts: "./*AppImage*" + body: "MegaGlest Snapshot Release" + allowUpdates: true + prerelease: true + removeArtifacts: false + replacesArtifacts: true + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + tag: snapshot diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index b987573c9..474975a66 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -8,14 +8,9 @@ on: branches: [ develop ] pull_request: branches: [ develop ] - workflow_run: - workflows: [Docker Image] - types: [completed] - branches: [develop] jobs: build-linux: - if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} strategy: fail-fast: false matrix: @@ -51,7 +46,6 @@ jobs: # well on Windows or Mac. You can convert this to a matrix build if you need # cross-platform coverage. # See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix - if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} strategy: fail-fast: false matrix: @@ -121,27 +115,18 @@ jobs: $7zPath = $(Get-Command 7z).Source cp $7zPath . Remove-Item glest-dev.ini - Compress-Archive -Path *.exe,*.ini -DestinationPath megaglest-$env:VERSION-x64-windows.zip + Compress-Archive -Path *.exe,*.ini -DestinationPath megaglest-x64-windows.zip cd ../.. - name: Create MegaGlest Snapshot if: ${{ github.ref == 'refs/heads/develop' }} uses: actions/upload-artifact@v4 with: - name: megaglest-x64-windows + name: megaglest-x64-windows-archive retention-days: 1 path: mk/windoze/*.zip - on-dockerbuild-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: | - echo 'The triggering workflow failed' - exit 1 - build-macos: - if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }} strategy: fail-fast: false runs-on: macos-latest @@ -168,7 +153,7 @@ jobs: cd mk/macos ./make-binary-archive.sh cd - - mv release/mg-binary-macos*.tar.bz2 release/megaglest-$VERSION-x64-macos.tar.bz2 + mv release/mg-binary-macos*.tar.bz2 release/megaglest-x64-macos.tar.bz2 - name: Create MegaGlest Snapshot if: ${{ github.ref == 'refs/heads/develop' }} @@ -177,3 +162,4 @@ jobs: name: megaglest-x64-macos retention-days: 1 path: release/*.tar.bz2 + diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index 975f17c23..000000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Docker Image - -on: - push: - branches: - - 'master' - - 'develop' - paths: - - '.github/workflows/docker.yml' - - 'mk/linux/Dockerfile' - schedule: - - cron: '0 0 1 * *' - -jobs: - build: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - file: mk/linux/Dockerfile - push: true - tags: ${{ secrets.DOCKER_HUB_USERNAME }}/megaglest-build-env:bionic - cache-from: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/megaglest-build-env:buildcache - cache-to: type=registry,ref=${{ secrets.DOCKER_HUB_USERNAME }}/megaglest-build-env:buildcache,mode=max diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml deleted file mode 100644 index fa3c59de8..000000000 --- a/.github/workflows/prerelease.yml +++ /dev/null @@ -1,84 +0,0 @@ -name: Pre-release - -on: - workflow_run: - workflows: [Make Snapshot] - types: [completed] - branches: [develop] -jobs: - - release: - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: 'Download artifact' - uses: actions/github-script@v7 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "megaglest-x64-windows" - })[0]; - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-windows.zip`, Buffer.from(download.data)); - - matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "megaglest-x64-ubuntu" - })[0]; - download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-ubuntu.zip`, Buffer.from(download.data)); - - matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "megaglest-x64-macos" - })[0]; - download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-macos.zip`, Buffer.from(download.data)); - - - name: 'Prepare artifacts' - run: | - unzip megaglest-x64-ubuntu.zip - unzip megaglest-x64-windows.zip - unzip megaglest-x64-macos.zip - rm megaglest-x64-windows.zip megaglest-x64-ubuntu.zip megaglest-x64-macos.zip - - name: 'Prerelease' - uses: ncipollo/release-action@v1 - with: - artifacts: "*.tar.xz,*.zip,*.tar.bz2" - body: "MegaGlest Snapshot Release" - allowUpdates: true - prerelease: true - removeArtifacts: true - replacesArtifacts: true - omitBodyDuringUpdate: true - omitNameDuringUpdate: True - tag: snapshot - - on-failure: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'failure' }} - steps: - - run: | - echo 'The triggering workflow failed' - exit 1 diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index 1876c41cb..0989be9a5 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -10,38 +10,7 @@ on: # The artifact only runs on the same distro that it was built on. jobs: - appimage-snapshot: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - container: megaglest/megaglest-build-env:bionic - steps: - - uses: actions/checkout@v4 - - - name: Git Hash - run: | - # Required because docker user is root. - git config --global safe.directory $GITHUB_WORKSPACE - echo "VERSION=$(git rev-parse --short HEAD)" >> $GITHUB_ENV - - - name: Build - run: mk/linux/build-appimage.sh - - - name: Pack - run: | - cd mk/linux/ - mv g2xml g2xml-$VERSION - mv xml2g xml2g-$VERSION - tar cfJ megaglest-$VERSION-x64-appimage.tar.xz *.AppImage g2xml-* xml2g-* - - - name: Create MegaGlest Snapshot - uses: actions/upload-artifact@v4 - with: - name: megaglest-x64-ubuntu - retention-days: 1 - path: | - mk/linux/*.tar.xz - - transfer-macos-snapshot: + release: runs-on: ubuntu-latest permissions: contents: write @@ -67,55 +36,37 @@ jobs: }); let fs = require('fs'); fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-macos.zip`, Buffer.from(download.data)); - - name: 'Prepare artifacts' - run: | - unzip megaglest-x64-macos.zip - rm megaglest-x64-macos.zip - - name: Create MegaGlest MacOS Snapshot - uses: actions/upload-artifact@v4 - with: - name: megaglest-x64-macos - retention-days: 1 - path: | - *.tar.bz2 - transfer-windows-snapshot: - runs-on: ubuntu-latest - permissions: - contents: write - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: 'Download artifact' - uses: actions/github-script@v7 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "megaglest-x64-windows" + matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "megaglest-x64-windows-archive" })[0]; - let download = await github.rest.actions.downloadArtifact({ + download = await github.rest.actions.downloadArtifact({ owner: context.repo.owner, repo: context.repo.repo, artifact_id: matchArtifact.id, archive_format: 'zip', }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-windows.zip`, Buffer.from(download.data)); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/megaglest-x64-windows-archive.zip`, Buffer.from(download.data)); + - name: 'Prepare artifacts' run: | - unzip megaglest-x64-windows.zip - rm megaglest-x64-windows.zip - - name: Create MegaGlest Windows Snapshot - uses: actions/upload-artifact@v4 + unzip megaglest-x64-windows-archive.zip + unzip megaglest-x64-macos.zip + rm megaglest-x64-windows-archive.zip megaglest-x64-macos.zip + + - name: 'Prerelease' + uses: ncipollo/release-action@v1 with: - name: megaglest-x64-windows - retention-days: 1 - path: | - *.zip + artifacts: "*.zip,*.tar.bz2" + body: "MegaGlest Snapshot Release" + allowUpdates: true + prerelease: true + removeArtifacts: false + replacesArtifacts: true + omitBodyDuringUpdate: true + omitNameDuringUpdate: true + tag: snapshot + on-failure: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 9bcf66be0..9ec5c4c69 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,14 @@ Session.vim # Emacs \#*\# +# AppImage +CMakeFiles/ +_build_appimage/ + +# These are output to the source root when the appimage script is run: +#/xml2g +#/g2xml + ## macOS *.DS_Store Icon diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ce01f0be..5970bbf4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,7 @@ OPTION(BUILD_MEGAGLEST_MODEL_VIEWER "Build model viewer" ON) OPTION(BUILD_MEGAGLEST_MAP_EDITOR "Build map editor" ON) OPTION(BUILD_MEGAGLEST "Build MegaGlest" ON) OPTION(BUILD_MEGAGLEST_TESTS "Build MegaGlest Unit Tests" OFF) +OPTION(INCLUDE_DATA "Include Game Data in build. If true but no data present, data will be skipped." ON) OPTION(WANT_SINGLE_INSTALL_DIRECTORY "Use single install directory for everything. It is useful for example for MacOS cpack bundles." OFF) OPTION(WANT_APPIMAGE "Enable AppImage compatibility" ON) OPTION(WANT_STATIC_LIBS "Builds as many static libs as possible." OFF) @@ -157,7 +158,7 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW OR MSVC) IF(NOT WANT_APPIMAGE) MESSAGE(STATUS "**Disable appimage code.") ADD_DEFINITIONS(-DNO_APPIMAGE) - ELSEIF((NOT EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt") AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") + ELSEIF((NOT INCLUDE_DATA OR NOT EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt") AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") MESSAGE(STATUS "**AppImage compatiblity + nodata wanted. Adding flag \"APPIMAGE_NODATA\".") ADD_DEFINITIONS(-DAPPIMAGE_NODATA) ENDIF() @@ -207,6 +208,7 @@ include(CheckCCompilerFlag) # Define your extra flags in a list set(EXTRA_FLAGS + # https://github.com/MegaGlest/megaglest-source/issues/275 "-Werror=odr" "-Werror=lto-type-mismatch" "-Werror=strict-aliasing" @@ -509,7 +511,7 @@ IF(EXISTS "${PROJECT_SOURCE_DIR}/source/") ENDIF() # Check if data exist -IF(EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt") +IF(INCLUDE_DATA AND EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/CMakeLists.txt") MESSAGE(STATUS "**Found game data.") ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/data/glest_game ) ENDIF() @@ -526,7 +528,7 @@ IF(NOT DEFINED CPACK_GENERATOR) ENDIF() # CPack configuration shared accross platforms SET(CPACK_PACKAGE_NAME ${PKG_NAME}) -IF(EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/others/megaglest-long-description.txt.in") +IF(INCLUDE_DATA AND EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/others/megaglest-long-description.txt.in") FILE(READ "${PROJECT_SOURCE_DIR}/data/glest_game/others/megaglest-long-description.txt.in" MEGAGLEST_LONG_DESCRIPTION) SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${MEGAGLEST_LONG_DESCRIPTION}") ELSE() diff --git a/mk/linux/AppRun b/mk/linux/AppRun new file mode 100755 index 000000000..3b08182e2 --- /dev/null +++ b/mk/linux/AppRun @@ -0,0 +1,22 @@ +#! /usr/bin/env bash + +set -e + +HERE="$(readlink -f "$(dirname "$0")")" + +BINARY_NAME="megaglest" + +if [ "$MG_BIN" = "editor" ]; then + BINARY_NAME="megaglest_editor" +elif [ "$MG_BIN" = "viewer" ]; then + BINARY_NAME="megaglest_g3dviewer" +fi + +echo "To invoke the map editor:" +echo "MG_BIN=editor $0" +echo "" +echo "To invoke the g3d model viewer:" +echo "MG_BIN=viewer $0" +echo "" + +exec "$HERE/usr/bin/$BINARY_NAME" "$@" diff --git a/mk/linux/Dockerfile b/mk/linux/Dockerfile deleted file mode 100644 index 120a269ce..000000000 --- a/mk/linux/Dockerfile +++ /dev/null @@ -1,57 +0,0 @@ -# Dockerfile for building mg appimage -FROM ubuntu:bionic - -RUN apt update \ - && apt install -y software-properties-common \ - && add-apt-repository ppa:git-core/ppa \ - && apt update && apt -y upgrade \ - && apt install -y \ - build-essential \ - cmake \ - git \ - imagemagick \ - libbrotli-dev \ - libcppunit-dev \ - libcurl4-gnutls-dev \ - libfreetype6-dev \ - libfribidi-dev \ - libftgl-dev \ - libgl1-mesa-dev \ - libglew-dev \ - libglu1-mesa-dev \ - libgnutls28-dev \ - libidn2-dev \ - libircclient-dev \ - libjpeg-dev \ - libkrb5-dev \ - libldap2-dev \ - liblua5.3-dev \ - libminiupnpc-dev \ - libnghttp2-dev \ - libogg-dev \ - libopenal-dev \ - libpng-dev \ - libpsl-dev \ - librtmp-dev \ - libsdl2-dev \ - libssh-dev \ - libvorbis-dev \ - libwxgtk3.0-gtk3-dev \ - libx11-dev \ - libxml2-dev \ - p7zip-full \ - wget \ - && rm -rf /var/lib/apt/lists - -# Install linuxdeploy -ENV TOOLS_DIR="/tools" -RUN mkdir -p $TOOLS_DIR -ARG ARCH=x86_64 -RUN /bin/bash -c 'cd $TOOLS_DIR \ - && wget https://github.com/linuxdeploy/linuxdeploy/releases/download/1-alpha-20220822-1/linuxdeploy-${ARCH}.AppImage \ - && chmod +x linuxdeploy-${ARCH}.AppImage \ - && ./linuxdeploy-${ARCH}.AppImage --appimage-extract \ - && rm ./linuxdeploy-${ARCH}.AppImage \ - && wget -c "https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh" \ - && chmod +x linuxdeploy-plugin-gtk.sh \ - && cd -' diff --git a/mk/linux/build-appimage.sh b/mk/linux/build-appimage.sh index e04ab8ca6..71a1df1a0 100755 --- a/mk/linux/build-appimage.sh +++ b/mk/linux/build-appimage.sh @@ -1,120 +1,160 @@ #!/bin/sh -set -e - -# SCRIPTLOC=$(dirname "$0") -SCRIPTLOC="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" - -if [ ! -f $TOOLS_DIR/squashfs-root/AppRun ]; then - echo "Please specify the path to the extracted linuxdeploy (squashfs-root) using \$TOOLS_DIR env variable." - exit -1 +# To test this script locally, from the source root directory, +# you can use: +# +# docker run -it --rm -e HOSTUID=$(id -u) -e \ +# -v $PWD:/workspace -w /workspace andy5995/linuxdeploy:v2-focal bash +# +# Normally 'bash' can be replaced with the /path/to/script but starting +# the container from a shell means you can run the script manually in the +# container and then fix any problems, then re-run the script (hint: the +# dependencies will be installed the first time, and not have to be installed +# on subsequent attempts). +# +# Then: 'su - builder' (preserve some environmental variables with '-') +# 'bash' +# 'export VERSION=snapshot' +# 'cd /workspace' +# 'mk/linux/build-appimage.sh' + +set -ev + +if [ -z "$VERSION" ]; then + echo "VERSION must be set" + exit 1 fi -mkdir -p $SCRIPTLOC/BuildAppImage/game -cd $SCRIPTLOC/BuildAppImage/game - -if [ -d $SCRIPTLOC/BuildAppImage/game/AppDir ]; then - rm -r $SCRIPTLOC/BuildAppImage/game/AppDir +# Check if the workspace path is absolute +if [[ "$WORKSPACE" != /* ]]; then + echo "The workspace path must be absolute" + exit 1 fi +test -d "$WORKSPACE" -cmake ../../../.. -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -make DESTDIR=AppDir -j$(nproc) install -strip AppDir/usr/local/bin/megaglest +# Used by linuxdeploy when it sets the filename +export LINUXDEPLOY_OUTPUT_VERSION="$VERSION" -if [ ! -d AppDir/usr/bin ]; then - mkdir -p AppDir/usr/bin -fi +APPIMAGE_BUILD_DIR="$WORKSPACE/_build_appimage" +INST_PREFIX="usr" -cp $(whereis 7z | awk -F ' ' '{print $2;}') AppDir/usr/bin/ -# Hacky workaround to use internal 7z. -sed -i 's#=7z#=$APPLICATIONPATH/7z#' AppDir/usr/local/share/megaglest/glest.ini +#if [ -n "$DO_CLEAN_BUILD" ] && [ -d $APPIMAGE_BUILD_DIR ]; then + #rm -rf $APPIMAGE_BUILD_DIR +#fi -if [ ! -f AppDir/usr/local/share/applications/megaglest.desktop ]; then - wget -P AppDir/usr/local/share/applications/ https://raw.githubusercontent.com/MegaGlest/megaglest-data/develop/others/desktop/megaglest.desktop; +if [ ! -d "$APPIMAGE_BUILD_DIR" ]; then + mkdir -p "$APPIMAGE_BUILD_DIR" fi -convert AppDir/usr/local/share/megaglest/megaglest.ico megaglest.png -mv megaglest-2.png megaglest.png - -$TOOLS_DIR/squashfs-root/AppRun -d AppDir/usr/local/share/applications/megaglest.desktop \ - --icon-file=megaglest.png \ - --icon-filename=megaglest --executable AppDir/usr/local/bin/megaglest --appdir AppDir --output appimage - -mv MegaGlest*.AppImage $SCRIPTLOC - -# MapEditor -mkdir -p $SCRIPTLOC/BuildAppImage/mapeditor -cd $SCRIPTLOC/BuildAppImage/mapeditor - -if [ -d $SCRIPTLOC/BuildAppImage/mapeditor/AppDir ]; then - rm -r $SCRIPTLOC/BuildAppImage/mapeditor/AppDir -fi +sudo DEBIAN_FRONTEND=noninteractive -i sh -c \ + "apt update && + apt upgrade -y && + apt install --no-install-recommends -y + build-essential + $CC + libcurl4-gnutls-dev + libsdl2-dev + libopenal-dev + liblua5.3-dev + libjpeg-dev + libpng-dev + libfreetype6-dev + libwxgtk3.0-gtk3-dev + libcppunit-dev + libfribidi-dev + libftgl-dev + libglew-dev + libogg-dev + libvorbis-dev + libminiupnpc-dev + libircclient-dev + libxml2-dev + libx11-dev + libgl1-mesa-dev + libglu1-mesa-dev + librtmp-dev + libkrb5-dev + libldap2-dev + libidn2-dev + libpsl-dev + libgnutls28-dev + libnghttp2-dev + libssh-dev + libbrotli-dev + p7zip-full + imagemagick" + +cd "$APPIMAGE_BUILD_DIR" +cmake $WORKSPACE \ + -DCMAKE_INSTALL_PREFIX=/$INST_PREFIX \ + -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF +make DESTDIR=$APPIMAGE_BUILD_DIR/AppDir -j$(nproc) install +# This is done by linuxdeploy +# strip AppDir/$INST_PREFIX/local/bin/megaglest + +cp $(whereis 7z | awk -F ' ' '{print $2;}') $APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/bin/ +# Hacky workaround to use internal 7z. +sed -i 's#=7z#=$APPLICATIONPATH/7z#' AppDir/$INST_PREFIX/share/megaglest/glest.ini -cmake ../../../.. -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=ON -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -make DESTDIR=AppDir -j$(nproc) install -strip AppDir/usr/local/bin/megaglest_editor +GAME_DESKTOP_DEST="$APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/applications" -if [ ! -d AppDir/usr/bin ]; then - mkdir -p AppDir/usr/bin +if [ ! -d "$GAME_DESKTOP_DEST" ]; then + mkdir -p "$GAME_DESKTOP_DEST" fi -if [ ! -f AppDir/usr/local/share/applications/megaglest_editor.desktop ]; then - wget -P AppDir/usr/local/share/applications/ https://raw.githubusercontent.com/MegaGlest/megaglest-data/develop/others/desktop/megaglest_editor.desktop; +if [ ! -f "$GAME_DESKTOP_DEST/megaglest.desktop" ]; then + cp "$WORKSPACE/data/glest_game/others/desktop/megaglest.desktop" "$GAME_DESKTOP_DEST" fi -convert AppDir/usr/local/share/megaglest/editor.ico editor.png -mv editor-2.png editor.png -# Another stupid hack to fix icons. -sed -i 's#Icon=megaglest#Icon=editor#' AppDir/usr/local/share/applications/megaglest_editor.desktop - -ln -s $TOOLS_DIR/linuxdeploy-plugin-gtk.sh . - -$TOOLS_DIR/squashfs-root/AppRun -d AppDir/usr/local/share/applications/megaglest_editor.desktop \ - --icon-file=editor.png \ - --icon-filename=editor --executable AppDir/usr/local/bin/megaglest_editor --appdir AppDir --plugin gtk --output appimage - -mv MegaGlest*.AppImage $SCRIPTLOC +convert $APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/megaglest.ico megaglest.png +mv megaglest-2.png megaglest.png -# G3D viewer -mkdir -p $SCRIPTLOC/BuildAppImage/g3dviewer -cd $SCRIPTLOC/BuildAppImage/g3dviewer +MAP_EDITOR_DESKTOP_DEST="$APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/applications" +if [ ! -d "$MAP_EDITOR_DESKTOP_DEST" ]; then + mkdir -p "$MAP_EDITOR_DESKTOP_DEST" +fi -if [ -d $SCRIPTLOC/BuildAppImage/g3dviewer/AppDir ]; then - rm -r $SCRIPTLOC/BuildAppImage/g3dviewer/AppDir +if [ ! -f "$MAP_EDITOR_DESKTOP_DEST/megaglest_editor.desktop" ]; then + cp "$WORKSPACE/data/glest_game/others/desktop/megaglest_editor.desktop" "$MAP_EDITOR_DESKTOP_DEST" + # Another stupid hack to fix icons. + sed -i 's#Icon=megaglest#Icon=editor#' $MAP_EDITOR_DESKTOP_DEST/megaglest_editor.desktop fi -cmake ../../../.. -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=ON -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -make DESTDIR=AppDir -j$(nproc) install -strip AppDir/usr/local/bin/megaglest_g3dviewer +#convert $APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/editor.ico editor.png +#mv editor-2.png editor.png -if [ ! -d AppDir/usr/bin ]; then - mkdir -p AppDir/usr/bin +G3DVIEWER_DESKTOP_DEST="$APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/applications" +if [ ! -d "$G3DVIEWER_DESKTOP_DEST" ]; then + mkdir -p "$G3DVIEWER_DESKTOP_DEST" fi -if [ ! -f AppDir/usr/local/share/applications/megaglest_g3dviewer.desktop ]; then - wget -P AppDir/usr/local/share/applications/ https://raw.githubusercontent.com/MegaGlest/megaglest-data/develop/others/desktop/megaglest_g3dviewer.desktop; +if [ ! -f "$G3DVIEWER_DESKTOP_DEST/megaglest_g3dviewer.desktop" ]; then + cp "$WORKSPACE/data/glest_game/others/desktop/megaglest_g3dviewer.desktop" "$G3DVIEWER_DESKTOP_DEST" + # Another stupid hack to fix icons. + sed -i 's#Icon=megaglest#Icon=g3dviewer#' $G3DVIEWER_DESKTOP_DEST/megaglest_g3dviewer.desktop fi -convert AppDir/usr/local/share/megaglest/g3dviewer.ico g3dviewer.png -mv g3dviewer-2.png g3dviewer.png -# Another stupid hack to fix icons. -sed -i 's#Icon=megaglest#Icon=g3dviewer#' AppDir/usr/local/share/applications/megaglest_g3dviewer.desktop +#convert $APPIMAGE_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/g3dviewer.ico g3dviewer.png +#mv g3dviewer-2.png g3dviewer.png -ln -s $TOOLS_DIR/linuxdeploy-plugin-gtk.sh . - -$TOOLS_DIR/squashfs-root/AppRun -d AppDir/usr/local/share/applications/megaglest_g3dviewer.desktop \ - --icon-file=g3dviewer.png \ - --icon-filename=g3dviewer --executable AppDir/usr/local/bin/megaglest_g3dviewer --appdir AppDir --plugin gtk --output appimage +linuxdeploy -d $GAME_DESKTOP_DEST/megaglest.desktop \ + --icon-file=megaglest.png \ + --icon-filename=megaglest \ + --custom-apprun="$WORKSPACE/mk/linux/AppRun" \ + --executable AppDir/$INST_PREFIX/bin/megaglest \ + --appdir AppDir \ + --plugin gtk \ + --output appimage -mv MegaGlest*.AppImage $SCRIPTLOC +mv MegaGlest*.AppImage "$WORKSPACE" # Tools -mkdir -p $SCRIPTLOC/BuildAppImage/tools -cd $SCRIPTLOC/BuildAppImage/tools +#mkdir -p $APPIMAGE_BUILD_DIR/tools +#cd $APPIMAGE_BUILD_DIR/tools -cmake ../../../.. -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=ON -make -j$(nproc) +#cmake $WORKSPACE -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=ON +#make -j$(nproc) -strip source/tools/glexemel/g2xml source/tools/glexemel/xml2g -mv source/tools/glexemel/g2xml $SCRIPTLOC -mv source/tools/glexemel/xml2g $SCRIPTLOC +#strip source/tools/glexemel/g2xml source/tools/glexemel/xml2g +#mv source/tools/glexemel/g2xml $WORKSPACE +#mv source/tools/glexemel/xml2g $WORKSPACE diff --git a/mk/linux/docker/.env b/mk/linux/docker/.env new file mode 100644 index 000000000..370b68e2f --- /dev/null +++ b/mk/linux/docker/.env @@ -0,0 +1,10 @@ +# These variables can be overridden by exporting them from the +# command line when running `docker compose` +# +# Your numeric uid and gid +HOSTUID= +HOSTGID= + +# When run from the root of your project directory, this will be +# the location in the container +WORKSPACE="/workspace" diff --git a/mk/linux/docker/docker-compose.yml b/mk/linux/docker/docker-compose.yml new file mode 100644 index 000000000..cc25779a2 --- /dev/null +++ b/mk/linux/docker/docker-compose.yml @@ -0,0 +1,21 @@ +services: + build: + environment: + HOSTUID: ${HOSTUID} + HOSTGID: ${HOSTGID} + VERSION: ${VERSION:-snapshot} + WORKSPACE: ${WORKSPACE} + CC: "${CC:-gcc}" + CXX: "${CXX:-g++}" + image: andy5995/linuxdeploy:v3-jammy + platform: ${PLATFORM} + volumes: + - ${PWD}:${WORKSPACE} + working_dir: ${WORKSPACE} + + # Note that SCRIPT is not used by the container, therefore + # is not included within the 'environment' section above + # + # Absolute path or Relative to workspace + # e.g. $WORKSPACE/path/to/script + command: "${SCRIPT:-mk/linux/build-appimage.sh}"