Skip to content

Commit

Permalink
Set install prefix, prevent duplicates (#282)
Browse files Browse the repository at this point in the history
* Set install prefix, prevent duplicates

* Exit if VERSION is not set
  • Loading branch information
andy5995 committed Oct 9, 2024
1 parent 8ddccc1 commit 2e21868
Showing 1 changed file with 31 additions and 34 deletions.
65 changes: 31 additions & 34 deletions mk/linux/build-appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -ev

if [ -z "$VERSION" ]; then
echo "VERSION must be set"
exit 1
fi

# Set default workspace if not provided
WORKSPACE=${WORKSPACE:-$(pwd)}
# Check if the workspace path is absolute
Expand All @@ -19,7 +24,11 @@ if [[ "$SOURCE_ROOT" != /* ]]; then
exit 1
fi

# Used by linuxdeploy when it sets the filename
export LINUXDEPLOY_OUTPUT_VERSION="$VERSION"

APPIMAGE_BUILD_DIR="$SOURCE_ROOT/_build_appimage"
INST_PREFIX="usr"

#if [ -n "$DO_CLEAN_BUILD" ] && [ -d $APPIMAGE_BUILD_DIR ]; then
#rm -rf $APPIMAGE_BUILD_DIR
Expand All @@ -37,26 +46,22 @@ for dir in "$GAME_BUILD_DIR" "$MAP_EDITOR_BUILD_DIR" "$G3DVIEWER_BUILD_DIR"; do
fi
done

cd $GAME_BUILD_DIR

sudo DEBIAN_FRONTEND=noninteractive -i sh -c \
"apt update &&
apt upgrade -y &&
apt install -y build-essential 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"

cmake $SOURCE_ROOT -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF
cd "$GAME_BUILD_DIR"
cmake $SOURCE_ROOT -DCMAKE_INSTALL_PREFIX=/$INST_PREFIX -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF
make DESTDIR=$GAME_BUILD_DIR/AppDir -j$(nproc) install
# strip AppDir/usr/local/bin/megaglest

if [ ! -d "$GAME_BUILD_DIR/AppDir/usr/bin" ]; then
mkdir -p "$GAME_BUILD_DIR/AppDir/usr/bin"
fi
# This is done by linuxdeploy
# strip AppDir/$INST_PREFIX/local/bin/megaglest

cp $(whereis 7z | awk -F ' ' '{print $2;}') $GAME_BUILD_DIR/AppDir/usr/bin/
cp $(whereis 7z | awk -F ' ' '{print $2;}') $GAME_BUILD_DIR/AppDir/$INST_PREFIX/bin/
# Hacky workaround to use internal 7z.
sed -i 's#=7z#=$APPLICATIONPATH/7z#' AppDir/usr/local/share/megaglest/glest.ini
sed -i 's#=7z#=$APPLICATIONPATH/7z#' AppDir/$INST_PREFIX/share/megaglest/glest.ini

GAME_DESKTOP_DEST="$GAME_BUILD_DIR/AppDir/usr/local/share/applications"
GAME_DESKTOP_DEST="$GAME_BUILD_DIR/AppDir/$INST_PREFIX/share/applications"

if [ ! -d "$GAME_DESKTOP_DEST" ]; then
mkdir -p "$GAME_DESKTOP_DEST"
Expand All @@ -66,32 +71,23 @@ if [ ! -f "$GAME_DESKTOP_DEST/megaglest.desktop" ]; then
curl -Lo $GAME_DESKTOP_DEST/megaglest.desktop https://raw.githubusercontent.com/MegaGlest/megaglest-data/develop/others/desktop/megaglest.desktop
fi

convert $GAME_BUILD_DIR/AppDir/usr/local/share/megaglest/megaglest.ico megaglest.png
convert $GAME_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/megaglest.ico megaglest.png
mv megaglest-2.png megaglest.png

LINUXDEPLOY_OUTPUT_VERSION="$VERSION"

linuxdeploy -d $GAME_DESKTOP_DEST/megaglest.desktop \
--icon-file=megaglest.png \
--icon-filename=megaglest \
--executable $GAME_BUILD_DIR/AppDir/usr/local/bin/megaglest \
--appdir $GAME_BUILD_DIR/AppDir \
--executable AppDir/$INST_PREFIX/bin/megaglest \
--appdir AppDir \
--output appimage

mv MegaGlest*.AppImage $WORKSPACE

cd $MAP_EDITOR_BUILD_DIR

cmake $SOURCE_ROOT -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=ON -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -DINCLUDE_DATA=OFF
cmake $SOURCE_ROOT -DCMAKE_INSTALL_PREFIX=/$INST_PREFIX -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=OFF -DBUILD_MEGAGLEST_MAP_EDITOR=ON -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -DINCLUDE_DATA=OFF
make DESTDIR=$MAP_EDITOR_BUILD_DIR/AppDir -j$(nproc) install
# strip AppDir/usr/local/bin/megaglest_editor

if [ ! -d $MAP_EDITOR_BUILD_DIR/AppDir/usr/bin ]; then
mkdir -p $MAP_EDITOR_BUILD_DIR/AppDir/usr/bin
fi

MAP_EDITOR_DESKTOP_DEST="$MAP_EDITOR_BUILD_DIR/AppDir/usr/local/share/applications"

MAP_EDITOR_DESKTOP_DEST="$MAP_EDITOR_BUILD_DIR/AppDir/$INST_PREFIX/share/applications"
if [ ! -d "$MAP_EDITOR_DESKTOP_DEST" ]; then
mkdir -p "$MAP_EDITOR_DESKTOP_DEST"
fi
Expand All @@ -102,23 +98,22 @@ if [ ! -f "$MAP_EDITOR_DESKTOP_DEST/megaglest_editor.desktop" ]; then
sed -i 's#Icon=megaglest#Icon=editor#' $MAP_EDITOR_DESKTOP_DEST/megaglest_editor.desktop
fi

convert $MAP_EDITOR_BUILD_DIR/AppDir/usr/local/share/megaglest/editor.ico editor.png
convert $MAP_EDITOR_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/editor.ico editor.png
mv editor-2.png editor.png

linuxdeploy -d $MAP_EDITOR_DESKTOP_DEST/megaglest_editor.desktop \
--icon-file=editor.png \
--icon-filename=editor --executable AppDir/usr/local/bin/megaglest_editor --appdir $MAP_EDITOR_BUILD_DIR/AppDir --plugin gtk --output appimage
--icon-filename=editor \
--executable AppDir/$INST_PREFIX/bin/megaglest_editor \
--appdir AppDir --plugin gtk --output appimage

mv MegaGlest*.AppImage $WORKSPACE

cd $G3DVIEWER_BUILD_DIR

cmake $SOURCE_ROOT -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=ON -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -DINCLUDE_DATA=OFF
cmake $SOURCE_ROOT -DCMAKE_INSTALL_PREFIX=/$INST_PREFIX -DBUILD_MEGAGLEST=OFF -DBUILD_MEGAGLEST_MODEL_VIEWER=ON -DBUILD_MEGAGLEST_MAP_EDITOR=OFF -DBUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS=OFF -DINCLUDE_DATA=OFF
make DESTDIR=$G3DVIEWER_BUILD_DIR/AppDir -j$(nproc) install
# strip AppDir/usr/local/bin/megaglest_g3dviewer

G3DVIEWER_DESKTOP_DEST="$G3DVIEWER_BUILD_DIR/AppDir/usr/local/share/applications"

G3DVIEWER_DESKTOP_DEST="$G3DVIEWER_BUILD_DIR/AppDir/$INST_PREFIX/share/applications"
if [ ! -d "$G3DVIEWER_DESKTOP_DEST" ]; then
mkdir -p "$G3DVIEWER_DESKTOP_DEST"
fi
Expand All @@ -129,12 +124,14 @@ if [ ! -f "$G3DVIEWER_DESKTOP_DEST/megaglest_g3dviewer.desktop" ]; then
sed -i 's#Icon=megaglest#Icon=g3dviewer#' $G3DVIEWER_DESKTOP_DEST/megaglest_g3dviewer.desktop
fi

convert $G3DVIEWER_BUILD_DIR/AppDir/usr/local/share/megaglest/g3dviewer.ico g3dviewer.png
convert $G3DVIEWER_BUILD_DIR/AppDir/$INST_PREFIX/share/megaglest/g3dviewer.ico g3dviewer.png
mv g3dviewer-2.png g3dviewer.png

linuxdeploy -d $G3DVIEWER_DESKTOP_DEST/megaglest_g3dviewer.desktop \
--icon-file=g3dviewer.png \
--icon-filename=g3dviewer --executable $G3DVIEWER_BUILD_DIR/AppDir/usr/local/bin/megaglest_g3dviewer --appdir AppDir --plugin gtk --output appimage
--icon-filename=g3dviewer \
--executable AppDir/$INST_PREFIX/bin/megaglest_g3dviewer \
--appdir AppDir --plugin gtk --output appimage

mv MegaGlest*.AppImage $WORKSPACE

Expand Down

0 comments on commit 2e21868

Please sign in to comment.