1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
|
#!/bin/bash
# AppImage BUILD SCRIPT FOR NAEV
#
# Written by Jack Greiner (ProjectSynchro on Github: https://github.com/ProjectSynchro/)
#
# For more information, see http://appimage.org/
# Pass in [-d] [-c] (set this for debug builds) [-n] (set this for nightly builds) [-m] (set this if you want to use Meson) -s <SOURCEROOT> (Sets location of source) -b <BUILDROOT> (Sets location of build directory) -o <BUILDOUTPUT> (Dist output directory)
# All outputs will be within pwd if nothing is passed in
set -e
# Defaults
SOURCEROOT="$(pwd)"
BUILDPATH="$(pwd)/build/appimageBuild"
NIGHTLY="false"
USEMESON="false"
BUILDOUTPUT="$(pwd)/dist"
BUILDDEBUG="false"
while getopts dcnms:b:o: OPTION "$@"; do
case $OPTION in
d)
set -x
;;
c)
BUILDDEBUG="true"
;;
n)
NIGHTLY="true"
;;
m)
USEMESON="true"
;;
s)
SOURCEROOT="${OPTARG}"
;;
b)
BUILDPATH="${OPTARG}"
;;
o)
BUILDOUTPUT="${OPTARG}"
;;
esac
done
BUILD_DATE="$(date +%Y%m%d)"
# Honours the MESON variable set by the environment before setting it manually.
if [ -z "$MESON" ]; then
MESON="$SOURCEROOT/meson.sh"
fi
# Output configured variables
echo "SOURCE ROOT: $SOURCEROOT"
echo "BUILD ROOT: $BUILDPATH"
echo "NIGHTLY: $NIGHTLY"
echo "BUILD OUTPUT: $BUILDOUTPUT"
if [ "$USEMESON" = "true" ]; then
echo "MESON WRAPPER PATH: $MESON"
else
echo "MESON BUILD: $USEMESON"
fi
# Set DESTDIR
OLDDISTDIR="$DISTDIR"
unset DESTDIR
export DESTDIR="$BUILDOUTPUT/Naev.AppDir"
# Run build
if [ "$USEMESON" == "true" ]; then
if [ "$BUILDDEBUG" == "true" ]; then
# Setup AppImage Build Directory
sh "$MESON" setup "$BUILDPATH" "$SOURCEROOT" \
--native-file "$SOURCEROOT/utils/build/linux_appimage.ini" \
--buildtype debug \
-Db_lto=true \
-Dauto_features=enabled \
-Ddocs_c=disabled \
-Ddocs_lua=disabled \
# Compile and Install Naev to DISTDIR
sh "$MESON" install -C "$BUILDPATH"
else
# Setup AppImage Build Directory
sh "$MESON" setup "$BUILDPATH" "$SOURCEROOT" \
--native-file "$SOURCEROOT/utils/build/linux_appimage.ini" \
--buildtype release \
-Db_lto=true \
-Dauto_features=enabled \
-Ddocs_c=disabled \
-Ddocs_lua=disabled
# Compile and Install Naev to DISTDIR
sh "$MESON" install -C "$BUILDPATH"
fi
else
pushd "$SOURCEROOT"
if [ "$BUILDDEBUG" == "true" ]; then
# Setup AppImage Build Directory
./autogen.sh
./configure --prefix=/usr
# Compile and Install Naev to DISTDIR
make -j"$(nproc --all)"
make install
else
# Setup AppImage Build Directory
./autogen.sh
./configure --disable-debug --prefix=/usr
# Compile and Install Naev to DISTDIR
make -j"$(nproc --all)"
make install
fi
popd
fi
# Prep dist directory for appimage
# (I hate this but otherwise linuxdeploy fails on systems that generate the desktop file)
rm "$DESTDIR"/usr/share/applications/*.desktop
cp "$SOURCEROOT/org.naev.naev.desktop" "$DESTDIR/usr/share/applications/"
# Set ARCH of AppImage
export ARCH=$(arch)
# Set VERSION and OUTPUT variables
if [ -f "$SOURCEROOT/dat/VERSION" ]; then
export VERSION="$(<"$SOURCEROOT/dat/VERSION")"
else
echo "The VERSION file is missing from $SOURCEROOT."
exit -1
fi
if [ "$NIGHTLY" == "true" ]; then
export VERSION="$VERSION.$BUILD_DATE"
fi
if [ "$BUILDDEBUG" == "true" ]; then
export VERSION="$VERSION+DEBUG.$BUILD_DATE"
fi
SUFFIX="$VERSION-linux-x86-64"
# Make output dir (if it does not exist)
mkdir -p "$BUILDOUTPUT/out"
export OUTPUT="$BUILDOUTPUT/out/naev-$SUFFIX.AppImage"
# Get linuxdeploy's AppImage
linuxdeploy="$BUILDPATH/linuxdeploy-x86_64.AppImage"
if [ ! -f "$linuxdeploy" ]; then
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage \
-O "$linuxdeploy"
chmod +x "$linuxdeploy"
fi
# Run linuxdeploy and generate an AppDir, then generate an AppImage
"$linuxdeploy" \
--appdir "$DESTDIR" \
--output appimage
# Move AppImage to dist/ and mark as executable
chmod +x "$OUTPUT"
#Reset DESTDIR to what it was before
unset DESTDIR
export DESTDIR="$OLDDISTDIR"
|