Changeset View
Changeset View
Standalone View
Standalone View
packaging/linux/appimage/build-image.sh
- This file was added.
1 | #!/bin/bash | ||||
---|---|---|---|---|---|
2 | | ||||
3 | # Halt on errors and be verbose about what we are doing | ||||
4 | set -e | ||||
5 | set -x | ||||
6 | | ||||
7 | # Read in our parameters | ||||
8 | export BUILD_PREFIX=$1 | ||||
9 | export KMYMONEY_SOURCES=$2 | ||||
10 | | ||||
11 | # Save some frequently referenced locations in variables for ease of use / updating | ||||
12 | export APPDIR=$BUILD_PREFIX/kmymoney.appdir | ||||
13 | export PLUGINS=$APPDIR/usr/lib/plugins/kmymoney/ | ||||
14 | | ||||
15 | # qjsonparser, used to add metadata to the plugins needs to work in a en_US.UTF-8 environment. | ||||
16 | # That's not always the case, so make sure it is | ||||
17 | export LC_ALL=en_US.UTF-8 | ||||
18 | export LANG=en_us.UTF-8 | ||||
19 | | ||||
20 | # We want to use $prefix/deps/usr/ for all our dependencies | ||||
21 | export DEPS_INSTALL_PREFIX=$BUILD_PREFIX/deps/usr/ | ||||
22 | export DOWNLOADS_DIR=$BUILD_PREFIX/downloads/ | ||||
23 | | ||||
24 | # Setup variables needed to help everything find what we built | ||||
25 | export LD_LIBRARY_PATH=$DEPS_INSTALL_PREFIX/lib/:$DEPS_INSTALL_PREFIX/lib/x86_64-linux-gnu/:$APPDIR/usr/lib/:$LD_LIBRARY_PATH | ||||
26 | export PATH=$DEPS_INSTALL_PREFIX/bin/:$PATH | ||||
27 | export PKG_CONFIG_PATH=$DEPS_INSTALL_PREFIX/share/pkgconfig/:$DEPS_INSTALL_PREFIX/lib/pkgconfig/:/usr/lib/pkgconfig/:$PKG_CONFIG_PATH | ||||
28 | export CMAKE_PREFIX_PATH=$DEPS_INSTALL_PREFIX:$CMAKE_PREFIX_PATH | ||||
29 | | ||||
30 | # Switch over to our build prefix | ||||
31 | cd $BUILD_PREFIX | ||||
32 | | ||||
33 | # | ||||
34 | # Now we can get the process started! | ||||
35 | # | ||||
36 | | ||||
37 | # Step 0: place the translations where ki18n and Qt look for them | ||||
38 | if [ -d $APPDIR/usr/share/locale ] ; then | ||||
39 | mv $APPDIR/usr/share/locale $APPDIR/usr/share/kmymoney | ||||
40 | fi | ||||
41 | | ||||
42 | # Step 1: Copy over all the resources provided by dependencies that we need | ||||
43 | cp -r $DEPS_INSTALL_PREFIX/share/locale $APPDIR/usr/share/kmymoney | ||||
44 | cp -r $DEPS_INSTALL_PREFIX/share/kf5 $APPDIR/usr/share | ||||
45 | cp -r $DEPS_INSTALL_PREFIX/share/mime $APPDIR/usr/share | ||||
46 | cp -r $DEPS_INSTALL_PREFIX/translations $APPDIR/usr/ | ||||
47 | | ||||
48 | # Step 2: Relocate x64 binaries from the architecture specific directory as required for Appimages | ||||
49 | mv $APPDIR/usr/lib/x86_64-linux-gnu/* $APPDIR/usr/lib | ||||
50 | rm -rf $APPDIR/usr/lib/x86_64-linux-gnu/ | ||||
51 | | ||||
52 | # Step 3: Update the rpath in the various plugins we have to make sure they'll be loadable in an Appimage context | ||||
53 | for lib in $PLUGINS/*.so*; do | ||||
54 | patchelf --set-rpath '$ORIGIN/..' $lib; | ||||
55 | done | ||||
56 | | ||||
57 | # Step 4: Build the image!!! | ||||
58 | linuxdeployqt $APPDIR/usr/share/applications/org.kde.kmymoney.desktop \ | ||||
59 | -executable=$APPDIR/usr/bin/kmymoney \ | ||||
60 | -qmldir=$DEPS_INSTALL_PREFIX/qml \ | ||||
61 | -verbose=2 \ | ||||
62 | -bundle-non-qt-libs \ | ||||
63 | -appimage | ||||
64 | | ||||
65 | # Step 5: Find out what version of KMyMoney we built and give the Appimage a proper name | ||||
66 | cd $BUILD_PREFIX/kmymoney-build | ||||
67 | KMYMONEY_VERSION=$(grep "KMyMoney VERSION" CMakeLists.txt | cut -d '"' -f 2) | ||||
68 | | ||||
69 | # Also find out the revision of Git we built | ||||
70 | # Then use that to generate a combined name we'll distribute | ||||
71 | cd $KMYMONEY_SOURCES | ||||
72 | if [[ -d .git ]]; then | ||||
73 | GIT_REVISION=$(git rev-parse --short HEAD) | ||||
74 | VERSION=$KMYMONEY_VERSION-$GIT_REVISION | ||||
75 | else | ||||
76 | VERSION=$KMYMONEY_VERSION | ||||
77 | fi | ||||
78 | | ||||
79 | # Return to our build root | ||||
80 | cd $BUILD_PREFIX | ||||
81 | | ||||
82 | # Generate a new name for the Appimage file and rename it accordingly | ||||
83 | APPIMAGE=kmymoney-"$VERSION"-x86_64.appimage | ||||
84 | mv KMyMoney-x86_64.AppImage $APPIMAGE |