build-linux-appimage.sh 4.33 KB
Newer Older
1
#!/bin/bash -e
Ilya Bizyaev's avatar
Ilya Bizyaev committed
2 3 4

# NOTE: To use this script, you need to set $QT_LINUX to your Qt for Linux installation

5 6 7
# Path to Qt installation
QT_LINUX=${QT_LINUX:-/usr}
echo Using Qt installation from $QT_LINUX
Ilya Bizyaev's avatar
Ilya Bizyaev committed
8

9
# Build type is one of:
Ilya Bizyaev's avatar
Ilya Bizyaev committed
10 11 12 13 14
# Debug, Release, RelWithDebInfo and MinSizeRel
BUILD_TYPE="${BUILD_TYPE:-Debug}"

KAIDAN_SOURCES=$(dirname "$(readlink -f "${0}")")/..
KIRIGAMI_BUILD=/tmp/kirigami-linux-build
15
QXMPP_BUILD=${QXMPP_BUILD:-/tmp/qxmpp-linux-build}
Ilya Bizyaev's avatar
Ilya Bizyaev committed
16 17 18 19 20 21 22 23 24 25 26 27

echo "-- Starting $BUILD_TYPE build of Kaidan --"

echo "*****************************************"
echo "Fetching dependencies if required"
echo "*****************************************"

if [ ! -f "$KAIDAN_SOURCES/3rdparty/kirigami/.git" ] || [ ! -f "$KAIDAN_SOURCES/3rdparty/breeze-icons/.git" ]; then
    echo "Cloning Kirigami and Breeze icons"
    git submodule update --init
fi

28
if [ ! -e "$KAIDAN_SOURCES/3rdparty/qxmpp/.git" ]; then
29 30 31 32
    echo "Cloning QXmpp"
    git clone https://github.com/qxmpp-project/qxmpp.git 3rdparty/qxmpp
fi

Ilya Bizyaev's avatar
Ilya Bizyaev committed
33 34 35 36 37 38 39 40
cdnew() {
    if [ -d "$1" ]; then
        rm -rf "$1"
    fi
    mkdir $1
    cd $1
}

41 42 43 44 45 46 47 48 49 50 51
if [ ! -f "$KAIDAN_SOURCES/3rdparty/linuxdeployqt/squashfs-root/AppRun" ]; then
    echo "Downloading linuxdeployqt"
    wget --continue -P $KAIDAN_SOURCES/3rdparty/ https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage
    chmod +x $KAIDAN_SOURCES/3rdparty/linuxdeployqt-continuous-x86_64.AppImage

    echo "Extracting linuxdeployqt"
    cdnew $KAIDAN_SOURCES/3rdparty/linuxdeployqt
    $KAIDAN_SOURCES/3rdparty/linuxdeployqt-continuous-x86_64.AppImage --appimage-extract
    cd $KAIDAN_SOURCES
fi

Ilya Bizyaev's avatar
Ilya Bizyaev committed
52 53
export QT_SELECT=qt5

54
if ! $(find $QXMPP_BUILD -name libqxmpp.so >/dev/null); then
55 56 57 58 59 60 61
echo "*****************************************"
echo "Building QXmpp"
echo "*****************************************"
{
    cdnew $KAIDAN_SOURCES/3rdparty/qxmpp/build
    cmake .. \
        -DCMAKE_PREFIX_PATH=$QT_LINUX \
62
        -DBUILD_EXAMPLES=OFF -DBUILD_TESTS=OFF \
63 64 65 66 67 68 69 70 71
        -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$QXMPP_BUILD \
        -DCMAKE_INSTALL_LIBDIR=$QXMPP_BUILD/lib

    make -j$(nproc)
    make install
    rm -rf $KAIDAN_SOURCES/3rdparty/qxmpp/build
}
fi

72
if [ ! -f "$KIRIGAMI_BUILD/lib/libKF5Kirigami2.so" ]; then
Ilya Bizyaev's avatar
Ilya Bizyaev committed
73 74 75 76 77 78 79 80
echo "*****************************************"
echo "Building Kirigami"
echo "*****************************************"
{
    cdnew $KAIDAN_SOURCES/3rdparty/kirigami/build
    cmake .. \
        -DECM_DIR=/usr/share/ECM/cmake \
        -DCMAKE_PREFIX_PATH=$QT_LINUX \
81 82 83
        -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=$KIRIGAMI_BUILD \
        -DCMAKE_INSTALL_LIBDIR=$KIRIGAMI_BUILD/lib

Ilya Bizyaev's avatar
Ilya Bizyaev committed
84 85 86 87 88 89
    make -j$(nproc)
    make install
    rm -rf $KAIDAN_SOURCES/3rdparty/kirigami/build
}
fi

90 91
export PKG_CONFIG_PATH=$QXMPP_BUILD/lib/pkgconfig

Ilya Bizyaev's avatar
Ilya Bizyaev committed
92 93 94 95 96 97
if [ ! -f "$KAIDAN_SOURCES/build/bin/kaidan" ]; then
echo "*****************************************"
echo "Building Kaidan"
echo "*****************************************"
{
    cdnew $KAIDAN_SOURCES/build
98

Ilya Bizyaev's avatar
Ilya Bizyaev committed
99 100
    cmake .. \
        -DECM_DIR=/usr/share/ECM/cmake \
101 102
        -DCMAKE_PREFIX_PATH=$QT_LINUX\;$KIRIGAMI_BUILD\;$QXMPP_BUILD \
        -DI18N=1 \
Ilya Bizyaev's avatar
Ilya Bizyaev committed
103
        -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_INSTALL_PREFIX=/usr
104

Ilya Bizyaev's avatar
Ilya Bizyaev committed
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
    make -j$(nproc)
}
fi

if [ ! -f "$KAIDAN_SOURCES/AppDir/usr/bin/kaidan" ]; then
echo "*****************************************"
echo "Installing Kaidan"
echo "*****************************************"
{
    cd $KAIDAN_SOURCES/build
    DESTDIR=$KAIDAN_SOURCES/AppDir cmake --build . --target install
}
fi

echo "*****************************************"
echo "Packing into AppImage"
echo "*****************************************"
{
    cd $KAIDAN_SOURCES
124
    export LD_LIBRARY_PATH=$QT_LINUX/lib/:$KIRIGAMI_BUILD/lib:$LD_LIBRARY_PATH
Ilya Bizyaev's avatar
Ilya Bizyaev committed
125
    export PATH=$QT_LINUX/bin/:$PATH
126 127 128
    # set qmake binary when using portable Qt; linuxdeployqt will find it on its
    # own on global installs
    if [ -f $QT_LINUX/bin/qmake ]; then
129
        QMAKE_BINARY="-qmake=$QT_LINUX/bin/qmake"
130
    fi
131 132 133 134 135

    $KAIDAN_SOURCES/3rdparty/linuxdeployqt/squashfs-root/AppRun \
        $KAIDAN_SOURCES/AppDir/usr/share/applications/kaidan.desktop \
        -qmldir=$KAIDAN_SOURCES/src/qml/ \
        -qmlimport=$KIRIGAMI_BUILD/lib/qml/ \
136
        -extra-plugins="imageformats/libqsvg.so,imageformats/libqjpeg.so,iconengines/libqsvgicon.so" \
137 138
        -appimage -no-copy-copyright-files \
        $QMAKE_BINARY
Ilya Bizyaev's avatar
Ilya Bizyaev committed
139
}