1#!/bin/bash
2
3# Halt on errors
4set -e
5
6# Be verbose
7set -x
8
9# Now we are inside CentOS 6
10grep -r "CentOS release 6" /etc/redhat-release || exit 1
11
12git_pull_rebase_helper()
13{
14    git fetch
15    git stash || true
16    git rebase $(git rev-parse --abbrev-ref --symbolic-full-name @{u}) || true
17    git stash pop || true
18}
19
20SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
22QTDIR=/opt/qt5
23
24if [ -z "$KDEVELOP_VERSION" ]; then
25    KDEVELOP_VERSION=5.6
26fi
27if [ -z "$KDEV_PG_QT_VERSION" ]; then
28    KDEV_PG_QT_VERSION=v2.2.1
29fi
30KF5_VERSION=v5.73.0
31LIBKSYSGUARD_VERSION=v5.18.5 # 5.19 needs Qt 5.14
32BREEZESTYLE_VERSION=v5.19.5
33KDE_RELEASESERVICE_VERSION=v20.08.1
34GRANTLEE_VERSION=v5.2.0
35OKTETA_VERSION=v0.26.4
36
37export LLVM_ROOT=/opt/llvm/
38export PATH=/opt/rh/python27/root/usr/bin/:$PATH
39export LD_LIBRARY_PATH=/opt/rh/python27/root/usr/lib64:$LD_LIBRARY_PATH
40
41# qjsonparser, used to add metadata to the plugins needs to work in a en_US.UTF-8 environment. That's
42# not always set correctly in CentOS 6.7
43export LANG=en_US.UTF-8
44
45# Determine which architecture should be built
46if [[ "$(arch)" = "i686" || "$(arch)" = "x86_64" ]] ; then
47  ARCH=$(arch)
48else
49  echo "Architecture could not be determined"
50  exit 1
51fi
52
53# Make sure we build from the /, parts of this script depends on that. We also need to run as root...
54cd  /
55
56# Use the new compiler
57. /opt/rh/devtoolset-6/enable
58
59# TODO: Use these vars more
60export FAKEROOT=/kdevelop.appdir
61export PREFIX=/kdevelop.appdir/usr/
62export SRC=$HOME/src/
63export BUILD=$HOME/build
64export CMAKE_PREFIX_PATH=$QTDIR:/kdevelop.appdir/share/llvm/
65
66# if the library path doesn't point to our usr/lib, linking will be broken and we won't find all deps either
67export LD_LIBRARY_PATH=/usr/lib64/:/usr/lib:/kdevelop.appdir/usr/lib:$QTDIR/lib/:/opt/python3.6/lib/:$LD_LIBRARY_PATH
68
69# Workaround for: On CentOS 6, .pc files in /usr/lib/pkgconfig are not recognized
70# However, this is where .pc files get installed when bulding libraries... (FIXME)
71# I found this by comparing the output of librevenge's "make install" command
72# between Ubuntu and CentOS 6
73ln -sf /usr/share/pkgconfig /usr/lib/pkgconfig
74
75# Prepare the install location
76if [ -z "$SKIP_PRUNE" ]; then
77    rm -rf /kdevelop.appdir/ || true
78    mkdir -p /kdevelop.appdir/usr
79
80    # refresh ldconfig cache
81    ldconfig
82
83    # make sure lib and lib64 are the same thing
84    mkdir -p /kdevelop.appdir/usr/lib
85    cd  /kdevelop.appdir/usr
86    ln -s lib lib64
87fi
88
89# start building the deps
90# usage: build_project <repourl> <repodirectory> <branch/tag>
91function build_project
92{ (
93    REPOURL=$1
94    PROJECT=$2
95    VERSION=$3
96    shift
97    shift
98    shift
99
100    # clone if not there
101    mkdir -p $SRC
102    cd $SRC
103    if ( test -d $PROJECT )
104    then
105        echo "$PROJECT already cloned"
106        cd $PROJECT
107        git stash
108        git reset --hard
109        git fetch
110        git fetch --tags
111        cd ..
112    else
113        git clone $REPOURL $PROJECT
114    fi
115
116    cd $PROJECT
117    git checkout $VERSION
118    git rebase $(git rev-parse --abbrev-ref --symbolic-full-name @{u}) || true # git rebase will fail if a tag is checked out
119    git stash pop || true
120    cd ..
121
122    if [ ! -z "$PATCH_FILE" ]; then
123        pushd $PROJECT
124        echo "Patching $PROJECT with $PATCH_FILE"
125        git reset --hard
126        patch -p1 < $PATCH_FILE
127        popd
128    fi
129
130    # create build dir
131    mkdir -p $BUILD/$PROJECT
132
133    # go there
134    cd $BUILD/$PROJECT
135
136    # cmake it
137    cmake3 $SRC/$PROJECT -G Ninja -DBUILD_TESTING=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX $@
138
139    # make
140    ninja
141
142    # install
143    ninja install
144) }
145
146function build_kde_project
147{ (
148    REPOPATH=$1
149    PROJECT=${1#*/}
150    shift
151    build_project https://invent.kde.org/$REPOPATH.git $PROJECT $@
152) }
153
154function build_framework
155{ (
156    PROJECT=$1
157    shift
158    build_kde_project frameworks/$PROJECT $KF5_VERSION $@
159) }
160
161# KDE Frameworks
162if [ -z "$SKIP_FRAMEWORKS" ]; then
163build_framework extra-cmake-modules -DBUILD_HTML_DOCS=OFF -DBUILD_MAN_DOCS=OFF
164
165build_framework kconfig
166build_framework kguiaddons
167build_framework ki18n
168build_framework kitemviews -DBUILD_DESIGNERPLUGIN=OFF
169build_framework sonnet -DBUILD_DESIGNERPLUGIN=OFF
170build_framework kwindowsystem
171build_framework kwidgetsaddons -DBUILD_DESIGNERPLUGIN=OFF
172build_framework kcompletion -DBUILD_DESIGNERPLUGIN=OFF
173build_framework kdbusaddons
174build_framework karchive
175build_framework kcoreaddons
176build_framework kjobwidgets
177build_framework kcrash
178build_framework kservice
179build_framework kcodecs
180build_framework kauth
181build_framework kconfigwidgets -DBUILD_DESIGNERPLUGIN=OFF
182build_framework kiconthemes -DBUILD_DESIGNERPLUGIN=OFF
183build_framework ktextwidgets -DBUILD_DESIGNERPLUGIN=OFF
184build_framework kglobalaccel
185build_framework kxmlgui -DBUILD_DESIGNERPLUGIN=OFF
186build_framework kbookmarks
187build_framework solid
188build_framework kio -DBUILD_DESIGNERPLUGIN=OFF
189build_framework kparts
190build_framework kitemmodels
191build_framework threadweaver
192build_framework attica
193build_framework kpackage
194build_framework knewstuff
195build_framework syntax-highlighting
196build_framework ktexteditor
197build_framework kdeclarative
198build_framework kcmutils
199(PATCH_FILE=$SCRIPT_DIR/knotifications_no_phonon.patch build_framework knotifications)
200(PATCH_FILE=$SCRIPT_DIR/knotifyconfig_no_phonon.patch build_framework knotifyconfig)
201build_framework kdoctools
202build_framework breeze-icons -DBINARY_ICONS_RESOURCE=1
203build_framework kpty
204build_framework kinit
205fi
206
207# KDE Plasma
208build_kde_project plasma/libksysguard $LIBKSYSGUARD_VERSION
209(PATCH_FILE=$SCRIPT_DIR/breeze-noconstexpr.patch build_kde_project plasma/breeze $BREEZESTYLE_VERSION -DWITH_DECORATIONS=OFF -DWITH_WALLPAPERS=OFF)
210
211# KDE Applications
212build_kde_project sdk/libkomparediff2 $KDE_RELEASESERVICE_VERSION
213build_kde_project utilities/kate $KDE_RELEASESERVICE_VERSION -DDISABLE_ALL_OPTIONAL_SUBDIRECTORIES=TRUE -DBUILD_addons=TRUE -DBUILD_snippets=TRUE -DBUILD_kate-ctags=TRUE
214build_kde_project utilities/konsole $KDE_RELEASESERVICE_VERSION
215build_kde_project utilities/okteta $OKTETA_VERSION -DBUILD_DESIGNERPLUGIN=OFF -DBUILD_OKTETAKASTENLIBS=OFF
216
217# Extra
218build_project https://github.com/steveire/grantlee.git  grantlee $GRANTLEE_VERSION -DBUILD_TESTS=OFF
219
220# KDevelop
221build_kde_project kdevelop/kdevelop-pg-qt $KDEV_PG_QT_VERSION
222build_kde_project kdevelop/kdevelop $KDEVELOP_VERSION
223build_kde_project kdevelop/kdev-php $KDEVELOP_VERSION
224
225# Build kdev-python
226export LD_LIBRARY_PATH=$LD_LIBRARY_PATH/kdevelop.appdir/usr/lib/
227build_kde_project kdevelop/kdev-python $KDEVELOP_VERSION
228
229# Install some colorschemes
230cd $BUILD
231$SRC/kdevelop/release-scripts/install_colorschemes.py /kdevelop.appdir/usr/share
232
233cd /kdevelop.appdir
234
235# FIXME: How to find out which subset of plugins is really needed? I used strace when running the binary
236mkdir -p ./usr/lib/qt5/plugins/
237
238PLUGINS=$($QTDIR/bin/qmake -query QT_INSTALL_PLUGINS)
239
240echo "Using plugin dir: $PLUGINS"
241cp -r $PLUGINS/bearer ./usr/lib/qt5/plugins/
242cp -r $PLUGINS/generic ./usr/lib/qt5/plugins/
243cp -r $PLUGINS/imageformats ./usr/lib/qt5/plugins/
244cp -r $PLUGINS/platforms ./usr/lib/qt5/plugins/
245cp -r $PLUGINS/iconengines ./usr/lib/qt5/plugins/
246cp -r $PLUGINS/platforminputcontexts ./usr/lib/qt5/plugins/
247# cp -r $PLUGINS/platformthemes ./usr/lib/qt5/plugins/
248cp -r $PLUGINS/sqldrivers ./usr/lib/qt5/plugins/ # qsqlite is required for the Welcome Page plugin and for QtHelp
249cp -r $PLUGINS/xcbglintegrations ./usr/lib/qt5/plugins/
250
251mkdir -p ./usr/lib/qt5/qml
252QML_DIR=$QTDIR/qml
253# for the Welcome Page plugin
254cp -r $QML_DIR/QtQuick ./usr/lib/qml
255cp -r $QML_DIR/QtQuick.2 ./usr/lib/qml
256
257cp -R /kdevelop.appdir/usr/lib/grantlee/ /kdevelop.appdir/usr/lib/qt5/plugins/
258rm -Rf /kdevelop.appdir/usr/lib/grantlee
259
260mkdir -p /kdevelop.appdir/$LLVM_ROOT/lib/
261cp -r $LLVM_ROOT/lib/clang /kdevelop.appdir/$LLVM_ROOT/lib
262
263cp -ru /usr/share/mime/* /kdevelop.appdir/usr/share/mime
264update-mime-database /kdevelop.appdir/usr/share/mime/
265
266cp -R ./usr/lib/plugins/* ./usr/lib/qt5/plugins/
267rm -Rf ./usr/lib/plugins/
268
269cp $(ldconfig -p | grep libsasl2.so.2 | cut -d ">" -f 2 | xargs) ./usr/lib/
270# Fedora 23 seemed to be missing SOMETHING from the Centos 6.7. The only message was:
271# This application failed to start because it could not find or load the Qt platform plugin "xcb".
272# Setting export QT_DEBUG_PLUGINS=1 revealed the cause.
273# QLibraryPrivate::loadPlugin failed on "/usr/lib64/qt5/plugins/platforms/libqxcb.so" :
274# "Cannot load library /usr/lib64/qt5/plugins/platforms/libqxcb.so: (/lib64/libEGL.so.1: undefined symbol: drmGetNodeTypeFromFd)"
275# Which means that we have to copy libEGL.so.1 in too
276cp $(ldconfig -p | grep libEGL.so.1 | cut -d ">" -f 2 | xargs) ./usr/lib/ # Otherwise F23 cannot load the Qt platform plugin "xcb"
277cp $(ldconfig -p | grep libxcb.so.1 | cut -d ">" -f 2 | xargs) ./usr/lib/
278
279ldd usr/bin/kdevelop | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ./usr/lib || true
280#ldd usr/lib64/kdevelop/*.so  | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ./usr/lib || true
281#ldd usr/lib64/plugins/imageformats/*.so  | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -v '{}' ./usr/lib || true
282
283ldd usr/lib/qt5/plugins/platforms/libqxcb.so | grep "=>" | awk '{print $3}'  |  xargs -I '{}' cp -v '{}' ./usr/lib || true
284
285# Copy in the indirect dependencies
286FILES=$(find . -type f -executable)
287
288for FILE in $FILES ; do
289    echo "*** Processing:" $FILE
290    ldd "${FILE}" | grep "=>" | awk '{print $3}' | xargs -I '{}' cp -vu '{}' usr/lib || true
291done
292
293# The following are assumed to be part of the base system
294rm -f usr/lib/libcom_err.so.2 || true
295rm -f usr/lib/libcrypt.so.1 || true
296rm -f usr/lib/libdl.so.2 || true
297rm -f usr/lib/libexpat.so.1 || true
298rm -f usr/lib/libfontconfig.so.1 || true
299rm -f usr/lib/libfreetype.so.6 || true
300rm -f usr/lib/libgcc_s.so.1 || true
301rm -f usr/lib/libglib-2.0.so.0 || true
302rm -f usr/lib/libgpg-error.so.0 || true
303rm -f usr/lib/libgssapi_krb5.so.2 || true
304rm -f usr/lib/libgssapi.so.3 || true
305rm -f usr/lib/libhcrypto.so.4 || true
306rm -f usr/lib/libheimbase.so.1 || true
307rm -f usr/lib/libheimntlm.so.0 || true
308rm -f usr/lib/libhx509.so.5 || true
309rm -f usr/lib/libICE.so.6 || true
310rm -f usr/lib/libidn.so.11 || true
311rm -f usr/lib/libk5crypto.so.3 || true
312rm -f usr/lib/libkeyutils.so.1 || true
313rm -f usr/lib/libkrb5.so.26 || true
314rm -f usr/lib/libkrb5.so.3 || true
315rm -f usr/lib/libkrb5support.so.0 || true
316# rm -f usr/lib/liblber-2.4.so.2 || true # needed for debian wheezy
317# rm -f usr/lib/libldap_r-2.4.so.2 || true # needed for debian wheezy
318rm -f usr/lib/libm.so.6 || true
319rm -f usr/lib/libp11-kit.so.0 || true
320rm -f usr/lib/libpcre.so.3 || true
321rm -f usr/lib/libpthread.so.0 || true
322rm -f usr/lib/libresolv.so.2 || true
323rm -f usr/lib/libroken.so.18 || true
324rm -f usr/lib/librt.so.1 || true
325rm -f usr/lib/libSM.so.6 || true
326rm -f usr/lib/libusb-1.0.so.0 || true
327rm -f usr/lib/libuuid.so.1 || true
328rm -f usr/lib/libwind.so.0 || true
329
330# Remove these libraries, we need to use the system versions; this means 11.04 is not supported (12.04 is our baseline)
331rm -f usr/lib/libGL.so.* || true
332rm -f usr/lib/libdrm.so.* || true
333
334# see https://github.com/AppImage/AppImageKit/issues/629#issuecomment-359013844 -- we assume this to be present on all systems
335rm -f usr/lib/libz.so.1 || true
336
337# These seem to be available on most systems but not Ubuntu 11.04
338# rm -f usr/lib/libffi.so.6 usr/lib/libGL.so.1 usr/lib/libglapi.so.0 usr/lib/libxcb.so.1 usr/lib/libxcb-glx.so.0 || true
339
340# Delete potentially dangerous libraries
341rm -f usr/lib/libstdc* usr/lib/libgobject* usr/lib/libc.so.* || true
342# Do NOT delete libX* because otherwise on Ubuntu 11.04:
343# loaded library "Xcursor" malloc.c:3096: sYSMALLOc: Assertion (...) Aborted
344
345# We don't bundle the developer stuff
346rm -rf usr/include || true
347rm -rf usr/lib/cmake || true
348rm -rf usr/lib/pkgconfig || true
349rm -rf usr/mkspecs || true
350rm -rf usr/share/ECM/ || true
351rm -rf usr/share/gettext || true
352rm -rf usr/share/pkgconfig || true
353rm -rf usr/etc/xdg/*.categories || true
354
355strip -g $(find usr/bin usr/lib -type f) || true
356
357# We do not bundle this, so let's not search that inside the AppImage.
358# Fixes "Qt: Failed to create XKB context!" and lets us enter text
359#sed -i -e 's|././/share/X11/|/usr/share/X11/|g' ./usr/lib/qt5/plugins/platforminputcontexts/libcomposeplatforminputcontextplugin.so
360#sed -i -e 's|././/share/X11/|/usr/share/X11/|g' ./usr/lib/libQt5XcbQpa.so.5
361
362# Workaround for:
363# D-Bus library appears to be incorrectly set up;
364# failed to read machine uuid: Failed to open
365# The file is more commonly in /etc/machine-id
366# sed -i -e 's|/var/lib/dbus/machine-id|//././././etc/machine-id|g' ./usr/lib/libdbus-1.so.3
367# or
368rm -f ./usr/lib/libdbus-1.so.3 || true
369
370# Remove python
371rm -f ./usr/bin/python*
372rm -f ./usr/bin/pydoc*
373rm -f ./usr/bin/pyenv*
374
375# remove big execs
376rm -f ./usr/bin/verify-uselistorder
377rm -f ./usr/bin/obj2yaml ./usr/bin/yaml2obj
378rm -f ./usr/bin/kwrite ./usr/bin/kate
379
380# remove unused registration data
381rm -rf ./usr/share/applications/ || true
382
383# remove all appdata besides kdevelop one
384rm -f ./usr/share/metainfo/org.kde.{breezedark.desktop,kate,kwrite,konsole}.appdata.xml
385rm -f ./usr/share/metainfo/org.kde.kdev-{php,python}.metainfo.xml
386
387cp /kdevelop.appdir/usr/lib/libexec/kf5/* /kdevelop.appdir/usr/bin/
388
389cd /
390if [ ! -d appimage-exec-wrapper ]; then
391    git clone https://invent.kde.org/brauch/appimage-exec-wrapper.git
392fi;
393cd /appimage-exec-wrapper/
394make clean
395make
396
397cd /kdevelop.appdir
398cp -v /appimage-exec-wrapper/exec.so exec_wrapper.so
399
400# Disabled plugins (yet build and bundled, as more complicated to remove from build):
401# * KDevWelcomePage - issues with Qt failing to load SSL during news feed fetching
402#                     thus causing KDevelop to hang while creating network connections
403# * KDevManPage - man:/ kio-slave & deps not bundled yet
404
405cat > AppRun << EOF
406#!/bin/bash
407
408DIR="\`dirname \"\$0\"\`" 
409DIR="\`( cd \"\$DIR\" && pwd )\`"
410export APPDIR=\$DIR
411
412export LD_PRELOAD=\$DIR/exec_wrapper.so
413
414export APPIMAGE_ORIGINAL_QML2_IMPORT_PATH=\$QML2_IMPORT_PATH
415export APPIMAGE_ORIGINAL_LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
416export APPIMAGE_ORIGINAL_QT_PLUGIN_PATH=\$QT_PLUGIN_PATH
417export APPIMAGE_ORIGINAL_XDG_DATA_DIRS=\$XDG_DATA_DIRS
418export APPIMAGE_ORIGINAL_PATH=\$PATH
419export APPIMAGE_ORIGINAL_PYTHONHOME=\$PYTHONHOME
420
421export QML2_IMPORT_PATH=\$DIR/usr/lib/qml:\$QML2_IMPORT_PATH
422export LD_LIBRARY_PATH=\$DIR/usr/lib/:\$LD_LIBRARY_PATH
423export QT_PLUGIN_PATH=\$DIR/usr/lib/qt5/plugins/
424export XDG_DATA_DIRS=\$DIR/usr/share/:\$XDG_DATA_DIRS
425export PATH=\$DIR/usr/bin:\$PATH
426export KDE_FORK_SLAVES=1
427export PYTHONHOME=\$DIR/usr/
428
429export APPIMAGE_STARTUP_QML2_IMPORT_PATH=\$QML2_IMPORT_PATH
430export APPIMAGE_STARTUP_LD_LIBRARY_PATH=\$LD_LIBRARY_PATH
431export APPIMAGE_STARTUP_QT_PLUGIN_PATH=\$QT_PLUGIN_PATH
432export APPIMAGE_STARTUP_XDG_DATA_DIRS=\$XDG_DATA_DIRS
433export APPIMAGE_STARTUP_PATH=\$PATH
434export APPIMAGE_STARTUP_PYTHONHOME=\$PYTHONHOME
435
436export KDEV_CLANG_BUILTIN_DIR=\$DIR/opt/llvm/lib/clang/${LLVM_VERSION}/include
437export KDEV_DISABLE_PLUGINS="KDevWelcomePage;KDevManPage"
438
439cd \$HOME
440
441kdevelop \$@
442EOF
443chmod +x AppRun
444
445# use normal desktop file, but remove actions, not yet handled by appimaged & Co
446cp $SRC/kdevelop/app/org.kde.kdevelop.desktop org.kde.kdevelop.desktop
447sed -i -e '/^Actions=/d;/^\[Desktop Action /Q' org.kde.kdevelop.desktop
448
449cp $SRC/kdevelop/app/icons/256-apps-kdevelop.png kdevelop.png
450cp -R /usr/lib/python3.6 /kdevelop.appdir/usr/lib/
451rm -Rf /kdevelop.appdir/usr/lib/python3.6/{test,config-3.5m,__pycache__,site-packages,lib-dynload,distutils,idlelib,unittest,tkinter,ensurepip}
452
453mkdir -p /kdevelop.appdir/usr/share/kdevelop/
454
455# Breeze cruft
456cp $BUILD/breeze-icons/icons/breeze-icons.rcc /kdevelop.appdir/usr/share/kdevelop/icontheme.rcc
457rm -Rf /kdevelop.appdir/usr/share/icons/{B,b}reeze* # not needed because of the rcc
458rm -Rf /kdevelop.appdir/usr/share/wallpapers
459rm -Rf /kdevelop.appdir/usr/share/plasma
460
461rm -f /kdevelop.appdir/usr/bin/llvm*
462rm -f /kdevelop.appdir/usr/bin/clang*
463rm -f /kdevelop.appdir/usr/bin/opt
464rm -f /kdevelop.appdir/usr/bin/lli
465rm -f /kdevelop.appdir/usr/bin/sancov
466rm -f /kdevelop.appdir/usr/bin/cmake
467rm -f /kdevelop.appdir/usr/bin/python
468rm -Rf /kdevelop.appdir/usr/lib/pkgconfig
469rm -Rf /kdevelop.appdir/usr/share/man
470rm -Rf /kdevelop.appdir/usr/share/locale
471rm -Rf /kdevelop.appdir/usr/lib/libLTO.so
472
473#At first it seems like "we shouldn't ship X11", but actually we should; the X11 protocol is sort of guaranteed to stay compatible,
474#while these libraries are not.
475# rm -Rf /kdevelop.appdir/usr/lib/libxcb*
476# add that back in
477# cp /usr/lib64/libxcb-keysyms.so.1 /kdevelop.appdir/usr/lib/
478# rm -Rf /kdevelop.appdir/usr/lib/{libX11.so.6,libXau.so.6,libXext.so.6,libXi.so.6,libXxf86vm.so.1,libX11-xcb.so.1,libXdamage.so.1,libXfixes.so.3,libXrender.so.1}
479
480rm -f /kdevelop.appdir/usr/bin/llc
481rm -f /kdevelop.appdir/usr/bin/bugpoint
482
483find /kdevelop.appdir -name '*.a' -exec rm {} \;
484
485echo "Final listing of files which will end up in the AppImage:"
486find /kdevelop.appdir
487
488cd /
489
490APP=KDevelop
491
492VERSION="git"
493
494if [[ "$ARCH" = "x86_64" ]] ; then
495    APPIMAGE=$APP"-"$VERSION"-x86_64.AppImage"
496fi
497if [[ "$ARCH" = "i686" ]] ; then
498    APPIMAGE=$APP"-"$VERSION"-i386.AppImage"
499fi
500echo $APPIMAGE
501
502# Get appimagetool
503APPIMAGETOOL_DIR=$SRC/appimagetool
504if [ ! -d $APPIMAGETOOL_DIR ]; then
505    mkdir -p $APPIMAGETOOL_DIR
506    pushd $APPIMAGETOOL_DIR
507    wget -c -O appimagetool https://github.com/AppImage/AppImageKit/releases/download/11/appimagetool-x86_64.AppImage
508    chmod +x ./appimagetool
509    ./appimagetool --appimage-extract # no fuse on this docker instance...
510    popd
511fi
512export PATH=$APPIMAGETOOL_DIR/squashfs-root/usr/bin:$PATH # add path to extracted appimage binary
513
514mkdir -p /out
515
516rm -f /out/*.AppImage || true
517appimagetool /kdevelop.appdir/ /out/$APPIMAGE
518
519chmod a+rwx /out/$APPIMAGE # So that we can edit the AppImage outside of the Docker container
520