1#!/bin/bash
2
3########################################################################
4# Install build-time and run-time dependencies
5########################################################################
6
7export DEBIAN_FRONTEND=noninteractive
8
9########################################################################
10# Build Siril and install to appdir/
11########################################################################
12
13BUILDDIR=build/appimage/build
14PREFIX=/usr
15
16meson ${BUILDDIR} \
17    --prefix=${PREFIX} \
18    --buildtype=release \
19    -Drelocatable-bundle=yes \
20    -Denable-libcurl=yes
21
22
23ninja -C ${BUILDDIR} -j$(nproc)
24DESTDIR=$PWD/${BUILDDIR}/appdir ninja -C ${BUILDDIR} -j$(nproc) install; find ${BUILDDIR}/appdir/
25cd ${BUILDDIR}
26cp ../AppRun appdir/AppRun ; chmod +x appdir/AppRun
27cp ./appdir/usr/share/icons/hicolor/scalable/apps/org.free_astro.siril.svg ./appdir/org.free_astro.siril.svg
28
29cd appdir/
30
31########################################################################
32# Bundle everyhting
33# to allow the AppImage to run on older systems as well
34########################################################################
35
36apt_bundle() {
37    apt-get download "$@"
38    find *.deb -exec dpkg-deb -x {} . \;
39    find *.deb -delete
40}
41
42# Bundle all of glibc; this should eventually be done by linuxdeployqt
43apt update
44apt_bundle libc6
45
46# Make absolutely sure it will not load stuff from /lib or /usr
47sed -i -e 's|/usr|/xxx|g' lib/x86_64-linux-gnu/ld-linux-x86-64.so.2
48
49# Bundle Gdk pixbuf loaders without which the bundled Gtk does not work;
50# this should eventually be done by linuxdeployqt
51apt_bundle librsvg2-common libgdk-pixbuf2.0-0
52cp /usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/* usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders/
53cp /usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/
54sed -i -e 's|/usr/lib/x86_64-linux-gnu/gdk-pixbuf-.*/.*/loaders/||g' usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders.cache
55
56# Bundle fontconfig settings
57mkdir -p etc/fonts/
58cp /etc/fonts/fonts.conf etc/fonts/
59
60cd -
61
62########################################################################
63# Generate AppImage
64########################################################################
65
66wget -c -nv "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
67chmod a+x linuxdeployqt-continuous-x86_64.AppImage
68
69linuxdeployqtargs=()
70
71for so in $(find \
72    appdir/usr/lib/x86_64-linux-gnu/gdk-pixbuf-*/*/loaders \
73    -name \*.so); do
74    linuxdeployqtargs+=("-executable=$(readlink -f "$so")")
75done
76
77./linuxdeployqt-continuous-x86_64.AppImage --appimage-extract-and-run appdir/usr/share/applications/org.free_astro.siril.desktop \
78  -appimage -unsupported-bundle-everything \
79  "${linuxdeployqtargs[@]}"
80
81mv Siril*.AppImage* ../
82
83