metaforce/lxd-build-appimage.sh

75 lines
2.8 KiB
Bash
Raw Normal View History

2021-02-28 03:35:44 +00:00
#!/bin/bash -ex
###############################################################
# Uses LXD to create an Ubuntu focal container and produce #
2021-04-06 22:58:11 +00:00
# a reasonably portable AppImage of Metaforce. #
2021-02-28 03:35:44 +00:00
###############################################################
VERSION=${VERSION:-local}
2021-04-06 22:58:11 +00:00
CONTAINER_NAME=metaforce-ci
2021-02-28 03:35:44 +00:00
# Set up container, deleting existing if necessary
if lxc info $CONTAINER_NAME >& /dev/null
then
lxc delete $CONTAINER_NAME --force
fi
lxc init ubuntu:20.04 $CONTAINER_NAME
# Inject build script
lxc file push - $CONTAINER_NAME/root/dobuild.sh <<END
set -e
2021-04-06 22:58:11 +00:00
# Metaforce build script for Ubuntu 20.04 LTS (Focal)
2021-02-28 03:35:44 +00:00
# Install build dependencies
apt update
apt -y install build-essential curl git ninja-build llvm-dev libclang-dev clang lld zlib1g-dev \
libglu1-mesa-dev libdbus-1-dev libvulkan-dev libxi-dev libxrandr-dev libasound2-dev libpulse-dev \
libudev-dev libpng-dev libncurses5-dev cmake libx11-xcb-dev python3 python-is-python3 qt5-default
# Doing everything in root is fine
cd /
# Get linuxdeploy
curl -OL https://github.com/encounter/linuxdeploy/releases/download/continuous/linuxdeploy-$(uname -m).AppImage
curl -OL https://github.com/encounter/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-$(uname -m).AppImage
chmod +x linuxdeploy-$(uname -m).AppImage linuxdeploy-plugin-qt-$(uname -m).AppImage
# Cleanup
2021-04-06 22:58:11 +00:00
rm -rf metaforce{-build,-appdir,}
2021-02-28 03:35:44 +00:00
# Clone repository
2021-04-06 22:58:11 +00:00
git clone https://github.com/AxioDL/metaforce.git --recursive
2021-02-28 03:35:44 +00:00
# Build
2021-04-06 22:58:11 +00:00
mkdir -p metaforce{-build,-appdir}
pushd metaforce-build
2021-02-28 03:35:44 +00:00
cmake -GNinja -DCMAKE_BUILD_TYPE=MinSizeRel -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
2021-04-06 22:58:11 +00:00
/metaforce
ninja hecl metaforce-gui metaforce visigen
2021-02-28 03:35:44 +00:00
popd
2021-04-06 22:58:11 +00:00
mkdir -p /metaforce-appdir/usr/{bin,share/{applications,icons/hicolor}}
cp /metaforce-build/Binaries/{hecl,metaforce-gui,metaforce,visigen} /metaforce-appdir/usr/bin
strip -s /metaforce-appdir/usr/bin/{hecl,metaforce-gui,metaforce,visigen}
2021-05-24 05:06:51 +00:00
cp -r /metaforce/Runtime/platforms/freedesktop/{16x16,32x32,48x48,64x64,128x128,256x256,512x512,1024x1024} /metaforce-appdir/usr/share/icons/hicolor
cp /metaforce/Runtime/platforms/freedesktop/metaforce.desktop /metaforce-appdir/usr/share/applications
2021-04-06 22:58:11 +00:00
sed -i 's/Exec=.*/Exec=metaforce-gui/' /metaforce-appdir/usr/share/applications/metaforce.desktop
VERSION=$VERSION /linuxdeploy-$(uname -m).AppImage --appdir /metaforce-appdir --plugin qt --output appimage
2021-02-28 03:35:44 +00:00
END
# Start container
lxc start $CONTAINER_NAME
# Wait for network
lxc exec $CONTAINER_NAME -- bash -c "while ! systemctl status network.target &>/dev/null; do echo 'Waiting for network...'; sleep 1; done"
# Run build script
lxc exec $CONTAINER_NAME -t -- bash /root/dobuild.sh
2021-05-24 05:06:51 +00:00
# Retrieve AppImage
2021-02-28 03:35:44 +00:00
lxc file pull $CONTAINER_NAME/URDE-$VERSION-$(uname -m).AppImage .
# Cleanup
lxc delete $CONTAINER_NAME --force